@glimstone/vue 4.2.8 → 4.3.5

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.
package/dist/Select.js CHANGED
@@ -1,467 +1 @@
1
- import { r as e } from "./fieldName-DBygJJfe.js";
2
- import { a as t, n } from "./glyphs-CYhs4mrY.js";
3
- import { n as r, r as i, t as a } from "./TipWrap-rNAEgvb0.js";
4
- import { Fragment as o, Teleport as s, computed as c, createBlock as l, createCommentVNode as u, createElementBlock as d, createElementVNode as f, createVNode as p, defineComponent as m, guardReactiveProps as h, mergeModels as g, mergeProps as _, normalizeClass as v, normalizeProps as y, onMounted as b, onScopeDispose as x, openBlock as S, renderList as C, resolveDynamicComponent as w, shallowRef as T, toDisplayString as E, unref as D, useId as O, useModel as k, watch as A, withCtx as j } from "vue";
5
- import { SELECT_POSITIONING as M, closeOnPageMove as N, defaultWidth as P, enableWheelStep as F, faceLabels as I, flattenRuns as L, hasSubmenu as R, homeRow as z, isSubmenu as B, pageDir as V, readPortalHue as H, selectRootClass as U, selectRowParts as W, selectTriggerClass as G, shake as K, wheelValue as q } from "@glimstone/core";
6
- import * as J from "@zag-js/select";
7
- import { normalizeProps as Y, useMachine as X } from "@zag-js/vue";
8
- import * as Z from "@zag-js/menu";
9
- // src/SelectFace.vue?vue&type=script&setup=true&lang.ts
10
- var ee = {
11
- key: 0,
12
- class: "glim-select-glyph"
13
- }, te = { class: "glim-select-value" }, ne = ["aria-hidden"], Q = /* @__PURE__ */ m({
14
- __name: "SelectFace",
15
- props: {
16
- all: {},
17
- value: {},
18
- placeholder: {},
19
- width: {},
20
- glyphs: { type: Boolean }
21
- },
22
- setup(e) {
23
- let t = e, n = c(() => I(t.all, t.value, t.placeholder, t.width)), r = c(() => t.all.find((e) => e.value === t.value)?.glyph);
24
- return (t, i) => (S(), d(o, null, [e.glyphs ? (S(), d("span", ee, [r.value ? (S(), l(w(r.value), { key: 0 })) : u("", !0)])) : u("", !0), f("span", te, [(S(!0), d(o, null, C(n.value.labels, (e) => (S(), d("span", {
25
- key: e,
26
- "aria-hidden": e !== n.value.text || void 0,
27
- class: v(e === n.value.text ? void 0 : "glim-select-ghost")
28
- }, E(e), 11, ne))), 128))])], 64));
29
- }
30
- });
31
- // src/selectParts.ts
32
- function $(e, t) {
33
- let n = T(null);
34
- return A(e, (e) => n.value = e && t.value ? H(t.value) : null, { flush: "sync" }), {
35
- style: c(() => n.value ?? void 0),
36
- className: c(() => n.value ? "glim-hue" : "")
37
- };
38
- }
39
- function re(e, t) {
40
- let n;
41
- A(e, (e) => {
42
- n?.(), n = e ? F(e, (e) => {
43
- if (t.inert()) return;
44
- let n = q(t.all(), t.value(), e);
45
- n !== void 0 && t.onChange(n);
46
- }) : void 0;
47
- }, { immediate: !0 }), A(t.shakeCount, (t, n, r) => {
48
- e.value && t > 0 && r(K(e.value));
49
- }), x(() => n?.());
50
- }
51
- // src/ListSelect.vue?vue&type=script&setup=true&lang.ts
52
- var ie = ["aria-busy", "aria-describedby"], ae = /* @__PURE__ */ m({
53
- __name: "ListSelect",
54
- props: {
55
- label: {},
56
- hideLabel: { type: Boolean },
57
- groups: {},
58
- value: {},
59
- placeholder: {},
60
- width: {},
61
- rows: {},
62
- triggerClass: {},
63
- id: {},
64
- triggerAttrs: {},
65
- listId: {},
66
- disabled: { type: Boolean },
67
- busy: { type: Boolean },
68
- tip: {},
69
- shake: {}
70
- },
71
- emits: ["change"],
72
- setup(e, { expose: m, emit: g }) {
73
- let b = e, x = g, k = O(), P = c(() => L(b.groups)), F = c(() => P.value.some((e) => e.glyph)), I = c(() => W(b.rows, F.value)), R = c(() => J.collection({
74
- items: P.value,
75
- itemToValue: (e) => e.value,
76
- itemToString: (e) => e.label,
77
- isItemDisabled: (e) => !!e.disabled
78
- })), z = X(J.machine, c(() => ({
79
- id: k,
80
- ids: {
81
- trigger: b.id,
82
- content: b.listId
83
- },
84
- dir: V(),
85
- collection: R.value,
86
- value: b.value === null ? [] : [b.value],
87
- disabled: b.disabled,
88
- readOnly: b.busy,
89
- onValueChange: (e) => {
90
- let t = e.value[0];
91
- t !== void 0 && t !== b.value && x("change", t);
92
- },
93
- positioning: M
94
- }))), B = c(() => J.connect(z, Y)), H = T(null), G = i(() => b.tip, () => !!b.disabled);
95
- re(H, {
96
- all: () => P.value,
97
- value: () => b.value,
98
- inert: () => !!(b.disabled || b.busy),
99
- onChange: (e) => x("change", e),
100
- shakeCount: () => b.shake ?? 0
101
- }), A(() => B.value.open, (e, t, n) => {
102
- e && n(N(() => B.value.setOpen(!1)));
103
- });
104
- let K = $(() => B.value.open, H);
105
- function q(e) {
106
- H.value = e, G.trigger.value = H.value;
107
- }
108
- return m({ trigger: H }), (i, c) => (S(), d("div", _(B.value.getRootProps(), { class: D(U)(e.width) }), [
109
- f("label", _(B.value.getLabelProps(), { class: e.hideLabel ? "glim-sr-only" : "glim-field-label" }), E(e.label), 17),
110
- f("div", y(h(B.value.getControlProps())), [p(D(a), {
111
- on: !!e.disabled && !!e.tip,
112
- show: D(G).show,
113
- hide: D(G).hide
114
- }, {
115
- default: j(() => [f("button", _({
116
- ...e.triggerAttrs,
117
- ...B.value.getTriggerProps()
118
- }, {
119
- ref: q,
120
- "aria-busy": e.busy || void 0,
121
- "aria-describedby": D(G).describedBy.value,
122
- class: e.triggerClass,
123
- onMouseenter: c[0] ||= (...e) => D(G).show && D(G).show(...e),
124
- onMouseleave: c[1] ||= (...e) => D(G).hide && D(G).hide(...e),
125
- onFocus: c[2] ||= (...e) => D(G).showOnFocus && D(G).showOnFocus(...e),
126
- onBlur: c[3] ||= (...e) => D(G).hide && D(G).hide(...e)
127
- }), [p(Q, {
128
- all: P.value,
129
- value: e.value,
130
- placeholder: e.placeholder,
131
- width: e.width,
132
- glyphs: F.value
133
- }, null, 8, [
134
- "all",
135
- "value",
136
- "placeholder",
137
- "width",
138
- "glyphs"
139
- ]), f("span", _(B.value.getIndicatorProps(), { class: "glim-select-indicator" }), [p(D(t))], 16)], 16, ie)]),
140
- _: 1
141
- }, 8, [
142
- "on",
143
- "show",
144
- "hide"
145
- ])], 16),
146
- p(r, { state: D(G) }, null, 8, ["state"]),
147
- (S(), l(s, { to: "body" }, [f("div", _(B.value.getPositionerProps(), {
148
- style: D(K).style.value,
149
- class: ["glim-select-positioner", D(K).className.value]
150
- }), [f("div", _(B.value.getContentProps(), { class: I.value.content }), [(S(!0), d(o, null, C(e.groups, (e, t) => (S(), d(o, { key: t }, [e.entries.length > 0 ? (S(), d("div", _({
151
- key: 0,
152
- ref_for: !0
153
- }, e.heading ? B.value.getItemGroupProps({ id: `${D(k)}-g${t}` }) : {}, { class: "glim-select-group" }), [e.heading ? (S(), d("div", _({
154
- key: 0,
155
- ref_for: !0
156
- }, B.value.getItemGroupLabelProps({ htmlFor: `${D(k)}-g${t}` }), { class: I.value.heading }), E(e.heading), 17)) : u("", !0), (S(!0), d(o, null, C(e.entries, (e) => (S(), d("div", _({ key: e.value }, { ref_for: !0 }, B.value.getItemProps({ item: e }), { class: I.value.item }), [
157
- I.value.glyph ? (S(), d("span", {
158
- key: 0,
159
- class: v(I.value.glyph)
160
- }, [e.glyph ? (S(), l(w(e.glyph), { key: 0 })) : u("", !0)], 2)) : u("", !0),
161
- f("span", _({ ref_for: !0 }, B.value.getItemTextProps({ item: e }), { class: I.value.label }), E(e.label), 17),
162
- f("span", _({ ref_for: !0 }, B.value.getItemIndicatorProps({ item: e }), { class: I.value.check }), [p(D(n))], 16)
163
- ], 16))), 128))], 16)) : u("", !0)], 64))), 128))], 16)], 16)])),
164
- f("select", y(h(B.value.getHiddenSelectProps())), null, 16)
165
- ], 16));
166
- }
167
- }), oe = ["data-state"], se = /* @__PURE__ */ m({
168
- __name: "MenuChoice",
169
- props: {
170
- api: {},
171
- option: {},
172
- value: {},
173
- parts: {}
174
- },
175
- emits: ["change"],
176
- setup(e, { emit: t }) {
177
- let r = e, i = t, a = c(() => r.option.value === r.value), o = c(() => ({
178
- type: "radio",
179
- value: r.option.value,
180
- valueText: r.option.label,
181
- checked: a.value,
182
- disabled: r.option.disabled,
183
- onCheckedChange: () => {
184
- a.value || i("change", r.option.value);
185
- }
186
- }));
187
- return (t, r) => (S(), d("div", _(e.api.getOptionItemProps(o.value), { class: e.parts.item }), [
188
- e.parts.glyph ? (S(), d("span", {
189
- key: 0,
190
- class: v(e.parts.glyph)
191
- }, [e.option.glyph ? (S(), l(w(e.option.glyph), { key: 0 })) : u("", !0)], 2)) : u("", !0),
192
- f("span", _(e.api.getItemTextProps(o.value), { class: e.parts.label }), E(e.option.label), 17),
193
- f("span", {
194
- "aria-hidden": "true",
195
- "data-state": a.value ? "checked" : "unchecked",
196
- class: v(e.parts.check)
197
- }, [p(D(n))], 10, oe)
198
- ], 16));
199
- }
200
- }), ce = /* @__PURE__ */ m({
201
- __name: "MenuSubmenu",
202
- props: {
203
- parent: {},
204
- parentApi: {},
205
- triggerId: {},
206
- entry: {},
207
- value: {},
208
- parts: {},
209
- hueStyle: {},
210
- hueClass: {}
211
- },
212
- emits: ["change"],
213
- setup(e, { emit: n }) {
214
- let r = e, i = n, a = X(Z.machine, {
215
- id: O(),
216
- ids: { trigger: r.triggerId },
217
- dir: V(),
218
- "aria-label": r.entry.label
219
- }), m = c(() => Z.connect(a, Y));
220
- return b(() => {
221
- r.parentApi.setChild(a), m.value.setParent(r.parent);
222
- }), (n, r) => (S(), d(o, null, [f("div", _(e.parentApi.getTriggerItemProps(m.value), { class: e.parts.item }), [
223
- e.parts.glyph ? (S(), d("span", {
224
- key: 0,
225
- class: v(e.parts.glyph)
226
- }, [e.entry.glyph ? (S(), l(w(e.entry.glyph), { key: 0 })) : u("", !0)], 2)) : u("", !0),
227
- f("span", { class: v(e.parts.label) }, E(e.entry.label), 3),
228
- f("span", {
229
- "aria-hidden": "true",
230
- class: v(e.parts.caret)
231
- }, [p(D(t))], 2)
232
- ], 16), (S(), l(s, { to: "body" }, [f("div", _(m.value.getPositionerProps(), {
233
- style: e.hueStyle,
234
- class: ["glim-select-positioner", e.hueClass]
235
- }), [f("div", _(m.value.getContentProps(), { class: e.parts.content }), [(S(!0), d(o, null, C(e.entry.options, (t) => (S(), l(se, {
236
- key: t.value,
237
- api: m.value,
238
- option: t,
239
- value: e.value,
240
- parts: e.parts,
241
- onChange: r[0] ||= (e) => i("change", e)
242
- }, null, 8, [
243
- "api",
244
- "option",
245
- "value",
246
- "parts"
247
- ]))), 128))], 16)], 16)]))], 64));
248
- }
249
- }), le = {
250
- key: 0,
251
- "aria-hidden": "true",
252
- class: "glim-field-label"
253
- }, ue = [
254
- "disabled",
255
- "data-disabled",
256
- "data-readonly",
257
- "aria-busy",
258
- "aria-label",
259
- "aria-describedby"
260
- ], de = /* @__PURE__ */ m({
261
- __name: "MenuSelect",
262
- props: {
263
- label: {},
264
- hideLabel: { type: Boolean },
265
- groups: {},
266
- value: {},
267
- placeholder: {},
268
- width: {},
269
- rows: {},
270
- triggerClass: {},
271
- id: {},
272
- triggerAttrs: {},
273
- listId: {},
274
- disabled: { type: Boolean },
275
- busy: { type: Boolean },
276
- tip: {},
277
- shake: {}
278
- },
279
- emits: ["change"],
280
- setup(e, { expose: n, emit: m }) {
281
- let h = e, g = m, y = O(), b = X(Z.machine, c(() => ({
282
- id: y,
283
- ids: {
284
- trigger: h.id,
285
- content: h.listId
286
- },
287
- dir: V(),
288
- "aria-label": h.label,
289
- positioning: M
290
- }))), x = c(() => Z.connect(b, Y)), w = c(() => L(h.groups)), k = c(() => w.value.some((e) => e.glyph)), P = c(() => W(h.rows, k.value)), F = c(() => I(w.value, h.value, h.placeholder, h.width).text), R = (e, t) => `${y}-sub-${e}-${t}`, H = T(null), G = i(() => h.tip, () => !!h.disabled);
291
- re(H, {
292
- all: () => w.value,
293
- value: () => h.value,
294
- inert: () => !!(h.disabled || h.busy),
295
- onChange: (e) => g("change", e),
296
- shakeCount: () => h.shake ?? 0
297
- });
298
- let K = $(() => x.value.open, H);
299
- A(() => x.value.open, (e, t, n) => {
300
- if (!e) return;
301
- n(N(() => x.value.setOpen(!1)));
302
- let r = z(h.groups, h.value, R);
303
- if (r === null) return;
304
- let i = 0, a = requestAnimationFrame(() => {
305
- i = requestAnimationFrame(() => x.value.setHighlightedValue(r));
306
- });
307
- n(() => {
308
- cancelAnimationFrame(a), cancelAnimationFrame(i);
309
- });
310
- });
311
- let q = c(() => {
312
- let e = x.value.getTriggerProps(), t = (t) => (n) => {
313
- h.busy ? n.preventDefault() : e[t]?.(n);
314
- };
315
- return {
316
- ...h.triggerAttrs,
317
- ...e,
318
- onPointerdown: t("onPointerdown"),
319
- onClick: t("onClick"),
320
- onKeydown: t("onKeydown")
321
- };
322
- });
323
- function J(e) {
324
- H.value = e, G.trigger.value = H.value;
325
- }
326
- return n({ trigger: H }), (n, i) => (S(), d("div", { class: v(D(U)(e.width)) }, [
327
- e.hideLabel ? u("", !0) : (S(), d("span", le, E(e.label), 1)),
328
- f("div", null, [p(D(a), {
329
- on: !!e.disabled && !!e.tip,
330
- show: D(G).show,
331
- hide: D(G).hide
332
- }, {
333
- default: j(() => [f("button", _(q.value, {
334
- ref: J,
335
- disabled: e.disabled,
336
- "data-disabled": e.disabled ? "" : void 0,
337
- "data-readonly": e.busy ? "" : void 0,
338
- "aria-busy": e.busy || void 0,
339
- "aria-label": `${e.label}: ${F.value}`,
340
- "aria-describedby": D(G).describedBy.value,
341
- class: e.triggerClass,
342
- onMouseenter: i[0] ||= (...e) => D(G).show && D(G).show(...e),
343
- onMouseleave: i[1] ||= (...e) => D(G).hide && D(G).hide(...e),
344
- onFocus: i[2] ||= (...e) => D(G).showOnFocus && D(G).showOnFocus(...e),
345
- onBlur: i[3] ||= (...e) => D(G).hide && D(G).hide(...e)
346
- }), [p(Q, {
347
- all: w.value,
348
- value: e.value,
349
- placeholder: e.placeholder,
350
- width: e.width,
351
- glyphs: k.value
352
- }, null, 8, [
353
- "all",
354
- "value",
355
- "placeholder",
356
- "width",
357
- "glyphs"
358
- ]), f("span", _(x.value.getIndicatorProps(), { class: "glim-select-indicator" }), [p(D(t))], 16)], 16, ue)]),
359
- _: 1
360
- }, 8, [
361
- "on",
362
- "show",
363
- "hide"
364
- ])]),
365
- p(r, { state: D(G) }, null, 8, ["state"]),
366
- (S(), l(s, { to: "body" }, [f("div", _(x.value.getPositionerProps(), {
367
- style: D(K).style.value,
368
- class: ["glim-select-positioner", D(K).className.value]
369
- }), [f("div", _(x.value.getContentProps(), { class: P.value.content }), [(S(!0), d(o, null, C(e.groups, (t, n) => (S(), d(o, { key: n }, [t.entries.length > 0 ? (S(), d("div", _({
370
- key: 0,
371
- ref_for: !0
372
- }, t.heading ? x.value.getItemGroupProps({ id: `g${n}` }) : {}, { class: "glim-select-group" }), [t.heading ? (S(), d("div", _({
373
- key: 0,
374
- ref_for: !0
375
- }, x.value.getItemGroupLabelProps({ htmlFor: `g${n}` }), { class: P.value.heading }), E(t.heading), 17)) : u("", !0), (S(!0), d(o, null, C(t.entries, (t, r) => (S(), d(o, { key: D(B)(t) ? `s${r}` : t.value }, [D(B)(t) ? (S(), l(ce, {
376
- key: 0,
377
- parent: D(b),
378
- "parent-api": x.value,
379
- "trigger-id": R(n, r),
380
- entry: t,
381
- value: e.value,
382
- parts: P.value,
383
- "hue-style": D(K).style.value,
384
- "hue-class": D(K).className.value,
385
- onChange: i[4] ||= (e) => g("change", e)
386
- }, null, 8, [
387
- "parent",
388
- "parent-api",
389
- "trigger-id",
390
- "entry",
391
- "value",
392
- "parts",
393
- "hue-style",
394
- "hue-class"
395
- ])) : (S(), l(se, {
396
- key: 1,
397
- api: x.value,
398
- option: t,
399
- value: e.value,
400
- parts: P.value,
401
- onChange: i[5] ||= (e) => g("change", e)
402
- }, null, 8, [
403
- "api",
404
- "option",
405
- "value",
406
- "parts"
407
- ]))], 64))), 128))], 16)) : u("", !0)], 64))), 128))], 16)], 16)]))
408
- ], 2));
409
- }
410
- }), fe = /* @__PURE__ */ m({
411
- __name: "Select",
412
- props: /*@__PURE__*/ g({
413
- label: {},
414
- hideLabel: {
415
- type: Boolean,
416
- default: !1
417
- },
418
- options: {},
419
- groups: {},
420
- placeholder: {},
421
- width: {},
422
- size: { default: "field" },
423
- rows: { default: "list" },
424
- wrap: {
425
- type: Boolean,
426
- default: !1
427
- },
428
- id: {},
429
- triggerAttrs: {},
430
- listId: {},
431
- disabled: {
432
- type: Boolean,
433
- default: !1
434
- },
435
- busy: {
436
- type: Boolean,
437
- default: !1
438
- },
439
- tip: {},
440
- shake: {}
441
- }, {
442
- modelValue: { required: !0 },
443
- modelModifiers: {}
444
- }),
445
- emits: ["update:modelValue"],
446
- setup(t) {
447
- let n = t, r = k(t, "modelValue"), i = c(() => n.groups ?? [{ entries: n.options ?? [] }]), a = e(() => n.label), o = c(() => n.label === void 0), s = c(() => ({
448
- label: a.value ?? "",
449
- hideLabel: n.hideLabel || o.value,
450
- groups: i.value,
451
- value: r.value,
452
- placeholder: n.placeholder,
453
- width: n.width ?? (o.value ? "steady" : P(n.size)),
454
- rows: n.rows,
455
- triggerClass: G(n.size, n.wrap),
456
- id: n.id,
457
- triggerAttrs: n.triggerAttrs,
458
- listId: n.listId,
459
- disabled: n.disabled,
460
- busy: n.busy,
461
- tip: n.tip,
462
- shake: n.shake
463
- }));
464
- return (e, t) => D(R)(i.value) ? (S(), l(de, _({ key: 0 }, s.value, { onChange: t[0] ||= (e) => r.value = e }), null, 16)) : (S(), l(ae, _({ key: 1 }, s.value, { onChange: t[1] ||= (e) => r.value = e }), null, 16));
465
- }
466
- });
467
- export { fe as Select };
1
+ export { t as Select } from "./Select-ohRK0e4y.js";
@@ -14,13 +14,14 @@ declare const __VLS_export: <V extends string | number = string, M extends Selec
14
14
  variant?: SelectorVariant;
15
15
  /** "manual" moves the focus and chooses on Space, Enter or a click, for a strip that saves a setting. */
16
16
  activation?: SelectorActivation;
17
- /** Pin every segment to the widest one's measured width; the page-level picker. */
17
+ /** Pin every segment to the widest one's measured width while they fit the row; the page-level picker. */
18
18
  equalWidth?: boolean;
19
19
  /** Hug the segments, for a strip that shares a toolbar row, as it does inside a FieldRow. */
20
20
  inline?: boolean;
21
- /** Keep every segment on one row, for page tabs. */
21
+ /** Share the row evenly without a pinned width, for page tabs. Every strip keeps to one row, a strip of one
22
+ * turning into a dropdown where its labels do not fit and not every segment has a glyph. */
22
23
  fit?: boolean;
23
- /** Below 600px, two segments to a row with labels that wrap. */
24
+ /** Has no effect: every strip keeps to one row. */
24
25
  pairsOnPhone?: boolean;
25
26
  /** The button height for every segment, for a strip beside a Button. */
26
27
  buttonHeight?: boolean;
@@ -7,14 +7,16 @@ type __VLS_Props = {
7
7
  on: boolean;
8
8
  disabled: boolean;
9
9
  roved: boolean;
10
+ /** The strip shows its dropdown, and the segment is only there to be measured. */
11
+ listed: boolean;
10
12
  share: Record<string, string>;
11
13
  squeezed: boolean;
14
+ cut: boolean;
12
15
  orientation: SelectorOrientation;
13
16
  size: SelectorSize;
14
17
  variant: SelectorVariant;
15
18
  equalWidth: boolean;
16
19
  buttonHeight: boolean;
17
- pairsOnPhone: boolean;
18
20
  hue: boolean;
19
21
  hueOffset?: number;
20
22
  panelId?: string;