@swell/swell-ui 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +165 -2
  3. package/custom-elements.json +8274 -0
  4. package/dist/chunks/badge-Dt6q8Cqa.js +11 -0
  5. package/dist/chunks/button-C7nCiu-t.js +123 -0
  6. package/dist/chunks/card-CvSQEug8.js +10 -0
  7. package/dist/chunks/checkbox-BRI_A1TP.js +99 -0
  8. package/dist/chunks/chip-BtnufSMG.js +48 -0
  9. package/dist/chunks/config-C-FYxOaJ.js +588 -0
  10. package/dist/chunks/define-BlQTa1g4.js +19 -0
  11. package/dist/chunks/description-BHfQ8meK.js +19 -0
  12. package/dist/chunks/disclosure-CET8-H6f.js +56 -0
  13. package/dist/chunks/divider-BfkO0c1j.js +27 -0
  14. package/dist/chunks/element-B4-_7TLZ.js +138 -0
  15. package/dist/chunks/input-Uun-ls2_.js +53 -0
  16. package/dist/chunks/link-8qHFEKQE.js +53 -0
  17. package/dist/chunks/link-D4NC86oc.js +24 -0
  18. package/dist/chunks/lookup-5icr_T6o.js +205 -0
  19. package/dist/chunks/lookup-list-Bw6OJoDS.js +19 -0
  20. package/dist/chunks/lookup-option-Mn3k8W2M.js +26 -0
  21. package/dist/chunks/popover-D3Ob6slA.js +92 -0
  22. package/dist/chunks/popup-Dbh2fchP.js +21 -0
  23. package/dist/chunks/quantity-h3wqn8tC.js +140 -0
  24. package/dist/chunks/radio-BhFDL3pO.js +192 -0
  25. package/dist/chunks/radio-option-hT29S8Zl.js +88 -0
  26. package/dist/chunks/select-DS1n_htj.js +331 -0
  27. package/dist/chunks/select-option-DoM9GAe0.js +66 -0
  28. package/dist/chunks/skeleton-DfPjhls9.js +13 -0
  29. package/dist/chunks/status-B23JZ5RQ.js +71 -0
  30. package/dist/chunks/tab-BpjFUbFO.js +107 -0
  31. package/dist/chunks/tabs-aWKq1Iaz.js +122 -0
  32. package/dist/chunks/text-ZWPy-iB3.js +26 -0
  33. package/dist/chunks/text-field-BB_MRt5h.js +158 -0
  34. package/dist/chunks/textarea-L6_OJ2IN.js +18 -0
  35. package/dist/chunks/thumbnail-CLe9AsFg.js +21 -0
  36. package/dist/chunks/toggle-C7-oPgWR.js +22 -0
  37. package/dist/chunks/ui-HcyMKwzs.js +11 -0
  38. package/dist/editors/vscode.css-custom-data.json +824 -0
  39. package/dist/editors/vscode.html-custom-data.json +1156 -0
  40. package/dist/editors/web-types.json +1706 -0
  41. package/dist/elements/badge.d.ts +1 -0
  42. package/dist/elements/badge.js +1 -0
  43. package/dist/elements/button.d.ts +1 -0
  44. package/dist/elements/button.js +1 -0
  45. package/dist/elements/card.d.ts +1 -0
  46. package/dist/elements/card.js +1 -0
  47. package/dist/elements/checkbox.d.ts +1 -0
  48. package/dist/elements/checkbox.js +1 -0
  49. package/dist/elements/chip.d.ts +1 -0
  50. package/dist/elements/chip.js +1 -0
  51. package/dist/elements/disclosure.d.ts +1 -0
  52. package/dist/elements/disclosure.js +1 -0
  53. package/dist/elements/divider.d.ts +1 -0
  54. package/dist/elements/divider.js +1 -0
  55. package/dist/elements/input.d.ts +1 -0
  56. package/dist/elements/input.js +1 -0
  57. package/dist/elements/link.d.ts +1 -0
  58. package/dist/elements/link.js +1 -0
  59. package/dist/elements/lookup-list.d.ts +1 -0
  60. package/dist/elements/lookup-list.js +1 -0
  61. package/dist/elements/lookup-option.d.ts +1 -0
  62. package/dist/elements/lookup-option.js +1 -0
  63. package/dist/elements/lookup.d.ts +1 -0
  64. package/dist/elements/lookup.js +1 -0
  65. package/dist/elements/popover.d.ts +1 -0
  66. package/dist/elements/popover.js +1 -0
  67. package/dist/elements/quantity.d.ts +1 -0
  68. package/dist/elements/quantity.js +1 -0
  69. package/dist/elements/radio-option.d.ts +1 -0
  70. package/dist/elements/radio-option.js +1 -0
  71. package/dist/elements/radio.d.ts +1 -0
  72. package/dist/elements/radio.js +1 -0
  73. package/dist/elements/select-option.d.ts +1 -0
  74. package/dist/elements/select-option.js +1 -0
  75. package/dist/elements/select.d.ts +1 -0
  76. package/dist/elements/select.js +1 -0
  77. package/dist/elements/skeleton.d.ts +1 -0
  78. package/dist/elements/skeleton.js +1 -0
  79. package/dist/elements/status.d.ts +1 -0
  80. package/dist/elements/status.js +1 -0
  81. package/dist/elements/tab.d.ts +1 -0
  82. package/dist/elements/tab.js +1 -0
  83. package/dist/elements/tabs.d.ts +1 -0
  84. package/dist/elements/tabs.js +1 -0
  85. package/dist/elements/text.d.ts +1 -0
  86. package/dist/elements/text.js +1 -0
  87. package/dist/elements/textarea.d.ts +1 -0
  88. package/dist/elements/textarea.js +1 -0
  89. package/dist/elements/thumbnail.d.ts +1 -0
  90. package/dist/elements/thumbnail.js +1 -0
  91. package/dist/elements/ui.d.ts +1 -0
  92. package/dist/elements/ui.js +1 -0
  93. package/dist/frameworks/jsx.d.ts +3589 -0
  94. package/dist/frameworks/preact.d.ts +9 -0
  95. package/dist/frameworks/solid.d.ts +7 -0
  96. package/dist/frameworks/svelte.d.ts +1676 -0
  97. package/dist/frameworks/vue.d.ts +827 -0
  98. package/dist/index.js +80 -0
  99. package/dist/react/badge.d.ts +12 -0
  100. package/dist/react/badge.js +4 -0
  101. package/dist/react/button.d.ts +16 -0
  102. package/dist/react/button.js +4 -0
  103. package/dist/react/card.d.ts +11 -0
  104. package/dist/react/card.js +4 -0
  105. package/dist/react/checkbox.d.ts +14 -0
  106. package/dist/react/checkbox.js +4 -0
  107. package/dist/react/chip.d.ts +12 -0
  108. package/dist/react/chip.js +4 -0
  109. package/dist/react/create.js +49 -0
  110. package/dist/react/disclosure.d.ts +11 -0
  111. package/dist/react/disclosure.js +4 -0
  112. package/dist/react/divider.d.ts +9 -0
  113. package/dist/react/divider.js +4 -0
  114. package/dist/react/index.d.ts +26 -0
  115. package/dist/react/index.js +26 -0
  116. package/dist/react/input.d.ts +28 -0
  117. package/dist/react/input.js +4 -0
  118. package/dist/react/link.d.ts +15 -0
  119. package/dist/react/link.js +4 -0
  120. package/dist/react/lookup-list.d.ts +9 -0
  121. package/dist/react/lookup-list.js +4 -0
  122. package/dist/react/lookup-option.d.ts +11 -0
  123. package/dist/react/lookup-option.js +4 -0
  124. package/dist/react/lookup.d.ts +28 -0
  125. package/dist/react/lookup.js +4 -0
  126. package/dist/react/popover.d.ts +11 -0
  127. package/dist/react/popover.js +4 -0
  128. package/dist/react/quantity.d.ts +15 -0
  129. package/dist/react/quantity.js +4 -0
  130. package/dist/react/radio-option.d.ts +11 -0
  131. package/dist/react/radio-option.js +4 -0
  132. package/dist/react/radio.d.ts +18 -0
  133. package/dist/react/radio.js +4 -0
  134. package/dist/react/select-option.d.ts +11 -0
  135. package/dist/react/select-option.js +4 -0
  136. package/dist/react/select.d.ts +20 -0
  137. package/dist/react/select.js +4 -0
  138. package/dist/react/skeleton.d.ts +11 -0
  139. package/dist/react/skeleton.js +4 -0
  140. package/dist/react/status.d.ts +12 -0
  141. package/dist/react/status.js +4 -0
  142. package/dist/react/tab.d.ts +10 -0
  143. package/dist/react/tab.js +4 -0
  144. package/dist/react/tabs.d.ts +17 -0
  145. package/dist/react/tabs.js +4 -0
  146. package/dist/react/text.d.ts +12 -0
  147. package/dist/react/text.js +4 -0
  148. package/dist/react/textarea.d.ts +23 -0
  149. package/dist/react/textarea.js +4 -0
  150. package/dist/react/thumbnail.d.ts +13 -0
  151. package/dist/react/thumbnail.js +4 -0
  152. package/dist/react/ui.d.ts +10 -0
  153. package/dist/react/ui.js +4 -0
  154. package/dist/types/components/core/badge/badge.d.ts +25 -0
  155. package/dist/types/components/core/button/button.d.ts +60 -0
  156. package/dist/types/components/core/card/card.d.ts +21 -0
  157. package/dist/types/components/core/checkbox/checkbox.d.ts +46 -0
  158. package/dist/types/components/core/chip/chip.d.ts +36 -0
  159. package/dist/types/components/core/disclosure/disclosure.d.ts +37 -0
  160. package/dist/types/components/core/divider/divider.d.ts +21 -0
  161. package/dist/types/components/core/index.d.ts +21 -0
  162. package/dist/types/components/core/input/input.d.ts +57 -0
  163. package/dist/types/components/core/link/link.d.ts +42 -0
  164. package/dist/types/components/core/lookup/lookup-list.d.ts +21 -0
  165. package/dist/types/components/core/lookup/lookup-option.d.ts +27 -0
  166. package/dist/types/components/core/lookup/lookup.d.ts +32 -0
  167. package/dist/types/components/core/popover/popover.d.ts +33 -0
  168. package/dist/types/components/core/quantity/quantity.d.ts +47 -0
  169. package/dist/types/components/core/radio/radio-option.d.ts +82 -0
  170. package/dist/types/components/core/radio/radio.d.ts +65 -0
  171. package/dist/types/components/core/select/select-option.d.ts +69 -0
  172. package/dist/types/components/core/select/select.d.ts +70 -0
  173. package/dist/types/components/core/skeleton/skeleton.d.ts +23 -0
  174. package/dist/types/components/core/status/status.d.ts +38 -0
  175. package/dist/types/components/core/tabs/tab.d.ts +76 -0
  176. package/dist/types/components/core/tabs/tabs.d.ts +46 -0
  177. package/dist/types/components/core/text/text.d.ts +23 -0
  178. package/dist/types/components/core/textarea/textarea.d.ts +45 -0
  179. package/dist/types/components/core/thumbnail/thumbnail.d.ts +27 -0
  180. package/dist/types/components/core/ui/ui.d.ts +16 -0
  181. package/dist/types/components/elements.d.ts +1 -0
  182. package/dist/types/react/create.d.ts +8 -0
  183. package/dist/types/runtime/config.d.ts +25 -0
  184. package/dist/types/runtime/css.d.ts +12 -0
  185. package/dist/types/runtime/define.d.ts +4 -0
  186. package/dist/types/runtime/description.d.ts +12 -0
  187. package/dist/types/runtime/element.d.ts +61 -0
  188. package/dist/types/runtime/focus.d.ts +5 -0
  189. package/dist/types/runtime/form.d.ts +5 -0
  190. package/dist/types/runtime/index.d.ts +2 -0
  191. package/dist/types/runtime/link.d.ts +17 -0
  192. package/dist/types/runtime/loader.d.ts +21 -0
  193. package/dist/types/runtime/popup.d.ts +8 -0
  194. package/dist/types/runtime/sheet.d.ts +31 -0
  195. package/dist/types/runtime/text-field.d.ts +47 -0
  196. package/dist/types/runtime/toggle.d.ts +8 -0
  197. package/dist/types/runtime/tokens.generated.d.ts +492 -0
  198. package/dist/types/runtime/values.d.ts +6 -0
  199. package/dist/types/runtime/variants.d.ts +4 -0
  200. package/package.json +136 -4
  201. package/resolver.json +111 -0
  202. package/src/components/core/badge/tokens.json +152 -0
  203. package/src/components/core/button/tokens.dark.json +16 -0
  204. package/src/components/core/button/tokens.json +232 -0
  205. package/src/components/core/card/tokens.json +35 -0
  206. package/src/components/core/checkbox/tokens.json +15 -0
  207. package/src/components/core/chip/tokens.json +144 -0
  208. package/src/components/core/link/tokens.json +24 -0
  209. package/src/components/core/radio/tokens.dark.json +17 -0
  210. package/src/components/core/radio/tokens.json +114 -0
  211. package/src/components/core/status/tokens.dark.json +71 -0
  212. package/src/components/core/status/tokens.json +135 -0
  213. package/src/components/core/tabs/tokens.json +80 -0
  214. package/src/components/core/text/tokens.json +222 -0
  215. package/src/components/core/thumbnail/tokens.json +46 -0
  216. package/tokens/border.json +38 -0
  217. package/tokens/color.dark.json +88 -0
  218. package/tokens/color.json +115 -0
  219. package/tokens/control.json +115 -0
  220. package/tokens/field.dark.json +65 -0
  221. package/tokens/field.json +158 -0
  222. package/tokens/focus.json +26 -0
  223. package/tokens/font.json +117 -0
  224. package/tokens/motion.json +49 -0
  225. package/tokens/overlay.json +81 -0
@@ -0,0 +1,25 @@
1
+ import { type Config, type Theme } from "./tokens.generated.js";
2
+ /** The kit's defaults of every global token, on the page root; under reduced motion, every duration this copy knows is zero. */
3
+ export declare const defaultsSheet: CSSStyleSheet;
4
+ /** The release whose configuration holds the page: this copy's, or the first copy's when the kit loaded twice. */
5
+ export declare const version: string;
6
+ /** The host's values and theme, on the page root after the defaults, and each area's on its `<swell-ui>`. */
7
+ export declare const configSheet: CSSStyleSheet;
8
+ /**
9
+ * Replaces the page's configuration, its theme included; with no configuration, restores the defaults. The configurations of areas stay.
10
+ * With `id`, replaces the configuration of that area instead: its tokens and theme apply inside every `<swell-ui config="id">`, and no configuration removes it.
11
+ */
12
+ export declare const configure: (config?: Config | null, id?: string) => void;
13
+ /** Chooses the light theme, the dark one, or the system setting, and keeps the rest of the configuration. */
14
+ export declare const setTheme: (theme: Theme) => void;
15
+ /** A copy of the page's applied configuration with the theme in effect; with `id`, a copy of that area's own configuration. */
16
+ export declare const getConfig: (id?: string) => Config;
17
+ /** The host's own variants, the palettes its configurations add to `color`. */
18
+ export declare const hostVariants: () => readonly string[];
19
+ /** Calls `listener` after every `configure`, the page's or an area's, and every `setTheme`; returns the function that unsubscribes it. */
20
+ export declare const onChange: (listener: () => void) => () => void;
21
+ /**
22
+ * The value of setting `name` on `node`: the host's, else the kit's default; `undefined` when the node has none.
23
+ * A setting the first copy doesn't know takes this copy's default.
24
+ */
25
+ export declare function resolveSetting(node: string, name: string): string | undefined;
@@ -0,0 +1,12 @@
1
+ /** CSS naming shared by the runtime and the token tool; this module imports nothing. */
2
+ /** The CSS variable of token `name`: `button.color.background` → `--swell-button-color-background`. */
3
+ export declare const cssVar: (name: string) => string;
4
+ /** The roles of a variant's palette, such as `color.secondary.background`: it holds the first four and may leave out `shadow`. */
5
+ export declare const VARIANT_ROLES: readonly ["background", "foreground", "border", "accent", "shadow"];
6
+ export declare const REQUIRED_VARIANT_ROLES: ("background" | "foreground" | "border" | "accent" | "shadow")[];
7
+ /** The private alias a component reads token `name` through, declared on its element: `--_swell-button-color-background`. */
8
+ export declare const alias: (name: string) => string;
9
+ /** A CSS time, such as `250ms` or `0.25s`, in milliseconds. */
10
+ export declare const milliseconds: (time: string) => number;
11
+ /** A font family name as CSS: a generic family or a single identifier as is, any other name quoted. */
12
+ export declare function familyName(name: string): string;
@@ -0,0 +1,4 @@
1
+ /** Defines a custom element once; a second copy of the kit on the page reuses the first one's element. */
2
+ export declare function defineElement(tag: `swell-${string}`, element: CustomElementConstructor): void;
3
+ /** Re-applies a property that was set on the element before its class was defined. */
4
+ export declare function upgradeProperty(element: HTMLElement, name: string): void;
@@ -0,0 +1,12 @@
1
+ /** The hint and the error of a field component, and how they describe its native control. */
2
+ export interface Description {
3
+ hint: HTMLElement;
4
+ error: HTMLElement;
5
+ }
6
+ /** Creates the hint and error elements, with classes `<prefix>-hint` and `<prefix>-error`. */
7
+ export declare function createDescription(prefix: string, id: string): Description;
8
+ /**
9
+ * Shows the field's `hint`, and its `error` while it is `invalid`, and points the control (a native input or a radio group) to them.
10
+ * The host's own hint content, `custom`, takes the place of the `hint` text.
11
+ */
12
+ export declare function describe(field: HTMLElement, control: HTMLElement, { hint, error }: Description, custom?: HTMLElement): void;
@@ -0,0 +1,61 @@
1
+ /** A copy of the markup of a class's shadow root, its static `template`, parsed once per class. */
2
+ export declare function cloneTemplate(owner: {
3
+ template: string;
4
+ }): DocumentFragment;
5
+ /** The base of every Swell UI element: it turns the appearance into a custom state. */
6
+ export declare abstract class SwellElement extends HTMLElement {
7
+ #private;
8
+ /** The token group whose attribute values the element supports, such as `button`. */
9
+ static group: string | null;
10
+ /** The settings node of the element's appearance, such as `button` or `field`. */
11
+ static appearance: string | null;
12
+ /** Appearances the element takes from its `appearance` attribute only, beyond the values of its setting, such as the radio's `segmented`. */
13
+ static appearances: string[];
14
+ /** The component's CSS, imported with `?inline`. */
15
+ static styles: string;
16
+ static observedAttributes: string[];
17
+ protected readonly internals: ElementInternals;
18
+ constructor();
19
+ protected get definition(): typeof SwellElement;
20
+ connectedCallback(): void;
21
+ disconnectedCallback(): void;
22
+ attributeChangedCallback(name: string, previous: string | null, value: string | null): void;
23
+ /** Called when an observed attribute changes. */
24
+ protected update(_name: string): void;
25
+ /** The element whose `appearance` and `variant` attributes set this element's appearance: the element itself, or a radio option's group. */
26
+ protected appearanceSource(): Element;
27
+ /** States beyond the appearance, such as the label position of a field. */
28
+ protected extraStates(): string[];
29
+ protected stylesheet(): CSSStyleSheet;
30
+ protected updateStates(): void;
31
+ }
32
+ /** Where a field's label sits: from the `field.label.position` setting, and above at size `xsmall`, which has no room for a floating label. */
33
+ export declare function labelPosition(field: Element): string | undefined;
34
+ /**
35
+ * Puts a focusable host into the tab order or takes it out. `tabindex="0"` counts as the kit's, also on a clone, which copies it; any other value is the host's and stays.
36
+ */
37
+ export declare function syncTabStop(host: HTMLElement, inTabOrder: boolean): void;
38
+ /**
39
+ * Makes a host with the button role click on Enter, as the key goes down, and on Space, as it comes up, as a native button does.
40
+ * A key that another listener cancelled, or that was pressed on a control in its shadow root, such as a link's anchor, keeps its own action; an inactive host takes the keys and stays still.
41
+ */
42
+ export declare function clickOnKeys(host: HTMLElement, inactive?: () => boolean): void;
43
+ /** A component that renders into shadow DOM and shows its children through slots. */
44
+ export declare abstract class SwellShadowElement extends SwellElement {
45
+ static template: string;
46
+ static shadowOptions: ShadowRootInit;
47
+ constructor();
48
+ }
49
+ /** A field component: it renders its own markup into light DOM and styles it from the root that holds it. */
50
+ export declare abstract class SwellFieldElement extends SwellElement {
51
+ #private;
52
+ /** Whether the element shows the label position as a state. */
53
+ static labelPosition: boolean;
54
+ connectedCallback(): void;
55
+ /**
56
+ * Builds the element's markup; runs once, on the first connect.
57
+ * Children found here are the markup of a deep clone's original, whose native control keeps the user's state, and a text field's `start` and `end` content, which stays.
58
+ */
59
+ protected abstract render(): void;
60
+ protected extraStates(): string[];
61
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Focuses the first control among `host`'s children, its trigger left out, that takes the focus (a hidden or disabled one doesn't);
3
+ * else `fallback`, for as long as it holds the focus.
4
+ */
5
+ export declare function focusFirst(host: Element, fallback: HTMLElement): void;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Enter in a field submits its form through the form's first submit button, as a browser does for native buttons.
3
+ * A native submit button is left to the browser; a `<swell-button>` is clicked, so a disabled one submits nothing.
4
+ */
5
+ export declare function submitImplicitly(event: KeyboardEvent, control: HTMLInputElement): void;
@@ -0,0 +1,2 @@
1
+ export { configure, getConfig, onChange, setTheme } from "./config.js";
2
+ export type { Color, Config, Theme } from "./tokens.generated.js";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Links a group element with its child elements, such as a radio group with its options:
3
+ * a child reaches its group's link through its parent, and the group applies its state to each child.
4
+ * The child's class passes its private way of taking the state to `receive` from a static block.
5
+ */
6
+ export declare function groupLink<Link, Child extends Element, State>(): {
7
+ /** Registers `group`, so the children among its children can reach it. */
8
+ link(group: Element, link: Link): void;
9
+ /** The group of a child: its parent, when the parent is linked. */
10
+ groupOf(child: Element): Element | undefined;
11
+ /** The link of a child's group, looked up on use, since the group may be defined after the child connected. */
12
+ linkOf(child: Element): Link | undefined;
13
+ /** Sets how a child takes its state. */
14
+ receive(fn: (child: Child, state: State) => void): void;
15
+ /** Applies the group's state to a child. */
16
+ sync(child: Child, state: State): void;
17
+ };
@@ -0,0 +1,21 @@
1
+ /** Where the kit's elements are searched for and observed: a document, a shadow root, or an element in either. */
2
+ export type Root = Document | ShadowRoot | Element;
3
+ export interface Loader {
4
+ /**
5
+ * With a root, loads the chunk of every undefined kit element in it and of each one added to it later; with tag names, loads those tags.
6
+ * Resolves when they are defined, and rejects when a chunk can't load.
7
+ */
8
+ load: (target: Root | readonly string[]) => Promise<void>;
9
+ /** Resolves when `tags` are defined; without them, the kit's tags undefined in the document now. */
10
+ ready: (tags?: readonly string[]) => Promise<void>;
11
+ }
12
+ /** Whether a module URL is the kit's entry the platform serves, `/.swell/ui/v<major>/index.js`, rather than a host's bundle that holds the kit. */
13
+ export declare const servedByPlatform: (url: string) => boolean;
14
+ /**
15
+ * The loader of the kit's elements: each tag's chunk loads the first time the tag appears.
16
+ * With `page`, the loader is the page's: it reports in the console a chunk that fails. With `page.refresh`, when a chunk fails,
17
+ * such as one a later deploy removed, it first reads a fresh module map once and loads the tag from it.
18
+ */
19
+ export declare function createLoader(elements: Record<string, () => Promise<unknown>>, page?: {
20
+ refresh?: () => Promise<Pick<Loader, "load">>;
21
+ }): Loader;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Places a fixed popup under `anchor`, or above it when there is more room there, at least as wide as the anchor.
3
+ * It lines up with the anchor's start edge in the direction of `host`, or with its end edge when it would leave the window there;
4
+ * when both would, it moves into the window, `EDGE` from its sides as far as its width allows. It keeps `overlay.offset` from the anchor and grows to `overlay.height` at most. Returns whether the popup went above.
5
+ */
6
+ export declare function place(anchor: Element, popup: HTMLElement, host: Element): boolean;
7
+ /** Calls `update` while the page scrolls or the window resizes; returns the function that stops it. */
8
+ export declare function follow(update: () => void): () => void;
@@ -0,0 +1,31 @@
1
+ import { type Config, type Theme } from "./tokens.generated.js";
2
+ export interface Flattened {
3
+ /** Configured values by token name. */
4
+ tokens: Map<string, unknown>;
5
+ /** Configured settings by setting name, such as `button.secondary.appearance`. */
6
+ settings: Map<string, string>;
7
+ /** The theme the host chose; none means the page's `color-scheme`. */
8
+ theme?: Theme;
9
+ /** The accepted values, the theme included, at their configuration paths. */
10
+ config: Config;
11
+ /** One message per key or value that was skipped. */
12
+ warnings: string[];
13
+ /** The area the configuration belongs to; none for the page's. */
14
+ area?: string;
15
+ /** The host's own variants, the palettes the configuration adds to `color`. */
16
+ variants: string[];
17
+ }
18
+ export declare const THEMES: readonly Theme[];
19
+ /**
20
+ * Reads a configuration into token and setting names: each key sits at its name, a component's under `components`.
21
+ * No configuration, `undefined` or `null`, reads as an empty one.
22
+ * The configuration of an area, named by `area`, holds tokens and a theme: its settings are reported and skipped.
23
+ */
24
+ export declare function flatten(config: unknown, area?: string): Flattened;
25
+ /** Zero for every duration under reduced motion, on the page root and in every area. */
26
+ export declare const REDUCED_MOTION: string;
27
+ /**
28
+ * The configuration stylesheet: the page's values and theme on the page root, then each area's on its `<swell-ui config>`.
29
+ * Inside an area, a token whose default references another one is declared again, so it follows the area's values, unless the page or the area gives it a value.
30
+ */
31
+ export declare function buildConfigCss(page: Flattened, areas?: ReadonlyMap<string, Flattened>): string;
@@ -0,0 +1,47 @@
1
+ import { SwellFieldElement } from "./element.js";
2
+ type Control = HTMLInputElement | HTMLTextAreaElement;
3
+ /**
4
+ * A text field: a native control with its label, hint and error, rendered into light DOM.
5
+ * Its shadow root only lays them out: the label above, the frame that draws the field around the control, and the hint and error under it.
6
+ * A subclass names its control and the attributes it passes to it.
7
+ */
8
+ export declare abstract class SwellTextFieldElement extends SwellFieldElement {
9
+ #private;
10
+ static appearance: string;
11
+ /** The shadow root's markup; a floating label goes into the frame's `control` slot, a label above into `label`. */
12
+ static template: string;
13
+ /** The tag of the native control. */
14
+ static control: "input" | "textarea";
15
+ /** The prefix of the classes and ids of the field's parts, such as `swell-input`. */
16
+ static prefix: string;
17
+ /** Attributes copied to the native control as they are. */
18
+ static passed: string[];
19
+ /** Attributes the subclass handles itself, in `syncControl`. */
20
+ static own: string[];
21
+ /** Every attribute a text field observes, for the subclass's `observedAttributes`. */
22
+ static attributesOf(passed: string[], own?: string[]): string[];
23
+ constructor();
24
+ /** The current value of the field. */
25
+ get value(): string;
26
+ set value(value: string);
27
+ get disabled(): boolean;
28
+ set disabled(value: boolean);
29
+ get required(): boolean;
30
+ set required(value: boolean);
31
+ get readOnly(): boolean;
32
+ set readOnly(value: boolean);
33
+ get invalid(): boolean;
34
+ set invalid(value: boolean);
35
+ get name(): string;
36
+ set name(value: string);
37
+ focus(options?: FocusOptions): void;
38
+ connectedCallback(): void;
39
+ /** Sets up the native control once it is created, such as its listeners. */
40
+ protected setUpControl(_control: Control): void;
41
+ /** Applies an attribute from the subclass's `own` list to the native control. */
42
+ protected syncControl(_name: string, _control: Control): void;
43
+ protected render(): void;
44
+ protected updateStates(): void;
45
+ protected update(name: string): void;
46
+ }
47
+ export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Announces the changes of a host's `open` with a `toggle` event, once the script that changed it has run, with the state before and after.
3
+ * The event neither bubbles nor cancels, as a native popover's; changes that end where they started fire nothing.
4
+ * Returns the function to call on each change of `open`.
5
+ */
6
+ export declare function announceToggle(host: HTMLElement & {
7
+ open: boolean;
8
+ }): () => void;