@kanso-labs/kanso-ui 0.28.3 → 0.28.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.
@@ -12,7 +12,7 @@ const COPIED_RESET_MS = 2e3;
12
12
  * on the button itself.
13
13
  */
14
14
  function CopyField(t0) {
15
- const $ = c(18);
15
+ const $ = c(31);
16
16
  const { copiedLabel: t1, copyLabel: t2, onCopied, value, ...props } = t0;
17
17
  const copiedLabel = t1 === void 0 ? "Copied" : t1;
18
18
  const copyLabel = t2 === void 0 ? "Copy" : t2;
@@ -66,48 +66,101 @@ function CopyField(t0) {
66
66
  $[5] = value;
67
67
  $[6] = t7;
68
68
  } else t7 = $[6];
69
- const t8 = copied ? copiedLabel : copyLabel;
69
+ const t8 = copied || void 0;
70
70
  let t9;
71
- if ($[7] !== handleCopy || $[8] !== t8) {
72
- t9 = /* @__PURE__ */ jsx(Button, {
71
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
72
+ t9 = {
73
+ 0: { className: "x15r89dc" },
74
+ 1: { className: "x15r89dc xlshs6z" }
75
+ };
76
+ $[7] = t9;
77
+ } else t9 = $[7];
78
+ const t10 = t9[!!copied << 0];
79
+ let t11;
80
+ if ($[8] !== copyLabel || $[9] !== t10 || $[10] !== t8) {
81
+ t11 = /* @__PURE__ */ jsx("span", {
82
+ "aria-hidden": t8,
83
+ ...t10,
84
+ children: copyLabel
85
+ });
86
+ $[8] = copyLabel;
87
+ $[9] = t10;
88
+ $[10] = t8;
89
+ $[11] = t11;
90
+ } else t11 = $[11];
91
+ const t12 = !copied || void 0;
92
+ let t13;
93
+ if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
94
+ t13 = {
95
+ 0: { className: "x15r89dc" },
96
+ 1: { className: "x15r89dc xlshs6z" }
97
+ };
98
+ $[12] = t13;
99
+ } else t13 = $[12];
100
+ const t14 = t13[!!!copied << 0];
101
+ let t15;
102
+ if ($[13] !== copiedLabel || $[14] !== t12 || $[15] !== t14) {
103
+ t15 = /* @__PURE__ */ jsx("span", {
104
+ "aria-hidden": t12,
105
+ ...t14,
106
+ children: copiedLabel
107
+ });
108
+ $[13] = copiedLabel;
109
+ $[14] = t12;
110
+ $[15] = t14;
111
+ $[16] = t15;
112
+ } else t15 = $[16];
113
+ let t16;
114
+ if ($[17] !== t11 || $[18] !== t15) {
115
+ t16 = /* @__PURE__ */ jsxs("span", {
116
+ className: "xrvj5dj x1o2pa38",
117
+ children: [t11, t15]
118
+ });
119
+ $[17] = t11;
120
+ $[18] = t15;
121
+ $[19] = t16;
122
+ } else t16 = $[19];
123
+ let t17;
124
+ if ($[20] !== handleCopy || $[21] !== t16) {
125
+ t17 = /* @__PURE__ */ jsx(Button, {
73
126
  onClick: handleCopy,
74
127
  size: "xs",
75
128
  variant: "text",
76
- children: t8
129
+ children: t16
77
130
  });
78
- $[7] = handleCopy;
79
- $[8] = t8;
80
- $[9] = t9;
81
- } else t9 = $[9];
82
- const t10 = copied ? copiedLabel : "";
83
- let t11;
84
- if ($[10] !== t10) {
85
- t11 = /* @__PURE__ */ jsx("output", {
131
+ $[20] = handleCopy;
132
+ $[21] = t16;
133
+ $[22] = t17;
134
+ } else t17 = $[22];
135
+ const t18 = copied ? copiedLabel : "";
136
+ let t19;
137
+ if ($[23] !== t18) {
138
+ t19 = /* @__PURE__ */ jsx("output", {
86
139
  className: "xjm9jq1 x1hyvwdk x1i1rx1s xb3r6kr x10l6tqk xuxw1ft",
87
- children: t10
140
+ children: t18
88
141
  });
89
- $[10] = t10;
90
- $[11] = t11;
91
- } else t11 = $[11];
92
- let t12;
93
- if ($[12] !== props || $[13] !== t11 || $[14] !== t6 || $[15] !== t7 || $[16] !== t9) {
94
- t12 = /* @__PURE__ */ jsxs("div", {
142
+ $[23] = t18;
143
+ $[24] = t19;
144
+ } else t19 = $[24];
145
+ let t20;
146
+ if ($[25] !== props || $[26] !== t17 || $[27] !== t19 || $[28] !== t6 || $[29] !== t7) {
147
+ t20 = /* @__PURE__ */ jsxs("div", {
95
148
  ...props,
96
149
  ...t6,
97
150
  children: [
98
151
  t7,
99
- t9,
100
- t11
152
+ t17,
153
+ t19
101
154
  ]
102
155
  });
103
- $[12] = props;
104
- $[13] = t11;
105
- $[14] = t6;
106
- $[15] = t7;
107
- $[16] = t9;
108
- $[17] = t12;
109
- } else t12 = $[17];
110
- return t12;
156
+ $[25] = props;
157
+ $[26] = t17;
158
+ $[27] = t19;
159
+ $[28] = t6;
160
+ $[29] = t7;
161
+ $[30] = t20;
162
+ } else t20 = $[30];
163
+ return t20;
111
164
  }
112
165
  //#endregion
113
166
  export { CopyField as default };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["HTMLAttributes","stylex","useCallback","useEffect","useRef","useState","mergeStyles","colors","radii","spacing","typography","Button","Code","COPIED_RESET_MS","CopyFieldProps","copiedLabel","copyLabel","onCopied","value","Omit","HTMLDivElement","CopyField","t0","$","_c","t1","t2","props","undefined","copied","setCopied","timer","t3","t4","Symbol","for","clearTimeout","current","t5","write","navigator","clipboard","writeText","setTimeout","handleCopy","t6","className","t7","t8","t9","t10","t11","t12"],"sources":["../../../src/components/copy-field/index.tsx"],"sourcesContent":["import type { HTMLAttributes } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, spacing, typography } from '../../tokens/design.tokens.stylex';\nimport Button from '../button';\nimport Code from '../code';\n\n// How long the confirmation stands before the control returns to offering the\n// copy again. Not a motion token: those are transition durations, measured in\n// hundreds of milliseconds, and this is a dwell — long enough to be read\n// without being long enough to leave the button lying about what it will do.\nconst COPIED_RESET_MS = 2000;\n\n// No Material Design page draws a read-only value with a copy control. It\n// follows the outlined text field: the 1dp rule in the outline role, the\n// surface behind it, and the control at its trailing end. The value is\n// body-small beside a 32dp text button, so the box is shorter than the\n// field's 56, which suits a value that is read rather than edited, and its\n// corner is the shape scale's small step for the same reason.\n\ntype CopyFieldProps = {\n /**\n * What the button says once the value has been copied. It reverts to\n * `copyLabel` on its own after a couple of seconds.\n * @default 'Copied'\n */\n copiedLabel?: string;\n /**\n * What the button says at rest.\n * @default 'Copy'\n */\n copyLabel?: string;\n /**\n * Called with the value after it reaches the clipboard, never before.\n *\n * Named `onCopied` rather than `onCopy` because the root is a `<div>`, which\n * already has an `onCopy` of its own — React's handler for the native copy\n * event, fired when the reader presses the copy shortcut inside the element.\n * The two are different moments, and a prop that quietly shadowed the\n * built-in would be a trap rather than a convenience.\n */\n onCopied?: (value: string) => void;\n /** The text shown, and the text copied. */\n value: string;\n} & Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\n/**\n * A value to be read and taken away — a repository URL, a token, a command.\n * It shows the value in the mono face and copies it on request, confirming\n * on the button itself.\n */\nfunction CopyField({\n copiedLabel = 'Copied',\n copyLabel = 'Copy',\n onCopied,\n value,\n ...props\n}: CopyFieldProps) {\n const [copied, setCopied] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n // Without this, a field unmounted inside the dwell leaves a timer holding a\n // setState for a tree that is gone.\n useEffect(() => () => {\n clearTimeout(timer.current);\n }, []);\n const handleCopy = useCallback(() => {\n const write = async () => {\n try {\n await navigator.clipboard.writeText(value);\n } catch {\n // A clipboard write is refused outside a secure context and wherever\n // the permission is denied, and neither is something the call site can\n // fix. Staying at rest is the honest report: the value is not on the\n // clipboard, so the control must not claim it is.\n setCopied(false);\n return;\n }\n setCopied(true);\n onCopied?.(value);\n clearTimeout(timer.current);\n timer.current = setTimeout(() => {\n setCopied(false);\n }, COPIED_RESET_MS);\n };\n void write();\n }, [onCopied, value]);\n return <div {...props} {...mergeStyles({\n className: \"x6s0dn4 x14s9m32 x1fwvt7v x1xdvaa9 x1y0btm7 xmkeg23 x9f619 x78zum5 x126z3so xmqoko8 x18fpw6u\"\n }, props)}>\n <span className=\"x1iyjqo2 x1b35g6e xeuugli\">\n <Code>{value}</Code>\n </span>\n <Button onClick={handleCopy} size=\"xs\" variant=\"text\">\n {copied ? copiedLabel : copyLabel}\n </Button>\n {/* The button's own label changes, but a label changing under a screen\n reader is not reliably announced. This is. `<output>` carries an\n implicit role of status, so it needs no role attribute of its own. */}\n <output className=\"xjm9jq1 x1hyvwdk x1i1rx1s xb3r6kr x10l6tqk xuxw1ft\">\n {copied ? copiedLabel : ''}\n </output>\n </div>;\n}\nexport type { CopyFieldProps };\nexport default CopyField;"],"mappings":";;;;;;;AAaA,MAAMa,kBAAkB;;;;;;AAwCxB,SAAAQ,UAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAmB,MAAA,EAAAT,aAAAU,IAAAT,WAAAU,IAAAT,UAAAC,OAAA,GAAAS,UAAAL;CACjB,MAAAP,cAAAU,OAAAG,KAAAA,IAAA,WAAAH;CACA,MAAAT,YAAAU,OAAAE,KAAAA,IAAA,SAAAF;CAKA,MAAA,CAAAG,QAAAC,aAA4BzB,SAAS,KAAK;CAC1C,MAAA0B,QAAc3B,OAAkDwB,KAAAA,CAAS;CAAE,IAAAI;CAAA,IAAAC;CAAA,IAAAV,EAAA,OAAAW,OAAAC,IAAA,2BAAA,GAAA;EAIjEH,iBAAM;GACdI,aAAaL,MAAKM,OAAQ;EAAC;EAC1BJ,KAAA,CAAA;EAAEV,EAAA,KAAAS;EAAAT,EAAA,KAAAU;CAAA,OAAA;EAAAD,KAAAT,EAAA;EAAAU,KAAAV,EAAA;CAAA;CAFLpB,UAAU6B,IAEPC,EAAE;CAAC,IAAAK;CAAA,IAAAf,EAAA,OAAAN,YAAAM,EAAA,OAAAL,OAAA;EACyBoB,WAAA;GAC7B,MAAAC,QAAc,YAAA;IACZ,IAAA;KACE,MAAMC,UAASC,UAAUC,UAAWxB,KAAK;IAAC,QAAA;KAM1CY,UAAU,KAAK;KAAC;IAAA;IAGlBA,UAAU,IAAI;IACdb,WAAWC,KAAK;IAChBkB,aAAaL,MAAKM,OAA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IAGAE;IAMAE;GAGI;;EAAA5B,EAAA,MAAAI;EAAAJ,EAAA,MAAA4B;EAAA5B,EAAA,MAAAsB;EAAAtB,EAAA,MAAAwB;EAAAxB,EAAA,MAAA0B;EAAA1B,EAAA,MAAA6B;CAAA,OAAAA,MAAA7B,EAAA;CAAA,OAfD6B;AAeC"}
1
+ {"version":3,"file":"index.js","names":["HTMLAttributes","stylex","useCallback","useEffect","useRef","useState","mergeStyles","colors","radii","spacing","typography","Button","Code","COPIED_RESET_MS","CopyFieldProps","copiedLabel","copyLabel","onCopied","value","Omit","HTMLDivElement","CopyField","t0","$","_c","t1","t2","props","undefined","copied","setCopied","timer","t3","t4","Symbol","for","clearTimeout","current","t5","write","navigator","clipboard","writeText","setTimeout","handleCopy","t6","className","t7","t8","t9","0","1","t10","t11","t12","t13","t14","t15","t16","t17","t18","t19","t20"],"sources":["../../../src/components/copy-field/index.tsx"],"sourcesContent":["import type { HTMLAttributes } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, spacing, typography } from '../../tokens/design.tokens.stylex';\nimport Button from '../button';\nimport Code from '../code';\n\n// How long the confirmation stands before the control returns to offering the\n// copy again. Not a motion token: those are transition durations, measured in\n// hundreds of milliseconds, and this is a dwell — long enough to be read\n// without being long enough to leave the button lying about what it will do.\nconst COPIED_RESET_MS = 2000;\n\n// No Material Design page draws a read-only value with a copy control. It\n// follows the outlined text field: the 1dp rule in the outline role, the\n// surface behind it, and the control at its trailing end. The value is\n// body-small beside a 32dp text button, so the box is shorter than the\n// field's 56, which suits a value that is read rather than edited, and its\n// corner is the shape scale's small step for the same reason.\n\ntype CopyFieldProps = {\n /**\n * What the button says once the value has been copied. It reverts to\n * `copyLabel` on its own after a couple of seconds.\n * @default 'Copied'\n */\n copiedLabel?: string;\n /**\n * What the button says at rest.\n * @default 'Copy'\n */\n copyLabel?: string;\n /**\n * Called with the value after it reaches the clipboard, never before.\n *\n * Named `onCopied` rather than `onCopy` because the root is a `<div>`, which\n * already has an `onCopy` of its own — React's handler for the native copy\n * event, fired when the reader presses the copy shortcut inside the element.\n * The two are different moments, and a prop that quietly shadowed the\n * built-in would be a trap rather than a convenience.\n */\n onCopied?: (value: string) => void;\n /** The text shown, and the text copied. */\n value: string;\n} & Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\n/**\n * A value to be read and taken away — a repository URL, a token, a command.\n * It shows the value in the mono face and copies it on request, confirming\n * on the button itself.\n */\nfunction CopyField({\n copiedLabel = 'Copied',\n copyLabel = 'Copy',\n onCopied,\n value,\n ...props\n}: CopyFieldProps) {\n const [copied, setCopied] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n // Without this, a field unmounted inside the dwell leaves a timer holding a\n // setState for a tree that is gone.\n useEffect(() => () => {\n clearTimeout(timer.current);\n }, []);\n const handleCopy = useCallback(() => {\n const write = async () => {\n try {\n await navigator.clipboard.writeText(value);\n } catch {\n // A clipboard write is refused outside a secure context and wherever\n // the permission is denied, and neither is something the call site can\n // fix. Staying at rest is the honest report: the value is not on the\n // clipboard, so the control must not claim it is.\n setCopied(false);\n return;\n }\n setCopied(true);\n onCopied?.(value);\n clearTimeout(timer.current);\n timer.current = setTimeout(() => {\n setCopied(false);\n }, COPIED_RESET_MS);\n };\n void write();\n }, [onCopied, value]);\n return <div {...props} {...mergeStyles({\n className: \"x6s0dn4 x14s9m32 x1fwvt7v x1xdvaa9 x1y0btm7 xmkeg23 x9f619 x78zum5 x126z3so xmqoko8 x18fpw6u\"\n }, props)}>\n <span className=\"x1iyjqo2 x1b35g6e xeuugli\">\n <Code>{value}</Code>\n </span>\n <Button onClick={handleCopy} size=\"xs\" variant=\"text\">\n <span className=\"xrvj5dj x1o2pa38\">\n <span aria-hidden={copied || undefined} {...{\n 0: {\n className: \"x15r89dc\"\n },\n 1: {\n className: \"x15r89dc xlshs6z\"\n }\n }[!!copied << 0]}>\n {copyLabel}\n </span>\n <span aria-hidden={!copied || undefined} {...{\n 0: {\n className: \"x15r89dc\"\n },\n 1: {\n className: \"x15r89dc xlshs6z\"\n }\n }[!!!copied << 0]}>\n {copiedLabel}\n </span>\n </span>\n </Button>\n {/* The button's own label changes, but a label changing under a screen\n reader is not reliably announced. This is. `<output>` carries an\n implicit role of status, so it needs no role attribute of its own. */}\n <output className=\"xjm9jq1 x1hyvwdk x1i1rx1s xb3r6kr x10l6tqk xuxw1ft\">\n {copied ? copiedLabel : ''}\n </output>\n </div>;\n}\nexport type { CopyFieldProps };\nexport default CopyField;"],"mappings":";;;;;;;AAaA,MAAMa,kBAAkB;;;;;;AAwCxB,SAAAQ,UAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAmB,MAAA,EAAAT,aAAAU,IAAAT,WAAAU,IAAAT,UAAAC,OAAA,GAAAS,UAAAL;CACjB,MAAAP,cAAAU,OAAAG,KAAAA,IAAA,WAAAH;CACA,MAAAT,YAAAU,OAAAE,KAAAA,IAAA,SAAAF;CAKA,MAAA,CAAAG,QAAAC,aAA4BzB,SAAS,KAAK;CAC1C,MAAA0B,QAAc3B,OAAkDwB,KAAAA,CAAS;CAAE,IAAAI;CAAA,IAAAC;CAAA,IAAAV,EAAA,OAAAW,OAAAC,IAAA,2BAAA,GAAA;EAIjEH,iBAAM;GACdI,aAAaL,MAAKM,OAAQ;EAAC;EAC1BJ,KAAA,CAAA;EAAEV,EAAA,KAAAS;EAAAT,EAAA,KAAAU;CAAA,OAAA;EAAAD,KAAAT,EAAA;EAAAU,KAAAV,EAAA;CAAA;CAFLpB,UAAU6B,IAEPC,EAAE;CAAC,IAAAK;CAAA,IAAAf,EAAA,OAAAN,YAAAM,EAAA,OAAAL,OAAA;EACyBoB,WAAA;GAC7B,MAAAC,QAAc,YAAA;IACZ,IAAA;KACE,MAAMC,UAASC,UAAUC,UAAWxB,KAAK;IAAC,QAAA;KAM1C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,MAAAtC,EAAA;CAAA,IAAAuC;CAAA,IAAAvC,EAAA,QAAAI,SAAAJ,EAAA,QAAAoC,OAAApC,EAAA,QAAAsC,OAAAtC,EAAA,QAAAsB,MAAAtB,EAAA,QAAAwB,IAAA;EAnCNe,MAAA,qBAAA,OAAA;GAoCC,GApCQnC;GAAK,GAAMkB;GAApB,UAAA;IAGHE;IAGAY;IA2BAE;GAGI;;EAAAtC,EAAA,MAAAI;EAAAJ,EAAA,MAAAoC;EAAApC,EAAA,MAAAsC;EAAAtC,EAAA,MAAAsB;EAAAtB,EAAA,MAAAwB;EAAAxB,EAAA,MAAAuC;CAAA,OAAAA,MAAAvC,EAAA;CAAA,OApCDuC;AAoCC"}
@@ -13,6 +13,13 @@ import { c } from "react/compiler-runtime";
13
13
  import { jsx, jsxs } from "react/jsx-runtime";
14
14
  import { Button, DateInput, DatePicker, Dialog, Group, Popover } from "react-aria-components";
15
15
  //#region src/components/date-picker/index.tsx
16
+ function calendarTrigger(triggerLabel) {
17
+ return /* @__PURE__ */ jsx(Button, {
18
+ "aria-label": triggerLabel,
19
+ className: triggerClassName,
20
+ children: /* @__PURE__ */ jsx(CalendarGlyph, { ...props(picker.triggerGlyph) })
21
+ });
22
+ }
16
23
  /**
17
24
  * A date typed into a field, or picked from a calendar behind a button. The
18
25
  * value is React Aria's — pass `value` with `onChange` to control it, or
@@ -34,7 +41,7 @@ import { Button, DateInput, DatePicker, Dialog, Group, Popover } from "react-ari
34
41
  * which is the element a layout positions.
35
42
  */
36
43
  function DatePicker$1(t0) {
37
- const $ = c(33);
44
+ const $ = c(32);
38
45
  const { container, description, error, floatingLabel: t1, isDisabled: t2, label, leadingIcon, triggerLabel: t3, variant: t4, ...props$1 } = t0;
39
46
  const floatingLabel = t1 === void 0 ? true : t1;
40
47
  const isDisabled = t2 === void 0 ? false : t2;
@@ -50,119 +57,111 @@ function DatePicker$1(t0) {
50
57
  } else t5 = $[1];
51
58
  const t6 = mergeStatefulStyles(props(fieldStyles.root), props$1);
52
59
  let t7;
53
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
54
- t7 = props(picker.group);
55
- $[2] = t7;
56
- } else t7 = $[2];
60
+ if ($[2] !== triggerLabel) {
61
+ t7 = calendarTrigger(triggerLabel);
62
+ $[2] = triggerLabel;
63
+ $[3] = t7;
64
+ } else t7 = $[3];
57
65
  let t8;
58
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
59
- t8 = /* @__PURE__ */ jsx(DateInput, {
60
- ...props(segmentStyles.input),
61
- children: renderSegment
62
- });
63
- $[3] = t8;
64
- } else t8 = $[3];
65
- let t9;
66
66
  if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
67
- t9 = /* @__PURE__ */ jsx(CalendarGlyph, { ...props(picker.triggerGlyph) });
68
- $[4] = t9;
69
- } else t9 = $[4];
70
- let t10;
71
- if ($[5] !== triggerLabel) {
72
- t10 = /* @__PURE__ */ jsx(FieldValue, { children: /* @__PURE__ */ jsxs(Group, {
73
- ...t7,
74
- children: [t8, /* @__PURE__ */ jsx(Button, {
75
- "aria-label": triggerLabel,
76
- className: triggerClassName,
77
- children: t9
78
- })]
67
+ t8 = props(picker.group);
68
+ $[4] = t8;
69
+ } else t8 = $[4];
70
+ let t9;
71
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
72
+ t9 = /* @__PURE__ */ jsx(FieldValue, { children: /* @__PURE__ */ jsx(Group, {
73
+ ...t8,
74
+ children: /* @__PURE__ */ jsx(DateInput, {
75
+ ...props(segmentStyles.input),
76
+ children: renderSegment
77
+ })
79
78
  }) });
80
- $[5] = triggerLabel;
81
- $[6] = t10;
82
- } else t10 = $[6];
83
- let t11;
84
- if ($[7] !== floatingLabel || $[8] !== label || $[9] !== leadingIcon || $[10] !== t10 || $[11] !== variant) {
85
- t11 = /* @__PURE__ */ jsx(FieldBox, {
79
+ $[5] = t9;
80
+ } else t9 = $[5];
81
+ let t10;
82
+ if ($[6] !== floatingLabel || $[7] !== label || $[8] !== leadingIcon || $[9] !== t7 || $[10] !== variant) {
83
+ t10 = /* @__PURE__ */ jsx(FieldBox, {
86
84
  floatingLabel,
87
85
  isPopulated: true,
88
86
  label,
89
87
  leading: leadingIcon,
88
+ trailing: t7,
90
89
  variant,
91
- children: t10
90
+ children: t9
92
91
  });
93
- $[7] = floatingLabel;
94
- $[8] = label;
95
- $[9] = leadingIcon;
96
- $[10] = t10;
97
- $[11] = variant;
98
- $[12] = t11;
99
- } else t11 = $[12];
100
- let t12;
101
- if ($[13] !== description || $[14] !== error) {
102
- t12 = /* @__PURE__ */ jsx(FieldMessage, {
92
+ $[6] = floatingLabel;
93
+ $[7] = label;
94
+ $[8] = leadingIcon;
95
+ $[9] = t7;
96
+ $[10] = variant;
97
+ $[11] = t10;
98
+ } else t10 = $[11];
99
+ let t11;
100
+ if ($[12] !== description || $[13] !== error) {
101
+ t11 = /* @__PURE__ */ jsx(FieldMessage, {
103
102
  description,
104
103
  error
105
104
  });
106
- $[13] = description;
107
- $[14] = error;
105
+ $[12] = description;
106
+ $[13] = error;
107
+ $[14] = t11;
108
+ } else t11 = $[14];
109
+ let t12;
110
+ if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
111
+ t12 = props(overlay.popup, picker.popover);
108
112
  $[15] = t12;
109
113
  } else t12 = $[15];
110
114
  let t13;
111
115
  if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
112
- t13 = props(overlay.popup, picker.popover);
116
+ t13 = props(overlay.popupDialog, focus.ring);
113
117
  $[16] = t13;
114
118
  } else t13 = $[16];
115
119
  let t14;
116
- if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
117
- t14 = props(overlay.popupDialog, focus.ring);
118
- $[17] = t14;
119
- } else t14 = $[17];
120
- let t15;
121
- if ($[18] !== label) {
122
- t15 = /* @__PURE__ */ jsx(Dialog, {
123
- ...t14,
120
+ if ($[17] !== label) {
121
+ t14 = /* @__PURE__ */ jsx(Dialog, {
122
+ ...t13,
124
123
  children: /* @__PURE__ */ jsx(Calendar$1, { "aria-label": label })
125
124
  });
126
- $[18] = label;
127
- $[19] = t15;
128
- } else t15 = $[19];
129
- let t16;
130
- if ($[20] !== container || $[21] !== t15) {
131
- t16 = /* @__PURE__ */ jsx(Popover, {
125
+ $[17] = label;
126
+ $[18] = t14;
127
+ } else t14 = $[18];
128
+ let t15;
129
+ if ($[19] !== container || $[20] !== t14) {
130
+ t15 = /* @__PURE__ */ jsx(Popover, {
132
131
  UNSTABLE_portalContainer: container,
133
- ...t13,
134
- children: t15
132
+ ...t12,
133
+ children: t14
135
134
  });
136
- $[20] = container;
135
+ $[19] = container;
136
+ $[20] = t14;
137
137
  $[21] = t15;
138
- $[22] = t16;
139
- } else t16 = $[22];
140
- let t17;
141
- if ($[23] !== T0 || $[24] !== isDisabled || $[25] !== props$1 || $[26] !== t11 || $[27] !== t12 || $[28] !== t16 || $[29] !== t5 || $[30] !== t6 || $[31] !== validationBehavior) {
142
- t17 = /* @__PURE__ */ jsxs(T0, {
138
+ } else t15 = $[21];
139
+ let t16;
140
+ if ($[22] !== T0 || $[23] !== isDisabled || $[24] !== props$1 || $[25] !== t10 || $[26] !== t11 || $[27] !== t15 || $[28] !== t5 || $[29] !== t6 || $[30] !== validationBehavior) {
141
+ t16 = /* @__PURE__ */ jsxs(T0, {
143
142
  isDisabled,
144
143
  isInvalid: t5,
145
144
  validationBehavior,
146
145
  ...props$1,
147
146
  ...t6,
148
147
  children: [
148
+ t10,
149
149
  t11,
150
- t12,
151
- t16
150
+ t15
152
151
  ]
153
152
  });
154
- $[23] = T0;
155
- $[24] = isDisabled;
156
- $[25] = props$1;
153
+ $[22] = T0;
154
+ $[23] = isDisabled;
155
+ $[24] = props$1;
156
+ $[25] = t10;
157
157
  $[26] = t11;
158
- $[27] = t12;
159
- $[28] = t16;
160
- $[29] = t5;
161
- $[30] = t6;
162
- $[31] = validationBehavior;
163
- $[32] = t17;
164
- } else t17 = $[32];
165
- return t17;
158
+ $[27] = t15;
159
+ $[28] = t5;
160
+ $[29] = t6;
161
+ $[30] = validationBehavior;
162
+ $[31] = t16;
163
+ } else t16 = $[31];
164
+ return t16;
166
165
  }
167
166
  //#endregion
168
167
  export { DatePicker$1 as default };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ReactNode","DateValue","DatePickerProps","RACDatePickerProps","stylex","Button","RACButton","DateInput","RACDateInput","DatePicker","RACDatePicker","Dialog","RACDialog","Group","RACGroup","Popover","RACPopover","FieldVariant","FieldBox","FieldMessage","FieldValue","fieldStyles","invalidFrom","useFieldValidationBehavior","CalendarGlyph","renderSegment","segmentStyles","focus","mergeStatefulStyles","overlay","picker","triggerClassName","Calendar","Omit","T","className","container","Element","description","error","floatingLabel","label","leadingIcon","style","triggerLabel","variant","t0","$","_c","t1","isDisabled","t2","t3","t4","props","undefined","validationBehavior","T0","t5","t6","root","t7","Symbol","for","group","t8","input","t9","triggerGlyph","t10","t11","t12","t13","popup","popover","t14","popupDialog","ring","t15","t16","t17"],"sources":["../../../src/components/date-picker/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { DateValue, DatePickerProps as RACDatePickerProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { Button as RACButton, DateInput as RACDateInput, DatePicker as RACDatePicker, Dialog as RACDialog, Group as RACGroup, Popover as RACPopover } from 'react-aria-components';\nimport type { FieldVariant } from '../../field';\nimport { FieldBox, FieldMessage, FieldValue } from '../../field';\nimport { fieldStyles, invalidFrom, useFieldValidationBehavior } from '../../field/root';\nimport { CalendarGlyph } from '../../glyphs';\nimport { renderSegment } from '../../segments';\nimport { segmentStyles } from '../../segments/styles';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport { overlay } from '../../styles/overlay';\nimport { picker, triggerClassName } from '../../styles/picker';\nimport Calendar from '../calendar';\n\n// The date pickers page's picker: the date field a date is typed into, with\n// a calendar behind a button for picking it instead. Both halves already\n// exist — the segments are `DateField`'s, from `src/segments`, and the\n// calendar is `Calendar` — so what this adds is the button between them and\n// the surface the calendar opens on.\n//\n// Two things are this component's own.\n//\n// **The picker is one field, not a field beside a button.** React Aria's\n// `Group` is what holds the segments and the trigger together, so the box\n// draws once around both and a reader tabs through the segments and reaches\n// the button at the end of them rather than as a separate control.\n//\n// **It is docked above the medium breakpoint and modal below it**, which is\n// the pairing the page draws and the same swap `Sheet` makes. It is done in\n// CSS rather than by rendering a different tree: a 360dp calendar anchored\n// to a field is unreachable at 375px, and a modal that stayed centred on a\n// desktop would cover a form for no reason. `Sheet` settles this the same\n// way, and doing it twice in two different ways is how the two would drift.\n\ntype DatePickerProps<T extends DateValue = DateValue> = Omit<RACDatePickerProps<T>, 'children' | 'className' | 'style'> & {\n /** A function may compute the class from the picker's render state. */\n className?: RACDatePickerProps<T>['className'];\n /**\n * Where to portal the calendar. Defaults to the end of `<body>`, which is\n * right for an app that sets its StyleX theme on `:root`. An app that\n * scopes the theme to a subtree has to point this at an element inside it,\n * or the calendar renders outside the theme and falls back to the tokens'\n * `prefers-color-scheme` default.\n */\n container?: Element;\n /** Supporting text under the field. */\n description?: string;\n /** The message shown instead of the description, which also marks the field invalid. */\n error?: string;\n /**\n * Whether the label floats into the box's top once the field holds a\n * value, rather than sitting above it.\n * @default true\n */\n floatingLabel?: boolean;\n /** What the field is for. Always rendered; never a placeholder. */\n label: string;\n /** An icon at the box's leading end. */\n leadingIcon?: ReactNode;\n /** A function may compute the style from the picker's render state. */\n style?: RACDatePickerProps<T>['style'];\n /**\n * What the button that opens the calendar is called, for a screen reader.\n * @default 'Choose a date'\n */\n triggerLabel?: string;\n /**\n * Which of the text fields page's two boxes to draw.\n * @default 'filled'\n */\n variant?: FieldVariant;\n};\n\n/**\n * A date typed into a field, or picked from a calendar behind a button. The\n * value is React Aria's — pass `value` with `onChange` to control it, or\n * `defaultValue` — as an `@internationalized/date` value from this package's\n * `./date` subpath.\n *\n * ```tsx\n * import { CalendarDate } from '@kanso-labs/kanso-ui/date'\n *\n * <DatePicker defaultValue={new CalendarDate(2026, 9, 15)} label=\"Label\" />\n * ```\n *\n * The segments are `DateField`'s and the calendar is `Calendar`, so\n * `granularity`, `minValue`, `maxValue` and `isDateUnavailable` all behave\n * as they do there. Above the medium breakpoint the calendar is docked to\n * the field; below it, it opens centred, which is the page's modal picker.\n *\n * The call site's `className` and `style` land on the picker as a whole,\n * which is the element a layout positions.\n */\nfunction DatePicker<T extends DateValue>({\n container,\n description,\n error,\n floatingLabel = true,\n isDisabled = false,\n label,\n leadingIcon,\n triggerLabel = 'Choose a date',\n variant = 'filled',\n ...props\n}: DatePickerProps<T>) {\n const validationBehavior = useFieldValidationBehavior();\n return <RACDatePicker<T> isDisabled={isDisabled} isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...mergeStatefulStyles(stylex.props(fieldStyles.root), props)}>\n <FieldBox floatingLabel={floatingLabel}\n // Always populated, which buys exactly one thing: the outlined\n // notch. The box decides populated twice over — in CSS for the\n // label's type, and in React for the notch, since CSS cannot cut an\n // outline to a width it has no way to measure. React Aria renders a\n // hidden `<input type=\"date\">` carrying no placeholder, so the CSS\n // half reads as populated on its own; the React half reads React\n // Aria's input context, which a picker does not provide. Without\n // this the notch stays shut across segments already showing\n // `mm/dd/yyyy`.\n isPopulated label={label} leading={leadingIcon} variant={variant}>\n <FieldValue>\n <RACGroup {...stylex.props(picker.group)}>\n <RACDateInput {...stylex.props(segmentStyles.input)}>\n {renderSegment}\n </RACDateInput>\n <RACButton aria-label={triggerLabel} className={triggerClassName}>\n <CalendarGlyph {...stylex.props(picker.triggerGlyph)} />\n </RACButton>\n </RACGroup>\n </FieldValue>\n </FieldBox>\n <FieldMessage description={description} error={error} />\n <RACPopover\n // oxlint-disable-next-line typescript/no-deprecated -- its replacement, UNSAFE_PortalProvider, is not exported by react-aria-components\n UNSTABLE_portalContainer={container} {...stylex.props(overlay.popup, picker.popover)}>\n <RACDialog {...stylex.props(overlay.popupDialog, focus.ring)}>\n <Calendar aria-label={label} />\n </RACD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AA+BW"}
1
+ {"version":3,"file":"index.js","names":["ReactNode","DateValue","DatePickerProps","RACDatePickerProps","stylex","Button","RACButton","DateInput","RACDateInput","DatePicker","RACDatePicker","Dialog","RACDialog","Group","RACGroup","Popover","RACPopover","FieldVariant","FieldBox","FieldMessage","FieldValue","fieldStyles","invalidFrom","useFieldValidationBehavior","CalendarGlyph","renderSegment","segmentStyles","focus","mergeStatefulStyles","overlay","picker","triggerClassName","Calendar","Omit","T","className","container","Element","description","error","floatingLabel","label","leadingIcon","style","triggerLabel","variant","calendarTrigger","props","triggerGlyph","t0","$","_c","t1","isDisabled","t2","t3","t4","undefined","validationBehavior","T0","t5","t6","root","t7","t8","Symbol","for","group","t9","input","t10","t11","t12","popup","popover","t13","popupDialog","ring","t14","t15","t16"],"sources":["../../../src/components/date-picker/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { DateValue, DatePickerProps as RACDatePickerProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { Button as RACButton, DateInput as RACDateInput, DatePicker as RACDatePicker, Dialog as RACDialog, Group as RACGroup, Popover as RACPopover } from 'react-aria-components';\nimport type { FieldVariant } from '../../field';\nimport { FieldBox, FieldMessage, FieldValue } from '../../field';\nimport { fieldStyles, invalidFrom, useFieldValidationBehavior } from '../../field/root';\nimport { CalendarGlyph } from '../../glyphs';\nimport { renderSegment } from '../../segments';\nimport { segmentStyles } from '../../segments/styles';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport { overlay } from '../../styles/overlay';\nimport { picker, triggerClassName } from '../../styles/picker';\nimport Calendar from '../calendar';\n\n// The date pickers page's picker: the date field a date is typed into, with\n// a calendar behind a button for picking it instead. Both halves already\n// exist — the segments are `DateField`'s, from `src/segments`, and the\n// calendar is `Calendar` — so what this adds is the button between them and\n// the surface the calendar opens on.\n//\n// Two things are this component's own.\n//\n// **The picker is one field, not a field beside a button.** React Aria's\n// `Group` is what holds the segments and the trigger together, so the box\n// draws once around both and a reader tabs through the segments and reaches\n// the button at the end of them rather than as a separate control.\n//\n// **It is docked above the medium breakpoint and modal below it**, which is\n// the pairing the page draws and the same swap `Sheet` makes. It is done in\n// CSS rather than by rendering a different tree: a 360dp calendar anchored\n// to a field is unreachable at 375px, and a modal that stayed centred on a\n// desktop would cover a form for no reason. `Sheet` settles this the same\n// way, and doing it twice in two different ways is how the two would drift.\n\ntype DatePickerProps<T extends DateValue = DateValue> = Omit<RACDatePickerProps<T>, 'children' | 'className' | 'style'> & {\n /** A function may compute the class from the picker's render state. */\n className?: RACDatePickerProps<T>['className'];\n /**\n * Where to portal the calendar. Defaults to the end of `<body>`, which is\n * right for an app that sets its StyleX theme on `:root`. An app that\n * scopes the theme to a subtree has to point this at an element inside it,\n * or the calendar renders outside the theme and falls back to the tokens'\n * `prefers-color-scheme` default.\n */\n container?: Element;\n /** Supporting text under the field. */\n description?: string;\n /** The message shown instead of the description, which also marks the field invalid. */\n error?: string;\n /**\n * Whether the label floats into the box's top once the field holds a\n * value, rather than sitting above it.\n * @default true\n */\n floatingLabel?: boolean;\n /** What the field is for. Always rendered; never a placeholder. */\n label: string;\n /** An icon at the box's leading end. */\n leadingIcon?: ReactNode;\n /** A function may compute the style from the picker's render state. */\n style?: RACDatePickerProps<T>['style'];\n /**\n * What the button that opens the calendar is called, for a screen reader.\n * @default 'Choose a date'\n */\n triggerLabel?: string;\n /**\n * Which of the text fields page's two boxes to draw.\n * @default 'filled'\n */\n variant?: FieldVariant;\n};\n\n// Built by a call rather than written inline at the prop, which is what\n// react-perf's no-jsx-as-prop is after — the same reason Select builds its\n// chevron this way.\nfunction calendarTrigger(triggerLabel: string) {\n return <RACButton aria-label={triggerLabel} className={triggerClassName}>\n <CalendarGlyph {...stylex.props(picker.triggerGlyph)} />\n </RACButton>;\n}\n\n/**\n * A date typed into a field, or picked from a calendar behind a button. The\n * value is React Aria's — pass `value` with `onChange` to control it, or\n * `defaultValue` — as an `@internationalized/date` value from this package's\n * `./date` subpath.\n *\n * ```tsx\n * import { CalendarDate } from '@kanso-labs/kanso-ui/date'\n *\n * <DatePicker defaultValue={new CalendarDate(2026, 9, 15)} label=\"Label\" />\n * ```\n *\n * The segments are `DateField`'s and the calendar is `Calendar`, so\n * `granularity`, `minValue`, `maxValue` and `isDateUnavailable` all behave\n * as they do there. Above the medium breakpoint the calendar is docked to\n * the field; below it, it opens centred, which is the page's modal picker.\n *\n * The call site's `className` and `style` land on the picker as a whole,\n * which is the element a layout positions.\n */\nfunction DatePicker<T extends DateValue>({\n container,\n description,\n error,\n floatingLabel = true,\n isDisabled = false,\n label,\n leadingIcon,\n triggerLabel = 'Choose a date',\n variant = 'filled',\n ...props\n}: DatePickerProps<T>) {\n const validationBehavior = useFieldValidationBehavior();\n return <RACDatePicker<T> isDisabled={isDisabled} isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...mergeStatefulStyles(stylex.props(fieldStyles.root), props)}>\n <FieldBox floatingLabel={floatingLabel}\n // Always populated, which buys exactly one thing: the outlined\n // notch. The box decides populated twice over — in CSS for the\n // label's type, and in React for the notch, since CSS cannot cut an\n // outline to a width it has no way to measure. React Aria renders a\n // hidden `<input type=\"date\">` carrying no placeholder, so the CSS\n // half reads as populated on its own; the React half reads React\n // Aria's input context, which a picker does not provide. Without\n // this the notch stays shut across segments already showing\n // `mm/dd/yyyy`.\n isPopulated label={label} leading={leadingIcon}\n // In the chrome's trailing slot rather than on the segments' line,\n // which is where Select and ComboBox put their chevron. The slot\n // cancels the box's top padding and stretches to its full height, so\n // it centres the 40dp trigger in the box; on the line the trigger\n // was taller than the row that held it and hung past the underline,\n // and the segments centred on it rather than on their own line.\n //\n // React Aria's `DatePicker` is what gives the trigger its press\n // behaviour, through context, so the slot reaches it as well as the\n // group did.\n trailing={calendarTrigger(triggerLabel)} variant={variant}>\n <FieldValue>\n <RACGroup {...stylex.props(picker.group)}>\n <RACDateInput {...stylex.props(segmentStyles.input)}>\n {renderSegment}\n </RACDateInput>\n </RACGroup>\n </FieldValue>\n </FieldBox>\n <FieldMessage description={description} error={error} />\n <RACPopover\n // oxlint-disable-next-line typescript/no-deprecated -- its replacement, UNSAFE_PortalProvider, is not exported by react-aria-components\n UNSTABLE_portalContainer={container} {...stylex.props(overlay.popup, picker.popover)}>\n <RACDialog {...stylex.props(overlay.popupDialog, focus.ring)}>\n <Calendar aria-label={label} />\n </RACDialog>\n </RACPopover>\n </RACDatePicker>;\n}\nexport type { DatePickerProps };\nexport default DatePicker;"],"mappings":";;;;;;;;;;;;;;;AA8EA,SAAS8C,gBAAgBF,cAAsB;CAC7C,OAAO,oBAAC,QAAD;EAAW,cAAYA;EAAc,WAAWb;EACnD,UAAA,oBAAC,eAAD,EAAe,GAAI3B,MAAa0B,OAAOkB,YAAY,EAAE,CAAA;CAC5C,CAAA;AACf;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAAvC,aAAAwC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAyC,MAAA,EAAAf,WAAAE,aAAAC,OAAAC,eAAAY,IAAAC,YAAAC,IAAAb,OAAAC,aAAAE,cAAAW,IAAAV,SAAAW,IAAA,GAAAT,YAAAE;CAIvC,MAAAT,gBAAAY,OAAAK,KAAAA,IAAA,OAAAL;CACA,MAAAC,aAAAC,OAAAG,KAAAA,IAAA,QAAAH;CAGA,MAAAV,eAAAW,OAAAE,KAAAA,IAAA,kBAAAF;CACA,MAAAV,UAAAW,OAAAC,KAAAA,IAAA,WAAAD;CAGA,MAAAE,qBAA2BnC,2BAA2B;CAC9C,MAAAoC,KAAAjD;CAAa,IAAAkD;CAAA,IAAAV,EAAA,OAAAX,OAAA;EAAuCqB,KAAAtC,YAAYiB,KAAK;EAACW,EAAA,KAAAX;EAAAW,EAAA,KAAAU;CAAA,OAAAA,KAAAV,EAAA;CAAyD,MAAAW,KAAAjC,oBAAoBxB,MAAaiB,YAAWyC,IAAK,GAAGf,OAAK;CAAC,IAAAgB;CAAA,IAAAb,EAAA,OAAA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