import type { Observable } from "@knyt/artisan"; import { StyleSheet, type StyleSheetMixin } from "@knyt/tailor"; import type { AnyProps, ElementBuilder, StyleObject } from "@knyt/weaver"; import type { AttributeName, PropertyDefinition, PropertyInfo } from "../types.ts"; /** * A builder for defining properties on an `KnytElement`. * * @internal scope: workspace */ export declare class PropertyBuilder implements PropertyDefinition { #private; /** @internal scope: workspace */ Value: PropertyInfo.ToValue; /** @internal scope: workspace */ AttributeName: PropertyInfo.ToAttributeName; /** @public */ attributeName?: PropertyDefinition["attributeName"]; /** @public */ toAttributeValue?: PropertyDefinition["toAttributeValue"]; /** @public */ toPropertyValue?: PropertyDefinition["toPropertyValue"]; /** @public */ comparator?: PropertyDefinition["comparator"]; /** * Sets the attribute name to which the property value will be reflected. * * @public */ attribute(attributeName?: A): PropertyBuilder<{ Value: PropertyInfo.ToValue; AttributeName: A; }>; /** * Sets the attribute name to which the property value will be reflected. * * @remarks * * Shorthand for calling `attribute()` method. * * @see {@link attribute} */ attr(attributeName?: A): PropertyBuilder<{ Value: PropertyInfo.ToValue; AttributeName: A; }>; /** * Defines the property value as a string. * * @public */ string(): PropertyBuilder<{ Value: T; AttributeName: PropertyInfo.ToAttributeName; }>; /** * Defines the property value as a string. * * @remarks * * Shorthand for calling `string()` method. * * @see {@link string} * @public */ get str(): PropertyBuilder<{ Value: string; AttributeName: PropertyInfo.ToAttributeName; }>; /** * Defines the property value as a boolean. * * @remarks * * Sets up transformation functions for converting a boolean * property value to and from an attribute value. * * @public */ boolean(): PropertyBuilder<{ Value: T; AttributeName: PropertyInfo.ToAttributeName; }>; /** * Defines the property value as a boolean. * * @remarks * * Sets up transformation functions for converting a boolean * property value to and from an attribute value. * * Shorthand for calling `boolean()` method. * * @see {@link boolean} * @public */ get bool(): PropertyBuilder<{ Value: boolean; AttributeName: PropertyInfo.ToAttributeName; }>; /** * Defines the property value as a number. * * @remarks * * Sets up transformation functions for converting a number * property value to and from an attribute value. * * @public */ number(): PropertyBuilder<{ Value: T; AttributeName: PropertyInfo.ToAttributeName; }>; /** * Defines the property value as a number. * * @remarks * * Sets up transformation functions for converting a number * property value to and from an attribute value. * * @remarks * * Shorthand for calling `number()` method. * * @see {@link number} * @public */ get num(): PropertyBuilder<{ Value: number; AttributeName: PropertyInfo.ToAttributeName; }>; /** * Defines the property value as an integer. * * @remarks * * Sets up transformation functions for converting a integer * property value to and from an attribute value. * * @public */ integer(): PropertyBuilder<{ Value: T; AttributeName: PropertyInfo.ToAttributeName; }>; /** * Defines the property value as an integer. * * @remarks * * Sets up transformation functions for converting a integer * property value to and from an attribute value. * * Shorthand for calling `integer()` method. * * @see {@link integer} * @public */ get int(): PropertyBuilder<{ Value: number; AttributeName: PropertyInfo.ToAttributeName; }>; /** * Defines the property value as a bigint. * * @remarks * * Sets up transformation functions for converting a bigint * property value to and from an attribute value. * * @public */ bigInteger(): PropertyBuilder<{ Value: T; AttributeName: PropertyInfo.ToAttributeName; }>; /** * Defines the property value as a bigint. * * @remarks * * Sets up transformation functions for converting a bigint * property value to and from an attribute value. * * Shorthand for calling `bigInteger()` method. * * @see {@link bigint} * @public */ get bigint(): PropertyBuilder<{ Value: bigint; AttributeName: PropertyInfo.ToAttributeName; }>; /** * Defines the property value as a numeric object. * * @remarks * * Numeric values are those that can be converted to a number using * the `Number()` constructor. This includes objects with a `valueOf()` * method returning a number, or primitives convertible to numbers. * e.g. `Date`. * * Sets up transformation functions for converting a numeric property * value to and from an attribute value. * * @example * * ```ts * define.prop.numeric(Date); * ``` * * @public */ numeric(Constructor: { new (value: number): T; }): PropertyBuilder<{ Value: T; AttributeName: PropertyInfo.ToAttributeName; }>; /** * Defines the property value as a DOM element reference. * * @public */ elementRef(): PropertyBuilder<{ Value: ElementBuilder.Ref; AttributeName: PropertyInfo.ToAttributeName; }>; /** * Defines the property value as an observer. * * @public */ observer(): PropertyBuilder<{ Value: Observable.Subscriber; AttributeName: PropertyInfo.ToAttributeName; }>; /** * Defines the property value as a shallow object or array. * * @remarks * * Because this property is a shallow object, the `shallowEqual` * function is used to compare the property value with the previous value. * As a result, it should be used as the last method called in the chain. * * @alpha This is an experimental feature and may change in the future. */ shallow>(): PropertyDefinition<{ Value: T; AttributeName: PropertyInfo.ToAttributeName; }>; /** * Defines the property value as a style object. * * @remarks * * Because this property is a shallow object, the `shallowEqual` * function is used to compare the property value with the previous value. * As a result, it should be used as the last method called in the chain. */ styleObject(): PropertyDefinition<{ Value: T; AttributeName: PropertyInfo.ToAttributeName; }>; /** * Defines the property value as a style sheet. * * @remarks * * Because this property sets a comparator function, * it should be used as the last method called in the chain. */ styleSheet>(): PropertyDefinition<{ Value: T; AttributeName: false; }>; /** * Defines the property value as a style sheet mixin. * * @remarks * * Because this property sets a comparator function, * it should be used as the last method called in the chain. * * @alpha This is an experimental feature and may change in the future. */ styleSheetMixin(): PropertyDefinition<{ Value: T; AttributeName: PropertyInfo.ToAttributeName; }>; /** * Sets the property's comparator function. * * @remarks * * This is used to compare the property value with the previous value. * It should be used as the last method called in the chain. */ equality(comparator: PropertyDefinition["comparator"]): PropertyDefinition; get [Symbol.toStringTag](): string; } /** * Defines a reactive property, optionally with an attribute name to reflect * the property value. * * @remarks * * * Commonly used for properties and attributes on `KnytElement` instances or * Knyt Glazier includes. * * @public */ export declare function defineProperty(): PropertyBuilder<{ Value: T; AttributeName: false; }>; //# sourceMappingURL=defineProperty.d.ts.map