@kanzo-tech/ui 0.11.0 → 0.12.0

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/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,57 @@
1
+ import { CollectionItem, ListCollection } from '@ark-ui/react/collection';
2
+ export interface AsyncCollectionOptions<T extends CollectionItem> {
3
+ /**
4
+ * Candidates for `query`. Called with an empty query on mount, so a list can be offered before
5
+ * anything is typed. `signal` aborts when a newer query starts; pass it to `fetch`.
6
+ */
7
+ load: (query: string, signal: AbortSignal | undefined) => Promise<T[]>;
8
+ /** @default `item.value` */
9
+ itemToValue?: (item: T) => string;
10
+ /** @default `item.label` */
11
+ itemToString?: (item: T) => string;
12
+ /**
13
+ * How long typing must pause before `load` runs, in milliseconds.
14
+ *
15
+ * @default 250
16
+ */
17
+ debounce?: number;
18
+ initialItems?: T[];
19
+ }
20
+ export interface AsyncCollection<T extends CollectionItem> {
21
+ /** What to hand a `Combobox`, `Select` or `Listbox`. Rebuilt when a load lands. */
22
+ collection: ListCollection<T>;
23
+ /** Wire this to `onInputValueChange`: `(d) => setQuery(d.inputValue)`. */
24
+ setQuery: (query: string) => void;
25
+ /** A request is in flight. The previous items stay in `collection` until it lands. */
26
+ loading: boolean;
27
+ /** The last request landed and offered nothing. False while loading. */
28
+ empty: boolean;
29
+ /** The last request failed. The previous items stay in `collection`. */
30
+ error: unknown;
31
+ reload: () => void;
32
+ /**
33
+ * The label of a value this hook has ever offered, and `undefined` for one it has not.
34
+ *
35
+ * It is not a cache: a selected value's label exists only in the batch that offered it, and
36
+ * the next keystroke replaces the batch, so without it a chosen item reads as its raw value
37
+ * again the moment the user types.
38
+ */
39
+ labelOf: (value: string) => string | undefined;
40
+ }
41
+ /**
42
+ * Items fetched as the user types: a debounced query, a request that aborts when a newer one
43
+ * starts, and the loading, empty and error states of the last one.
44
+ *
45
+ * The machine is Ark's `useAsyncList`; this adds the pause before it runs, the collection a
46
+ * `Combobox` wants, and `labelOf`. Filtering is the server's — the `Combobox` machine never mutates
47
+ * the collection it is given.
48
+ *
49
+ * @example
50
+ * const { collection, setQuery, loading } = useAsyncCollection({ load });
51
+ * <Combobox collection={collection} onInputValueChange={(d) => setQuery(d.inputValue)}>
52
+ */
53
+ export declare function useAsyncCollection<T extends CollectionItem = {
54
+ label: string;
55
+ value: string;
56
+ }>(options: AsyncCollectionOptions<T>): AsyncCollection<T>;
57
+ //# sourceMappingURL=use-async-collection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-async-collection.d.ts","sourceRoot":"","sources":["../../src/lib/use-async-collection.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,cAAc,EAEpB,MAAM,0BAA0B,CAAC;AAGlC,MAAM,WAAW,sBAAsB,CAAC,CAAC,SAAS,cAAc;IAC9D;;;OAGG;IACH,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IACvE,4BAA4B;IAC5B,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAClC,4BAA4B;IAC5B,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IACnC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,cAAc;IACvD,mFAAmF;IACnF,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAC9B,0EAA0E;IAC1E,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,sFAAsF;IACtF,OAAO,EAAE,OAAO,CAAC;IACjB,wEAAwE;IACxE,KAAK,EAAE,OAAO,CAAC;IACf,wEAAwE;IACxE,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB;;;;;;OAMG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;CAChD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,cAAc,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAC5F,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,GACjC,eAAe,CAAC,CAAC,CAAC,CAmDpB"}
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ import { useAsyncList as S, createListCollection as w } from "@ark-ui/react/collection";
3
+ import { useRef as u, useEffect as m, useState as x, useMemo as L } from "react";
4
+ function C(d) {
5
+ const { debounce: f = 250, initialItems: g, itemToString: o, itemToValue: n, load: c } = d, l = u(c);
6
+ m(() => {
7
+ l.current = c;
8
+ });
9
+ const [p, T] = x(/* @__PURE__ */ new Map()), e = S({
10
+ autoReload: !0,
11
+ initialItems: g,
12
+ load: async ({ filterText: t, signal: i }) => ({ items: await l.current(t, i) }),
13
+ onSuccess: ({ items: t }) => T((i) => {
14
+ const a = new Map(i);
15
+ for (const r of t)
16
+ a.set(
17
+ n ? n(r) : String(r.value),
18
+ o ? o(r) : String(r.label)
19
+ );
20
+ return a;
21
+ })
22
+ }), s = u(void 0);
23
+ m(() => () => clearTimeout(s.current), []);
24
+ const { setFilterText: b } = e, y = (t) => {
25
+ clearTimeout(s.current), s.current = setTimeout(() => b(t), f);
26
+ };
27
+ return {
28
+ collection: L(
29
+ () => w({ items: e.items, itemToValue: n, itemToString: o }),
30
+ [e.items, n, o]
31
+ ),
32
+ setQuery: y,
33
+ loading: e.loading,
34
+ empty: !e.loading && e.items.length === 0,
35
+ error: e.error,
36
+ reload: e.reload,
37
+ labelOf: (t) => p.get(t)
38
+ };
39
+ }
40
+ export {
41
+ C as useAsyncCollection
42
+ };
43
+ //# sourceMappingURL=use-async-collection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-async-collection.js","sources":["../../src/lib/use-async-collection.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type CollectionItem,\n createListCollection,\n type ListCollection,\n useAsyncList,\n} from \"@ark-ui/react/collection\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\n\nexport interface AsyncCollectionOptions<T extends CollectionItem> {\n /**\n * Candidates for `query`. Called with an empty query on mount, so a list can be offered before\n * anything is typed. `signal` aborts when a newer query starts; pass it to `fetch`.\n */\n load: (query: string, signal: AbortSignal | undefined) => Promise<T[]>;\n /** @default `item.value` */\n itemToValue?: (item: T) => string;\n /** @default `item.label` */\n itemToString?: (item: T) => string;\n /**\n * How long typing must pause before `load` runs, in milliseconds.\n *\n * @default 250\n */\n debounce?: number;\n initialItems?: T[];\n}\n\nexport interface AsyncCollection<T extends CollectionItem> {\n /** What to hand a `Combobox`, `Select` or `Listbox`. Rebuilt when a load lands. */\n collection: ListCollection<T>;\n /** Wire this to `onInputValueChange`: `(d) => setQuery(d.inputValue)`. */\n setQuery: (query: string) => void;\n /** A request is in flight. The previous items stay in `collection` until it lands. */\n loading: boolean;\n /** The last request landed and offered nothing. False while loading. */\n empty: boolean;\n /** The last request failed. The previous items stay in `collection`. */\n error: unknown;\n reload: () => void;\n /**\n * The label of a value this hook has ever offered, and `undefined` for one it has not.\n *\n * It is not a cache: a selected value's label exists only in the batch that offered it, and\n * the next keystroke replaces the batch, so without it a chosen item reads as its raw value\n * again the moment the user types.\n */\n labelOf: (value: string) => string | undefined;\n}\n\n/**\n * Items fetched as the user types: a debounced query, a request that aborts when a newer one\n * starts, and the loading, empty and error states of the last one.\n *\n * The machine is Ark's `useAsyncList`; this adds the pause before it runs, the collection a\n * `Combobox` wants, and `labelOf`. Filtering is the server's — the `Combobox` machine never mutates\n * the collection it is given.\n *\n * @example\n * const { collection, setQuery, loading } = useAsyncCollection({ load });\n * <Combobox collection={collection} onInputValueChange={(d) => setQuery(d.inputValue)}>\n */\nexport function useAsyncCollection<T extends CollectionItem = { label: string; value: string }>(\n options: AsyncCollectionOptions<T>\n): AsyncCollection<T> {\n const { debounce = 250, initialItems, itemToString, itemToValue, load } = options;\n\n // `load` is usually an inline closure, and Ark reads it when the request starts rather than when\n // the machine is created; the ref is what keeps a caller from having to memoise it.\n const latest = useRef(load);\n useEffect(() => {\n latest.current = load;\n });\n\n const [labels, setLabels] = useState<ReadonlyMap<string, string>>(new Map());\n\n const list = useAsyncList<T, never>({\n autoReload: true,\n initialItems,\n load: async ({ filterText, signal }) => ({ items: await latest.current(filterText, signal) }),\n onSuccess: ({ items }) =>\n setLabels((known) => {\n const next = new Map(known);\n for (const item of items) {\n next.set(\n itemToValue ? itemToValue(item) : String((item as { value: unknown }).value),\n itemToString ? itemToString(item) : String((item as { label: unknown }).label)\n );\n }\n return next;\n }),\n });\n\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n useEffect(() => () => clearTimeout(timer.current), []);\n const { setFilterText } = list;\n const setQuery = (query: string) => {\n clearTimeout(timer.current);\n timer.current = setTimeout(() => setFilterText(query), debounce);\n };\n\n const collection = useMemo(\n () => createListCollection<T>({ items: list.items, itemToValue, itemToString }),\n [list.items, itemToValue, itemToString]\n );\n\n return {\n collection,\n setQuery,\n loading: list.loading,\n empty: !list.loading && list.items.length === 0,\n error: list.error,\n reload: list.reload,\n labelOf: (value) => labels.get(value),\n };\n}\n"],"names":[],"mappings":";;;AA+DO;AAGL;AAKA;AACE;AAAiB;AAGnB;AAEoC;AACtB;AACZ;AACyF;AAGrF;AACA;AACE;AAAK;AACwE;AACE;AAGjF;AAAO;AACR;AAIL;AACA;AAEE;AAC+D;AAQjE;AAAO;AALY;AAC6D;AACxC;AAAA;AAKtC;AACc;AACgC;AAClC;AACC;AACuB;AAExC;;;;"}
@@ -0,0 +1,28 @@
1
+ export interface DebouncedCommit<T> {
2
+ /** What the control shows: the last thing typed until the value it commits to comes back. */
3
+ draft: T;
4
+ /** A keystroke. Updates `draft` now and commits after `delay`, restarting the wait each time. */
5
+ change: (next: T) => void;
6
+ /** Commits a pending draft immediately. Call it on blur; it does nothing when nothing is pending. */
7
+ flush: () => void;
8
+ /** Commits `next` now and drops anything pending — a pick supersedes typing. */
9
+ commit: (next: T) => void;
10
+ }
11
+ /**
12
+ * A control that keeps what is being typed to itself and tells its owner once typing pauses.
13
+ *
14
+ * For an owner that is expensive to write to — a form model that revalidates, a request, a
15
+ * document that re-renders — and a control that would otherwise write on every keystroke. `draft`
16
+ * follows `value` whenever nothing is pending, so a change made elsewhere (a reset, another
17
+ * editor) still lands in the control, and a change made while the user is typing does not.
18
+ *
19
+ * Nothing is committed on unmount: a cleanup that commits also commits in Strict Mode's
20
+ * mount–unmount–mount, and the owner then hears a value nobody typed. `flush` on blur is what
21
+ * keeps the last characters from being lost when the control goes away before the timer fires.
22
+ *
23
+ * @example
24
+ * const { draft, change, flush } = useDebouncedCommit(value, onChange);
25
+ * <input value={draft} onChange={(e) => change(e.target.value)} onBlur={flush} />
26
+ */
27
+ export declare function useDebouncedCommit<T>(value: T, onCommit: (next: T) => void, delay?: number): DebouncedCommit<T>;
28
+ //# sourceMappingURL=use-debounced-commit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-debounced-commit.d.ts","sourceRoot":"","sources":["../../src/lib/use-debounced-commit.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,6FAA6F;IAC7F,KAAK,EAAE,CAAC,CAAC;IACT,iGAAiG;IACjG,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAC1B,qGAAqG;IACrG,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,gFAAgF;IAChF,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,EAC3B,KAAK,SAAM,GACV,eAAe,CAAC,CAAC,CAAC,CAsCpB"}
@@ -0,0 +1,26 @@
1
+ "use client";
2
+ import { useState as T, useRef as f, useEffect as d } from "react";
3
+ function b(r, o, l = 250) {
4
+ const [e, u] = T({ draft: r, dirty: !1, seen: r });
5
+ Object.is(e.seen, r) || u({ draft: e.dirty ? e.draft : r, dirty: e.dirty, seen: r });
6
+ const a = f(o);
7
+ d(() => {
8
+ a.current = o;
9
+ });
10
+ const n = f(void 0), t = f(null);
11
+ d(() => () => clearTimeout(n.current), []);
12
+ const s = (c) => {
13
+ clearTimeout(n.current), t.current = null, u((i) => ({ ...i, draft: c, dirty: !1 })), a.current(c);
14
+ }, m = (c) => {
15
+ u((i) => ({ ...i, draft: c, dirty: !0 })), t.current = { value: c }, clearTimeout(n.current), n.current = setTimeout(() => {
16
+ t.current && s(t.current.value);
17
+ }, l);
18
+ }, y = () => {
19
+ t.current && s(t.current.value);
20
+ };
21
+ return { draft: e.draft, change: m, flush: y, commit: s };
22
+ }
23
+ export {
24
+ b as useDebouncedCommit
25
+ };
26
+ //# sourceMappingURL=use-debounced-commit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-debounced-commit.js","sources":["../../src/lib/use-debounced-commit.ts"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\n\nexport interface DebouncedCommit<T> {\n /** What the control shows: the last thing typed until the value it commits to comes back. */\n draft: T;\n /** A keystroke. Updates `draft` now and commits after `delay`, restarting the wait each time. */\n change: (next: T) => void;\n /** Commits a pending draft immediately. Call it on blur; it does nothing when nothing is pending. */\n flush: () => void;\n /** Commits `next` now and drops anything pending — a pick supersedes typing. */\n commit: (next: T) => void;\n}\n\n/**\n * A control that keeps what is being typed to itself and tells its owner once typing pauses.\n *\n * For an owner that is expensive to write to — a form model that revalidates, a request, a\n * document that re-renders — and a control that would otherwise write on every keystroke. `draft`\n * follows `value` whenever nothing is pending, so a change made elsewhere (a reset, another\n * editor) still lands in the control, and a change made while the user is typing does not.\n *\n * Nothing is committed on unmount: a cleanup that commits also commits in Strict Mode's\n * mount–unmount–mount, and the owner then hears a value nobody typed. `flush` on blur is what\n * keeps the last characters from being lost when the control goes away before the timer fires.\n *\n * @example\n * const { draft, change, flush } = useDebouncedCommit(value, onChange);\n * <input value={draft} onChange={(e) => change(e.target.value)} onBlur={flush} />\n */\nexport function useDebouncedCommit<T>(\n value: T,\n onCommit: (next: T) => void,\n delay = 250\n): DebouncedCommit<T> {\n const [state, setState] = useState({ draft: value, dirty: false, seen: value });\n\n // Adopt the owner's value during render rather than in an effect, so the control never paints\n // a frame of the old value — and only when the user is not mid-word.\n if (!Object.is(state.seen, value)) {\n setState({ draft: state.dirty ? state.draft : value, dirty: state.dirty, seen: value });\n }\n\n const latest = useRef(onCommit);\n useEffect(() => {\n latest.current = onCommit;\n });\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const pending = useRef<{ value: T } | null>(null);\n useEffect(() => () => clearTimeout(timer.current), []);\n\n const commit = (next: T) => {\n clearTimeout(timer.current);\n pending.current = null;\n setState((s) => ({ ...s, draft: next, dirty: false }));\n latest.current(next);\n };\n\n const change = (next: T) => {\n setState((s) => ({ ...s, draft: next, dirty: true }));\n pending.current = { value: next };\n clearTimeout(timer.current);\n timer.current = setTimeout(() => {\n if (pending.current) commit(pending.current.value);\n }, delay);\n };\n\n const flush = () => {\n if (pending.current) commit(pending.current.value);\n };\n\n return { draft: state.draft, change, flush, commit };\n}\n"],"names":[],"mappings":";;AA+BO;AAKL;AAIA;AAIA;AACA;AACE;AAAiB;AAEnB;AAEA;AAEA;AACE;AAGmB;AAInB;AAIE;AAAiD;AAC3C;AAIR;AAAiD;AAGnD;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"shark-parity.divergences.d.ts","sourceRoot":"","sources":["../src/shark-parity.divergences.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,8FAA8F;AAC9F,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAIvD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA6BtD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAUvD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAUhG,CAAC;AA+DF;;;;;;;;;GASG;AACH,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAmCrD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA2BlD,CAAC;AAaF;;;;;GAKG;AACH,e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1D,CAAC"}
1
+ {"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../src/simples/date-picker.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,IAAI,aAAa,EAE5B,MAAM,2BAA2B,CAAC;AAInC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EACL,QAAQ,EAET,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAQjD,eAAO,MAAM,aAAa,oDAAuB,CAAC;AAMlD,eAAO,MAAM,UAAU,GAAI,OAAO,KAAK,CAAC,cAAc,CAAC,OAAO,QAAQ,CAAC,sBAiBtE,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,OAAO,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,OAAO,CAAC,sBAqB1D,CAAC;AAEF,UAAU,oBACR,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,EACpE,UAAU;CAAG;AAEjB,eAAO,MAAM,eAAe,GAAI,OAAO,oBAAoB,sBA0B1D,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,OAAO,KAAK,CAAC,cAAc,CAAC,OAAO,KAAK,CAAC,sBAqBxE,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,OAAO,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,OAAO,CAAC,sBA8B1D,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,OAAO,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,SAAS,CAAC,sBAW5D,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,mBAGrC,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,aAAa,CAAC,sBAK1D,CAAC"}
@@ -1,68 +1,74 @@
1
+ "use client";
1
2
  import { jsx as e, jsxs as c } from "react/jsx-runtime";
2
- import { useDatePickerContext as m, DatePicker as n } from "@ark-ui/react/date-picker";
3
- import { Portal as g } from "@ark-ui/react/portal";
4
- import { CalendarIcon as k, ClockIcon as h } from "lucide-react";
3
+ import { useDatePickerContext as m, DatePicker as i } from "@ark-ui/react/date-picker";
4
+ import { useFieldContext as g } from "@ark-ui/react/field";
5
+ import { Portal as k } from "@ark-ui/react/portal";
6
+ import { CalendarIcon as h, ClockIcon as P } from "lucide-react";
5
7
  import { cn as s } from "../lib/cn.js";
6
- import { Button as f } from "./button.js";
7
- import { Calendar as P, CalendarPresetTrigger as x } from "./calendar.js";
8
- import { InputGroup as l, InputGroupInput as d, InputGroupAddon as p, InputGroupButton as C } from "./input-group.js";
9
- const y = m, G = (t) => {
10
- const { positioning: r = { placement: "top" }, slot: o, ...a } = t;
8
+ import { Button as x } from "./button.js";
9
+ import { Calendar as f, CalendarPresetTrigger as C } from "./calendar.js";
10
+ import { InputGroup as d, InputGroupInput as l, InputGroupAddon as p, InputGroupButton as v } from "./input-group.js";
11
+ const j = m, V = (r) => {
12
+ const { positioning: a = { placement: "top" }, slot: n, ...o } = r, t = g();
11
13
  return /* @__PURE__ */ e(
12
- P,
14
+ f,
13
15
  {
16
+ disabled: t == null ? void 0 : t.disabled,
14
17
  inline: !1,
15
- positioning: r,
16
- ...a,
17
- slot: o ?? "date-picker"
18
+ invalid: t == null ? void 0 : t.invalid,
19
+ positioning: a,
20
+ readOnly: t == null ? void 0 : t.readOnly,
21
+ required: t == null ? void 0 : t.required,
22
+ ...o,
23
+ slot: n ?? "date-picker"
18
24
  }
19
25
  );
20
- }, j = (t) => {
21
- const { className: r, children: o, slot: a, ...i } = t;
22
- return /* @__PURE__ */ e(n.Control, { "data-slot": "date-picker-control", children: /* @__PURE__ */ e(
23
- n.Trigger,
26
+ }, q = (r) => {
27
+ const { className: a, children: n, slot: o, ...t } = r;
28
+ return /* @__PURE__ */ e(i.Control, { "data-slot": "date-picker-control", children: /* @__PURE__ */ e(
29
+ i.Trigger,
24
30
  {
25
31
  className: s(
26
32
  "justify-start",
27
33
  "text-start data-placeholder-shown:[&>span]:text-muted-foreground",
28
34
  "active:scale-100",
29
35
  "[&_svg:not([class*='text-'])]:opacity-64",
30
- r
36
+ a
31
37
  ),
32
- ...i,
33
- "data-slot": a ?? "date-picker-trigger",
34
- children: o
38
+ ...t,
39
+ "data-slot": o ?? "date-picker-trigger",
40
+ children: n
35
41
  }
36
42
  ) });
37
- }, V = (t) => {
38
- const { size: r, className: o, slot: a, ...i } = t;
39
- return /* @__PURE__ */ e(n.Control, { "data-slot": "date-picker-control", children: /* @__PURE__ */ c(l, { size: r, children: [
40
- /* @__PURE__ */ e(n.Input, { asChild: !0, ...i, children: /* @__PURE__ */ e(d, { slot: a ?? "date-picker-input" }) }),
41
- /* @__PURE__ */ e(p, { align: "inline-end", children: /* @__PURE__ */ e(C, { asChild: !0, size: "icon-sm", variant: "ghost", children: /* @__PURE__ */ e(n.Trigger, { asChild: !0, children: /* @__PURE__ */ e(f, { slot: "date-picker-trigger", variant: "ghost", children: /* @__PURE__ */ e(k, { "aria-hidden": !0, className: "text-muted-foreground" }) }) }) }) })
43
+ }, B = (r) => {
44
+ const { size: a, className: n, slot: o, ...t } = r;
45
+ return /* @__PURE__ */ e(i.Control, { "data-slot": "date-picker-control", children: /* @__PURE__ */ c(d, { size: a, children: [
46
+ /* @__PURE__ */ e(i.Input, { asChild: !0, ...t, children: /* @__PURE__ */ e(l, { slot: o ?? "date-picker-input" }) }),
47
+ /* @__PURE__ */ e(p, { align: "inline-end", children: /* @__PURE__ */ e(v, { asChild: !0, size: "icon-sm", variant: "ghost", children: /* @__PURE__ */ e(i.Trigger, { asChild: !0, children: /* @__PURE__ */ e(x, { slot: "date-picker-trigger", variant: "ghost", children: /* @__PURE__ */ e(h, { "aria-hidden": !0, className: "text-muted-foreground" }) }) }) }) })
42
48
  ] }) });
43
- }, B = (t) => {
44
- const { id: r, value: o, defaultValue: a, className: i, ...u } = t;
45
- return /* @__PURE__ */ c(l, { ...u, children: [
46
- /* @__PURE__ */ e(p, { children: /* @__PURE__ */ e(h, {}) }),
49
+ }, O = (r) => {
50
+ const { id: a, value: n, defaultValue: o, className: t, ...u } = r;
51
+ return /* @__PURE__ */ c(d, { ...u, children: [
52
+ /* @__PURE__ */ e(p, { children: /* @__PURE__ */ e(P, {}) }),
47
53
  /* @__PURE__ */ e(
48
- d,
54
+ l,
49
55
  {
50
56
  className: s(
51
57
  "[&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none",
52
- i
58
+ t
53
59
  ),
54
- defaultValue: a,
55
- id: r,
60
+ defaultValue: o,
61
+ id: a,
56
62
  step: "1",
57
63
  type: "time",
58
- value: o
64
+ value: n
59
65
  }
60
66
  )
61
67
  ] });
62
- }, A = (t) => {
63
- const { className: r, slot: o, ...a } = t;
64
- return /* @__PURE__ */ e(g, { children: /* @__PURE__ */ e(n.Positioner, { "data-slot": "date-picker-positioner", children: /* @__PURE__ */ e(
65
- n.Content,
68
+ }, A = (r) => {
69
+ const { className: a, slot: n, ...o } = r;
70
+ return /* @__PURE__ */ e(k, { children: /* @__PURE__ */ e(i.Positioner, { "data-slot": "date-picker-positioner", children: /* @__PURE__ */ e(
71
+ i.Content,
66
72
  {
67
73
  className: s(
68
74
  "[--cell-size:--spacing(8)]",
@@ -78,40 +84,40 @@ const y = m, G = (t) => {
78
84
  "data-[state=closed]:animate-out data-[state=open]:animate-in",
79
85
  "data-[state=closed]:zoom-out-[98%] data-[state=open]:zoom-in-[98%]",
80
86
  "motion-reduce:animate-none!",
81
- r
87
+ a
82
88
  ),
83
- ...a,
84
- "data-slot": o ?? "date-picker-content"
89
+ ...o,
90
+ "data-slot": n ?? "date-picker-content"
85
91
  }
86
92
  ) }) });
87
- }, _ = (t) => {
88
- const { className: r, slot: o, ...a } = t;
93
+ }, F = (r) => {
94
+ const { className: a, slot: n, ...o } = r;
89
95
  return /* @__PURE__ */ e(
90
- n.ValueText,
96
+ i.ValueText,
91
97
  {
92
- className: s("font-medium text-sm", r),
93
- ...a,
94
- "data-slot": o ?? "date-picker-value"
98
+ className: s("font-medium text-sm", a),
99
+ ...o,
100
+ "data-slot": n ?? "date-picker-value"
95
101
  }
96
102
  );
97
- }, $ = ({
98
- slot: t,
99
- ...r
103
+ }, _ = ({
104
+ slot: r,
105
+ ...a
100
106
  }) => /* @__PURE__ */ e(
101
- x,
107
+ C,
102
108
  {
103
- ...r,
104
- slot: t ?? "date-picker-preset-trigger"
109
+ ...a,
110
+ slot: r ?? "date-picker-preset-trigger"
105
111
  }
106
112
  );
107
113
  export {
108
- G as DatePicker,
114
+ V as DatePicker,
109
115
  A as DatePickerContent,
110
- V as DatePickerInput,
111
- $ as DatePickerPresetTrigger,
112
- B as DatePickerTimer,
113
- j as DatePickerTrigger,
114
- _ as DatePickerValue,
115
- y as useDatePicker
116
+ B as DatePickerInput,
117
+ _ as DatePickerPresetTrigger,
118
+ O as DatePickerTimer,
119
+ q as DatePickerTrigger,
120
+ F as DatePickerValue,
121
+ j as useDatePicker
116
122
  };
117
123
  //# sourceMappingURL=date-picker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"date-picker.js","sources":["../../src/simples/date-picker.tsx"],"sourcesContent":["import {\n DatePicker as ArkDatePicker,\n useDatePickerContext,\n} from \"@ark-ui/react/date-picker\";\nimport { Portal } from \"@ark-ui/react/portal\";\nimport { CalendarIcon, ClockIcon } from \"lucide-react\";\nimport type React from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { Button } from \"./button\";\nimport {\n Calendar,\n CalendarPresetTrigger,\n} from \"./calendar\";\nimport type { Input, InputProps } from \"./input\";\nimport {\n InputGroup,\n InputGroupAddon,\n InputGroupButton,\n InputGroupInput,\n} from \"./input-group\";\n\nexport const useDatePicker = useDatePickerContext;\n\nexport const DatePicker = (props: React.ComponentProps<typeof Calendar>) => {\n const { positioning = { placement: \"top\" }, slot, ...rest } = props;\n\n return (\n <Calendar\n inline={false}\n positioning={positioning}\n {...rest}\n slot={slot ?? \"date-picker\"}\n />\n );\n};\n\nexport const DatePickerTrigger = (\n props: React.ComponentProps<typeof ArkDatePicker.Trigger>\n) => {\n const { className, children, slot, ...rest } = props;\n\n return (\n <ArkDatePicker.Control data-slot=\"date-picker-control\">\n <ArkDatePicker.Trigger\n className={cn(\n \"justify-start\",\n \"text-start data-placeholder-shown:[&>span]:text-muted-foreground\",\n \"active:scale-100\",\n \"[&_svg:not([class*='text-'])]:opacity-64\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"date-picker-trigger\"}\n >\n {children}\n </ArkDatePicker.Trigger>\n </ArkDatePicker.Control>\n );\n};\n\ninterface DatePickerInputProps\n extends Omit<React.ComponentProps<typeof ArkDatePicker.Input>, \"size\">,\n InputProps {}\n\nexport const DatePickerInput = (props: DatePickerInputProps) => {\n const { size, className, slot, ...rest } = props;\n\n return (\n <ArkDatePicker.Control data-slot=\"date-picker-control\">\n <InputGroup size={size}>\n <ArkDatePicker.Input asChild {...rest}>\n <InputGroupInput slot={slot ?? \"date-picker-input\"} />\n </ArkDatePicker.Input>\n\n <InputGroupAddon align=\"inline-end\">\n {/* One size for the chain, and it used to declare two: the outer `InputGroupButton` asked\n for `icon-sm` and the inner `Button` — which exists only because Ark's Trigger needs a\n child to hand its props to — overrode it with `icon-md`. The outer one is the size a\n control inside a group has, so the inner declares none. */}\n <InputGroupButton asChild size=\"icon-sm\" variant=\"ghost\">\n <ArkDatePicker.Trigger asChild>\n <Button slot=\"date-picker-trigger\" variant=\"ghost\">\n <CalendarIcon aria-hidden className=\"text-muted-foreground\" />\n </Button>\n </ArkDatePicker.Trigger>\n </InputGroupButton>\n </InputGroupAddon>\n </InputGroup>\n </ArkDatePicker.Control>\n );\n};\n\nexport const DatePickerTimer = (props: React.ComponentProps<typeof Input>) => {\n const { id, value, defaultValue, className, ...rest } = props;\n\n return (\n <InputGroup {...rest}>\n <InputGroupAddon>\n <ClockIcon />\n </InputGroupAddon>\n <InputGroupInput\n className={cn(\n \"[&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none\",\n className\n )}\n defaultValue={defaultValue}\n id={id}\n step=\"1\"\n type=\"time\"\n value={value}\n />\n </InputGroup>\n );\n};\n\nexport const DatePickerContent = (\n props: React.ComponentProps<typeof ArkDatePicker.Content>\n) => {\n const { className, slot, ...rest } = props;\n\n return (\n <Portal>\n <ArkDatePicker.Positioner data-slot=\"date-picker-positioner\">\n <ArkDatePicker.Content\n className={cn(\n \"[--cell-size:--spacing(8)]\",\n \"z-[calc(50+var(--layer-index,0))]\",\n \"w-fit min-w-72\",\n \"p-3\",\n \"bg-popover\",\n \"text-popover-foreground\",\n \"rounded-box border shadow-lg/5\",\n \"outline-none\",\n \"origin-(--transform-origin)\",\n \"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n \"data-[state=closed]:animate-out data-[state=open]:animate-in\",\n \"data-[state=closed]:zoom-out-[98%] data-[state=open]:zoom-in-[98%]\",\n \"motion-reduce:animate-none!\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"date-picker-content\"}\n />\n </ArkDatePicker.Positioner>\n </Portal>\n );\n};\n\nexport const DatePickerValue = (\n props: React.ComponentProps<typeof ArkDatePicker.ValueText>\n) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ArkDatePicker.ValueText\n className={cn(\"font-medium text-sm\", className)}\n {...rest}\n data-slot={slot ?? \"date-picker-value\"}\n />\n );\n};\n\nexport const DatePickerPresetTrigger = ({\n slot,\n ...rest\n}: React.ComponentProps<typeof ArkDatePicker.PresetTrigger>) => (\n <CalendarPresetTrigger\n {...rest}\n slot={slot ?? \"date-picker-preset-trigger\"}\n />\n);\n"],"names":["useDatePicker","useDatePickerContext","DatePicker","props","positioning","slot","rest","jsx","Calendar","DatePickerTrigger","className","children","ArkDatePicker","cn","DatePickerInput","size","jsxs","InputGroup","InputGroupInput","InputGroupAddon","InputGroupButton","Button","CalendarIcon","DatePickerTimer","id","value","defaultValue","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C7B3B,MACG;AACH,QAAM,EAAE,WAAAO,GAAW,MAAAL,GAAM,GAAGC,MAASH;AAErC,SACE,gBAAAI;AAAA,IAACK,EAAc;AAAA,IAAd;AAAA,MACC,WAAWC,EAAG,uBAAuBH,CAAS;AAAA,MAC7C,GAAGJ;AAAA,MACJ,aAAWD,KAAQ;AAAA,IAAA;AAAA,EAAA;AAGzB,GAEa0B,IAA0B,CAAC;AAAA,EACtC,MAAA1B;AAAA,EACA,GAAGC;AACL,MACE,gBAAAC;AAAA,EAACyB;AAAA,EAAA;AAAA,IACE,GAAG1B;AAAA,IACJ,MAAMD,KAAQ;AAAA,EAAA;AAChB;"}
1
+ {"version":3,"file":"date-picker.js","sources":["../../src/simples/date-picker.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n DatePicker as ArkDatePicker,\n useDatePickerContext,\n} from \"@ark-ui/react/date-picker\";\nimport { type UseFieldContext, useFieldContext } from \"@ark-ui/react/field\";\nimport { Portal } from \"@ark-ui/react/portal\";\nimport { CalendarIcon, ClockIcon } from \"lucide-react\";\nimport type React from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { Button } from \"./button\";\nimport {\n Calendar,\n CalendarPresetTrigger,\n} from \"./calendar\";\nimport type { Input, InputProps } from \"./input\";\nimport {\n InputGroup,\n InputGroupAddon,\n InputGroupButton,\n InputGroupInput,\n} from \"./input-group\";\n\nexport const useDatePicker = useDatePickerContext;\n\n// Ark's `useDatePicker` reads no `useFieldContext` (it takes environment and locale only), so a\n// `Field disabled` greyed the input while the popover still opened and a click still wrote a value.\n// Bridged here the way `RadioGroup` does it: state flags only, explicit props win, and with no\n// `Field` ancestor every flag is `undefined`, which Ark strips before the machine sees it.\nexport const DatePicker = (props: React.ComponentProps<typeof Calendar>) => {\n const { positioning = { placement: \"top\" }, slot, ...rest } = props;\n\n const field: UseFieldContext | undefined = useFieldContext();\n\n return (\n <Calendar\n disabled={field?.disabled}\n inline={false}\n invalid={field?.invalid}\n positioning={positioning}\n readOnly={field?.readOnly}\n required={field?.required}\n {...rest}\n slot={slot ?? \"date-picker\"}\n />\n );\n};\n\nexport const DatePickerTrigger = (\n props: React.ComponentProps<typeof ArkDatePicker.Trigger>\n) => {\n const { className, children, slot, ...rest } = props;\n\n return (\n <ArkDatePicker.Control data-slot=\"date-picker-control\">\n <ArkDatePicker.Trigger\n className={cn(\n \"justify-start\",\n \"text-start data-placeholder-shown:[&>span]:text-muted-foreground\",\n \"active:scale-100\",\n \"[&_svg:not([class*='text-'])]:opacity-64\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"date-picker-trigger\"}\n >\n {children}\n </ArkDatePicker.Trigger>\n </ArkDatePicker.Control>\n );\n};\n\ninterface DatePickerInputProps\n extends Omit<React.ComponentProps<typeof ArkDatePicker.Input>, \"size\">,\n InputProps {}\n\nexport const DatePickerInput = (props: DatePickerInputProps) => {\n const { size, className, slot, ...rest } = props;\n\n return (\n <ArkDatePicker.Control data-slot=\"date-picker-control\">\n <InputGroup size={size}>\n <ArkDatePicker.Input asChild {...rest}>\n <InputGroupInput slot={slot ?? \"date-picker-input\"} />\n </ArkDatePicker.Input>\n\n <InputGroupAddon align=\"inline-end\">\n {/* One size for the chain, and it used to declare two: the outer `InputGroupButton` asked\n for `icon-sm` and the inner `Button` — which exists only because Ark's Trigger needs a\n child to hand its props to — overrode it with `icon-md`. The outer one is the size a\n control inside a group has, so the inner declares none. */}\n <InputGroupButton asChild size=\"icon-sm\" variant=\"ghost\">\n <ArkDatePicker.Trigger asChild>\n <Button slot=\"date-picker-trigger\" variant=\"ghost\">\n <CalendarIcon aria-hidden className=\"text-muted-foreground\" />\n </Button>\n </ArkDatePicker.Trigger>\n </InputGroupButton>\n </InputGroupAddon>\n </InputGroup>\n </ArkDatePicker.Control>\n );\n};\n\nexport const DatePickerTimer = (props: React.ComponentProps<typeof Input>) => {\n const { id, value, defaultValue, className, ...rest } = props;\n\n return (\n <InputGroup {...rest}>\n <InputGroupAddon>\n <ClockIcon />\n </InputGroupAddon>\n <InputGroupInput\n className={cn(\n \"[&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none\",\n className\n )}\n defaultValue={defaultValue}\n id={id}\n step=\"1\"\n type=\"time\"\n value={value}\n />\n </InputGroup>\n );\n};\n\nexport const DatePickerContent = (\n props: React.ComponentProps<typeof ArkDatePicker.Content>\n) => {\n const { className, slot, ...rest } = props;\n\n return (\n <Portal>\n <ArkDatePicker.Positioner data-slot=\"date-picker-positioner\">\n <ArkDatePicker.Content\n className={cn(\n \"[--cell-size:--spacing(8)]\",\n \"z-[calc(50+var(--layer-index,0))]\",\n \"w-fit min-w-72\",\n \"p-3\",\n \"bg-popover\",\n \"text-popover-foreground\",\n \"rounded-box border shadow-lg/5\",\n \"outline-none\",\n \"origin-(--transform-origin)\",\n \"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n \"data-[state=closed]:animate-out data-[state=open]:animate-in\",\n \"data-[state=closed]:zoom-out-[98%] data-[state=open]:zoom-in-[98%]\",\n \"motion-reduce:animate-none!\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"date-picker-content\"}\n />\n </ArkDatePicker.Positioner>\n </Portal>\n );\n};\n\nexport const DatePickerValue = (\n props: React.ComponentProps<typeof ArkDatePicker.ValueText>\n) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ArkDatePicker.ValueText\n className={cn(\"font-medium text-sm\", className)}\n {...rest}\n data-slot={slot ?? \"date-picker-value\"}\n />\n );\n};\n\nexport const DatePickerPresetTrigger = ({\n slot,\n ...rest\n}: React.ComponentProps<typeof ArkDatePicker.PresetTrigger>) => (\n <CalendarPresetTrigger\n {...rest}\n slot={slot ?? \"date-picker-preset-trigger\"}\n />\n);\n"],"names":[],"mappings":";;;;;;;;;;AAwBO;AAOL;AAIA;AACE;AAAC;AAAA;AACkB;AACT;AACQ;AAChB;AACiB;AACA;AACb;AACU;AAAA;AAGpB;AAKE;AAEA;AAEI;AAAe;AAAd;AACY;AACT;AACA;AACA;AACA;AACA;AAAA;AAEE;AACe;AAElB;AAAA;AAIT;AAOE;AAEA;AAGM;AAEA;AAcA;AAIR;AAGE;AAEA;AAEI;AAEA;AACA;AAAC;AAAA;AACY;AACT;AACA;AAAA;AAEF;AACA;AACK;AACA;AACL;AAAA;AAAA;AAIR;AAKE;AAEA;AAGM;AAAe;AAAd;AACY;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAEE;AACe;AAAA;AAK7B;AAKE;AAEA;AACE;AAAe;AAAd;AAC+C;AAC1C;AACe;AAAA;AAGzB;AAEwC;AACtC;AAEF;AACE;AAAC;AAAA;AACK;AACU;AAChB;;;;;;;;;;;"}
@@ -43,7 +43,14 @@ interface FieldLegendProps extends React.ComponentProps<typeof ArkFieldset.Legen
43
43
  variant?: "legend" | "label";
44
44
  }
45
45
  export declare const FieldLegend: (props: FieldLegendProps) => React.JSX.Element;
46
- export declare const FieldGroup: (props: React.ComponentProps<typeof ark.div>) => React.JSX.Element;
46
+ interface FieldGroupProps extends React.ComponentProps<typeof ark.div> {
47
+ /**
48
+ * Lay the fields out in a grid: one to four equal columns, or `"auto"` to fit as many as the
49
+ * width allows. Omitted, they stack. A field that should span the row takes `col-span-full`.
50
+ */
51
+ columns?: 1 | 2 | 3 | 4 | "auto";
52
+ }
53
+ export declare const FieldGroup: (props: FieldGroupProps) => React.JSX.Element;
47
54
  export declare const FieldContent: (props: React.ComponentProps<typeof ark.div>) => React.JSX.Element;
48
55
  export declare const FieldLabel: (props: React.ComponentProps<typeof ArkField.Label>) => React.JSX.Element;
49
56
  /**
@@ -56,7 +63,33 @@ export declare const FieldRequiredIndicator: (props: React.ComponentProps<typeof
56
63
  export declare const FieldTitle: (props: React.ComponentProps<typeof ark.div>) => React.JSX.Element;
57
64
  export declare const FieldDescription: (props: React.ComponentProps<typeof ark.p>) => React.JSX.Element;
58
65
  export declare const FieldSeparator: (props: React.ComponentProps<typeof ark.div>) => React.JSX.Element;
59
- export declare const FieldHelper: (props: React.ComponentProps<typeof ArkField.HelperText>) => React.JSX.Element;
66
+ declare const fieldHelperVariants: import('tailwind-variants').TVReturnType<{
67
+ tone: {
68
+ muted: string;
69
+ info: string;
70
+ warning: string;
71
+ };
72
+ }, undefined, "text-sm", {
73
+ tone: {
74
+ muted: string;
75
+ info: string;
76
+ warning: string;
77
+ };
78
+ }, undefined, import('tailwind-variants').TVReturnType<{
79
+ tone: {
80
+ muted: string;
81
+ info: string;
82
+ warning: string;
83
+ };
84
+ }, undefined, "text-sm", unknown, unknown, undefined>>;
85
+ interface FieldHelperProps extends React.ComponentProps<typeof ArkField.HelperText>, VariantProps<typeof fieldHelperVariants> {
86
+ }
87
+ /**
88
+ * The one message wired into the control's `aria-describedby`, and there is one per `Field`: Ark
89
+ * gives every `HelperText` the same id, so a second would collide. A warning beside a description
90
+ * is therefore this part with a `tone` for the warning and `FieldDescription` for the description.
91
+ */
92
+ export declare const FieldHelper: (props: FieldHelperProps) => React.JSX.Element;
60
93
  export declare const FieldError: (props: React.ComponentProps<typeof ArkField.ErrorText>) => React.JSX.Element;
61
94
  export declare const FieldSetHelper: (props: React.ComponentProps<typeof ArkFieldset.HelperText>) => React.JSX.Element;
62
95
  export declare const FieldSetError: (props: React.ComponentProps<typeof ArkFieldset.ErrorText>) => React.JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/simples/field.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EACL,KAAK,IAAI,QAAQ,EAElB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,IAAI,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAM,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAI1D,eAAO,MAAM,QAAQ,+CAAq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