@websublime/line-components 0.2.0 → 0.2.2

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.
@@ -0,0 +1,84 @@
1
+ import { LineElement } from '@websublime/line-core';
2
+ import { type PropertyDeclarations, type PropertyValues, type TemplateResult } from 'lit';
3
+ import type { ButtonFormEnctype, ButtonFormMethod, ButtonType, ButtonVariant } from './button.types.js';
4
+ declare const LineButton_base: typeof LineElement & (new (...args: any[]) => import("@websublime/line-core").FormAssociatedMembers) & {
5
+ readonly formAssociated: true;
6
+ };
7
+ /**
8
+ * `<line-button>` runs an action when the user activates it. It renders a
9
+ * native `<button>` in its shadow root, and the host is a form-associated
10
+ * custom element, so `type="submit"` and `type="reset"` act on its form as a
11
+ * native button does. `pressed` makes it a toggle; `loading` keeps it
12
+ * focusable while it ignores presses.
13
+ *
14
+ * @summary A form-associated button that runs an action, submits or resets its form, or toggles with `pressed`.
15
+ *
16
+ * @slot - The label: text or inline content.
17
+ * @slot prefix - A leading icon.
18
+ * @slot suffix - A trailing icon.
19
+ * @slot loading - A spinner, loading text or both; rendered only while `loading` is on.
20
+ *
21
+ * @csspart root - The inner native `<button>`: box, background, border and focus ring.
22
+ * @csspart label - Wraps the default slot.
23
+ * @csspart loading - Wraps the `loading` slot; present only while `loading` is on.
24
+ *
25
+ * @cssprop [--line-button-radius=var(--line-radius-2)] - Corner radius of `root`.
26
+ * @cssprop [--line-button-bg=var(--line-gray-bg)] - Background of `root`; `primary` uses `var(--line-accent-solid)` and `borderless` uses `transparent`.
27
+ * @cssprop [--line-button-color=var(--line-gray-text)] - Text colour of `root`; `primary` uses `var(--line-accent-contrast)` and `borderless` uses `var(--line-accent-text)`.
28
+ * @cssprop [--line-button-height=var(--line-size-7)] - Minimum block size of `root`.
29
+ * @cssprop [--line-button-padding-inline=var(--line-size-3)] - Inline padding of `root`.
30
+ * @cssprop [--line-button-gap=var(--line-size-2)] - Gap between the prefix, label, suffix and loading zones.
31
+ * @cssprop [--line-button-font-size=var(--line-font-size-1)] - Font size of `root`.
32
+ * @cssprop [--line-button-font-weight=var(--line-font-weight-5)] - Font weight of `root`.
33
+ * @cssprop [--line-button-focus-ring=var(--line-focus-ring, 2px solid currentColor)] - `outline` of `root` while the host has `data-focus-visible`.
34
+ *
35
+ * @fires {CustomEvent<LineButtonChangeDetail>} line-change - A user activation flipped `pressed` on a toggle button; `detail.value` is the new state. Bubbles, not composed.
36
+ *
37
+ * @attr {string} name - The key the submitter value goes under; read through the inherited `name` getter.
38
+ */
39
+ export declare class LineButton extends LineButton_base {
40
+ #private;
41
+ static shadowRootOptions: ShadowRootInit;
42
+ static properties: PropertyDeclarations;
43
+ static styles: (import("lit").CSSResult | CSSStyleSheet)[];
44
+ /** Semantic emphasis; an unknown value behaves as `default`. */
45
+ variant: ButtonVariant;
46
+ /** What activation does to the form owner; an unknown value behaves as `submit`. */
47
+ type: ButtonType;
48
+ /** Removes the button from the tab order and blocks activation. */
49
+ disabled: boolean;
50
+ /** Keeps focus, sets `aria-disabled="true"`, blocks activation and renders the `loading` part. */
51
+ loading: boolean;
52
+ /** `undefined` means not a toggle; a toggle flips it on each activation and fires `line-change`. */
53
+ pressed: boolean | undefined;
54
+ /** The submitter value; it enters the form data only when this button submits. */
55
+ value: string;
56
+ /** Overrides the form's `action` when this button submits. */
57
+ formAction: string;
58
+ /** Overrides the form's `method` when this button submits. */
59
+ formMethod: ButtonFormMethod | undefined;
60
+ /** Overrides the form's `enctype` when this button submits. */
61
+ formEnctype: ButtonFormEnctype | undefined;
62
+ /** Overrides the form's `target` when this button submits. */
63
+ formTarget: string | undefined;
64
+ /** Skips constraint validation when this button submits. */
65
+ formNoValidate: boolean;
66
+ /** External validity: a non-empty message marks the button invalid while `type` is `submit`. */
67
+ customValidity: string;
68
+ /** Copied to the inner button, where it names the role. */
69
+ ariaLabel: string | null;
70
+ /** Copied to the inner button. */
71
+ ariaDescription: string | null;
72
+ constructor();
73
+ formDisabledCallback(disabled: boolean): void;
74
+ protected update(changed: PropertyValues<this>): void;
75
+ protected updated(changed: PropertyValues<this>): void;
76
+ render(): TemplateResult;
77
+ }
78
+ declare global {
79
+ interface HTMLElementTagNameMap {
80
+ 'line-button': LineButton;
81
+ }
82
+ }
83
+ export {};
84
+ //# sourceMappingURL=button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/button/button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpE,OAAO,EAML,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAUb,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,aAAa,EAEd,MAAM,mBAAmB,CAAC;;;;AA8B3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,UAAW,SAAQ,eAA2B;;IACzD,OAAgB,iBAAiB,EAAE,cAAc,CAA6D;IAE9G,OAAgB,UAAU,EAAE,oBAAoB,CAe9C;IAEF,OAAgB,MAAM,8CAkDpB;IAEF,gEAAgE;IACxD,OAAO,EAAE,aAAa,CAAC;IAC/B,oFAAoF;IAC5E,IAAI,EAAE,UAAU,CAAC;IACzB,mEAAmE;IAC3D,QAAQ,EAAE,OAAO,CAAC;IAC1B,kGAAkG;IAC1F,OAAO,EAAE,OAAO,CAAC;IACzB,oGAAoG;IAC5F,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IACrC,kFAAkF;IAC1E,KAAK,EAAE,MAAM,CAAC;IACtB,8DAA8D;IACtD,UAAU,EAAE,MAAM,CAAC;IAC3B,8DAA8D;IACtD,UAAU,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACjD,+DAA+D;IACvD,WAAW,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACnD,8DAA8D;IACtD,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,4DAA4D;IACpD,cAAc,EAAE,OAAO,CAAC;IAChC,gGAAgG;IACxF,cAAc,EAAE,MAAM,CAAC;IAC/B,2DAA2D;IACnD,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,kCAAkC;IAC1B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IA4BvC,cAWC;IAEQ,oBAAoB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAGrD;IAyFD,UAAmB,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI,CAQ7D;IAED,UAAmB,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI,CAU9D;IAEQ,MAAM,IAAI,cAAc,CAkBhC;CACF;AAID,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,UAAU,CAAC;KAC3B;CACF"}
@@ -0,0 +1,13 @@
1
+ /** Semantic emphasis of `<line-button>` (ARCH §17.2 C6). */
2
+ export type ButtonVariant = 'default' | 'primary' | 'borderless';
3
+ /** What activation does to the form owner, as on a native `<button>`. */
4
+ export type ButtonType = 'submit' | 'reset' | 'button';
5
+ /** The `formmethod` override values. */
6
+ export type ButtonFormMethod = 'get' | 'post' | 'dialog';
7
+ /** The `formenctype` override values. */
8
+ export type ButtonFormEnctype = 'application/x-www-form-urlencoded' | 'multipart/form-data' | 'text/plain';
9
+ /** `detail` of the `line-change` event: the new pressed state of a toggle button. */
10
+ export interface LineButtonChangeDetail {
11
+ value: boolean;
12
+ }
13
+ //# sourceMappingURL=button.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button.types.d.ts","sourceRoot":"","sources":["../../src/button/button.types.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,YAAY,CAAC;AAEjE,yEAAyE;AACzE,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEvD,wCAAwC;AACxC,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEzD,yCAAyC;AACzC,MAAM,MAAM,iBAAiB,GAAG,mCAAmC,GAAG,qBAAqB,GAAG,YAAY,CAAC;AAE3G,qFAAqF;AACrF,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,OAAO,CAAC;CAChB"}
@@ -0,0 +1,3 @@
1
+ export { LineButton } from './button.js';
2
+ export type { ButtonFormEnctype, ButtonFormMethod, ButtonType, ButtonVariant, LineButtonChangeDetail, } from './button.types.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/button/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,sBAAsB,GACvB,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,333 @@
1
+ import { FormAssociated as e, LineElement as t } from "@websublime/line-core";
2
+ import { LineMachineController as n } from "@websublime/line-core/machine";
3
+ import { buttonReset as r, commonReset as i } from "@websublime/line-core/styles";
4
+ import { LitElement as a, css as o, html as s, nothing as c } from "lit";
5
+ import { ifDefined as l } from "lit/directives/if-defined.js";
6
+ import { createMachine as u } from "@zag-js/core";
7
+ //#region src/shared/button-machine.ts
8
+ var d = u({
9
+ initialState: () => "idle",
10
+ context: ({ bindable: e }) => ({ focusVisible: e(() => ({ defaultValue: !1 })) }),
11
+ watch({ track: e, prop: t, guard: n, send: r }) {
12
+ e([() => t("disabled"), () => t("loading")], () => {
13
+ n("isInteractive") || r({ type: "PRESS_CANCEL" });
14
+ });
15
+ },
16
+ on: {
17
+ ACTIVATE: {
18
+ guard: "isInteractive",
19
+ actions: ["togglePressed"]
20
+ },
21
+ FOCUS: { actions: ["setFocusVisible"] },
22
+ BLUR: { actions: ["clearFocusVisible"] }
23
+ },
24
+ states: {
25
+ idle: { on: { PRESS_START: {
26
+ target: "active",
27
+ guard: "isInteractive"
28
+ } } },
29
+ active: { on: {
30
+ PRESS_END: { target: "idle" },
31
+ PRESS_CANCEL: { target: "idle" }
32
+ } }
33
+ },
34
+ implementations: {
35
+ guards: { isInteractive: ({ prop: e }) => !(e("disabled") || e("loading")) },
36
+ actions: {
37
+ togglePressed({ prop: e }) {
38
+ let t = e("pressed");
39
+ t !== void 0 && e("onPressedChange")?.(!t);
40
+ },
41
+ setFocusVisible({ context: e, event: t }) {
42
+ e.set("focusVisible", t.type === "FOCUS" && t.visible === !0);
43
+ },
44
+ clearFocusVisible({ context: e }) {
45
+ e.set("focusVisible", !1);
46
+ }
47
+ }
48
+ }
49
+ });
50
+ function f(e, t, n) {
51
+ let r = e.disabled === !0, i = e.loading === !0;
52
+ return {
53
+ active: t,
54
+ pressed: e.pressed === !0,
55
+ loading: i,
56
+ disabled: r,
57
+ focusVisible: n,
58
+ interactive: !(r || i),
59
+ buttonAttrs: {
60
+ "aria-pressed": e.pressed === void 0 ? void 0 : String(e.pressed),
61
+ "aria-disabled": i && !r ? "true" : void 0,
62
+ disabled: r
63
+ }
64
+ };
65
+ }
66
+ function p(e) {
67
+ let { prop: t } = e;
68
+ return f({
69
+ disabled: t("disabled"),
70
+ loading: t("loading"),
71
+ pressed: t("pressed")
72
+ }, e.state.matches("active"), e.context.get("focusVisible"));
73
+ }
74
+ function m(e) {
75
+ return f(e, !1, !1);
76
+ }
77
+ //#endregion
78
+ //#region src/button/button.ts
79
+ var h = [
80
+ "default",
81
+ "primary",
82
+ "borderless"
83
+ ], g = [
84
+ "submit",
85
+ "reset",
86
+ "button"
87
+ ], _ = [
88
+ "formaction",
89
+ "formmethod",
90
+ "formenctype",
91
+ "formtarget",
92
+ "formnovalidate"
93
+ ], v = { fromAttribute: (e) => h.find((t) => t === e) ?? "default" }, y = { fromAttribute: (e) => g.find((t) => t === e?.toLowerCase()) ?? "submit" }, b = {
94
+ fromAttribute: (e) => e === null ? void 0 : e !== "false",
95
+ toAttribute: (e) => e === void 0 ? null : String(e)
96
+ }, x = {
97
+ fromAttribute: (e) => e ?? "",
98
+ toAttribute: (e) => e || null
99
+ }, S = class extends e(t) {
100
+ static {
101
+ this.shadowRootOptions = {
102
+ ...a.shadowRootOptions,
103
+ delegatesFocus: !0
104
+ };
105
+ }
106
+ static {
107
+ this.properties = {
108
+ variant: {
109
+ reflect: !0,
110
+ converter: v
111
+ },
112
+ type: {
113
+ reflect: !0,
114
+ converter: y
115
+ },
116
+ disabled: {
117
+ type: Boolean,
118
+ reflect: !0
119
+ },
120
+ loading: {
121
+ type: Boolean,
122
+ reflect: !0
123
+ },
124
+ pressed: {
125
+ reflect: !0,
126
+ converter: b
127
+ },
128
+ value: {
129
+ reflect: !0,
130
+ converter: x
131
+ },
132
+ formAction: {
133
+ attribute: "formaction",
134
+ reflect: !0,
135
+ converter: x
136
+ },
137
+ formMethod: {
138
+ attribute: "formmethod",
139
+ reflect: !0
140
+ },
141
+ formEnctype: {
142
+ attribute: "formenctype",
143
+ reflect: !0
144
+ },
145
+ formTarget: {
146
+ attribute: "formtarget",
147
+ reflect: !0
148
+ },
149
+ formNoValidate: {
150
+ attribute: "formnovalidate",
151
+ type: Boolean,
152
+ reflect: !0
153
+ },
154
+ customValidity: { attribute: "custom-validity" },
155
+ ariaLabel: {
156
+ attribute: "aria-label",
157
+ reflect: !0
158
+ },
159
+ ariaDescription: {
160
+ attribute: "aria-description",
161
+ reflect: !0
162
+ }
163
+ };
164
+ }
165
+ static {
166
+ this.styles = [
167
+ i,
168
+ r,
169
+ o`
170
+ :host {
171
+ --line-button-radius: var(--line-radius-2);
172
+ --line-button-bg: var(--line-gray-bg);
173
+ --line-button-color: var(--line-gray-text);
174
+ --line-button-height: var(--line-size-7);
175
+ --line-button-padding-inline: var(--line-size-3);
176
+ --line-button-gap: var(--line-size-2);
177
+ --line-button-font-size: var(--line-font-size-1);
178
+ --line-button-font-weight: var(--line-font-weight-5);
179
+ --line-button-focus-ring: var(--line-focus-ring, 2px solid currentColor);
180
+
181
+ display: inline-block;
182
+ }
183
+
184
+ :host([hidden]) {
185
+ display: none;
186
+ }
187
+
188
+ :host([variant='primary']) {
189
+ --line-button-bg: var(--line-accent-solid);
190
+ --line-button-color: var(--line-accent-contrast);
191
+ }
192
+
193
+ :host([variant='borderless']) {
194
+ --line-button-bg: transparent;
195
+ --line-button-color: var(--line-accent-text);
196
+ }
197
+
198
+ [part='root'] {
199
+ display: inline-flex;
200
+ align-items: center;
201
+ justify-content: center;
202
+ gap: var(--line-button-gap);
203
+ min-block-size: var(--line-button-height);
204
+ padding-inline: var(--line-button-padding-inline);
205
+ border-radius: var(--line-button-radius);
206
+ background: var(--line-button-bg);
207
+ color: var(--line-button-color);
208
+ font-size: var(--line-button-font-size);
209
+ font-weight: var(--line-button-font-weight);
210
+ }
211
+
212
+ :host([data-focus-visible]) [part='root'] {
213
+ outline: var(--line-button-focus-ring);
214
+ }
215
+ `
216
+ ];
217
+ }
218
+ #e = !1;
219
+ #t = (e) => {
220
+ this.pressed = e, this.dispatchEvent(new CustomEvent("line-change", {
221
+ detail: { value: e },
222
+ bubbles: !0,
223
+ composed: !1
224
+ }));
225
+ };
226
+ #n = () => ({
227
+ disabled: this.disabled || this.#e,
228
+ loading: this.loading,
229
+ pressed: this.pressed,
230
+ onPressedChange: this.#t
231
+ });
232
+ #r = new n(this, {
233
+ machine: d,
234
+ props: this.#n
235
+ });
236
+ constructor() {
237
+ super(), this.variant = "default", this.type = "submit", this.disabled = !1, this.loading = !1, this.value = "", this.formAction = "", this.formNoValidate = !1, this.customValidity = "", this.addEventListener("click", this.#a, { capture: !0 });
238
+ }
239
+ formDisabledCallback(e) {
240
+ this.#e = e, this.requestUpdate();
241
+ }
242
+ #i() {
243
+ let e = this.#r.service;
244
+ return e && !this.#r.fallback ? p(e) : m(this.#n());
245
+ }
246
+ #a = (e) => {
247
+ this.#i().interactive ? setTimeout(() => {
248
+ e.defaultPrevented || this.#o();
249
+ }) : (e.preventDefault(), e.stopImmediatePropagation());
250
+ };
251
+ #o() {
252
+ this.#r.send({ type: "ACTIVATE" });
253
+ let e = this.form;
254
+ e && (this.type === "reset" ? HTMLFormElement.prototype.reset.call(e) : this.type === "submit" && this.#s(e));
255
+ }
256
+ #s(e) {
257
+ let t = e.ownerDocument.createElement("button");
258
+ t.type = "submit", t.hidden = !0, t.setAttribute("data-line-button-submitter", "");
259
+ let n = this.getAttribute("name");
260
+ n !== null && (t.name = n), t.value = this.value;
261
+ for (let e of _) {
262
+ let n = this.getAttribute(e);
263
+ n !== null && t.setAttribute(e, n);
264
+ }
265
+ e.append(t);
266
+ try {
267
+ t.click();
268
+ } finally {
269
+ t.remove();
270
+ }
271
+ }
272
+ #c = (e) => {
273
+ if (e.button !== 0) return;
274
+ this.#r.send({ type: "PRESS_START" });
275
+ let t = new AbortController(), n = (e) => {
276
+ t.abort(), this.#r.send({ type: e.type === "pointerup" ? "PRESS_END" : "PRESS_CANCEL" });
277
+ };
278
+ window.addEventListener("pointerup", n, {
279
+ capture: !0,
280
+ signal: t.signal
281
+ }), window.addEventListener("pointercancel", n, {
282
+ capture: !0,
283
+ signal: t.signal
284
+ });
285
+ };
286
+ #l = (e) => {
287
+ !e.repeat && (e.key === "Enter" || e.key === " ") && this.#r.send({ type: "PRESS_START" });
288
+ };
289
+ #u = (e) => {
290
+ (e.key === "Enter" || e.key === " ") && this.#r.send({ type: "PRESS_END" });
291
+ };
292
+ #d = (e) => {
293
+ let t = e.currentTarget.matches(":focus-visible");
294
+ this.#r.send({
295
+ type: "FOCUS",
296
+ visible: t
297
+ });
298
+ };
299
+ #f = () => {
300
+ this.#r.send({ type: "PRESS_CANCEL" }), this.#r.send({ type: "BLUR" });
301
+ };
302
+ update(e) {
303
+ let t = this.#i();
304
+ this.reflectState("active", t.active), this.reflectState("pressed", t.pressed), this.reflectState("loading", t.loading), this.reflectState("disabled", t.disabled), this.reflectState("focus-visible", t.focusVisible), super.update(e);
305
+ }
306
+ updated(e) {
307
+ if (!(e.has("customValidity") || e.has("type"))) return;
308
+ let t = this.type === "submit" ? this.customValidity : "", n = this.renderRoot.querySelector("[part=\"root\"]") ?? void 0;
309
+ t ? this.setValidity({ customError: !0 }, t, n) : this.setValidity({}), this.reflectState("invalid", t !== "");
310
+ }
311
+ render() {
312
+ let { loading: e, buttonAttrs: t } = this.#i();
313
+ return s`<button
314
+ part="root"
315
+ type="button"
316
+ ?disabled=${t.disabled}
317
+ aria-pressed=${l(t["aria-pressed"])}
318
+ aria-disabled=${l(t["aria-disabled"])}
319
+ aria-label=${l(this.ariaLabel ?? void 0)}
320
+ aria-description=${l(this.ariaDescription ?? void 0)}
321
+ @pointerdown=${this.#c}
322
+ @keydown=${this.#l}
323
+ @keyup=${this.#u}
324
+ @focus=${this.#d}
325
+ @blur=${this.#f}
326
+ ><slot name="prefix"></slot><span part="label"><slot></slot></span><slot name="suffix"></slot>${e ? s`<span part="loading"><slot name="loading"></slot></span>` : c}</button>`;
327
+ }
328
+ };
329
+ customElements.define("line-button", S);
330
+ //#endregion
331
+ export { S as LineButton };
332
+
333
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["buttonMachine","createMachine","bindable","prop","guard","send","pressed","event","api","disabled","props","loading","connect","service","connectStatic","VARIANTS","TYPES","FORM_ATTRIBUTES","variantConverter","variant","value","typeConverter","type","pressedConverter","emptyRemovesConverter","LineButton","FormAssociated","LineElement","LitElement","commonReset","buttonReset","next","#formDisabled","#onPressedChange","LineMachineController","#machineProps","#onClick","#ctrl","#api","#activate","form","#submit","submitter","name","attribute","release","end","ended","visible","changed","message","root","buttonAttrs","ifDefined","#onPointerDown","#onKeyDown","#onKeyUp","#onFocus","#onBlur","nothing"],"sources":["../../src/shared/button-machine.ts","../../src/button/button.ts"],"sourcesContent":["/**\n * The Button press machine, shared by `<line-button>` and `<line-icon-button>`\n * (spec `0002-button.md` States; Phase 1 spec §6.C.5; ARCH §13.1).\n *\n * The press is the only finite state: `idle → active`. `disabled`, `loading`\n * and `pressed` are props that the `isInteractive` guard and the actions read\n * at event time. `ACTIVATE` flips a toggle through `onPressedChange`. A `watch`\n * cancels a running press when `disabled` or `loading` turns true. The module\n * knows nothing about forms or DOM events and imports no component\n * (MANIFESTO Law 4).\n *\n * @module shared/button-machine\n */\n\nimport { createMachine, type Service } from '@zag-js/core';\n\n/** Machine props. A component passes them as a live function of its own properties. */\nexport interface ButtonMachineProps {\n disabled?: boolean | undefined;\n loading?: boolean | undefined;\n /** `undefined` means the button is not a toggle. */\n pressed?: boolean | undefined;\n /** Called with the next pressed state when an activation flips a toggle. */\n onPressedChange?: ((next: boolean) => void) | undefined;\n}\n\nexport type ButtonMachineEvent =\n | { type: 'PRESS_START' }\n | { type: 'PRESS_END' }\n | { type: 'PRESS_CANCEL' }\n | { type: 'ACTIVATE' }\n | { type: 'FOCUS'; visible: boolean }\n | { type: 'BLUR' };\n\nexport interface ButtonMachineSchema {\n props: ButtonMachineProps;\n context: { focusVisible: boolean };\n state: 'idle' | 'active';\n guard: 'isInteractive';\n action: 'togglePressed' | 'setFocusVisible' | 'clearFocusVisible';\n event: ButtonMachineEvent;\n}\n\nexport type ButtonService = Service<ButtonMachineSchema>;\n\nexport const buttonMachine = createMachine<ButtonMachineSchema>({\n initialState: () => 'idle',\n context: ({ bindable }) => ({\n focusVisible: bindable<boolean>(() => ({ defaultValue: false })),\n }),\n watch({ track, prop, guard, send }) {\n track([() => prop('disabled'), () => prop('loading')], () => {\n if (!guard('isInteractive')) send({ type: 'PRESS_CANCEL' });\n });\n },\n on: {\n ACTIVATE: { guard: 'isInteractive', actions: ['togglePressed'] },\n FOCUS: { actions: ['setFocusVisible'] },\n BLUR: { actions: ['clearFocusVisible'] },\n },\n states: {\n idle: {\n on: { PRESS_START: { target: 'active', guard: 'isInteractive' } },\n },\n active: {\n on: {\n PRESS_END: { target: 'idle' },\n PRESS_CANCEL: { target: 'idle' },\n },\n },\n },\n implementations: {\n guards: {\n isInteractive: ({ prop }) => !(prop('disabled') || prop('loading')),\n },\n actions: {\n togglePressed({ prop }) {\n const pressed = prop('pressed');\n if (pressed !== undefined) prop('onPressedChange')?.(!pressed);\n },\n setFocusVisible({ context, event }) {\n context.set('focusVisible', event.type === 'FOCUS' && event.visible === true);\n },\n clearFocusVisible({ context }) {\n context.set('focusVisible', false);\n },\n },\n },\n});\n\n/** What the inner native `<button>` and the host reflection read. */\nexport interface ButtonApi {\n active: boolean;\n /** `true` only on a pressed toggle. */\n pressed: boolean;\n loading: boolean;\n disabled: boolean;\n focusVisible: boolean;\n /** `!disabled && !loading`: whether an activation runs now. */\n interactive: boolean;\n /** ARIA and `disabled` for the inner `<button>`; an `undefined` attribute is left off. */\n buttonAttrs: {\n 'aria-pressed': 'true' | 'false' | undefined;\n 'aria-disabled': 'true' | undefined;\n disabled: boolean;\n };\n}\n\nfunction api(props: ButtonMachineProps, active: boolean, focusVisible: boolean): ButtonApi {\n const disabled = props.disabled === true;\n const loading = props.loading === true;\n return {\n active,\n pressed: props.pressed === true,\n loading,\n disabled,\n focusVisible,\n interactive: !(disabled || loading),\n buttonAttrs: {\n 'aria-pressed': props.pressed === undefined ? undefined : (String(props.pressed) as 'true' | 'false'),\n 'aria-disabled': loading && !disabled ? 'true' : undefined,\n disabled,\n },\n };\n}\n\n/** Reads the running machine at call time. */\nexport function connect(service: ButtonService): ButtonApi {\n const { prop } = service;\n return api(\n { disabled: prop('disabled'), loading: prop('loading'), pressed: prop('pressed') },\n service.state.matches('active'),\n service.context.get('focusVisible'),\n );\n}\n\n/** The same view without a machine, for the controller's static fallback (MANIFESTO Law 9). */\nexport function connectStatic(props: ButtonMachineProps): ButtonApi {\n return api(props, false, false);\n}\n","import { FormAssociated, LineElement } from '@websublime/line-core';\nimport { LineMachineController } from '@websublime/line-core/machine';\nimport { buttonReset, commonReset } from '@websublime/line-core/styles';\nimport {\n type ComplexAttributeConverter,\n css,\n html,\n LitElement,\n nothing,\n type PropertyDeclarations,\n type PropertyValues,\n type TemplateResult,\n} from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport {\n type ButtonApi,\n type ButtonMachineProps,\n type ButtonMachineSchema,\n buttonMachine,\n connect,\n connectStatic,\n} from '../shared/button-machine.js';\nimport type {\n ButtonFormEnctype,\n ButtonFormMethod,\n ButtonType,\n ButtonVariant,\n LineButtonChangeDetail,\n} from './button.types.js';\n\nconst VARIANTS: readonly ButtonVariant[] = ['default', 'primary', 'borderless'];\nconst TYPES: readonly ButtonType[] = ['submit', 'reset', 'button'];\n\n/** The host attributes the temporary submitter copies, besides `name` and `value`. */\nconst FORM_ATTRIBUTES = ['formaction', 'formmethod', 'formenctype', 'formtarget', 'formnovalidate'] as const;\n\n/** An unknown `variant` behaves as `default`; the attribute keeps what the author wrote. */\nconst variantConverter: ComplexAttributeConverter<ButtonVariant> = {\n fromAttribute: (value) => VARIANTS.find((variant) => variant === value) ?? 'default',\n};\n\n/** An unknown or missing `type` behaves as `submit`, as on a native button; the match ignores case. */\nconst typeConverter: ComplexAttributeConverter<ButtonType> = {\n fromAttribute: (value) => TYPES.find((type) => type === value?.toLowerCase()) ?? 'submit',\n};\n\n/** Absent means not a toggle; `\"false\"` parses to `false` and any other value to `true`. */\nconst pressedConverter: ComplexAttributeConverter<boolean | undefined> = {\n fromAttribute: (value) => (value === null ? undefined : value !== 'false'),\n toAttribute: (value) => (value === undefined ? null : String(value)),\n};\n\n/** Reflects a string and removes the attribute when the string is empty. */\nconst emptyRemovesConverter: ComplexAttributeConverter<string> = {\n fromAttribute: (value) => value ?? '',\n toAttribute: (value) => value || null,\n};\n\n/**\n * `<line-button>` runs an action when the user activates it. It renders a\n * native `<button>` in its shadow root, and the host is a form-associated\n * custom element, so `type=\"submit\"` and `type=\"reset\"` act on its form as a\n * native button does. `pressed` makes it a toggle; `loading` keeps it\n * focusable while it ignores presses.\n *\n * @summary A form-associated button that runs an action, submits or resets its form, or toggles with `pressed`.\n *\n * @slot - The label: text or inline content.\n * @slot prefix - A leading icon.\n * @slot suffix - A trailing icon.\n * @slot loading - A spinner, loading text or both; rendered only while `loading` is on.\n *\n * @csspart root - The inner native `<button>`: box, background, border and focus ring.\n * @csspart label - Wraps the default slot.\n * @csspart loading - Wraps the `loading` slot; present only while `loading` is on.\n *\n * @cssprop [--line-button-radius=var(--line-radius-2)] - Corner radius of `root`.\n * @cssprop [--line-button-bg=var(--line-gray-bg)] - Background of `root`; `primary` uses `var(--line-accent-solid)` and `borderless` uses `transparent`.\n * @cssprop [--line-button-color=var(--line-gray-text)] - Text colour of `root`; `primary` uses `var(--line-accent-contrast)` and `borderless` uses `var(--line-accent-text)`.\n * @cssprop [--line-button-height=var(--line-size-7)] - Minimum block size of `root`.\n * @cssprop [--line-button-padding-inline=var(--line-size-3)] - Inline padding of `root`.\n * @cssprop [--line-button-gap=var(--line-size-2)] - Gap between the prefix, label, suffix and loading zones.\n * @cssprop [--line-button-font-size=var(--line-font-size-1)] - Font size of `root`.\n * @cssprop [--line-button-font-weight=var(--line-font-weight-5)] - Font weight of `root`.\n * @cssprop [--line-button-focus-ring=var(--line-focus-ring, 2px solid currentColor)] - `outline` of `root` while the host has `data-focus-visible`.\n *\n * @fires {CustomEvent<LineButtonChangeDetail>} line-change - A user activation flipped `pressed` on a toggle button; `detail.value` is the new state. Bubbles, not composed.\n *\n * @attr {string} name - The key the submitter value goes under; read through the inherited `name` getter.\n */\nexport class LineButton extends FormAssociated(LineElement) {\n static override shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n static override properties: PropertyDeclarations = {\n variant: { reflect: true, converter: variantConverter },\n type: { reflect: true, converter: typeConverter },\n disabled: { type: Boolean, reflect: true },\n loading: { type: Boolean, reflect: true },\n pressed: { reflect: true, converter: pressedConverter },\n value: { reflect: true, converter: emptyRemovesConverter },\n formAction: { attribute: 'formaction', reflect: true, converter: emptyRemovesConverter },\n formMethod: { attribute: 'formmethod', reflect: true },\n formEnctype: { attribute: 'formenctype', reflect: true },\n formTarget: { attribute: 'formtarget', reflect: true },\n formNoValidate: { attribute: 'formnovalidate', type: Boolean, reflect: true },\n customValidity: { attribute: 'custom-validity' },\n ariaLabel: { attribute: 'aria-label', reflect: true },\n ariaDescription: { attribute: 'aria-description', reflect: true },\n };\n\n static override styles = [\n commonReset,\n buttonReset,\n css`\n :host {\n --line-button-radius: var(--line-radius-2);\n --line-button-bg: var(--line-gray-bg);\n --line-button-color: var(--line-gray-text);\n --line-button-height: var(--line-size-7);\n --line-button-padding-inline: var(--line-size-3);\n --line-button-gap: var(--line-size-2);\n --line-button-font-size: var(--line-font-size-1);\n --line-button-font-weight: var(--line-font-weight-5);\n --line-button-focus-ring: var(--line-focus-ring, 2px solid currentColor);\n\n display: inline-block;\n }\n\n :host([hidden]) {\n display: none;\n }\n\n :host([variant='primary']) {\n --line-button-bg: var(--line-accent-solid);\n --line-button-color: var(--line-accent-contrast);\n }\n\n :host([variant='borderless']) {\n --line-button-bg: transparent;\n --line-button-color: var(--line-accent-text);\n }\n\n [part='root'] {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--line-button-gap);\n min-block-size: var(--line-button-height);\n padding-inline: var(--line-button-padding-inline);\n border-radius: var(--line-button-radius);\n background: var(--line-button-bg);\n color: var(--line-button-color);\n font-size: var(--line-button-font-size);\n font-weight: var(--line-button-font-weight);\n }\n\n :host([data-focus-visible]) [part='root'] {\n outline: var(--line-button-focus-ring);\n }\n `,\n ];\n\n /** Semantic emphasis; an unknown value behaves as `default`. */\n declare variant: ButtonVariant;\n /** What activation does to the form owner; an unknown value behaves as `submit`. */\n declare type: ButtonType;\n /** Removes the button from the tab order and blocks activation. */\n declare disabled: boolean;\n /** Keeps focus, sets `aria-disabled=\"true\"`, blocks activation and renders the `loading` part. */\n declare loading: boolean;\n /** `undefined` means not a toggle; a toggle flips it on each activation and fires `line-change`. */\n declare pressed: boolean | undefined;\n /** The submitter value; it enters the form data only when this button submits. */\n declare value: string;\n /** Overrides the form's `action` when this button submits. */\n declare formAction: string;\n /** Overrides the form's `method` when this button submits. */\n declare formMethod: ButtonFormMethod | undefined;\n /** Overrides the form's `enctype` when this button submits. */\n declare formEnctype: ButtonFormEnctype | undefined;\n /** Overrides the form's `target` when this button submits. */\n declare formTarget: string | undefined;\n /** Skips constraint validation when this button submits. */\n declare formNoValidate: boolean;\n /** External validity: a non-empty message marks the button invalid while `type` is `submit`. */\n declare customValidity: string;\n /** Copied to the inner button, where it names the role. */\n declare ariaLabel: string | null;\n /** Copied to the inner button. */\n declare ariaDescription: string | null;\n\n /** A disabled `fieldset` ancestor or the host's own `disabled`, from `formDisabledCallback`. */\n #formDisabled = false;\n\n readonly #onPressedChange = (next: boolean): void => {\n this.pressed = next;\n this.dispatchEvent(\n new CustomEvent<LineButtonChangeDetail>('line-change', {\n detail: { value: next },\n bubbles: true,\n composed: false,\n }),\n );\n };\n\n readonly #machineProps = (): ButtonMachineProps => ({\n disabled: this.disabled || this.#formDisabled,\n loading: this.loading,\n pressed: this.pressed,\n onPressedChange: this.#onPressedChange,\n });\n\n readonly #ctrl = new LineMachineController<ButtonMachineSchema>(this, {\n machine: buttonMachine,\n props: this.#machineProps,\n });\n\n constructor() {\n super();\n this.variant = 'default';\n this.type = 'submit';\n this.disabled = false;\n this.loading = false;\n this.value = '';\n this.formAction = '';\n this.formNoValidate = false;\n this.customValidity = '';\n this.addEventListener('click', this.#onClick, { capture: true });\n }\n\n override formDisabledCallback(disabled: boolean): void {\n this.#formDisabled = disabled;\n this.requestUpdate();\n }\n\n /** The machine view, or the static view from the host props when the machine failed to start. */\n #api(): ButtonApi {\n const service = this.#ctrl.service;\n return service && !this.#ctrl.fallback ? connect(service) : connectStatic(this.#machineProps());\n }\n\n /**\n * Stops a click while the button is not interactive. It listens in the\n * capture phase, so it runs before every bubble listener on the host,\n * including an inline `onclick` or a listener added before the upgrade.\n * Otherwise it activates in a later task, once the click dispatch has\n * ended, unless a listener called `preventDefault()`.\n */\n readonly #onClick = (event: MouseEvent): void => {\n if (!this.#api().interactive) {\n event.preventDefault();\n event.stopImmediatePropagation();\n return;\n }\n setTimeout(() => {\n if (!event.defaultPrevented) this.#activate();\n });\n };\n\n #activate(): void {\n this.#ctrl.send({ type: 'ACTIVATE' });\n const form = this.form;\n if (!form) return;\n if (this.type === 'reset') {\n // A control with id or name \"reset\" shadows the method on the form.\n HTMLFormElement.prototype.reset.call(form);\n } else if (this.type === 'submit') {\n this.#submit(form);\n }\n }\n\n /** Submits through a temporary native submitter, so the submission gets the native submitter semantics. */\n #submit(form: HTMLFormElement): void {\n const submitter = form.ownerDocument.createElement('button');\n submitter.type = 'submit';\n submitter.hidden = true;\n submitter.setAttribute('data-line-button-submitter', '');\n const name = this.getAttribute('name');\n if (name !== null) submitter.name = name;\n submitter.value = this.value;\n for (const attribute of FORM_ATTRIBUTES) {\n const value = this.getAttribute(attribute);\n if (value !== null) submitter.setAttribute(attribute, value);\n }\n form.append(submitter);\n try {\n submitter.click();\n } finally {\n submitter.remove();\n }\n }\n\n readonly #onPointerDown = (event: PointerEvent): void => {\n if (event.button !== 0) return;\n this.#ctrl.send({ type: 'PRESS_START' });\n const release = new AbortController();\n const end = (ended: Event): void => {\n release.abort();\n this.#ctrl.send({ type: ended.type === 'pointerup' ? 'PRESS_END' : 'PRESS_CANCEL' });\n };\n window.addEventListener('pointerup', end, { capture: true, signal: release.signal });\n window.addEventListener('pointercancel', end, { capture: true, signal: release.signal });\n };\n\n readonly #onKeyDown = (event: KeyboardEvent): void => {\n if (!event.repeat && (event.key === 'Enter' || event.key === ' ')) this.#ctrl.send({ type: 'PRESS_START' });\n };\n\n readonly #onKeyUp = (event: KeyboardEvent): void => {\n if (event.key === 'Enter' || event.key === ' ') this.#ctrl.send({ type: 'PRESS_END' });\n };\n\n readonly #onFocus = (event: FocusEvent): void => {\n const visible = (event.currentTarget as HTMLButtonElement).matches(':focus-visible');\n this.#ctrl.send({ type: 'FOCUS', visible });\n };\n\n readonly #onBlur = (): void => {\n this.#ctrl.send({ type: 'PRESS_CANCEL' });\n this.#ctrl.send({ type: 'BLUR' });\n };\n\n protected override update(changed: PropertyValues<this>): void {\n const api = this.#api();\n this.reflectState('active', api.active);\n this.reflectState('pressed', api.pressed);\n this.reflectState('loading', api.loading);\n this.reflectState('disabled', api.disabled);\n this.reflectState('focus-visible', api.focusVisible);\n super.update(changed);\n }\n\n protected override updated(changed: PropertyValues<this>): void {\n if (!(changed.has('customValidity') || changed.has('type'))) return;\n const message = this.type === 'submit' ? this.customValidity : '';\n const root = this.renderRoot.querySelector<HTMLButtonElement>('[part=\"root\"]') ?? undefined;\n if (message) {\n this.setValidity({ customError: true }, message, root);\n } else {\n this.setValidity({});\n }\n this.reflectState('invalid', message !== '');\n }\n\n override render(): TemplateResult {\n const { loading, buttonAttrs } = this.#api();\n return html`<button\n part=\"root\"\n type=\"button\"\n ?disabled=${buttonAttrs.disabled}\n aria-pressed=${ifDefined(buttonAttrs['aria-pressed'])}\n aria-disabled=${ifDefined(buttonAttrs['aria-disabled'])}\n aria-label=${ifDefined(this.ariaLabel ?? undefined)}\n aria-description=${ifDefined(this.ariaDescription ?? undefined)}\n @pointerdown=${this.#onPointerDown}\n @keydown=${this.#onKeyDown}\n @keyup=${this.#onKeyUp}\n @focus=${this.#onFocus}\n @blur=${this.#onBlur}\n ><slot name=\"prefix\"></slot><span part=\"label\"><slot></slot></span><slot name=\"suffix\"></slot>${\n loading ? html`<span part=\"loading\"><slot name=\"loading\"></slot></span>` : nothing\n }</button>`;\n }\n}\n\ncustomElements.define('line-button', LineButton);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'line-button': LineButton;\n }\n}\n"],"mappings":";;;;;;;AA6CA,IAAaA,IAAgBC,EAAmC;CAC9D,oBAAoB;CACpB,UAAU,EAAE,mBAAgB,EAC1B,cAAcC,SAAyB,EAAE,cAAc,GAAM,EAAE,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AAK,YAAY,EAAE,aAAa,GAAK,GAAGA,GAASC,CAAI,IAErD,KAAK,YAAY,CAAC,CAAC,GAErB,KAAK,aAAa,WAAWD,MAAY,EAAE;CAC7C;CAEA,SAAkC;EAChC,IAAM,EAAE,YAAS,mBAAgB,KAAKZ,GAAK;EAC3C,OAAO,CAAI;;;kBAGGc,EAAY,SAAS;qBAClBC,EAAUD,EAAY,eAAe,EAAE;sBACtCC,EAAUD,EAAY,gBAAgB,EAAE;mBAC3CC,EAAU,KAAK,aAAa,KAAA,CAAS,EAAE;yBACjCA,EAAU,KAAK,mBAAmB,KAAA,CAAS,EAAE;qBACjD,KAAKC,GAAe;iBACxB,KAAKC,GAAW;eAClB,KAAKC,GAAS;eACd,KAAKC,GAAS;cACf,KAAKC,GAAQ;oGAErB/C,IAAU,CAAI,6DAA6DgD,EAC5E;CACH;AACF;AAEA,eAAe,OAAO,eAAelC,CAAU"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The Button press machine, shared by `<line-button>` and `<line-icon-button>`
3
+ * (spec `0002-button.md` States; Phase 1 spec §6.C.5; ARCH §13.1).
4
+ *
5
+ * The press is the only finite state: `idle → active`. `disabled`, `loading`
6
+ * and `pressed` are props that the `isInteractive` guard and the actions read
7
+ * at event time. `ACTIVATE` flips a toggle through `onPressedChange`. A `watch`
8
+ * cancels a running press when `disabled` or `loading` turns true. The module
9
+ * knows nothing about forms or DOM events and imports no component
10
+ * (MANIFESTO Law 4).
11
+ *
12
+ * @module shared/button-machine
13
+ */
14
+ import { type Service } from '@zag-js/core';
15
+ /** Machine props. A component passes them as a live function of its own properties. */
16
+ export interface ButtonMachineProps {
17
+ disabled?: boolean | undefined;
18
+ loading?: boolean | undefined;
19
+ /** `undefined` means the button is not a toggle. */
20
+ pressed?: boolean | undefined;
21
+ /** Called with the next pressed state when an activation flips a toggle. */
22
+ onPressedChange?: ((next: boolean) => void) | undefined;
23
+ }
24
+ export type ButtonMachineEvent = {
25
+ type: 'PRESS_START';
26
+ } | {
27
+ type: 'PRESS_END';
28
+ } | {
29
+ type: 'PRESS_CANCEL';
30
+ } | {
31
+ type: 'ACTIVATE';
32
+ } | {
33
+ type: 'FOCUS';
34
+ visible: boolean;
35
+ } | {
36
+ type: 'BLUR';
37
+ };
38
+ export interface ButtonMachineSchema {
39
+ props: ButtonMachineProps;
40
+ context: {
41
+ focusVisible: boolean;
42
+ };
43
+ state: 'idle' | 'active';
44
+ guard: 'isInteractive';
45
+ action: 'togglePressed' | 'setFocusVisible' | 'clearFocusVisible';
46
+ event: ButtonMachineEvent;
47
+ }
48
+ export type ButtonService = Service<ButtonMachineSchema>;
49
+ export declare const buttonMachine: import("@zag-js/core").Machine<ButtonMachineSchema>;
50
+ /** What the inner native `<button>` and the host reflection read. */
51
+ export interface ButtonApi {
52
+ active: boolean;
53
+ /** `true` only on a pressed toggle. */
54
+ pressed: boolean;
55
+ loading: boolean;
56
+ disabled: boolean;
57
+ focusVisible: boolean;
58
+ /** `!disabled && !loading`: whether an activation runs now. */
59
+ interactive: boolean;
60
+ /** ARIA and `disabled` for the inner `<button>`; an `undefined` attribute is left off. */
61
+ buttonAttrs: {
62
+ 'aria-pressed': 'true' | 'false' | undefined;
63
+ 'aria-disabled': 'true' | undefined;
64
+ disabled: boolean;
65
+ };
66
+ }
67
+ /** Reads the running machine at call time. */
68
+ export declare function connect(service: ButtonService): ButtonApi;
69
+ /** The same view without a machine, for the controller's static fallback (MANIFESTO Law 9). */
70
+ export declare function connectStatic(props: ButtonMachineProps): ButtonApi;
71
+ //# sourceMappingURL=button-machine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button-machine.d.ts","sourceRoot":"","sources":["../../src/shared/button-machine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAE3D,uFAAuF;AACvF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS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cAAc,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;QAC7C,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;QACpC,QAAQ,EAAE,OAAO,CAAC;KACnB,CAAC;CACH;AAoBD,8CAA8C;AAC9C,wBAAgB,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,SAAS,CAOzD;AAED,+FAA+F;AAC/F,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,SAAS,CAElE"}
@@ -0,0 +1,3 @@
1
+ export { LineStack } from './stack.js';
2
+ export type { StackAlign, StackGap, StackJustify, StackOrientation } from './stack.types.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stack/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}