@kanso-labs/kanso-ui 0.45.20 → 0.45.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/calendar/index.js +119 -11
  2. package/dist/calendar/index.js.map +1 -1
  3. package/dist/calendar/styles.js +19 -1
  4. package/dist/calendar/styles.js.map +1 -1
  5. package/dist/components/app-bar/index.d.ts +8 -2
  6. package/dist/components/app-bar/index.js +123 -73
  7. package/dist/components/app-bar/index.js.map +1 -1
  8. package/dist/components/calendar/index.d.ts +3 -3
  9. package/dist/components/calendar/index.js +8 -19
  10. package/dist/components/calendar/index.js.map +1 -1
  11. package/dist/components/carousel/index.d.ts +22 -3
  12. package/dist/components/carousel/index.js +26 -14
  13. package/dist/components/carousel/index.js.map +1 -1
  14. package/dist/components/chip-group/index.js +3 -0
  15. package/dist/components/chip-group/index.js.map +1 -1
  16. package/dist/components/color-picker/index.js +64 -46
  17. package/dist/components/color-picker/index.js.map +1 -1
  18. package/dist/components/color-swatch/index.js +20 -16
  19. package/dist/components/color-swatch/index.js.map +1 -1
  20. package/dist/components/copy-field/index.js +1 -0
  21. package/dist/components/copy-field/index.js.map +1 -1
  22. package/dist/components/date-range-picker/index.js +165 -81
  23. package/dist/components/date-range-picker/index.js.map +1 -1
  24. package/dist/components/index.d.ts +2 -2
  25. package/dist/components/popover/index.js +14 -4
  26. package/dist/components/popover/index.js.map +1 -1
  27. package/dist/components/range-calendar/index.js +53 -80
  28. package/dist/components/range-calendar/index.js.map +1 -1
  29. package/dist/components/segmented-button/index.js +261 -145
  30. package/dist/components/segmented-button/index.js.map +1 -1
  31. package/dist/components/sheet/index.js +149 -82
  32. package/dist/components/sheet/index.js.map +1 -1
  33. package/dist/components/table/index.js +251 -123
  34. package/dist/components/table/index.js.map +1 -1
  35. package/dist/hooks/useRipple.js +3 -2
  36. package/dist/hooks/useRipple.js.map +1 -1
  37. package/dist/index.d.ts +2 -2
  38. package/dist/segments/index.js +2 -1
  39. package/dist/segments/index.js.map +1 -1
  40. package/dist/segments/styles.js +5 -1
  41. package/dist/segments/styles.js.map +1 -1
  42. package/dist/styles/focus.js.map +1 -1
  43. package/dist/styles.css +40 -8
  44. package/dist/swatch/index.js +19 -0
  45. package/dist/swatch/index.js.map +1 -0
  46. package/package.json +3 -3
@@ -4,14 +4,28 @@ import { focus } from "../../styles/focus.js";
4
4
  import { mergeStatefulStyles } from "../../styles/merge.js";
5
5
  import { overlay } from "../../styles/overlay.js";
6
6
  import { popoverClassName } from "../../styles/picker.js";
7
+ import { SwatchSquareContext } from "../../swatch/index.js";
7
8
  import ColorArea$1 from "../color-area/index.js";
8
9
  import ColorField$1 from "../color-field/index.js";
9
10
  import ColorSlider$1 from "../color-slider/index.js";
10
11
  import ColorSwatch$1 from "../color-swatch/index.js";
11
12
  import { c } from "react/compiler-runtime";
12
- import { jsx, jsxs } from "react/jsx-runtime";
13
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
14
  import { Button, ColorPicker, Dialog, DialogTrigger, Popover, parseColor, useLocale } from "react-aria-components";
14
15
  // src/components/color-picker/index.tsx
16
+ const styles = {
17
+ triggerSwatch: {
18
+ kZKoxP: "xxk0z11",
19
+ kmuXW: "x2lah0s",
20
+ kzqmXN: "xvy4d1p",
21
+ $$css: true
22
+ },
23
+ triggerSwatchDisabled: {
24
+ kSiTet: "x1ppv7y9",
25
+ $$css: true
26
+ }
27
+ };
28
+ const DISABLED_TRIGGER_SWATCH = [styles.triggerSwatch, styles.triggerSwatchDisabled];
15
29
  const triggerStyles = {
16
30
  base: {
17
31
  kGNEyG: "x6s0dn4",
@@ -73,7 +87,7 @@ const CHANNELS = parseColor("hsl(0, 0%, 0%)");
73
87
  * element a layout positions.
74
88
  */
75
89
  function ColorPicker$1(t0) {
76
- const $ = c(43);
90
+ const $ = c(44);
77
91
  let children;
78
92
  let className;
79
93
  let container;
@@ -129,31 +143,35 @@ function ColorPicker$1(t0) {
129
143
  $[15] = t3;
130
144
  } else t3 = $[15];
131
145
  let t4;
132
- if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
133
- t4 = /* @__PURE__ */ jsx(ColorSwatch$1, { className: "xxk0z11 x2lah0s xvy4d1p" });
134
- $[16] = t4;
135
- } else t4 = $[16];
146
+ if ($[16] !== label) {
147
+ t4 = (state_0) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(SwatchSquareContext, {
148
+ value: state_0.isDisabled ? DISABLED_TRIGGER_SWATCH : styles.triggerSwatch,
149
+ children: /* @__PURE__ */ jsx(ColorSwatch$1, {})
150
+ }), label] });
151
+ $[16] = label;
152
+ $[17] = t4;
153
+ } else t4 = $[17];
136
154
  let t5;
137
- if ($[17] !== isDisabled || $[18] !== label || $[19] !== ref || $[20] !== t3) {
138
- t5 = /* @__PURE__ */ jsxs(Button, {
155
+ if ($[18] !== isDisabled || $[19] !== ref || $[20] !== t3 || $[21] !== t4) {
156
+ t5 = /* @__PURE__ */ jsx(Button, {
139
157
  isDisabled,
140
158
  ref,
141
159
  ...t3,
142
- children: [t4, label]
160
+ children: t4
143
161
  });
144
- $[17] = isDisabled;
145
- $[18] = label;
162
+ $[18] = isDisabled;
146
163
  $[19] = ref;
147
164
  $[20] = t3;
148
- $[21] = t5;
149
- } else t5 = $[21];
165
+ $[21] = t4;
166
+ $[22] = t5;
167
+ } else t5 = $[22];
150
168
  let t6;
151
- if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
169
+ if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
152
170
  t6 = props(overlay.popupDialog, focus.ring);
153
- $[22] = t6;
154
- } else t6 = $[22];
171
+ $[23] = t6;
172
+ } else t6 = $[23];
155
173
  let t7;
156
- if ($[23] !== alpha || $[24] !== children || $[25] !== isDisabled || $[26] !== label || $[27] !== locale) {
174
+ if ($[24] !== alpha || $[25] !== children || $[26] !== isDisabled || $[27] !== label || $[28] !== locale) {
157
175
  t7 = children ?? /* @__PURE__ */ jsxs("div", {
158
176
  className: "x9f619 x78zum5 xdt5ytf x1gka490 x1dz1jew x193iq5w xgc26li",
159
177
  children: [
@@ -181,58 +199,58 @@ function ColorPicker$1(t0) {
181
199
  })
182
200
  ]
183
201
  });
184
- $[23] = alpha;
185
- $[24] = children;
186
- $[25] = isDisabled;
187
- $[26] = label;
188
- $[27] = locale;
189
- $[28] = t7;
190
- } else t7 = $[28];
202
+ $[24] = alpha;
203
+ $[25] = children;
204
+ $[26] = isDisabled;
205
+ $[27] = label;
206
+ $[28] = locale;
207
+ $[29] = t7;
208
+ } else t7 = $[29];
191
209
  let t8;
192
- if ($[29] !== t7) {
210
+ if ($[30] !== t7) {
193
211
  t8 = /* @__PURE__ */ jsx(Dialog, {
194
212
  ...t6,
195
213
  children: t7
196
214
  });
197
- $[29] = t7;
198
- $[30] = t8;
199
- } else t8 = $[30];
215
+ $[30] = t7;
216
+ $[31] = t8;
217
+ } else t8 = $[31];
200
218
  let t9;
201
- if ($[31] !== container || $[32] !== t8) {
219
+ if ($[32] !== container || $[33] !== t8) {
202
220
  t9 = /* @__PURE__ */ jsx(Popover, {
203
221
  className: popoverClassName,
204
222
  UNSTABLE_portalContainer: container,
205
223
  children: t8
206
224
  });
207
- $[31] = container;
208
- $[32] = t8;
209
- $[33] = t9;
210
- } else t9 = $[33];
225
+ $[32] = container;
226
+ $[33] = t8;
227
+ $[34] = t9;
228
+ } else t9 = $[34];
211
229
  let t10;
212
- if ($[34] !== defaultOpen || $[35] !== isOpen || $[36] !== onOpenChange || $[37] !== t5 || $[38] !== t9) {
230
+ if ($[35] !== defaultOpen || $[36] !== isOpen || $[37] !== onOpenChange || $[38] !== t5 || $[39] !== t9) {
213
231
  t10 = /* @__PURE__ */ jsxs(DialogTrigger, {
214
232
  defaultOpen,
215
233
  isOpen,
216
234
  onOpenChange,
217
235
  children: [t5, t9]
218
236
  });
219
- $[34] = defaultOpen;
220
- $[35] = isOpen;
221
- $[36] = onOpenChange;
222
- $[37] = t5;
223
- $[38] = t9;
224
- $[39] = t10;
225
- } else t10 = $[39];
237
+ $[35] = defaultOpen;
238
+ $[36] = isOpen;
239
+ $[37] = onOpenChange;
240
+ $[38] = t5;
241
+ $[39] = t9;
242
+ $[40] = t10;
243
+ } else t10 = $[40];
226
244
  let t11;
227
- if ($[40] !== props$1 || $[41] !== t10) {
245
+ if ($[41] !== props$1 || $[42] !== t10) {
228
246
  t11 = /* @__PURE__ */ jsx(ColorPicker, {
229
247
  ...props$1,
230
248
  children: t10
231
249
  });
232
- $[40] = props$1;
233
- $[41] = t10;
234
- $[42] = t11;
235
- } else t11 = $[42];
250
+ $[41] = props$1;
251
+ $[42] = t10;
252
+ $[43] = t11;
253
+ } else t11 = $[43];
236
254
  return t11;
237
255
  }
238
256
  function _temp(state) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","CSSProperties","ReactNode","RefAttributes","ButtonRenderProps","ColorPickerProps","RACColorPickerProps","stylex","parseColor","Button","RACButton","ColorPicker","RACColorPicker","Dialog","RACDialog","DialogTrigger","RACDialogTrigger","Popover","RACPopover","useLocale","focus","mergeStatefulStyles","overlay","popoverClassName","colors","radii","spacing","stateLayerOpacity","typography","ColorArea","ColorField","ColorSlider","ColorSwatch","triggerStyles","base","kGNEyG","kWkggS","kaIpWk","kMzoRj","kB7OPa","kMwMTN","kkrTdU","k1xSpc","kMv6JI","kGuDYH","k63SB2","kOIVth","kb6lSQ","kLWn49","k8WAf4","kg3NbH","$$css","disabled","hovered","pressed","Omit","alpha","children","className","container","Element","defaultOpen","isDisabled","isOpen","label","onOpenChange","style","CHANNELS","t0","$","props","ref","t1","t2","undefined","locale","t3","_temp","t4","Symbol","for","t5","t6","popupDialog","ring","t7","getChannelName","t8","t9","t10","t11","state","isHovered","isPressed","ColorPicker","_c","props","ColorSwatch","RACButton","stylex.props","ColorArea","ColorSlider","ColorField","RACDialog","RACPopover","RACDialogTrigger","RACColorPicker"],"sources":["../../../src/components/color-picker/index.tsx"],"sourcesContent":["'use client';\n\nimport type { CSSProperties, ReactNode, RefAttributes } from 'react';\nimport type { ButtonRenderProps, ColorPickerProps as RACColorPickerProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { parseColor, Button as RACButton, ColorPicker as RACColorPicker, Dialog as RACDialog, DialogTrigger as RACDialogTrigger, Popover as RACPopover, useLocale } from 'react-aria-components';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport { overlay } from '../../styles/overlay';\nimport { popoverClassName } from '../../styles/picker';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, spacing, stateLayerOpacity, typography } from '../../tokens/design.tokens.stylex';\nimport ColorArea from '../color-area';\nimport ColorField from '../color-field';\nimport ColorSlider from '../color-slider';\nimport ColorSwatch from '../color-swatch';\n\n// Everything in this phase, in one control: a swatch and a label as the\n// trigger, and a plane, a hue slider, an alpha slider and a text field on\n// the surface it opens. React Aria's `ColorPicker` renders nothing of its\n// own — it is the state the five share — so what is here is the trigger,\n// the overlay and the arrangement inside it.\n//\n// The design carries no page for a colour picker. What it does carry is the\n// text fields page, which the field inside this one already draws through,\n// and the overlay surface every popover here shares. Three choices are the\n// library's own.\n//\n// **The trigger is a swatch beside a name, not a swatch alone.** A swatch\n// on its own is a coloured square with no affordance — nothing says it can\n// be pressed, and a screen reader is told a colour rather than an action.\n// The label is what makes it a button.\n//\n// **Hue is a slider rather than a wheel here.** A wheel and the plane want\n// the same space and would make the surface square and large; the strip\n// sits under the plane at the width it already has. `ColorWheel` is for a\n// picker that wants to be round, which is a different shape rather than a\n// different control.\n//\n// **It is docked above the medium breakpoint and modal below it**, centred\n// over a scrim there — the same swap `DatePicker` makes, at the width `Sheet`\n// changes presentation too, and the shared one in `src/styles/picker.ts`\n// rather than a third copy. A 280dp surface anchored to a trigger is\n// unreachable at 375px.\n//\n// One thing the picker has to do that its parts do not. **The plane and the\n// hue strip are pinned to HSL.** A channel has to belong to the value's own\n// space or React Aria throws, and a hex parses as RGB, which has no\n// saturation — so `<ColorPicker defaultValue=\"#6750A4\" />`, the call anyone\n// writes first, would throw outright. Converting here is what makes the\n// picker take any notation, and it costs the caller nothing: the value\n// handed back is still in whatever they passed.\n\nconst triggerStyles = {\n base: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"x1vnz5z6\",\n kaIpWk: \"x1dkaolv\",\n kMzoRj: \"xc342km\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x139gbkf\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n kMv6JI: \"xkknnkr\",\n kGuDYH: \"x14zspaw\",\n k63SB2: \"x1v9cpvo\",\n kOIVth: \"x126z3so\",\n kb6lSQ: \"x155f00i\",\n kLWn49: \"x1lz68p4\",\n k8WAf4: \"x1cmllll\",\n kg3NbH: \"x18fpw6u\",\n $$css: true\n },\n disabled: {\n kWkggS: \"x19v6zzp\",\n kMwMTN: \"x1xj74d8\",\n kkrTdU: \"x1h6gzvc\",\n $$css: true\n },\n hovered: {\n kWkggS: \"x1ei6177\",\n $$css: true\n },\n pressed: {\n kWkggS: \"x1vt8e7r\",\n $$css: true\n }\n};\ntype ColorPickerProps = Omit<RACColorPickerProps, 'children'> & {\n /** Whether the alpha strip is drawn under the hue one. @default false */\n alpha?: boolean;\n /** Replaces everything on the surface, for a picker that arranges its own parts. */\n children?: ReactNode;\n /** Lands on the trigger, which is the element a layout positions. */\n className?: string;\n /**\n * Where to portal the surface. Defaults to the container of the `ThemeScope`\n * around it, which keeps the surface on that scope's tokens, or to the end of\n * `<body>` where there is none. A subtree themed through the `themeScope`\n * class has no container of its own, so point this inside it, or the surface\n * renders outside and keeps the page's tokens.\n */\n container?: Element;\n /** Whether the surface starts open. Uncontrolled; pair `isOpen` with `onOpenChange` instead. */\n defaultOpen?: boolean;\n /**\n * Whether the whole picker is inert — the trigger, and the plane, strips\n * and field on the surface, which can be on screen while disabled since\n * the surface opens independently of the trigger. An arrangement passed\n * as `children` is the call site's own to disable.\n * @default false\n */\n isDisabled?: boolean;\n /** Whether the surface is open. Controlled; needs `onOpenChange`. */\n isOpen?: boolean;\n /** What the trigger says beside its swatch. Always rendered; it is the button's name. */\n label: string;\n /** Called when the surface opens or closes. */\n onOpenChange?: (isOpen: boolean) => void;\n /** Lands on the trigger, as `className` does. */\n style?: CSSProperties;\n};\n\n// Any HSL colour names the channels the two strips draw. The labels are read\n// off it in the reader's locale, as React Aria words them, rather than written\n// here in English.\nconst CHANNELS = parseColor('hsl(0, 0%, 0%)');\n\n/**\n * A colour picked from a plane, a hue strip and a text field, behind a\n * trigger showing the colour. The value is React Aria's: pass `value` with\n * `onChange` to control it, or `defaultValue`, as a CSS colour string or a\n * `Color` from `parseColor`, which this package re-exports.\n *\n * ```tsx\n * <ColorPicker defaultValue=\"#6750A4\" label=\"Label\" />\n * ```\n *\n * `alpha` adds the transparency strip. Above the medium breakpoint the\n * surface is docked to the trigger; below it, it opens centred, the same\n * swap `DatePicker` makes. `defaultOpen`, `isOpen` and `onOpenChange` reach\n * the overlay, since the picker itself carries no open state — React Aria\n * keeps that on the dialog trigger this renders inside.\n *\n * Every part inside is this package's own — `ColorArea`, `ColorSlider`,\n * `ColorField` and `ColorSwatch` — and they share the picker's value\n * through React Aria's context rather than props. Passing `children`\n * replaces all of them, for a picker that wants a different arrangement.\n *\n * The call site's `className` and `style` land on the trigger, which is the\n * element a layout positions.\n */\nfunction ColorPicker({\n alpha = false,\n children,\n className,\n container,\n defaultOpen,\n isDisabled = false,\n isOpen,\n label,\n onOpenChange,\n ref,\n style,\n ...props\n}: ColorPickerProps & RefAttributes<HTMLButtonElement>) {\n const {\n locale\n } = useLocale();\n return <RACColorPicker {...props}>\n <RACDialogTrigger defaultOpen={defaultOpen} isOpen={isOpen} onOpenChange={onOpenChange}>\n <RACButton isDisabled={isDisabled}\n // React Aria's picker renders no element of its own, so the ref\n // lands on the trigger, as the call site's class and style do.\n ref={ref} {...mergeStatefulStyles(\n // A function of the state rather than a fixed class, since the\n // trigger is the element a layout positions and the call site's\n // own class has to merge into it — a plain `className` would\n // overwrite one or the other.\n (state: ButtonRenderProps) => stylex.props(triggerStyles.base, focus.ring, state.isHovered && triggerStyles.hovered, state.isPressed && triggerStyles.pressed, state.isDisabled && triggerStyles.disabled), {\n className,\n style\n })}>\n <ColorSwatch className=\"xxk0z11 x2lah0s xvy4d1p\" />\n {label}\n </RACButton>\n <RACPopover className={popoverClassName}\n // oxlint-disable-next-line typescript/no-deprecated -- its replacement, UNSAFE_PortalProvider, is not exported by react-aria-components\n UNSTABLE_portalContainer={container}>\n <RACDialog {...stylex.props(overlay.popupDialog, focus.ring)}>\n {/*\n Disabled reaches every control here, not only the trigger.\n React Aria's colour picker carries no disabled state of its\n own — react-stately's `useColorPickerState` has no such\n concept — so nothing hands it down the way a field's context\n would. And the surface opens independently of the trigger, so\n a disabled picker can still be on screen: already open when a\n form disables it, or opened from outside. Without this the\n plane could be dragged, the strips moved with the arrow keys\n and the field typed into, all changing the value of something\n documented as inert.\n An arrangement a call site passes as `children` is its own to\n disable; there is no context to reach it through.\n */}\n {children ?? <div className=\"x9f619 x78zum5 xdt5ytf x1gka490 x1dz1jew x193iq5w xgc26li\">\n <ColorArea aria-label={label} colorSpace=\"hsl\" isDisabled={isDisabled} xChannel=\"saturation\" yChannel=\"lightness\" />\n <ColorSlider channel=\"hue\" colorSpace=\"hsl\" isDisabled={isDisabled} label={CHANNELS.getChannelName('hue', locale)} />\n {alpha ? <ColorSlider channel=\"alpha\" isDisabled={isDisabled} label={CHANNELS.getChannelName('alpha', locale)} /> : null}\n <ColorField isDisabled={isDisabled} label={label} />\n </div>}\n </RACDialog>\n </RACPopover>\n </RACDialogTrigger>\n </RACColorPicker>;\n}\nexport type { ColorPickerProps };\nexport default ColorPicker;"],"mappings":";;;;;;;;;;;;;;AAqDA,MAAMkC,gBAAgB;CACpBC,MAAM;EACJC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ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EgB,IAeAO,EAhBe;;EA0CEnB,EAAA,MAAAR;EAAAQ,EAAA,MAAAN;EAAAM,EAAA,MAAAJ;EAAAI,EAAA,MAAAY;EAAAZ,EAAA,MAAAmB;EAAAnB,EAAA,MAAAoB;CAAA,OAAAA,MAAApB,EAAA;CAAA,IAAAqB;CAAA,IAAArB,EAAA,QAAAC,WAAAD,EAAA,QAAAoB,KAAA;EA3ChBC,MAAA,oBAACgB,aAAD;GAAe,GAAKpC;GACvBmB,UAAAA;EADkB,CAAA;EA4CHpB,EAAA,MAAAC;EAAAD,EAAA,MAAAoB;EAAApB,EAAA,MAAAqB;CAAA,OAAAA,MAAArB,EAAA;CAAA,OA5CZqB;AA4CY;AA7DrB,SAAAb,MAAAc,OAAA;CAAA,OA2BoCpF,MAAa0B,cAAaC,MAAOd,MAAKgE,MAAOO,MAAKC,aAAc3D,cAAaoB,SAAUsC,MAAKE,aAAc5D,cAAaqB,SAAUqC,MAAK7B,cAAe7B,cAAamB,QAAS;AAAC"}
1
+ {"version":3,"file":"index.js","names":["c","_c","CSSProperties","ReactNode","RefAttributes","ButtonRenderProps","ColorPickerProps","RACColorPickerProps","stylex","parseColor","Button","RACButton","ColorPicker","RACColorPicker","Dialog","RACDialog","DialogTrigger","RACDialogTrigger","Popover","RACPopover","useLocale","focus","mergeStatefulStyles","overlay","popoverClassName","SwatchSquareContext","colors","radii","spacing","stateLayerOpacity","typography","ColorArea","ColorField","ColorSlider","ColorSwatch","styles","triggerSwatch","kZKoxP","kmuXW","kzqmXN","$$css","triggerSwatchDisabled","kSiTet","DISABLED_TRIGGER_SWATCH","triggerStyles","base","kGNEyG","kWkggS","kaIpWk","kMzoRj","kB7OPa","kMwMTN","kkrTdU","k1xSpc","kMv6JI","kGuDYH","k63SB2","kOIVth","kb6lSQ","kLWn49","k8WAf4","kg3NbH","disabled","hovered","pressed","Omit","alpha","children","className","container","Element","defaultOpen","isDisabled","isOpen","label","onOpenChange","style","CHANNELS","t0","$","props","ref","t1","t2","undefined","locale","t3","_temp","t4","state_0","state","t5","t6","Symbol","for","popupDialog","ring","t7","getChannelName","t8","t9","t10","t11","isHovered","isPressed","ColorPicker","_c","props","ColorSwatch","RACButton","stylex.props","ColorArea","ColorSlider","ColorField","RACDialog","RACPopover","RACDialogTrigger","RACColorPicker"],"sources":["../../../src/components/color-picker/index.tsx"],"sourcesContent":["'use client';\n\nimport type { CSSProperties, ReactNode, RefAttributes } from 'react';\nimport type { ButtonRenderProps, ColorPickerProps as RACColorPickerProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { parseColor, Button as RACButton, ColorPicker as RACColorPicker, Dialog as RACDialog, DialogTrigger as RACDialogTrigger, Popover as RACPopover, useLocale } from 'react-aria-components';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport { overlay } from '../../styles/overlay';\nimport { popoverClassName } from '../../styles/picker';\nimport { SwatchSquareContext } from '../../swatch';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, spacing, stateLayerOpacity, typography } from '../../tokens/design.tokens.stylex';\nimport ColorArea from '../color-area';\nimport ColorField from '../color-field';\nimport ColorSlider from '../color-slider';\nimport ColorSwatch from '../color-swatch';\n\n// Everything in this phase, in one control: a swatch and a label as the\n// trigger, and a plane, a hue slider, an alpha slider and a text field on\n// the surface it opens. React Aria's `ColorPicker` renders nothing of its\n// own — it is the state the five share — so what is here is the trigger,\n// the overlay and the arrangement inside it.\n//\n// The design carries no page for a colour picker. What it does carry is the\n// text fields page, which the field inside this one already draws through,\n// and the overlay surface every popover here shares. Three choices are the\n// library's own.\n//\n// **The trigger is a swatch beside a name, not a swatch alone.** A swatch\n// on its own is a coloured square with no affordance — nothing says it can\n// be pressed, and a screen reader is told a colour rather than an action.\n// The label is what makes it a button.\n//\n// **Hue is a slider rather than a wheel here.** A wheel and the plane want\n// the same space and would make the surface square and large; the strip\n// sits under the plane at the width it already has. `ColorWheel` is for a\n// picker that wants to be round, which is a different shape rather than a\n// different control.\n//\n// **It is docked above the medium breakpoint and modal below it**, centred\n// over a scrim there — the same swap `DatePicker` makes, at the width `Sheet`\n// changes presentation too, and the shared one in `src/styles/picker.ts`\n// rather than a third copy. A 280dp surface anchored to a trigger is\n// unreachable at 375px.\n//\n// One thing the picker has to do that its parts do not. **The plane and the\n// hue strip are pinned to HSL.** A channel has to belong to the value's own\n// space or React Aria throws, and a hex parses as RGB, which has no\n// saturation — so `<ColorPicker defaultValue=\"#6750A4\" />`, the call anyone\n// writes first, would throw outright. Converting here is what makes the\n// picker take any notation, and it costs the caller nothing: the value\n// handed back is still in whatever they passed.\n\nconst styles = {\n triggerSwatch: {\n kZKoxP: \"xxk0z11\",\n kmuXW: \"x2lah0s\",\n kzqmXN: \"xvy4d1p\",\n $$css: true\n },\n triggerSwatchDisabled: {\n kSiTet: \"x1ppv7y9\",\n $$css: true\n }\n};\n\n// Hoisted so the context is handed one array rather than a new one on every\n// render, which would re-render every swatch reading it.\nconst DISABLED_TRIGGER_SWATCH = [styles.triggerSwatch, styles.triggerSwatchDisabled];\nconst triggerStyles = {\n base: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"x1vnz5z6\",\n kaIpWk: \"x1dkaolv\",\n kMzoRj: \"xc342km\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x139gbkf\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n kMv6JI: \"xkknnkr\",\n kGuDYH: \"x14zspaw\",\n k63SB2: \"x1v9cpvo\",\n kOIVth: \"x126z3so\",\n kb6lSQ: \"x155f00i\",\n kLWn49: \"x1lz68p4\",\n k8WAf4: \"x1cmllll\",\n kg3NbH: \"x18fpw6u\",\n $$css: true\n },\n disabled: {\n kWkggS: \"x19v6zzp\",\n kMwMTN: \"x1xj74d8\",\n kkrTdU: \"x1h6gzvc\",\n $$css: true\n },\n hovered: {\n kWkggS: \"x1ei6177\",\n $$css: true\n },\n pressed: {\n kWkggS: \"x1vt8e7r\",\n $$css: true\n }\n};\ntype ColorPickerProps = Omit<RACColorPickerProps, 'children'> & {\n /** Whether the alpha strip is drawn under the hue one. @default false */\n alpha?: boolean;\n /** Replaces everything on the surface, for a picker that arranges its own parts. */\n children?: ReactNode;\n /** Lands on the trigger, which is the element a layout positions. */\n className?: string;\n /**\n * Where to portal the surface. Defaults to the container of the `ThemeScope`\n * around it, which keeps the surface on that scope's tokens, or to the end of\n * `<body>` where there is none. A subtree themed through the `themeScope`\n * class has no container of its own, so point this inside it, or the surface\n * renders outside and keeps the page's tokens.\n */\n container?: Element;\n /** Whether the surface starts open. Uncontrolled; pair `isOpen` with `onOpenChange` instead. */\n defaultOpen?: boolean;\n /**\n * Whether the whole picker is inert — the trigger, and the plane, strips\n * and field on the surface, which can be on screen while disabled since\n * the surface opens independently of the trigger. An arrangement passed\n * as `children` is the call site's own to disable.\n * @default false\n */\n isDisabled?: boolean;\n /** Whether the surface is open. Controlled; needs `onOpenChange`. */\n isOpen?: boolean;\n /** What the trigger says beside its swatch. Always rendered; it is the button's name. */\n label: string;\n /** Called when the surface opens or closes. */\n onOpenChange?: (isOpen: boolean) => void;\n /** Lands on the trigger, as `className` does. */\n style?: CSSProperties;\n};\n\n// Any HSL colour names the channels the two strips draw. The labels are read\n// off it in the reader's locale, as React Aria words them, rather than written\n// here in English.\nconst CHANNELS = parseColor('hsl(0, 0%, 0%)');\n\n/**\n * A colour picked from a plane, a hue strip and a text field, behind a\n * trigger showing the colour. The value is React Aria's: pass `value` with\n * `onChange` to control it, or `defaultValue`, as a CSS colour string or a\n * `Color` from `parseColor`, which this package re-exports.\n *\n * ```tsx\n * <ColorPicker defaultValue=\"#6750A4\" label=\"Label\" />\n * ```\n *\n * `alpha` adds the transparency strip. Above the medium breakpoint the\n * surface is docked to the trigger; below it, it opens centred, the same\n * swap `DatePicker` makes. `defaultOpen`, `isOpen` and `onOpenChange` reach\n * the overlay, since the picker itself carries no open state — React Aria\n * keeps that on the dialog trigger this renders inside.\n *\n * Every part inside is this package's own — `ColorArea`, `ColorSlider`,\n * `ColorField` and `ColorSwatch` — and they share the picker's value\n * through React Aria's context rather than props. Passing `children`\n * replaces all of them, for a picker that wants a different arrangement.\n *\n * The call site's `className` and `style` land on the trigger, which is the\n * element a layout positions.\n */\nfunction ColorPicker({\n alpha = false,\n children,\n className,\n container,\n defaultOpen,\n isDisabled = false,\n isOpen,\n label,\n onOpenChange,\n ref,\n style,\n ...props\n}: ColorPickerProps & RefAttributes<HTMLButtonElement>) {\n const {\n locale\n } = useLocale();\n return <RACColorPicker {...props}>\n <RACDialogTrigger defaultOpen={defaultOpen} isOpen={isOpen} onOpenChange={onOpenChange}>\n <RACButton isDisabled={isDisabled}\n // React Aria's picker renders no element of its own, so the ref\n // lands on the trigger, as the call site's class and style do.\n ref={ref} {...mergeStatefulStyles(\n // A function of the state rather than a fixed class, since the\n // trigger is the element a layout positions and the call site's\n // own class has to merge into it — a plain `className` would\n // overwrite one or the other.\n (state: ButtonRenderProps) => stylex.props(triggerStyles.base, focus.ring, state.isHovered && triggerStyles.hovered, state.isPressed && triggerStyles.pressed, state.isDisabled && triggerStyles.disabled), {\n className,\n style\n })}>\n {(state: ButtonRenderProps) => <>\n <SwatchSquareContext value={state.isDisabled ? DISABLED_TRIGGER_SWATCH : styles.triggerSwatch}>\n <ColorSwatch />\n </SwatchSquareContext>\n {label}\n </>}\n </RACButton>\n <RACPopover className={popoverClassName}\n // oxlint-disable-next-line typescript/no-deprecated -- its replacement, UNSAFE_PortalProvider, is not exported by react-aria-components\n UNSTABLE_portalContainer={container}>\n <RACDialog {...stylex.props(overlay.popupDialog, focus.ring)}>\n {/*\n Disabled reaches every control here, not only the trigger.\n React Aria's colour picker carries no disabled state of its\n own — react-stately's `useColorPickerState` has no such\n concept — so nothing hands it down the way a field's context\n would. And the surface opens independently of the trigger, so\n a disabled picker can still be on screen: already open when a\n form disables it, or opened from outside. Without this the\n plane could be dragged, the strips moved with the arrow keys\n and the field typed into, all changing the value of something\n documented as inert.\n An arrangement a call site passes as `children` is its own to\n disable; there is no context to reach it through.\n */}\n {children ?? <div className=\"x9f619 x78zum5 xdt5ytf x1gka490 x1dz1jew x193iq5w xgc26li\">\n <ColorArea aria-label={label} colorSpace=\"hsl\" isDisabled={isDisabled} xChannel=\"saturation\" yChannel=\"lightness\" />\n <ColorSlider channel=\"hue\" colorSpace=\"hsl\" isDisabled={isDisabled} label={CHANNELS.getChannelName('hue', locale)} />\n {alpha ? <ColorSlider channel=\"alpha\" isDisabled={isDisabled} label={CHANNELS.getChannelName('alpha', locale)} /> : null}\n <ColorField isDisabled={isDisabled} label={label} />\n </div>}\n </RACDialog>\n </RACPopover>\n </RACDialogTrigger>\n </RACColorPicker>;\n}\nexport type { ColorPickerProps };\nexport default ColorPicker;"],"mappings":";;;;;;;;;;;;;;;AAsDA,MAAMmC,SAAS;CACbC,eAAe;EACbC,QAAQ;EACRC,OAAO;EACPC,QAAQ;EACRC,OAAO;CACT;CACAC,uBAAuB;EACrBC,QAAQ;EACRF,OAAO;CACT;AACF;AAIA,MAAMG,0BAA0B,CAACR,OAAOC,eAAeD,OAAOM,qBAAqB;AACnF,MAAMG,gBAAgB;CACpBC,MAAM;EACJC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRrB,OAAO;CACT;CACAsB,UAAU;EACRf,QAAQ;EACRI,QAAQ;EACRC,QAAQ;EACRZ,OAAO;CACT;CACAuB,SAAS;EACPhB,QAAQ;EACRP,OAAO;CACT;CACAwB,SAAS;EACPjB,QAAQ;EACRP,OAAO;CACT;AACF;AAuCA,MAAMqC,WAAWpE,WAAW,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;AA0B5C,SAAAG,cAAAkE,IAAA;CAAA,MAAAC,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UAAAA;EADkB,CAAA;EAgDHtB,EAAA,MAAAC;EAAAD,EAAA,MAAAsB;EAAAtB,EAAA,MAAAuB;CAAA,OAAAA,MAAAvB,EAAA;CAAA,OAhDZuB;AAgDY;AAjErB,SAAAf,MAAAG,OAAA;CAAA,OA2BoClF,MAAaoC,cAAaC,MAAOxB,MAAK2E,MAAON,MAAKa,aAAc3D,cAAamB,SAAU2B,MAAKc,aAAc5D,cAAaoB,SAAU0B,MAAKlB,cAAe5B,cAAakB,QAAS;AAAC"}
@@ -2,7 +2,9 @@
2
2
  import { props } from "../../node_modules/@stylexjs/stylex/lib/es/stylex.js";
3
3
  import { chequer } from "../../styles/chequer.js";
4
4
  import { mergeStyles } from "../../styles/merge.js";
5
+ import { SwatchSquareContext } from "../../swatch/index.js";
5
6
  import { c } from "react/compiler-runtime";
7
+ import { useContext } from "react";
6
8
  import { jsx } from "react/jsx-runtime";
7
9
  import { ColorSwatch } from "react-aria-components";
8
10
  // src/components/color-swatch/index.tsx
@@ -37,7 +39,7 @@ const styles = { ground: {
37
39
  * interactive state for one to read.
38
40
  */
39
41
  function ColorSwatch$1(t0) {
40
- const $ = c(14);
42
+ const $ = c(15);
41
43
  let className;
42
44
  let props$1;
43
45
  let ref;
@@ -55,37 +57,39 @@ function ColorSwatch$1(t0) {
55
57
  ref = $[3];
56
58
  style = $[4];
57
59
  }
60
+ const placed = useContext(SwatchSquareContext);
58
61
  let t1;
59
- if ($[5] !== className || $[6] !== style) {
60
- t1 = mergeStyles(props(chequer.ground, styles.ground), {
62
+ if ($[5] !== className || $[6] !== placed || $[7] !== style) {
63
+ t1 = mergeStyles(props(chequer.ground, styles.ground, placed), {
61
64
  className,
62
65
  style
63
66
  });
64
67
  $[5] = className;
65
- $[6] = style;
66
- $[7] = t1;
67
- } else t1 = $[7];
68
+ $[6] = placed;
69
+ $[7] = style;
70
+ $[8] = t1;
71
+ } else t1 = $[8];
68
72
  let t2;
69
- if ($[8] !== props$1) {
73
+ if ($[9] !== props$1) {
70
74
  t2 = /* @__PURE__ */ jsx(ColorSwatch, {
71
75
  ...props$1,
72
76
  className: "x5yr21d x1tfhd1 xbd69nm x9f619 x1lliihq xh8yej3"
73
77
  });
74
- $[8] = props$1;
75
- $[9] = t2;
76
- } else t2 = $[9];
78
+ $[9] = props$1;
79
+ $[10] = t2;
80
+ } else t2 = $[10];
77
81
  let t3;
78
- if ($[10] !== ref || $[11] !== t1 || $[12] !== t2) {
82
+ if ($[11] !== ref || $[12] !== t1 || $[13] !== t2) {
79
83
  t3 = /* @__PURE__ */ jsx("span", {
80
84
  ref,
81
85
  ...t1,
82
86
  children: t2
83
87
  });
84
- $[10] = ref;
85
- $[11] = t1;
86
- $[12] = t2;
87
- $[13] = t3;
88
- } else t3 = $[13];
88
+ $[11] = ref;
89
+ $[12] = t1;
90
+ $[13] = t2;
91
+ $[14] = t3;
92
+ } else t3 = $[14];
89
93
  return t3;
90
94
  }
91
95
  export { ColorSwatch$1 as default };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","CSSProperties","RefAttributes","ColorSwatchProps","RACColorSwatchProps","stylex","ColorSwatch","RACColorSwatch","chequer","mergeStyles","colors","radii","SQUARE","styles","ground","kZKoxP","kaIpWk","kB7OPa","k1xSpc","kzqmXN","kVQacm","$$css","Omit","className","style","t0","$","props","ref","t1","t2","t3","ColorSwatch","_c","props","stylex.props","RACColorSwatch"],"sources":["../../../src/components/color-swatch/index.tsx"],"sourcesContent":["'use client';\n\nimport type { CSSProperties, RefAttributes } from 'react';\nimport type { ColorSwatchProps as RACColorSwatchProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { ColorSwatch as RACColorSwatch } from 'react-aria-components';\nimport { chequer } from '../../styles/chequer';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii } from '../../tokens/design.tokens.stylex';\n\n// A single colour, drawn as a square. The design carries no page for this —\n// its colour guidance is about the roles a component takes, not about\n// showing a colour as a value — so the shape here is the library's own,\n// built from what the rest of it already uses.\n//\n// Three things follow from that, and each is a choice rather than a reading.\n//\n// **A swatch is outlined.** Its own colour is the content, so it cannot\n// carry a contrasting one — and a white swatch on a light surface, or a\n// near-black one in dark mode, would otherwise have no edge at all. The\n// outline is the same hairline a field's box takes.\n//\n// **Transparency is drawn against a chequer rather than against the page.**\n// A half-transparent red over a white surface and an opaque pink are the\n// same pixels; the chequer is what tells them apart. It is built from two\n// surface tokens, so it follows the theme rather than being a fixed grey.\n//\n// **The chequer is a layer behind the swatch, not a background on it.**\n// React Aria sets the colour through the element's own inline\n// `background-color`, and CSS paints a background image over a background\n// colour rather than under it — so a chequer on the same element would\n// cover the colour it is there to reveal.\n\nconst SQUARE = '40px';\nconst styles = {\n ground: {\n kZKoxP: \"x1vqgdyp\",\n kaIpWk: \"x1tfhd1\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x1rg5ohu\",\n kzqmXN: \"x100vrsf\",\n kVQacm: \"xb3r6kr\",\n $$css: true\n }\n};\ntype ColorSwatchProps = Omit<RACColorSwatchProps, 'className' | 'style'> & {\n /**\n * Lands on the square around the swatch, which is the element a layout\n * positions and the one that carries its size.\n */\n className?: string;\n /** Lands on the square around the swatch, as `className` does. */\n style?: CSSProperties;\n};\n\n/**\n * A colour shown as a value: a square of it, with a chequer behind so\n * transparency reads as transparency. The colour is React Aria's — a CSS\n * string, or a `Color` from `parseColor`, which this package re-exports.\n *\n * ```tsx\n * import { parseColor } from '@kanso-labs/kanso-ui'\n *\n * <ColorSwatch color={parseColor('hsla(200, 100%, 50%, 0.4)')} />\n * ```\n *\n * React Aria names it from the colour itself — \"light vibrant cyan blue, 60%\n * transparent\" — so it needs no label. Pass `colorName` to say something\n * else instead.\n *\n * The call site's `className` and `style` land on the square around the\n * swatch rather than on the swatch itself, which is what makes setting a\n * size from outside work — the colour fills whatever square it is given.\n * React Aria's function forms are not taken here, since a swatch has no\n * interactive state for one to read.\n */\n// The ref lands on the chequered ground, the element the call site's class\n// and style do, rather than on React Aria's swatch inside it.\nfunction ColorSwatch({\n className,\n ref,\n style,\n ...props\n}: ColorSwatchProps & RefAttributes<HTMLSpanElement>) {\n return <span ref={ref} {...mergeStyles(stylex.props(chequer.ground, styles.ground), {\n className,\n style\n })}>\n <RACColorSwatch {...props} className=\"x5yr21d x1tfhd1 xbd69nm x9f619 x1lliihq xh8yej3\" />\n </span>;\n}\nexport type { ColorSwatchProps };\nexport default ColorSwatch;"],"mappings":";;;;;;;;AAmCA,MAAMc,SAAS,EACbC,QAAQ;CACNC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,OAAO;AACT,EACF;;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAAf,cAAAmB,IAAA;CAAA,MAAAC,IAAA1B,EAAA,EAAA;CAAA,IAAAuB;CAAA,IAAAI;CAAA,IAAAC;CAAA,IAAAJ;CAAA,IAAAE,EAAA,OAAAD,IAAA;EAAqB,CAAA,CAAAF,WAAAK,KAAAJ,OAAA,GAAAG,WAAAF;EAK+BC,EAAA,KAAAD;EAAAC,EAAA,KAAAH;EAAAG,EAAA,KAAAC;EAAAD,EAAA,KAAAE;EAAAF,EAAA,KAAAF;CAAA,OAAA;EAAAD,YAAAG,EAAA;EAAAC,UAAAD,EAAA;EAAAE,MAAAF,EAAA;EAAAF,QAAAE,EAAA;CAAA;CAAA,IAAAG;CAAA,IAAAH,EAAA,OAAAH,aAAAG,EAAA,OAAAF,OAAA;EACvBK,KAAApB,YAAYJ,MAAaG,QAAOM,QAASD,OAAMC,MAAO,GAAG;GAAAS;GAAAC;EAGpF,CAAC;EAACE,EAAA,KAAAH;EAAAG,EAAA,KAAAF;EAAAE,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAA,IAAAI;CAAA,IAAAJ,EAAA,OAAAC,SAAA;EACEG,KAAA,oBAACM,aAAD;GAAe,GAAKT;GAAiB,WAAA;EAAiD,CAAA;EAAGD,EAAA,KAAAC;EAAAD,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,QAAAE,OAAAF,EAAA,QAAAG,MAAAH,EAAA,QAAAI,IAAA;EAJtFC,KAAA,oBAAA,QAAA;GAAWH;GAAG,GAAMC;GAIvBC,UAAAA;EACK,CAAA;EAAAJ,EAAA,MAAAE;EAAAF,EAAA,MAAAG;EAAAH,EAAA,MAAAI;EAAAJ,EAAA,MAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OALFK;AAKE"}
1
+ {"version":3,"file":"index.js","names":["c","_c","CSSProperties","RefAttributes","ColorSwatchProps","RACColorSwatchProps","stylex","useContext","ColorSwatch","RACColorSwatch","chequer","mergeStyles","SwatchSquareContext","colors","radii","SQUARE","styles","ground","kZKoxP","kaIpWk","kB7OPa","k1xSpc","kzqmXN","kVQacm","$$css","Omit","className","style","t0","$","props","ref","placed","t1","t2","t3","ColorSwatch","_c","props","stylex.props","RACColorSwatch"],"sources":["../../../src/components/color-swatch/index.tsx"],"sourcesContent":["'use client';\n\nimport type { CSSProperties, RefAttributes } from 'react';\nimport type { ColorSwatchProps as RACColorSwatchProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useContext } from 'react';\nimport { ColorSwatch as RACColorSwatch } from 'react-aria-components';\nimport { chequer } from '../../styles/chequer';\nimport { mergeStyles } from '../../styles/merge';\nimport { SwatchSquareContext } from '../../swatch';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii } from '../../tokens/design.tokens.stylex';\n\n// A single colour, drawn as a square. The design carries no page for this —\n// its colour guidance is about the roles a component takes, not about\n// showing a colour as a value — so the shape here is the library's own,\n// built from what the rest of it already uses.\n//\n// Three things follow from that, and each is a choice rather than a reading.\n//\n// **A swatch is outlined.** Its own colour is the content, so it cannot\n// carry a contrasting one — and a white swatch on a light surface, or a\n// near-black one in dark mode, would otherwise have no edge at all. The\n// outline is the same hairline a field's box takes.\n//\n// **Transparency is drawn against a chequer rather than against the page.**\n// A half-transparent red over a white surface and an opaque pink are the\n// same pixels; the chequer is what tells them apart. It is built from two\n// surface tokens, so it follows the theme rather than being a fixed grey.\n//\n// **The chequer is a layer behind the swatch, not a background on it.**\n// React Aria sets the colour through the element's own inline\n// `background-color`, and CSS paints a background image over a background\n// colour rather than under it — so a chequer on the same element would\n// cover the colour it is there to reveal.\n\nconst SQUARE = '40px';\nconst styles = {\n ground: {\n kZKoxP: \"x1vqgdyp\",\n kaIpWk: \"x1tfhd1\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x1rg5ohu\",\n kzqmXN: \"x100vrsf\",\n kVQacm: \"xb3r6kr\",\n $$css: true\n }\n};\ntype ColorSwatchProps = Omit<RACColorSwatchProps, 'className' | 'style'> & {\n /**\n * Lands on the square around the swatch, which is the element a layout\n * positions and the one that carries its size.\n */\n className?: string;\n /** Lands on the square around the swatch, as `className` does. */\n style?: CSSProperties;\n};\n\n/**\n * A colour shown as a value: a square of it, with a chequer behind so\n * transparency reads as transparency. The colour is React Aria's — a CSS\n * string, or a `Color` from `parseColor`, which this package re-exports.\n *\n * ```tsx\n * import { parseColor } from '@kanso-labs/kanso-ui'\n *\n * <ColorSwatch color={parseColor('hsla(200, 100%, 50%, 0.4)')} />\n * ```\n *\n * React Aria names it from the colour itself — \"light vibrant cyan blue, 60%\n * transparent\" — so it needs no label. Pass `colorName` to say something\n * else instead.\n *\n * The call site's `className` and `style` land on the square around the\n * swatch rather than on the swatch itself, which is what makes setting a\n * size from outside work — the colour fills whatever square it is given.\n * React Aria's function forms are not taken here, since a swatch has no\n * interactive state for one to read.\n */\n// The ref lands on the chequered ground, the element the call site's class\n// and style do, rather than on React Aria's swatch inside it.\nfunction ColorSwatch({\n className,\n ref,\n style,\n ...props\n}: ColorSwatchProps & RefAttributes<HTMLSpanElement>) {\n const placed = useContext(SwatchSquareContext);\n return <span ref={ref} {...mergeStyles(stylex.props(chequer.ground, styles.ground, placed), {\n className,\n style\n })}>\n <RACColorSwatch {...props} className=\"x5yr21d x1tfhd1 xbd69nm x9f619 x1lliihq xh8yej3\" />\n </span>;\n}\nexport type { ColorSwatchProps };\nexport default ColorSwatch;"],"mappings":";;;;;;;;;;AAqCA,MAAMgB,SAAS,EACbC,QAAQ;CACNC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,OAAO;AACT,EACF;;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAAhB,cAAAoB,IAAA;CAAA,MAAAC,IAAA5B,EAAA,EAAA;CAAA,IAAAyB;CAAA,IAAAI;CAAA,IAAAC;CAAA,IAAAJ;CAAA,IAAAE,EAAA,OAAAD,IAAA;EAAqB,CAAA,CAAAF,WAAAK,KAAAJ,OAAA,GAAAG,WAAAF;EAK+BC,EAAA,KAAAD;EAAAC,EAAA,KAAAH;EAAAG,EAAA,KAAAC;EAAAD,EAAA,KAAAE;EAAAF,EAAA,KAAAF;CAAA,OAAA;EAAAD,YAAAG,EAAA;EAAAC,UAAAD,EAAA;EAAAE,MAAAF,EAAA;EAAAF,QAAAE,EAAA;CAAA;CAClD,MAAAG,SAAezB,WAAWK,mBAAmB;CAAE,IAAAqB;CAAA,IAAAJ,EAAA,OAAAH,aAAAG,EAAA,OAAAG,UAAAH,EAAA,OAAAF,OAAA;EACpBM,KAAAtB,YAAYL,MAAaI,QAAOO,QAASD,OAAMC,QAASe,MAAM,GAAG;GAAAN;GAAAC;EAG5F,CAAC;EAACE,EAAA,KAAAH;EAAAG,EAAA,KAAAG;EAAAH,EAAA,KAAAF;EAAAE,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAC,SAAA;EACEI,KAAA,oBAACM,aAAD;GAAe,GAAKV;GAAiB,WAAA;EAAiD,CAAA;EAAGD,EAAA,KAAAC;EAAAD,EAAA,MAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,IAAAM;CAAA,IAAAN,EAAA,QAAAE,OAAAF,EAAA,QAAAI,MAAAJ,EAAA,QAAAK,IAAA;EAJtFC,KAAA,oBAAA,QAAA;GAAWJ;GAAG,GAAME;GAIvBC,UAAAA;EACK,CAAA;EAAAL,EAAA,MAAAE;EAAAF,EAAA,MAAAI;EAAAJ,EAAA,MAAAK;EAAAL,EAAA,MAAAM;CAAA,OAAAA,KAAAN,EAAA;CAAA,OALFM;AAKE"}
@@ -174,6 +174,7 @@ function CopyField(t0) {
174
174
  onClick: handleCopy,
175
175
  size: "xs",
176
176
  variant: "text",
177
+ className: "x2lah0s",
177
178
  children: t14
178
179
  });
179
180
  $[23] = buttonName;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","HTMLAttributes","RefAttributes","stylex","useCallback","useEffect","useId","useRef","useState","useMessages","mergeStyles","colors","radii","spacing","typography","Button","COPIED_RESET_MS","CopyFieldProps","copiedLabel","copyLabel","label","onCopied","value","onCopyFailed","error","selectedLabel","Omit","HTMLDivElement","CopyField","t0","$","copiedLabelProp","copyLabelProp","selectedLabelProp","props","messages","copied","copy","copySelected","setCopy","shown","text","kind","timer","undefined","code","generatedId","rootId","id","copyId","copiedId","named","role","buttonName","t1","t2","Symbol","for","clearTimeout","current","t3","settle","setTimeout","count","write","navigator","clipboard","writeText","t4","selectAndCopy","reportCopied","handleCopy","className","t5","t6","t7","0","1","t8","t9","t10","t11","t12","t13","t14","t15","t16","t17","t18","thrown","queueMicrotask","element","HTMLElement","selection","window","getSelection","range","document","createRange","selectNodeContents","removeAllRanges","addRange","execCommand","_c"],"sources":["../../../src/components/copy-field/index.tsx"],"sourcesContent":["'use client';\n\nimport type { HTMLAttributes, RefAttributes } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport { useCallback, useEffect, useId, useRef, useState } from 'react';\nimport { useMessages } from '../../i18n';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, spacing, typography } from '../../tokens/design.tokens.stylex';\nimport Button from '../button';\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 with 8dp above and below it, so the\n// box is 50dp against the field's 56, which suits a value that is read\n// rather than edited, and its corner is the shape scale's small step for the\n// same reason.\n//\n// The 8dp is what holds the button's focus ring, which reaches 4dp out from\n// it, clear of the rule, and the trailing end gives the button the same 8dp\n// rather than the 12dp the value starts in by. The button brings 12dp of its\n// own around its label, so the label ends 20dp in where the two paddings\n// added up to 24.\n\ntype CopyFieldProps = {\n /**\n * What the button says once the value has been copied, and what is\n * announced. It reverts to `copyLabel` on its own after a couple of\n * seconds. Left out, it is the word for it in the I18nProvider's locale —\n * \"Copied\" in English.\n */\n copiedLabel?: string;\n /**\n * What the button says at rest. Left out, it is the word for it in the\n * I18nProvider's locale — \"Copy\" in English.\n */\n copyLabel?: string;\n /**\n * What the value is — \"Repository URL\", \"Access token\" — for a page with\n * more than one field. It names the field as a group and joins the button's\n * name, so a screen reader hears \"Copy Repository URL\" rather than one\n * \"Copy\" after another; it is not shown. The value itself stays out of the\n * button's name, since a token would be read aloud. Left out, the field is\n * unnamed and its button is \"Copy\" alone, as it always was.\n */\n label?: 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 /**\n * Called when the write is refused, with whatever was thrown, and the\n * field's own fallback has not copied the value either. By then the value\n * is selected and the field says so — see `selectedLabel` — so this is for\n * an app that wants to say more, in a snackbar say.\n *\n * Takes the error where `onCopied` takes the value, because the value is\n * the one thing the call site already has and the reason is the one thing\n * it does not. The two refusals throw differently: outside a secure\n * context `navigator.clipboard` is not there at all, and where the\n * permission is denied it is a `DOMException`.\n */\n onCopyFailed?: (error: unknown) => void;\n /**\n * What is announced when the clipboard refused the write and the value has\n * been selected for the reader to copy themselves. The button keeps saying\n * `copyLabel`, since a label slot wide enough for this would double the\n * button's width at rest; the selection itself is what shows. Left out, it\n * is the phrase for it in the I18nProvider's locale — \"Selected to copy\"\n * in English.\n */\n selectedLabel?: string;\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 *\n * A write refused — outside a secure context, or where the permission is\n * denied — does not leave the reader with nothing. The field selects the\n * value and tries the older copy command, which some of those places still\n * allow; failing that, the selection is left ready for the keyboard's own\n * copy, the field announces so, and `onCopyFailed` is called. One click on\n * the value selects exactly the value too.\n */\nfunction CopyField({\n copiedLabel: copiedLabelProp,\n copyLabel: copyLabelProp,\n label,\n onCopied,\n onCopyFailed,\n selectedLabel: selectedLabelProp,\n value,\n ...props\n}: CopyFieldProps & RefAttributes<HTMLDivElement>) {\n const messages = useMessages();\n const copiedLabel = copiedLabelProp ?? messages.copied;\n const copyLabel = copyLabelProp ?? messages.copy;\n const selectedLabel = selectedLabelProp ?? messages.copySelected;\n // What the last write put on the clipboard, and how many writes there have\n // been. The confirmation is that text still being the value shown, so a\n // value that changes inside the dwell — a token regenerated, a selection\n // swapped — takes the label back to Copy at once rather than confirming a\n // copy of something else. The count is what lets a second press be\n // announced, below. `kind` is whether the text reached the clipboard or\n // was only selected for the reader to copy, after a refusal.\n const [copy, setCopy] = useState<null | {\n count: number;\n kind: 'copied' | 'selected';\n text: string;\n }>(null);\n const shown: 'copied' | 'copy' | 'selected' = copy?.text === value ? copy.kind : 'copy';\n const copied = shown === 'copied';\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const code = useRef<HTMLElement>(null);\n const generatedId = useId();\n const rootId = props.id ?? generatedId;\n const copyId = useId();\n const copiedId = useId();\n\n // With a label, the field is a group it names, and the button is named by\n // the label slot on show and then by the group: \"Copy Repository URL\",\n // then \"Copied Repository URL\". The slot on show rather than both, since\n // the two swap `aria-hidden` and a name taking both would say both.\n const named = label === undefined ? undefined : {\n 'aria-label': label,\n id: rootId,\n role: 'group'\n };\n const buttonName = label === undefined ? undefined : `${copied ? copiedId : copyId} ${rootId}`;\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 // The component's own state first, the dwell included, and the call\n // site's handler after it: a handler that threw used to skip the timer,\n // leaving the button on Copied for good. Its error is still the call\n // site's to see, raised on its own rather than swallowed.\n const settle = (kind: 'copied' | 'selected') => {\n clearTimeout(timer.current);\n timer.current = setTimeout(() => {\n setCopy(null);\n }, COPIED_RESET_MS);\n setCopy(current => ({\n count: (current?.count ?? 0) + 1,\n kind,\n text: value\n }));\n };\n const write = async () => {\n try {\n await navigator.clipboard.writeText(value);\n } catch (error) {\n // A clipboard write is refused outside a secure context and wherever\n // the permission is denied, neither of which the call site can fix,\n // and a button that did nothing there left the reader with nothing.\n // So the value is selected, which is what the keyboard's own copy\n // acts on, and the older copy command is tried on that selection,\n // since some of those places still allow it. Only where that fails\n // too does the field announce that the value is selected — not that\n // it is copied, which it is not — and report the refusal.\n //\n // Nothing is logged — the library writes to the console nowhere, and\n // a warning an app cannot turn off is not its to emit.\n if (selectAndCopy(code.current)) {\n settle('copied');\n reportCopied(onCopied, value);\n return;\n }\n settle('selected');\n onCopyFailed?.(error);\n return;\n }\n settle('copied');\n reportCopied(onCopied, value);\n };\n void write();\n }, [onCopied, onCopyFailed, value]);\n return <div {...props} {...named} {...mergeStyles({\n className: \"x6s0dn4 x14s9m32 x1fwvt7v x1xdvaa9 x1y0btm7 xmkeg23 x9f619 x78zum5 x126z3so x1cmllll xq7elwu xwde665\"\n }, props)}>\n <span className=\"x139gbkf x1iyjqo2 x1b35g6e xdb2kus x9d6959 xwth0xh xybisxh xeuugli x6mezaz xvrbanz x126k92a\">\n <code dir=\"ltr\" ref={code} className=\"x9f619 xbppi91 x1qlqyl8 xj0a0fe x4ej8vm\">\n {value}\n </code>\n </span>\n <Button aria-labelledby={buttonName} onClick={handleCopy} size=\"xs\" variant=\"text\">\n <span className=\"xrvj5dj x1o2pa38\">\n <span aria-hidden={copied || undefined} id={copyId} {...{\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} id={copiedId} {...{\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 Each write puts a new node in it, keyed by the count, since a second\n press inside the dwell otherwise left the text as it was and the\n region had nothing to announce. */}\n <output className=\"xjm9jq1 x1hyvwdk x1i1rx1s xb3r6kr x10l6tqk xuxw1ft\">\n {copy !== null && shown !== 'copy' ? <span key={copy.count}>\n {shown === 'copied' ? copiedLabel : selectedLabel}\n </span> : null}\n </output>\n </div>;\n}\n\n/**\n * Hands the call site the value it copied. What its handler throws is raised\n * on its own, outside the copy: it still reaches the page's error reporting,\n * where a rejection of the copy's own promise reached nothing but an\n * unhandled-rejection warning. Outside the component, since the React\n * Compiler compiles neither optional chaining nor a captured catch binding\n * inside a `try`.\n */\nfunction reportCopied(onCopied: ((value: string) => void) | undefined, value: string) {\n if (onCopied === undefined) {\n return;\n }\n try {\n onCopied(value);\n } catch (thrown) {\n queueMicrotask(() => {\n throw thrown;\n });\n }\n}\n\n/**\n * Selects the value's text, which is what the keyboard's own copy acts on,\n * and tries the older copy command on that selection, saying whether it\n * copied. The command is deprecated, and still the one way to the clipboard\n * on an insecure origin, which is where the newer one is refused.\n */\nfunction selectAndCopy(element: HTMLElement | null) {\n const selection = window.getSelection();\n if (element === null || selection === null) {\n return false;\n }\n const range = document.createRange();\n range.selectNodeContents(element);\n selection.removeAllRanges();\n selection.addRange(range);\n try {\n // oxlint-disable-next-line typescript/no-deprecated -- the one fallback an insecure origin still allows\n return document.execCommand('copy');\n } catch {\n return false;\n }\n}\nexport type { CopyFieldProps };\nexport default CopyField;"],"mappings":";;;;;;;;AAeA,MAAMiB,kBAAkB;;;;;;;;;;;;;AAsFxB,SAAAY,UAAAC,IAAA;CAAA,MAAAC,IAAA9B,EAAA,EAAA;CAAmB,MAAA,EAAAkB,aAAAa,iBAAAZ,WAAAa,eAAAZ,OAAAC,UAAAE,cAAAE,eAAAQ,mBAAAX,OAAA,GAAAY,UAAAL;CAUjB,MAAAM,WAAiB1B,YAAY;CAC7B,MAAAS,cAAoBa,mBAAmBI,SAAQC;CAC/C,MAAAjB,YAAkBa,iBAAiBG,SAAQE;CAC3C,MAAAZ,gBAAsBQ,qBAAqBE,SAAQG;CAQnD,MAAA,CAAAD,MAAAE,WAAwB/B,SAIrB,IAAI;CACP,MAAAgC,QAA8CH,MAAII,SAAWnB,QAAQe,KAAIK,OAA3B;CAC9C,MAAAN,SAAeI,UAAU;CACzB,MAAAG,QAAcpC,OAAkDqC,KAAAA,CAAS;CACzE,MAAAC,OAAatC,OAAoB,IAAI;CACrC,MAAAuC,cAAoBxC,MAAM;CAC1B,MAAAyC,SAAeb,MAAKc,MAALF;CACf,MAAAG,SAAe3C,MAAM;CACrB,MAAA4C,WAAiB5C,MAAM;CAMvB,MAAA6C,QAAc/B,UAAUwB,KAAAA,IAAVA,KAAAA,IAAA;EAAA,cACExB;EAAK4B,IACfD;EAAMK,MACJ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CACT;AACF"}
1
+ {"version":3,"file":"index.js","names":["c","_c","HTMLAttributes","RefAttributes","stylex","useCallback","useEffect","useId","useRef","useState","useMessages","mergeStyles","colors","radii","spacing","typography","Button","COPIED_RESET_MS","CopyFieldProps","copiedLabel","copyLabel","label","onCopied","value","onCopyFailed","error","selectedLabel","Omit","HTMLDivElement","CopyField","t0","$","copiedLabelProp","copyLabelProp","selectedLabelProp","props","messages","copied","copy","copySelected","setCopy","shown","text","kind","timer","undefined","code","generatedId","rootId","id","copyId","copiedId","named","role","buttonName","t1","t2","Symbol","for","clearTimeout","current","t3","settle","setTimeout","count","write","navigator","clipboard","writeText","t4","selectAndCopy","reportCopied","handleCopy","className","t5","t6","t7","0","1","t8","t9","t10","t11","t12","t13","t14","t15","t16","t17","t18","thrown","queueMicrotask","element","HTMLElement","selection","window","getSelection","range","document","createRange","selectNodeContents","removeAllRanges","addRange","execCommand","_c"],"sources":["../../../src/components/copy-field/index.tsx"],"sourcesContent":["'use client';\n\nimport type { HTMLAttributes, RefAttributes } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport { useCallback, useEffect, useId, useRef, useState } from 'react';\nimport { useMessages } from '../../i18n';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, spacing, typography } from '../../tokens/design.tokens.stylex';\nimport Button from '../button';\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 with 8dp above and below it, so the\n// box is 50dp against the field's 56, which suits a value that is read\n// rather than edited, and its corner is the shape scale's small step for the\n// same reason.\n//\n// The 8dp is what holds the button's focus ring, which reaches 4dp out from\n// it, clear of the rule, and the trailing end gives the button the same 8dp\n// rather than the 12dp the value starts in by. The button brings 12dp of its\n// own around its label, so the label ends 20dp in where the two paddings\n// added up to 24.\n\ntype CopyFieldProps = {\n /**\n * What the button says once the value has been copied, and what is\n * announced. It reverts to `copyLabel` on its own after a couple of\n * seconds. Left out, it is the word for it in the I18nProvider's locale —\n * \"Copied\" in English.\n */\n copiedLabel?: string;\n /**\n * What the button says at rest. Left out, it is the word for it in the\n * I18nProvider's locale — \"Copy\" in English.\n */\n copyLabel?: string;\n /**\n * What the value is — \"Repository URL\", \"Access token\" — for a page with\n * more than one field. It names the field as a group and joins the button's\n * name, so a screen reader hears \"Copy Repository URL\" rather than one\n * \"Copy\" after another; it is not shown. The value itself stays out of the\n * button's name, since a token would be read aloud. Left out, the field is\n * unnamed and its button is \"Copy\" alone, as it always was.\n */\n label?: 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 /**\n * Called when the write is refused, with whatever was thrown, and the\n * field's own fallback has not copied the value either. By then the value\n * is selected and the field says so — see `selectedLabel` — so this is for\n * an app that wants to say more, in a snackbar say.\n *\n * Takes the error where `onCopied` takes the value, because the value is\n * the one thing the call site already has and the reason is the one thing\n * it does not. The two refusals throw differently: outside a secure\n * context `navigator.clipboard` is not there at all, and where the\n * permission is denied it is a `DOMException`.\n */\n onCopyFailed?: (error: unknown) => void;\n /**\n * What is announced when the clipboard refused the write and the value has\n * been selected for the reader to copy themselves. The button keeps saying\n * `copyLabel`, since a label slot wide enough for this would double the\n * button's width at rest; the selection itself is what shows. Left out, it\n * is the phrase for it in the I18nProvider's locale — \"Selected to copy\"\n * in English.\n */\n selectedLabel?: string;\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 *\n * A write refused — outside a secure context, or where the permission is\n * denied — does not leave the reader with nothing. The field selects the\n * value and tries the older copy command, which some of those places still\n * allow; failing that, the selection is left ready for the keyboard's own\n * copy, the field announces so, and `onCopyFailed` is called. One click on\n * the value selects exactly the value too.\n */\nfunction CopyField({\n copiedLabel: copiedLabelProp,\n copyLabel: copyLabelProp,\n label,\n onCopied,\n onCopyFailed,\n selectedLabel: selectedLabelProp,\n value,\n ...props\n}: CopyFieldProps & RefAttributes<HTMLDivElement>) {\n const messages = useMessages();\n const copiedLabel = copiedLabelProp ?? messages.copied;\n const copyLabel = copyLabelProp ?? messages.copy;\n const selectedLabel = selectedLabelProp ?? messages.copySelected;\n // What the last write put on the clipboard, and how many writes there have\n // been. The confirmation is that text still being the value shown, so a\n // value that changes inside the dwell — a token regenerated, a selection\n // swapped — takes the label back to Copy at once rather than confirming a\n // copy of something else. The count is what lets a second press be\n // announced, below. `kind` is whether the text reached the clipboard or\n // was only selected for the reader to copy, after a refusal.\n const [copy, setCopy] = useState<null | {\n count: number;\n kind: 'copied' | 'selected';\n text: string;\n }>(null);\n const shown: 'copied' | 'copy' | 'selected' = copy?.text === value ? copy.kind : 'copy';\n const copied = shown === 'copied';\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const code = useRef<HTMLElement>(null);\n const generatedId = useId();\n const rootId = props.id ?? generatedId;\n const copyId = useId();\n const copiedId = useId();\n\n // With a label, the field is a group it names, and the button is named by\n // the label slot on show and then by the group: \"Copy Repository URL\",\n // then \"Copied Repository URL\". The slot on show rather than both, since\n // the two swap `aria-hidden` and a name taking both would say both.\n const named = label === undefined ? undefined : {\n 'aria-label': label,\n id: rootId,\n role: 'group'\n };\n const buttonName = label === undefined ? undefined : `${copied ? copiedId : copyId} ${rootId}`;\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 // The component's own state first, the dwell included, and the call\n // site's handler after it: a handler that threw used to skip the timer,\n // leaving the button on Copied for good. Its error is still the call\n // site's to see, raised on its own rather than swallowed.\n const settle = (kind: 'copied' | 'selected') => {\n clearTimeout(timer.current);\n timer.current = setTimeout(() => {\n setCopy(null);\n }, COPIED_RESET_MS);\n setCopy(current => ({\n count: (current?.count ?? 0) + 1,\n kind,\n text: value\n }));\n };\n const write = async () => {\n try {\n await navigator.clipboard.writeText(value);\n } catch (error) {\n // A clipboard write is refused outside a secure context and wherever\n // the permission is denied, neither of which the call site can fix,\n // and a button that did nothing there left the reader with nothing.\n // So the value is selected, which is what the keyboard's own copy\n // acts on, and the older copy command is tried on that selection,\n // since some of those places still allow it. Only where that fails\n // too does the field announce that the value is selected — not that\n // it is copied, which it is not — and report the refusal.\n //\n // Nothing is logged — the library writes to the console nowhere, and\n // a warning an app cannot turn off is not its to emit.\n if (selectAndCopy(code.current)) {\n settle('copied');\n reportCopied(onCopied, value);\n return;\n }\n settle('selected');\n onCopyFailed?.(error);\n return;\n }\n settle('copied');\n reportCopied(onCopied, value);\n };\n void write();\n }, [onCopied, onCopyFailed, value]);\n return <div {...props} {...named} {...mergeStyles({\n className: \"x6s0dn4 x14s9m32 x1fwvt7v x1xdvaa9 x1y0btm7 xmkeg23 x9f619 x78zum5 x126z3so x1cmllll xq7elwu xwde665\"\n }, props)}>\n <span className=\"x139gbkf x1iyjqo2 x1b35g6e xdb2kus x9d6959 xwth0xh xybisxh xeuugli x6mezaz xvrbanz x126k92a\">\n <code dir=\"ltr\" ref={code} className=\"x9f619 xbppi91 x1qlqyl8 xj0a0fe x4ej8vm\">\n {value}\n </code>\n </span>\n <Button aria-labelledby={buttonName} onClick={handleCopy} size=\"xs\" variant=\"text\" className=\"x2lah0s\">\n <span className=\"xrvj5dj x1o2pa38\">\n <span aria-hidden={copied || undefined} id={copyId} {...{\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} id={copiedId} {...{\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 Each write puts a new node in it, keyed by the count, since a second\n press inside the dwell otherwise left the text as it was and the\n region had nothing to announce. */}\n <output className=\"xjm9jq1 x1hyvwdk x1i1rx1s xb3r6kr x10l6tqk xuxw1ft\">\n {copy !== null && shown !== 'copy' ? <span key={copy.count}>\n {shown === 'copied' ? copiedLabel : selectedLabel}\n </span> : null}\n </output>\n </div>;\n}\n\n/**\n * Hands the call site the value it copied. What its handler throws is raised\n * on its own, outside the copy: it still reaches the page's error reporting,\n * where a rejection of the copy's own promise reached nothing but an\n * unhandled-rejection warning. Outside the component, since the React\n * Compiler compiles neither optional chaining nor a captured catch binding\n * inside a `try`.\n */\nfunction reportCopied(onCopied: ((value: string) => void) | undefined, value: string) {\n if (onCopied === undefined) {\n return;\n }\n try {\n onCopied(value);\n } catch (thrown) {\n queueMicrotask(() => {\n throw thrown;\n });\n }\n}\n\n/**\n * Selects the value's text, which is what the keyboard's own copy acts on,\n * and tries the older copy command on that selection, saying whether it\n * copied. The command is deprecated, and still the one way to the clipboard\n * on an insecure origin, which is where the newer one is refused.\n */\nfunction selectAndCopy(element: HTMLElement | null) {\n const selection = window.getSelection();\n if (element === null || selection === null) {\n return false;\n }\n const range = document.createRange();\n range.selectNodeContents(element);\n selection.removeAllRanges();\n selection.addRange(range);\n try {\n // oxlint-disable-next-line typescript/no-deprecated -- the one fallback an insecure origin still allows\n return document.execCommand('copy');\n } catch {\n return false;\n }\n}\nexport type { CopyFieldProps };\nexport default CopyField;"],"mapp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