@kanso-labs/kanso-ui 0.45.34 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/button/index.js +13 -9
- package/dist/button/index.js.map +1 -1
- package/dist/calendar/styles.js +12 -7
- package/dist/calendar/styles.js.map +1 -1
- package/dist/chip/label.js +1 -0
- package/dist/chip/label.js.map +1 -1
- package/dist/chip/styles.js +2 -0
- package/dist/chip/styles.js.map +1 -1
- package/dist/collection/styles.js +1 -1
- package/dist/collection/styles.js.map +1 -1
- package/dist/components/breadcrumbs/index.js +4 -1
- package/dist/components/breadcrumbs/index.js.map +1 -1
- package/dist/components/button-group/index.d.ts +16 -3
- package/dist/components/button-group/index.js +53 -86
- package/dist/components/button-group/index.js.map +1 -1
- package/dist/components/calendar/index.d.ts +3 -3
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/card/index.js +5 -1
- package/dist/components/card/index.js.map +1 -1
- package/dist/components/carousel/index.js +162 -105
- package/dist/components/carousel/index.js.map +1 -1
- package/dist/components/chip/index.d.ts +38 -15
- package/dist/components/chip/index.js +104 -8
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/code/index.js +32 -26
- package/dist/components/code/index.js.map +1 -1
- package/dist/components/color-area/index.d.ts +5 -3
- package/dist/components/color-area/index.js +5 -3
- package/dist/components/color-area/index.js.map +1 -1
- package/dist/components/color-picker/index.js +6 -3
- package/dist/components/color-picker/index.js.map +1 -1
- package/dist/components/color-swatch/index.js +1 -1
- package/dist/components/color-swatch/index.js.map +1 -1
- package/dist/components/color-swatch-picker/index.js +24 -9
- package/dist/components/color-swatch-picker/index.js.map +1 -1
- package/dist/components/combo-box/index.d.ts +11 -3
- package/dist/components/combo-box/index.js +66 -62
- package/dist/components/combo-box/index.js.map +1 -1
- package/dist/components/copy-field/index.js +1 -0
- package/dist/components/copy-field/index.js.map +1 -1
- package/dist/components/date-picker/index.d.ts +22 -3
- package/dist/components/date-picker/index.js +234 -45
- package/dist/components/date-picker/index.js.map +1 -1
- package/dist/components/date-range-picker/index.d.ts +3 -1
- package/dist/components/date-range-picker/index.js +6 -4
- package/dist/components/date-range-picker/index.js.map +1 -1
- package/dist/components/disclosure/index.d.ts +4 -3
- package/dist/components/disclosure/index.js +159 -101
- package/dist/components/disclosure/index.js.map +1 -1
- package/dist/components/fab/index.d.ts +3 -1
- package/dist/components/fab/index.js +25 -12
- package/dist/components/fab/index.js.map +1 -1
- package/dist/components/fab-menu/index.js +1 -1
- package/dist/components/fab-menu/index.js.map +1 -1
- package/dist/components/icon-button/index.js +3 -3
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/index.d.ts +3 -3
- package/dist/components/link/index.js +2 -2
- package/dist/components/link/index.js.map +1 -1
- package/dist/components/menu/index.js +5 -2
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/navigation-bar/index.js.map +1 -1
- package/dist/components/navigation-rail/index.js +4 -4
- package/dist/components/navigation-rail/index.js.map +1 -1
- package/dist/components/navigation-tree/index.js +16 -13
- package/dist/components/navigation-tree/index.js.map +1 -1
- package/dist/components/popover/index.js +35 -33
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/progress-indicator/index.js +258 -172
- package/dist/components/progress-indicator/index.js.map +1 -1
- package/dist/components/range-calendar/index.js +41 -7
- package/dist/components/range-calendar/index.js.map +1 -1
- package/dist/components/search-view/index.js +1 -1
- package/dist/components/search-view/index.js.map +1 -1
- package/dist/components/segmented-button/index.d.ts +3 -2
- package/dist/components/segmented-button/index.js +46 -95
- package/dist/components/segmented-button/index.js.map +1 -1
- package/dist/components/select/index.js +5 -2
- package/dist/components/select/index.js.map +1 -1
- package/dist/components/slider/index.js +42 -10
- package/dist/components/slider/index.js.map +1 -1
- package/dist/components/table/index.d.ts +26 -5
- package/dist/components/table/index.js +93 -75
- package/dist/components/table/index.js.map +1 -1
- package/dist/components/tag/index.js +1 -0
- package/dist/components/tag/index.js.map +1 -1
- package/dist/components/time-picker/index.js +37 -5
- package/dist/components/time-picker/index.js.map +1 -1
- package/dist/components/token-field/index.js +89 -66
- package/dist/components/token-field/index.js.map +1 -1
- package/dist/components/toolbar/index.d.ts +8 -3
- package/dist/components/toolbar/index.js +123 -43
- package/dist/components/toolbar/index.js.map +1 -1
- package/dist/components/tree/index.js +1 -1
- package/dist/components/tree/index.js.map +1 -1
- package/dist/fab/styles.js +12 -0
- package/dist/fab/styles.js.map +1 -1
- package/dist/field/styles.js +2 -2
- package/dist/field/styles.js.map +1 -1
- package/dist/hooks/useDockedMonths.js +36 -0
- package/dist/hooks/useDockedMonths.js.map +1 -0
- package/dist/i18n/index.js +1 -0
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.js +34 -0
- package/dist/i18n/messages.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/navigation/index.js +5 -5
- package/dist/navigation/index.js.map +1 -1
- package/dist/navigation/styles.js +5 -1
- package/dist/navigation/styles.js.map +1 -1
- package/dist/row/context.js +6 -0
- package/dist/row/context.js.map +1 -0
- package/dist/row/index.js +77 -66
- package/dist/row/index.js.map +1 -1
- package/dist/row/styles.js +15 -0
- package/dist/row/styles.js.map +1 -1
- package/dist/segments/index.js +2 -5
- package/dist/segments/index.js.map +1 -1
- package/dist/segments/literal.js +66 -0
- package/dist/segments/literal.js.map +1 -0
- package/dist/segments/styles.js +8 -0
- package/dist/segments/styles.js.map +1 -1
- package/dist/styles/chequer.js +1 -0
- package/dist/styles/chequer.js.map +1 -1
- package/dist/styles/focus.js.map +1 -1
- package/dist/styles.css +509 -69
- package/dist/toggle-group/index.js +133 -0
- package/dist/toggle-group/index.js.map +1 -0
- package/package.json +3 -3
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { props } from "../../node_modules/@stylexjs/stylex/lib/es/stylex.js";
|
|
3
|
+
import { focus } from "../../styles/focus.js";
|
|
3
4
|
import { mergeStatefulStyles } from "../../styles/merge.js";
|
|
5
|
+
import { colors } from "../../tokens/design.tokens.stylex.js";
|
|
4
6
|
import ColorSwatch$1 from "../color-swatch/index.js";
|
|
5
7
|
import { c } from "react/compiler-runtime";
|
|
6
8
|
import { jsx } from "react/jsx-runtime";
|
|
7
9
|
import { ColorSwatchPicker as ColorSwatchPicker$1, ColorSwatchPickerItem as ColorSwatchPickerItem$1 } from "react-aria-components";
|
|
8
10
|
// src/components/color-swatch-picker/index.tsx
|
|
11
|
+
`${colors.surface}${colors.onSurface}${colors.surface}`;
|
|
9
12
|
const styles = {
|
|
10
13
|
item: {
|
|
11
|
-
kUfP38: "
|
|
14
|
+
kUfP38: "xdzrvcx",
|
|
12
15
|
kbwMcY: "x1v5kskh",
|
|
13
16
|
kPGmMm: "x1941vk7",
|
|
14
17
|
kWgvks: "xx38sju",
|
|
15
18
|
k5JduY: "x1s928wv",
|
|
16
|
-
kv0HGH: "
|
|
19
|
+
kv0HGH: "xzkkzs7",
|
|
17
20
|
kloYau: "x2q1x1w",
|
|
18
21
|
kwXMNM: "x1j6awrg",
|
|
19
22
|
kaIpWk: "x1tfhd1",
|
|
@@ -25,15 +28,20 @@ const styles = {
|
|
|
25
28
|
$$css: true
|
|
26
29
|
},
|
|
27
30
|
itemDisabled: {
|
|
31
|
+
k3DiCg: "xkqgyyi x1vz15c4",
|
|
32
|
+
kPB484: "x13uuyx9",
|
|
33
|
+
kQmYQc: "xtql2tq",
|
|
34
|
+
kgeoSG: "x1cpjm7i",
|
|
35
|
+
ku0W4C: "x13rwrtk",
|
|
36
|
+
kFcpXp: "xxx281p",
|
|
37
|
+
km8f2m: "xkk1bqk",
|
|
38
|
+
kEoFBp: "x1hmns74",
|
|
39
|
+
kxmVGU: "x12maryy",
|
|
28
40
|
kkrTdU: "xt0e3qv",
|
|
29
|
-
kSiTet: "x1ppv7y9",
|
|
30
41
|
$$css: true
|
|
31
42
|
},
|
|
32
43
|
itemFocused: {
|
|
33
|
-
kjBf7l: "xrgy624",
|
|
34
44
|
kInvED: "x8wkva7",
|
|
35
|
-
k3XXqK: "xaatb59",
|
|
36
|
-
kMeerF: "x1de99jn",
|
|
37
45
|
$$css: true
|
|
38
46
|
},
|
|
39
47
|
itemHovered: {
|
|
@@ -47,8 +55,9 @@ const styles = {
|
|
|
47
55
|
$$css: true
|
|
48
56
|
},
|
|
49
57
|
itemSelected: {
|
|
50
|
-
kXtpa: "
|
|
58
|
+
kXtpa: "xmi6dwc",
|
|
51
59
|
kbwMcY: "x86avzo",
|
|
60
|
+
kPGmMm: "x14wq4lv",
|
|
52
61
|
$$css: true
|
|
53
62
|
}
|
|
54
63
|
};
|
|
@@ -121,7 +130,13 @@ function ColorSwatchPickerItem(t0) {
|
|
|
121
130
|
}
|
|
122
131
|
let t3;
|
|
123
132
|
if ($[5] !== children) {
|
|
124
|
-
t3 =
|
|
133
|
+
t3 = (state) => /* @__PURE__ */ jsx("span", {
|
|
134
|
+
...{
|
|
135
|
+
0: { className: "x9f619 x3nfvp2" },
|
|
136
|
+
1: { className: "x9f619 x3nfvp2 x1ppv7y9" }
|
|
137
|
+
}[!!state.isDisabled << 0],
|
|
138
|
+
children: children ?? /* @__PURE__ */ jsx(ColorSwatch$1, {})
|
|
139
|
+
});
|
|
125
140
|
$[5] = children;
|
|
126
141
|
$[6] = t3;
|
|
127
142
|
} else t3 = $[6];
|
|
@@ -141,7 +156,7 @@ function ColorSwatchPickerItem(t0) {
|
|
|
141
156
|
return t4;
|
|
142
157
|
}
|
|
143
158
|
function itemStyles(state) {
|
|
144
|
-
return props(styles.item, state.isHovered && styles.itemHovered, state.isPressed && styles.itemPressed, state.isSelected && styles.itemSelected, state.isFocusVisible && styles.itemFocused, state.isDisabled && styles.itemDisabled);
|
|
159
|
+
return props(styles.item, state.isHovered && styles.itemHovered, state.isPressed && styles.itemPressed, state.isSelected && styles.itemSelected, state.isFocusVisible && [focus.ringVisible, styles.itemFocused], state.isDisabled && styles.itemDisabled);
|
|
145
160
|
}
|
|
146
161
|
ColorSwatchPicker.Item = ColorSwatchPickerItem;
|
|
147
162
|
export { ColorSwatchPickerItem, ColorSwatchPicker as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_c","stylex","ColorSwatchPicker","ColorSwatchPickerItem","RACColorSwatchPickerItem","mergeStatefulStyles","styles","item","kUfP38","kbwMcY","kPGmMm","kWgvks","k5JduY","kv0HGH","kloYau","kwXMNM","kaIpWk","kB7OPa","kkrTdU","k1xSpc","k3XXqK","kVAEAm","$$css","itemDisabled","kSiTet","itemFocused","kjBf7l","kInvED","kMeerF","itemHovered","kXtpa","itemPressed","itemSelected","children","className","props","$","t0","t1","T0","t2","t3","itemStyles","t4","state","isDisabled","isFocusVisible","isHovered","isPressed","isSelected","Item","RACColorSwatchPicker","ColorSwatch"],"sources":["../../../src/components/color-swatch-picker/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { ColorSwatchPickerItemProps as RACColorSwatchPickerItemProps, ColorSwatchPickerProps as RACColorSwatchPickerProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { ColorSwatchPicker as RACColorSwatchPicker, ColorSwatchPickerItem as RACColorSwatchPickerItem } from 'react-aria-components';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, spacing, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\nimport ColorSwatch from '../color-swatch';\n\n// A row of colours to choose one from. React Aria makes it a listbox of\n// swatches, so it is a selection control rather than a palette: arrow keys\n// move between colours and one of them is selected.\n//\n// The design carries no page for this either, so what an item looks like\n// when it is chosen is the library's own. Three choices, each with its\n// reason.\n//\n// **Selection is a ring around the swatch, not a mark on it.** A tick drawn\n// over a colour has to be readable against every colour in the row, which no\n// single ink is; a ring sits outside the swatch and needs only to read\n// against the surface behind it.\n//\n// **The ring is the primary role, and offset.** It is the same weight and\n// colour the focus ring takes elsewhere, one step out from the swatch so the\n// colour stays whole — a ring drawn on the swatch would eat two pixels of\n// the thing being chosen.\n//\n// **Focus and selection are drawn by different properties.** An element has\n// one outline, so with both drawn in it the second replaced the first, and a\n// keyboard arrowing onto the chosen colour saw a swatch that looked\n// unchosen. The focus ring is the item's outline, 6px out; the selection\n// ring is a border on a box laid 2px around the swatch, inside it. Both are\n// properties forced colours keep, which a box shadow is not.\n//\n// **Hover and press are a ring too, in the slot selection would take.** Every\n// other interactive element here answers the pointer with a state layer, but\n// a state layer is a fill and a swatch's fill is the colour being chosen:\n// behind it the tint is hidden, over it the tint changes the colour. So an\n// unselected swatch under the pointer takes a ring at the selection ring's\n// offset, drawn in the outline roles rather than primary so it cannot be read\n// as chosen — outline variant while a pointer is over it, and outline while a\n// touch or a pen holds it. Those are the only presses anyone sees: React Aria\n// chooses a swatch the moment a mouse or a key presses it, and on release for\n// a touch, so that press is the one a reader waits through before the swatch\n// is theirs. Under forced colours both roles become one system colour, so the\n// ring turns dashed there, where the selection ring stays solid.\n\nconst FORCED_COLORS = '@media (forced-colors: active)';\nconst styles = {\n item: {\n kUfP38: \"x1upluxz\",\n kbwMcY: \"x1v5kskh\",\n kPGmMm: \"x1941vk7\",\n kWgvks: \"xx38sju\",\n k5JduY: \"x1s928wv\",\n kv0HGH: \"xramuyw\",\n kloYau: \"x2q1x1w\",\n kwXMNM: \"x1j6awrg\",\n kaIpWk: \"x1tfhd1\",\n kB7OPa: \"x9f619\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n k3XXqK: \"x1t137rt\",\n kVAEAm: \"x1n2onr6\",\n $$css: true\n },\n itemDisabled: {\n kkrTdU: \"xt0e3qv\",\n kSiTet: \"x1ppv7y9\",\n $$css: true\n },\n itemFocused: {\n kjBf7l: \"xrgy624\",\n kInvED: \"x8wkva7\",\n k3XXqK: \"xaatb59\",\n kMeerF: \"x1de99jn\",\n $$css: true\n },\n itemHovered: {\n kXtpa: \"x1ek9lwj\",\n kbwMcY: \"x86avzo xssfeg4\",\n $$css: true\n },\n itemPressed: {\n kXtpa: \"xrwozs3\",\n kbwMcY: \"x86avzo xssfeg4\",\n $$css: true\n },\n itemSelected: {\n kXtpa: \"xtl7nvb\",\n kbwMcY: \"x86avzo\",\n $$css: true\n }\n};\ntype ColorSwatchPickerItemProps = Omit<RACColorSwatchPickerItemProps, 'children' | 'className' | 'style'> & {\n /** What the item draws. A `ColorSwatch` with no `color` of its own by default. */\n children?: ReactNode;\n /** A function may compute the class from the item's render state. */\n className?: RACColorSwatchPickerItemProps['className'];\n /** A function may compute the style from the item's render state. */\n style?: RACColorSwatchPickerItemProps['style'];\n};\ntype ColorSwatchPickerProps = Omit<RACColorSwatchPickerProps, 'className' | 'style'> & {\n /** A function may compute the class from the picker's render state. */\n className?: RACColorSwatchPickerProps['className'];\n /** A function may compute the style from the picker's render state. */\n style?: RACColorSwatchPickerProps['style'];\n};\n\n/**\n * A row of colours to choose one from, drawn as swatches. The value is React\n * Aria's — pass `value` with `onChange` to control it, or `defaultValue` —\n * as a CSS colour string or a `Color` from `parseColor`, which this package\n * re-exports.\n *\n * ```tsx\n * <ColorSwatchPicker defaultValue=\"#6750A4\">\n * <ColorSwatchPicker.Item color=\"#6750A4\" />\n * <ColorSwatchPicker.Item color=\"#625B71\" />\n * </ColorSwatchPicker>\n * ```\n *\n * It is a listbox, so arrow keys move between colours and the chosen one\n * carries a ring. Name it with `aria-label` or `aria-labelledby`; React Aria\n * calls it \"Color swatches\" otherwise.\n *\n * The call site's `className` and `style` land on the picker, which is the\n * element a layout positions.\n */\nfunction ColorSwatchPicker(props: ColorSwatchPickerProps & RefAttributes<HTMLDivElement>) {\n return <RACColorSwatchPicker {...props} {...mergeStatefulStyles({\n className: \"x9f619 x78zum5 x1a02dak x126z3so x1t137rt\"\n }, props)} />;\n}\n\n/**\n * One swatch in a {@link ColorSwatchPicker}. Renders a `ColorSwatch` of its\n * own `color` unless given different children.\n */\nfunction ColorSwatchPickerItem({\n children,\n ...props\n}: ColorSwatchPickerItemProps & RefAttributes<HTMLDivElement>) {\n return <RACColorSwatchPickerItem {...props} {...mergeStatefulStyles(itemStyles, props)}>\n {children ?? <ColorSwatch />}\n </RACColorSwatchPickerItem>;\n}\n\n// The item's styles, from React Aria's render state. StyleX cannot target\n// `[data-selected]` on the element it is styling, so the state comes from\n// what React Aria hands the className.\n//\n// The order matters where two styles draw on one property. The hover and\n// press rings come before `selected`, which draws on the same border, so a\n// chosen swatch keeps the ring that says so. `focused` draws on the outline,\n// which nothing else touches, so a swatch that is chosen and focused keeps\n// both. `disabled` is last, so it takes the cursor with it; React Aria\n// reports neither hover nor press on one.\nfunction itemStyles(state: {\n isDisabled: boolean;\n isFocusVisible: boolean;\n isHovered: boolean;\n isPressed: boolean;\n isSelected: boolean;\n}) {\n return stylex.props(styles.item, state.isHovered && styles.itemHovered, state.isPressed && styles.itemPressed, state.isSelected && styles.itemSelected, state.isFocusVisible && styles.itemFocused, state.isDisabled && styles.itemDisabled);\n}\nColorSwatchPicker.Item = ColorSwatchPickerItem;\nexport type { ColorSwatchPickerItemProps, ColorSwatchPickerProps };\nexport { ColorSwatchPickerItem };\nexport default ColorSwatchPicker;"],"mappings":";;;;;;;;AAkDA,MAAMM,SAAS;CACbC,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,OAAO;CACT;CACAC,cAAc;EACZL,QAAQ;EACRM,QAAQ;EACRF,OAAO;CACT;CACAG,aAAa;EACXC,QAAQ;EACRC,QAAQ;EACRP,QAAQ;EACRQ,QAAQ;EACRN,OAAO;CACT;CACAO,aAAa;EACXC,OAAO;EACPrB,QAAQ;EACRa,OAAO;CACT;CACAS,aAAa;EACXD,OAAO;EACPrB,QAAQ;EACRa,OAAO;CACT;CACAU,cAAc;EACZF,OAAO;EACPrB,QAAQ;E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,OAAAE,MAAAF,EAAA,OAAAI,MAAAJ,EAAA,QAAAK,IAAA;EADzBE,KAAA,oBAAC,IAAD;GAAyB,GAAKR;GAAK,GAAMK;GAC3CC,UAAAA;EAD2B,CAAA;EAEHL,EAAA,KAAAG;EAAAH,EAAA,KAAAE;EAAAF,EAAA,KAAAI;EAAAJ,EAAA,MAAAK;EAAAL,EAAA,MAAAO;CAAA,OAAAA,KAAAP,EAAA;CAAA,OAFtBO;AAEsB;AAa/B,SAASD,WAAWE,OAMjB;CACD,OAAO3C,MAAaK,OAAOC,MAAMqC,MAAMG,aAAazC,OAAOuB,aAAae,MAAMI,aAAa1C,OAAOyB,aAAaa,MAAMK,cAAc3C,OAAO0B,cAAcY,MAAME,kBAAkBxC,OAAOmB,aAAamB,MAAMC,cAAcvC,OAAOiB,YAAY;AAC7O;AACArB,kBAAkBgD,OAAO/C"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_c","stylex","ColorSwatchPicker","ColorSwatchPickerItem","RACColorSwatchPickerItem","focus","mergeStatefulStyles","colors","surface","onSurface","styles","item","kUfP38","kbwMcY","kPGmMm","kWgvks","k5JduY","kv0HGH","kloYau","kwXMNM","kaIpWk","kB7OPa","kkrTdU","k1xSpc","k3XXqK","kVAEAm","$$css","itemDisabled","k3DiCg","kPB484","kQmYQc","kgeoSG","ku0W4C","kFcpXp","km8f2m","kEoFBp","kxmVGU","itemFocused","kInvED","itemHovered","kXtpa","itemPressed","itemSelected","children","className","props","$","t0","t1","T0","t2","t3","itemStyles","state","0","1","isDisabled","t4","isFocusVisible","isHovered","isPressed","isSelected","ringVisible","Item","RACColorSwatchPicker","ColorSwatch"],"sources":["../../../src/components/color-swatch-picker/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { ColorSwatchPickerItemProps as RACColorSwatchPickerItemProps, ColorSwatchPickerProps as RACColorSwatchPickerProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { ColorSwatchPicker as RACColorSwatchPicker, ColorSwatchPickerItem as RACColorSwatchPickerItem } from 'react-aria-components';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, spacing, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\nimport ColorSwatch from '../color-swatch';\n\n// A row of colours to choose one from. React Aria makes it a listbox of\n// swatches, so it is a selection control rather than a palette: arrow keys\n// move between colours and one of them is selected.\n//\n// The design carries no page for this either, so what an item looks like\n// when it is chosen is the library's own. Three choices, each with its\n// reason.\n//\n// **Selection is a ring around the swatch, not a mark on it.** A tick drawn\n// over a colour has to be readable against every colour in the row, which no\n// single ink is; a ring sits outside the swatch and needs only to read\n// against the surface behind it.\n//\n// **The ring is 3px of on-surface, and offset.** It sits 2px out from the\n// swatch so the colour stays whole — a ring drawn on the swatch would eat\n// pixels of the thing being chosen. It is not the focus ring's colour or\n// weight on purpose: the arrow keys move focus without choosing, so one\n// swatch is chosen while another is focused, and when both rings were 2px of\n// primary only their distance from the swatch told them apart. Focus keeps\n// the library's ring, the one every other control draws, so the selection\n// ring is the one that differs, heavier and in on-surface.\n//\n// **Focus and selection are drawn by different properties.** An element has\n// one outline, so with both drawn in it the second replaced the first, and a\n// keyboard arrowing onto the chosen colour saw a swatch that looked\n// unchosen. The focus ring is the item's outline, 6px out; the selection\n// ring is a border on a box laid 5px around the swatch, inside it, with 1px\n// clear between the two. Both are properties forced colours keep, which a\n// box shadow is not, and there the difference in weight is what is left.\n//\n// **Hover and press are a ring too, in the slot selection would take.** Every\n// other interactive element here answers the pointer with a state layer, but\n// a state layer is a fill and a swatch's fill is the colour being chosen:\n// behind it the tint is hidden, over it the tint changes the colour. So an\n// unselected swatch under the pointer takes a ring at the selection ring's\n// outer edge, 2px wide and in the outline roles, so it cannot be read\n// as chosen — outline variant while a pointer is over it, and outline while a\n// touch or a pen holds it. Those are the only presses anyone sees: React Aria\n// chooses a swatch the moment a mouse or a key presses it, and on release for\n// a touch, so that press is the one a reader waits through before the swatch\n// is theirs. Under forced colours both roles become one system colour, so the\n// ring turns dashed there, where the selection ring stays solid.\n//\n// **A colour that cannot be chosen is struck through, as well as faded.**\n// Faded alone it read as a paler colour, and a pale colour is as good an\n// option as any. The slash is drawn over the swatch, where the first choice\n// says no single ink reads against every colour, so it is two: an on-surface\n// line edged in surface, and whichever of the two the colour beneath is\n// nearer to, the other reads against it. The fade is on the item's contents\n// rather than the item, so the slash over them keeps its full strength.\n\nconst FORCED_COLORS = '@media (forced-colors: active)';\n\n// The slash, corner to corner across a square: a 2px line of ink with 1.5px\n// of edge either side, measured across the line rather than along the\n// square's side. Written out twice, once per pair of colours, since StyleX\n// evaluates a constant but not a function building one.\nconst SLASH = `linear-gradient(to top right, transparent calc(50% - 2.5px), ${colors.surface} calc(50% - 2.5px) calc(50% - 1px), ${colors.onSurface} calc(50% - 1px) calc(50% + 1px), ${colors.surface} calc(50% + 1px) calc(50% + 2.5px), transparent calc(50% + 2.5px))`;\nconst SLASH_FORCED = 'linear-gradient(to top right, transparent calc(50% - 2.5px), Canvas calc(50% - 2.5px) calc(50% - 1px), GrayText calc(50% - 1px) calc(50% + 1px), Canvas calc(50% + 1px) calc(50% + 2.5px), transparent calc(50% + 2.5px))';\nconst styles = {\n item: {\n kUfP38: \"xdzrvcx\",\n kbwMcY: \"x1v5kskh\",\n kPGmMm: \"x1941vk7\",\n kWgvks: \"xx38sju\",\n k5JduY: \"x1s928wv\",\n kv0HGH: \"xzkkzs7\",\n kloYau: \"x2q1x1w\",\n kwXMNM: \"x1j6awrg\",\n kaIpWk: \"x1tfhd1\",\n kB7OPa: \"x9f619\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n k3XXqK: \"x1t137rt\",\n kVAEAm: \"x1n2onr6\",\n $$css: true\n },\n itemDisabled: {\n k3DiCg: \"xkqgyyi x1vz15c4\",\n kPB484: \"x13uuyx9\",\n kQmYQc: \"xtql2tq\",\n kgeoSG: \"x1cpjm7i\",\n ku0W4C: \"x13rwrtk\",\n kFcpXp: \"xxx281p\",\n km8f2m: \"xkk1bqk\",\n kEoFBp: \"x1hmns74\",\n kxmVGU: \"x12maryy\",\n kkrTdU: \"xt0e3qv\",\n $$css: true\n },\n itemFocused: {\n kInvED: \"x8wkva7\",\n $$css: true\n },\n itemHovered: {\n kXtpa: \"x1ek9lwj\",\n kbwMcY: \"x86avzo xssfeg4\",\n $$css: true\n },\n itemPressed: {\n kXtpa: \"xrwozs3\",\n kbwMcY: \"x86avzo xssfeg4\",\n $$css: true\n },\n itemSelected: {\n kXtpa: \"xmi6dwc\",\n kbwMcY: \"x86avzo\",\n kPGmMm: \"x14wq4lv\",\n $$css: true\n }\n};\ntype ColorSwatchPickerItemProps = Omit<RACColorSwatchPickerItemProps, 'children' | 'className' | 'style'> & {\n /** What the item draws. A `ColorSwatch` with no `color` of its own by default. */\n children?: ReactNode;\n /** A function may compute the class from the item's render state. */\n className?: RACColorSwatchPickerItemProps['className'];\n /** A function may compute the style from the item's render state. */\n style?: RACColorSwatchPickerItemProps['style'];\n};\ntype ColorSwatchPickerProps = Omit<RACColorSwatchPickerProps, 'className' | 'style'> & {\n /** A function may compute the class from the picker's render state. */\n className?: RACColorSwatchPickerProps['className'];\n /** A function may compute the style from the picker's render state. */\n style?: RACColorSwatchPickerProps['style'];\n};\n\n/**\n * A row of colours to choose one from, drawn as swatches. The value is React\n * Aria's — pass `value` with `onChange` to control it, or `defaultValue` —\n * as a CSS colour string or a `Color` from `parseColor`, which this package\n * re-exports.\n *\n * ```tsx\n * <ColorSwatchPicker defaultValue=\"#6750A4\">\n * <ColorSwatchPicker.Item color=\"#6750A4\" />\n * <ColorSwatchPicker.Item color=\"#625B71\" />\n * </ColorSwatchPicker>\n * ```\n *\n * It is a listbox, so arrow keys move between colours and the chosen one\n * carries a ring. Name it with `aria-label` or `aria-labelledby`; React Aria\n * calls it \"Color swatches\" otherwise.\n *\n * The call site's `className` and `style` land on the picker, which is the\n * element a layout positions.\n */\nfunction ColorSwatchPicker(props: ColorSwatchPickerProps & RefAttributes<HTMLDivElement>) {\n return <RACColorSwatchPicker {...props} {...mergeStatefulStyles({\n className: \"x9f619 x78zum5 x1a02dak x126z3so x1t137rt\"\n }, props)} />;\n}\n\n/**\n * One swatch in a {@link ColorSwatchPicker}. Renders a `ColorSwatch` of its\n * own `color` unless given different children.\n */\nfunction ColorSwatchPickerItem({\n children,\n ...props\n}: ColorSwatchPickerItemProps & RefAttributes<HTMLDivElement>) {\n return <RACColorSwatchPickerItem {...props} {...mergeStatefulStyles(itemStyles, props)}>\n {state => <span {...{\n 0: {\n className: \"x9f619 x3nfvp2\"\n },\n 1: {\n className: \"x9f619 x3nfvp2 x1ppv7y9\"\n }\n }[!!state.isDisabled << 0]}>\n {children ?? <ColorSwatch />}\n </span>}\n </RACColorSwatchPickerItem>;\n}\n\n// The item's styles, from React Aria's render state. StyleX cannot target\n// `[data-selected]` on the element it is styling, so the state comes from\n// what React Aria hands the className.\n//\n// The order matters where two styles draw on one property. The hover and\n// press rings come before `selected`, which draws on the same border, so a\n// chosen swatch keeps the ring that says so. Focus is the library's ring and\n// then `focused`, which moves it out; both draw on the outline, which\n// nothing else touches but the item's resting `none`, so a swatch that is\n// chosen and focused keeps both. `disabled` is last, so it takes the cursor\n// with it, and draws the slash; React Aria reports neither hover nor press\n// on one.\nfunction itemStyles(state: {\n isDisabled: boolean;\n isFocusVisible: boolean;\n isHovered: boolean;\n isPressed: boolean;\n isSelected: boolean;\n}) {\n return stylex.props(styles.item, state.isHovered && styles.itemHovered, state.isPressed && styles.itemPressed, state.isSelected && styles.itemSelected, state.isFocusVisible && [focus.ringVisible, styles.itemFocused], state.isDisabled && styles.itemDisabled);\n}\nColorSwatchPicker.Item = ColorSwatchPickerItem;\nexport type { ColorSwatchPickerItemProps, ColorSwatchPickerProps };\nexport { ColorSwatchPickerItem };\nexport default ColorSwatchPicker;"],"mappings":";;;;;;;;;;AAqEc,GA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nD,OAAOgC,cAAcW,MAAMK,kBAAkB,CAACrD,MAAMyD,aAAapD,OAAO2B,WAAW,GAAGgB,MAAMG,cAAc9C,OAAOiB,YAAY;AAClQ;AACAzB,kBAAkB6D,OAAO5D"}
|
|
@@ -2,6 +2,12 @@ import { FieldVariant } from "../../field/index.js";
|
|
|
2
2
|
import { ReactElement, ReactNode, Ref, RefAttributes } from "react";
|
|
3
3
|
import { ComboBoxProps as ComboBoxProps$1 } from "react-aria-components";
|
|
4
4
|
type ComboBoxProps<T extends object = object, M extends ComboBoxSelectionMode = 'single'> = {
|
|
5
|
+
/**
|
|
6
|
+
* Whether the list stays open when a search leaves nothing in it, showing
|
|
7
|
+
* the ListBox's "No results" row, rather than closing.
|
|
8
|
+
* @default true
|
|
9
|
+
*/
|
|
10
|
+
allowsEmptyCollection?: boolean;
|
|
5
11
|
/**
|
|
6
12
|
* Where to portal the list. Defaults to the container of the `ThemeScope`
|
|
7
13
|
* around it, which keeps the list on that scope's tokens, or to the end of
|
|
@@ -60,7 +66,7 @@ type ComboBoxProps<T extends object = object, M extends ComboBoxSelectionMode =
|
|
|
60
66
|
* @default 'filled'
|
|
61
67
|
*/
|
|
62
68
|
variant?: FieldVariant;
|
|
63
|
-
} & Omit<ComboBoxProps$1<T, M>, 'children' | 'defaultSelectedKey' | 'isInvalid' | 'onSelectionChange' | 'selectedKey' | 'validationBehavior'>;
|
|
69
|
+
} & Omit<ComboBoxProps$1<T, M>, 'allowsEmptyCollection' | 'children' | 'defaultSelectedKey' | 'isInvalid' | 'onSelectionChange' | 'selectedKey' | 'validationBehavior'>;
|
|
64
70
|
type ComboBoxSelectionMode = 'multiple' | 'single';
|
|
65
71
|
/**
|
|
66
72
|
* A labelled text field that filters a list as it is typed. Its value is
|
|
@@ -85,7 +91,9 @@ type ComboBoxSelectionMode = 'multiple' | 'single';
|
|
|
85
91
|
* Filtering is React Aria's: `defaultFilter` takes a predicate, `useFilter`
|
|
86
92
|
* is re-exported for a locale-aware one, and `items` with `useAsyncList`
|
|
87
93
|
* feeds a list that is fetched rather than listed. `allowsCustomValue` lets
|
|
88
|
-
* the field keep text that matches nothing.
|
|
94
|
+
* the field keep text that matches nothing. A search that matches nothing
|
|
95
|
+
* keeps the list open on a "No results" row; `allowsEmptyCollection={false}`
|
|
96
|
+
* closes it instead.
|
|
89
97
|
*
|
|
90
98
|
* The box, label, input, supporting line and error are the field chrome in
|
|
91
99
|
* `src/field`, shared with every other field; the list is ListBox on the
|
|
@@ -94,5 +102,5 @@ type ComboBoxSelectionMode = 'multiple' | 'single';
|
|
|
94
102
|
* The call site's `className` and `style` land on the field as a whole,
|
|
95
103
|
* which is the element a layout positions.
|
|
96
104
|
*/
|
|
97
|
-
declare function ComboBox<T extends object = object, M extends ComboBoxSelectionMode = 'single'>({ container, description, error, floatingLabel, inputRef, isDisabled, label, leadingIcon, options, variant, ...props }: ComboBoxProps<T, M> & RefAttributes<HTMLDivElement>): import("react").JSX.Element;
|
|
105
|
+
declare function ComboBox<T extends object = object, M extends ComboBoxSelectionMode = 'single'>({ allowsEmptyCollection, container, description, error, floatingLabel, inputRef, isDisabled, label, leadingIcon, options, variant, ...props }: ComboBoxProps<T, M> & RefAttributes<HTMLDivElement>): import("react").JSX.Element;
|
|
98
106
|
export { type ComboBoxProps, type ComboBoxSelectionMode, ComboBox as default };
|
|
@@ -22,7 +22,6 @@ const styles = {
|
|
|
22
22
|
ks0D6T: "x1x1rfll",
|
|
23
23
|
k7Eaqz: "xeuugli",
|
|
24
24
|
kORKVm: "x1odjw0f",
|
|
25
|
-
k8WAf4: "x1cmllll",
|
|
26
25
|
$$css: true
|
|
27
26
|
},
|
|
28
27
|
toggle: {
|
|
@@ -78,7 +77,9 @@ function ChosenValues() {
|
|
|
78
77
|
* Filtering is React Aria's: `defaultFilter` takes a predicate, `useFilter`
|
|
79
78
|
* is re-exported for a locale-aware one, and `items` with `useAsyncList`
|
|
80
79
|
* feeds a list that is fetched rather than listed. `allowsCustomValue` lets
|
|
81
|
-
* the field keep text that matches nothing.
|
|
80
|
+
* the field keep text that matches nothing. A search that matches nothing
|
|
81
|
+
* keeps the list open on a "No results" row; `allowsEmptyCollection={false}`
|
|
82
|
+
* closes it instead.
|
|
82
83
|
*
|
|
83
84
|
* The box, label, input, supporting line and error are the field chrome in
|
|
84
85
|
* `src/field`, shared with every other field; the list is ListBox on the
|
|
@@ -88,41 +89,42 @@ function ChosenValues() {
|
|
|
88
89
|
* which is the element a layout positions.
|
|
89
90
|
*/
|
|
90
91
|
function ComboBox(t0) {
|
|
91
|
-
const $ = c(
|
|
92
|
-
const { container, description, error, floatingLabel:
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
const
|
|
92
|
+
const $ = c(33);
|
|
93
|
+
const { allowsEmptyCollection: t1, container, description, error, floatingLabel: t2, inputRef, isDisabled: t3, label, leadingIcon, options, variant: t4, ...props$1 } = t0;
|
|
94
|
+
const allowsEmptyCollection = t1 === void 0 ? true : t1;
|
|
95
|
+
const floatingLabel = t2 === void 0 ? true : t2;
|
|
96
|
+
const isDisabled = t3 === void 0 ? false : t3;
|
|
97
|
+
const variant = t4 === void 0 ? "filled" : t4;
|
|
96
98
|
const validationBehavior = useFieldValidationBehavior();
|
|
97
99
|
const boxRef = useRef(null);
|
|
98
100
|
const T0 = ComboBox$1;
|
|
99
|
-
let
|
|
101
|
+
let t5;
|
|
100
102
|
if ($[0] !== error) {
|
|
101
|
-
|
|
103
|
+
t5 = invalidFrom(error);
|
|
102
104
|
$[0] = error;
|
|
103
|
-
$[1] =
|
|
104
|
-
} else
|
|
105
|
-
const
|
|
106
|
-
let
|
|
105
|
+
$[1] = t5;
|
|
106
|
+
} else t5 = $[1];
|
|
107
|
+
const t6 = mergeStatefulStyles(props(fieldStyles.root), props$1);
|
|
108
|
+
let t7;
|
|
107
109
|
if ($[2] !== error) {
|
|
108
|
-
|
|
110
|
+
t7 = invalidFrom(error);
|
|
109
111
|
$[2] = error;
|
|
110
|
-
$[3] =
|
|
111
|
-
} else
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
let
|
|
115
|
-
if ($[4] !== floatingLabel || $[5] !== inputRef || $[6] !== isDisabled || $[7] !== label || $[8] !== leadingIcon || $[9] !==
|
|
116
|
-
|
|
112
|
+
$[3] = t7;
|
|
113
|
+
} else t7 = $[3];
|
|
114
|
+
const t8 = props$1.isRequired ?? false;
|
|
115
|
+
const t9 = props$1.selectionMode === "multiple";
|
|
116
|
+
let t10;
|
|
117
|
+
if ($[4] !== floatingLabel || $[5] !== inputRef || $[6] !== isDisabled || $[7] !== label || $[8] !== leadingIcon || $[9] !== t7 || $[10] !== t8 || $[11] !== t9 || $[12] !== variant) {
|
|
118
|
+
t10 = /* @__PURE__ */ jsx(ComboBoxBox, {
|
|
117
119
|
boxRef,
|
|
118
120
|
floatingLabel,
|
|
119
121
|
inputRef,
|
|
120
122
|
isDisabled,
|
|
121
|
-
isInvalid:
|
|
122
|
-
isRequired:
|
|
123
|
+
isInvalid: t7,
|
|
124
|
+
isRequired: t8,
|
|
123
125
|
label,
|
|
124
126
|
leadingIcon,
|
|
125
|
-
multiple:
|
|
127
|
+
multiple: t9,
|
|
126
128
|
variant
|
|
127
129
|
});
|
|
128
130
|
$[4] = floatingLabel;
|
|
@@ -130,66 +132,68 @@ function ComboBox(t0) {
|
|
|
130
132
|
$[6] = isDisabled;
|
|
131
133
|
$[7] = label;
|
|
132
134
|
$[8] = leadingIcon;
|
|
133
|
-
$[9] =
|
|
134
|
-
$[10] =
|
|
135
|
-
$[11] =
|
|
135
|
+
$[9] = t7;
|
|
136
|
+
$[10] = t8;
|
|
137
|
+
$[11] = t9;
|
|
136
138
|
$[12] = variant;
|
|
137
|
-
$[13] =
|
|
138
|
-
} else
|
|
139
|
-
let
|
|
139
|
+
$[13] = t10;
|
|
140
|
+
} else t10 = $[13];
|
|
141
|
+
let t11;
|
|
140
142
|
if ($[14] !== description || $[15] !== error) {
|
|
141
|
-
|
|
143
|
+
t11 = /* @__PURE__ */ jsx(FieldMessage, {
|
|
142
144
|
description,
|
|
143
145
|
error
|
|
144
146
|
});
|
|
145
147
|
$[14] = description;
|
|
146
148
|
$[15] = error;
|
|
147
|
-
$[16] =
|
|
148
|
-
} else
|
|
149
|
-
let
|
|
149
|
+
$[16] = t11;
|
|
150
|
+
} else t11 = $[16];
|
|
151
|
+
let t12;
|
|
150
152
|
if ($[17] !== options) {
|
|
151
|
-
|
|
153
|
+
t12 = /* @__PURE__ */ jsx(ListBox$1, { children: options });
|
|
152
154
|
$[17] = options;
|
|
153
|
-
$[18] =
|
|
154
|
-
} else
|
|
155
|
-
let
|
|
156
|
-
if ($[19] !== container || $[20] !==
|
|
157
|
-
|
|
155
|
+
$[18] = t12;
|
|
156
|
+
} else t12 = $[18];
|
|
157
|
+
let t13;
|
|
158
|
+
if ($[19] !== container || $[20] !== t12) {
|
|
159
|
+
t13 = /* @__PURE__ */ jsx(Popover, {
|
|
158
160
|
className: listClassName,
|
|
159
161
|
triggerRef: boxRef,
|
|
160
162
|
UNSTABLE_portalContainer: container,
|
|
161
|
-
children:
|
|
163
|
+
children: t12
|
|
162
164
|
});
|
|
163
165
|
$[19] = container;
|
|
164
|
-
$[20] =
|
|
165
|
-
$[21] =
|
|
166
|
-
} else
|
|
167
|
-
let
|
|
168
|
-
if ($[22] !== T0 || $[23] !==
|
|
169
|
-
|
|
166
|
+
$[20] = t12;
|
|
167
|
+
$[21] = t13;
|
|
168
|
+
} else t13 = $[21];
|
|
169
|
+
let t14;
|
|
170
|
+
if ($[22] !== T0 || $[23] !== allowsEmptyCollection || $[24] !== isDisabled || $[25] !== props$1 || $[26] !== t10 || $[27] !== t11 || $[28] !== t13 || $[29] !== t5 || $[30] !== t6 || $[31] !== validationBehavior) {
|
|
171
|
+
t14 = /* @__PURE__ */ jsxs(T0, {
|
|
172
|
+
allowsEmptyCollection,
|
|
170
173
|
isDisabled,
|
|
171
|
-
isInvalid:
|
|
174
|
+
isInvalid: t5,
|
|
172
175
|
validationBehavior,
|
|
173
176
|
...props$1,
|
|
174
|
-
...
|
|
177
|
+
...t6,
|
|
175
178
|
children: [
|
|
176
|
-
t9,
|
|
177
179
|
t10,
|
|
178
|
-
|
|
180
|
+
t11,
|
|
181
|
+
t13
|
|
179
182
|
]
|
|
180
183
|
});
|
|
181
184
|
$[22] = T0;
|
|
182
|
-
$[23] =
|
|
183
|
-
$[24] =
|
|
184
|
-
$[25] =
|
|
185
|
-
$[26] =
|
|
186
|
-
$[27] =
|
|
187
|
-
$[28] =
|
|
188
|
-
$[29] =
|
|
189
|
-
$[30] =
|
|
190
|
-
$[31] =
|
|
191
|
-
|
|
192
|
-
|
|
185
|
+
$[23] = allowsEmptyCollection;
|
|
186
|
+
$[24] = isDisabled;
|
|
187
|
+
$[25] = props$1;
|
|
188
|
+
$[26] = t10;
|
|
189
|
+
$[27] = t11;
|
|
190
|
+
$[28] = t13;
|
|
191
|
+
$[29] = t5;
|
|
192
|
+
$[30] = t6;
|
|
193
|
+
$[31] = validationBehavior;
|
|
194
|
+
$[32] = t14;
|
|
195
|
+
} else t14 = $[32];
|
|
196
|
+
return t14;
|
|
193
197
|
}
|
|
194
198
|
/**
|
|
195
199
|
* The box and what it holds. Its own component so it can read React Aria's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_c","stylex","useContext","useRef","ComboBoxStateContext","ComboBox","RACComboBox","fieldStyles","invalidFrom","useFieldValidationBehavior","focus","mergeStatefulStyles","overlay","popupOrigin","TOGGLE","styles","list","kWkggS","kaIpWk","kzqmXN","kskxy","ks0D6T","k7Eaqz","kORKVm","k8WAf4","$$css","toggle","kGNEyG","kZKoxP","kMzoRj","kB7OPa","kMwMTN","kkrTdU","k1xSpc","kjj79g","kmVPX3","container","description","error","floatingLabel","inputRef","label","leadingIcon","options","variant","ChosenValues","$","t0","Symbol","for","t1","isDisabled","t2","t3","props","undefined","validationBehavior","boxRef","T0","t4","t5","root","t6","t7","isRequired","t8","selectionMode","t9","t10","t11","t12","listClassName","t13","ComboBoxBox","isInvalid","multiple","state","selectedItems","length","ComboToggle","ring","0","className","1","isOpen","popup","placement","RACComboBoxValue","ListBox","RACPopover","RACButton"],"sources":["../../../src/components/combo-box/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactElement, ReactNode, Ref, RefAttributes, RefObject } from 'react';\nimport type { PopoverRenderProps, ComboBoxProps as RACComboBoxProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useContext, useRef } from 'react';\nimport { ComboBoxStateContext, Button as RACButton, ComboBox as RACComboBox, ComboBoxValue as RACComboBoxValue, Popover as RACPopover } from 'react-aria-components';\nimport type { FieldVariant } from '../../field';\nimport { FieldBox, FieldInput, FieldMessage, FieldValue } from '../../field';\nimport { fieldStyles, invalidFrom, useFieldValidationBehavior } from '../../field/root';\nimport { ChevronEndGlyph } from '../../glyphs';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport { overlay, popupOrigin } from '../../styles/overlay';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, radii, spacing } from '../../tokens/design.tokens.stylex';\nimport ListBox from '../list-box';\n\n// The text fields page's autocomplete text field: a text field that filters a\n// list as it is typed. Everything above the list is the field chrome in\n// `src/field` — the same box, label, supporting line and error treatment\n// every other field draws — and the list is ListBox on the shared overlay\n// surface, positioned and sized against the box exactly as Select's is.\n//\n// It is Select's shape with two differences.\n//\n// The control is a real input, so the box is not a press target — typing has\n// to reach the input — and only the chevron at the end opens the list. That\n// is what the page draws too: an autocomplete text field is a text field,\n// with a button on it.\n//\n// And the field is an element tree rather than a function of React Aria's\n// render state, which every other component here writes. React Aria builds a\n// combo box's collection by walking its children for options, and a function\n// is opaque to that walk: with one, the collection is empty until the list\n// has been opened, so a `defaultSelectedKey` resolves to no text and the\n// field starts blank. What needed the render state — whether the list is\n// open — reads the combo box's own state from context instead.\n//\n// Two more things are this component's own.\n//\n// **Filtering is React Aria's, and stays theirs.** `defaultFilter` takes a\n// predicate, and the package re-exports `useFilter` for a locale-aware one;\n// `items` with `useAsyncList` is how a list that is fetched rather than\n// listed gets in. None of that is wrapped, because a combo box's whole job\n// is which options it shows and a wrapper would be a second place to decide\n// it.\n//\n// **A value that is not in the list is allowed or refused, not corrected.**\n// `allowsCustomValue` is React Aria's, and with it off the input reverts to\n// the last chosen option on blur rather than keeping text that means nothing.\n//\n// Choosing more than one is `selectionMode=\"multiple\"`, which draws the\n// chosen options before the input on its line, through React Aria's\n// `ComboBoxValue`, with the label floated over them. For a field that draws\n// each of them as a removable chip, the coverage plan has TokenField.\n\n// Hoisted so it is not a new element on every render, which is what\n// react-perf's jsx-no-jsx-as-prop is after.\nconst TOGGLE = <ComboToggle />;\nconst styles = {\n list: {\n kWkggS: \"x1vnz5z6\",\n kaIpWk: \"x1tfhd1\",\n kzqmXN: \"xlvufjm\",\n kskxy: \"xedcshv\",\n ks0D6T: \"x1x1rfll\",\n k7Eaqz: \"xeuugli\",\n kORKVm: \"x1odjw0f\",\n k8WAf4: \"x1cmllll\",\n $$css: true\n },\n toggle: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"xxk0z11\",\n kaIpWk: \"x16fbrrb\",\n kMzoRj: \"xc342km\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x1heor9g\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n kzqmXN: \"xvy4d1p\",\n kjj79g: \"xl56j7k\",\n kmVPX3: \"x1717udv\",\n $$css: true\n }\n};\ntype ComboBoxProps<T extends object = object, M extends ComboBoxSelectionMode = 'single'> = {\n /**\n * Where to portal the list. Defaults to the container of the `ThemeScope`\n * around it, which keeps the list 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 list\n * renders outside and keeps the page's tokens.\n */\n container?: Element;\n /**\n * A hint shown under the field. Replaced by `error` when there is one, so\n * the two never stack.\n */\n description?: string;\n /**\n * The problem with the current value, in words. Its presence is what puts\n * the field in its error state — the message, the red underline, and\n * `aria-invalid` all follow from it.\n *\n * Outside a `Form` the message line arrives with the message, so the\n * field grows when this does and moves what is under it. A `Form` holds\n * that space from the start; so does a permanent `description`.\n */\n error?: string;\n /**\n * Whether the label sits in the empty box and floats to the top once the\n * field is focused or holds a value. `false` keeps it small at the top in\n * every state.\n * @default true\n */\n floatingLabel?: boolean;\n /**\n * A ref to the field's own `<input>`, which is the element a call site moves\n * focus to — after a server's error, say. `ref` is the field as a whole.\n */\n inputRef?: Ref<HTMLInputElement>;\n /**\n * What the field is for. Required rather than optional: a combo box with\n * no label is a box a screen reader cannot name.\n */\n label: string;\n /**\n * An icon at the start of the box, before the label and the value: the\n * page's 24dp leading icon, in the muted role. An icon drawn in `em` takes\n * that size from the slot.\n */\n leadingIcon?: ReactNode;\n /**\n * The options. `ListBox.Item` for each, and `ListBox.Section` to group\n * them — the list inside is a ListBox, and takes everything one does. With\n * `items` or `defaultItems`, a function from an item to its option, which\n * React Aria calls for each item the list shows.\n */\n options?: ((item: T) => ReactElement) | ReactNode;\n /**\n * The filled box, or the outlined one, as the text fields page draws them.\n * @default 'filled'\n */\n variant?: FieldVariant;\n} & Omit<RACComboBoxProps<T, M>, 'children' | 'defaultSelectedKey' | 'isInvalid' | 'onSelectionChange' | 'selectedKey' | 'validationBehavior'>;\n\n// React Aria's combo box takes its own two-value selection mode rather than\n// the collection-wide one, which also has `none`; that type is local to its\n// module, so the two values are named again here.\ntype ComboBoxSelectionMode = 'multiple' | 'single';\n\n/**\n * The chosen options, drawn before the input on its line when more than one\n * may be chosen. The chrome's `FieldValue` is the styled element and React\n * Aria's `ComboBoxValue` sits inside it, as it does in Select.\n */\nfunction ChosenValues() {\n return <FieldValue>\n <RACComboBoxValue className=\"xb3r6kr xlyipyv xuxw1ft\" />\n </FieldValue>;\n}\n\n/**\n * A labelled text field that filters a list as it is typed. Its value is\n * React Aria's: pass `value` with `onChange` to control which option is\n * chosen, `inputValue` with `onInputChange` to control the text, or the\n * `default` forms of either to let it keep its own. React Aria's older\n * `selectedKey` names are deprecated and are left out of this component's\n * props rather than passed through.\n *\n * ```tsx\n * <ComboBox\n * label=\"Label\"\n * options={\n * <>\n * <ListBox.Item id=\"first\">First item</ListBox.Item>\n * <ListBox.Item id=\"second\">Second item</ListBox.Item>\n * </>\n * }\n * />\n * ```\n *\n * Filtering is React Aria's: `defaultFilter` takes a predicate, `useFilter`\n * is re-exported for a locale-aware one, and `items` with `useAsyncList`\n * feeds a list that is fetched rather than listed. `allowsCustomValue` lets\n * the field keep text that matches nothing.\n *\n * The box, label, input, supporting line and error are the field chrome in\n * `src/field`, shared with every other field; the list is ListBox on the\n * overlay surface every anchored panel here draws.\n *\n * The call site's `className` and `style` land on the field as a whole,\n * which is the element a layout positions.\n */\nfunction ComboBox<T extends object = object, M extends ComboBoxSelectionMode = 'single'>({\n container,\n description,\n error,\n floatingLabel = true,\n inputRef,\n isDisabled = false,\n label,\n leadingIcon,\n options,\n variant = 'filled',\n ...props\n}: ComboBoxProps<T, M> & RefAttributes<HTMLDivElement>) {\n const validationBehavior = useFieldValidationBehavior();\n // What the list is anchored to and takes its width from: the box, not the\n // button inside it, which is a 24dp icon.\n const boxRef = useRef<HTMLDivElement>(null);\n return <RACComboBox<T, M> isDisabled={isDisabled} isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...mergeStatefulStyles(stylex.props(fieldStyles.root), props)}>\n <ComboBoxBox boxRef={boxRef} floatingLabel={floatingLabel} inputRef={inputRef} isDisabled={isDisabled} isInvalid={invalidFrom(error)} isRequired={props.isRequired ?? false} label={label} leadingIcon={leadingIcon} multiple={props.selectionMode === 'multiple'} variant={variant} />\n <FieldMessage description={description} error={error} />\n <RACPopover className={listClassName} triggerRef={boxRef}\n // oxlint-disable-next-line typescript/no-deprecated -- its replacement, UNSAFE_PortalProvider, is not exported by react-aria-components\n UNSTABLE_portalContainer={container}>\n <ListBox<T>>{options}</ListBox>\n </RACPopover>\n </RACComboBox>;\n}\n\n/**\n * The box and what it holds. Its own component so it can read React Aria's\n * state for what is chosen: with more than one option allowed, the input is\n * empty while options are chosen, so it cannot be what says the field holds\n * something. The box is told instead, and the label floats over the chosen\n * options rather than resting on them. Otherwise the box reads the input, as\n * it does for one option, which is what floats the label on typed text.\n */\nfunction ComboBoxBox({\n boxRef,\n floatingLabel,\n inputRef,\n isDisabled,\n isInvalid,\n isRequired,\n label,\n leadingIcon,\n multiple,\n variant\n}: {\n boxRef: RefObject<HTMLDivElement | null>;\n floatingLabel: boolean;\n inputRef: Ref<HTMLInputElement> | undefined;\n isDisabled: boolean;\n isInvalid: boolean | undefined;\n isRequired: boolean;\n label: string;\n leadingIcon: ReactNode;\n multiple: boolean;\n variant: FieldVariant;\n}) {\n const state = useContext(ComboBoxStateContext);\n const chosen = multiple && (state?.selectedItems.length ?? 0) > 0;\n return <FieldBox floatingLabel={floatingLabel}\n // React Aria's `TextField` hands its group the field's disabled and\n // invalid state through context; its `ComboBox` does not, so the box\n // is told outright or its label and its underline never turn.\n isDisabled={isDisabled} isInvalid={isInvalid} isPopulated={chosen ? true : undefined} isRequired={isRequired} label={label} leading={leadingIcon} ref={boxRef} trailing={TOGGLE} variant={variant}>\n {multiple ? <span className=\"xpr5407 xrvj5dj xuptkxw\">\n <ChosenValues />\n <FieldInput ref={inputRef} />\n </span> : <FieldInput ref={inputRef} />}\n </FieldBox>;\n}\n\n/**\n * The button that opens the list. It takes its press behaviour from the\n * combo box around it through React Aria's button context, and reads whether\n * the list is open from the combo box's state rather than from a render prop\n * — the whole field cannot be a render function, since React Aria builds its\n * collection by walking the children and a function is opaque to that walk.\n */\nfunction ComboToggle() {\n const state = useContext(ComboBoxStateContext);\n return <RACButton {...stylex.props(styles.toggle, focus.ring)}>\n <ChevronEndGlyph {...{\n 0: {\n className: \"x12w9bfk xxk0z11 xvy4d1p x1iffjtl xkzkux9 x11xpdln xpc4ca7\"\n },\n 1: {\n className: \"x12w9bfk xxk0z11 xvy4d1p xkzkux9 x11xpdln xpc4ca7 x9tu13d\"\n }\n }[!!(state?.isOpen === true) << 0]} />\n </RACButton>;\n}\n\n// The list's classes, from React Aria's render state: it grows from the\n// edge it is anchored by, as every anchored overlay does, so a list that\n// opens above the field grows upward.\nfunction listClassName(state: PopoverRenderProps) {\n return stylex.props(overlay.popup, styles.list, popupOrigin(state.placement)).className ?? '';\n}\nexport type { ComboBoxProps, ComboBoxSelectionMode };\nexport default ComboBox;"],"mappings":";;;;;;;;;;;;;;AA2DA,MAAMc,SAAS,oBAAC,aAAD,CAAY,CAAA;AAC3B,MAAMC,SAAS;CACbC,MAAM;EACJC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;EACPC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;CACT;CACAC,QAAQ;EACNC,QAAQ;EACRV,QAAQ;EACRW,QAAQ;EACRV,QAAQ;EACRW,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRd,QAAQ;EACRe,QAAQ;EACRC,QAAQ;EACRV,OAAO;CACT;AACF;;;;;;AAwEA,SAAAoB,eAAA;CAAA,MAAAC,IAAA9C,EAAA,CAAA;CAAA,IAAA+C;CAAA,IAAAD,EAAA,OAAAE,OAAAC,IAAA,2BAAA,GAAA;EACSF,KAAA,oBAAC,YAAD,EAAA,UACH,oBAACwC,eAAD,EAA4B,WAAA,0BAAyB,CAAA,EADvC,CAAA;EAEHzC,EAAA,KAAAC;CAAA,OAAAA,KAAAD,EAAA;CAAA,OAFRC;AAEQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCjB,SAAA1C,SAAA0C,IAAA;CAAA,MAAAD,IAAA9C,EAAA,EAAA;CAAyF,MAAA,EAAAoC,WAAAC,aAAAC,OAAAC,eAAAW,IAAAV,UAAAW,YAAAC,IAAAX,OAAAC,aAAAC,SAAAC,SAAAS,IAAA,GAAAC,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K;EAAAL,EAAA,KAAA4B;EAAA5B,EAAA,KAAAkB;EAAAlB,EAAA,KAAAL;EAAAK,EAAA,KAAAJ;EAAAI,EAAA,MAAAI;EAAAJ,EAAA,MAAAM;EAAAN,EAAA,MAAAF;EAAAE,EAAA,MAAAO;CAAA,OAAAA,KAAAP,EAAA;CAAA,OATNO;AASM;;;;;;;;AAUf,SAAA0B,cAAA;CAAA,MAAAjC,IAAA9C,EAAA,CAAA;CACE,MAAA4E,QAAc1E,WAAWE,oBAAoB;CAAE,IAAA2C;CAAA,IAAAD,EAAA,OAAAE,OAAAC,IAAA,2BAAA,GAAA;EACzBF,KAAA9C,MAAac,OAAMW,QAAShB,MAAKsE,IAAK;EAAClC,EAAA,KAAAC;CAAA,OAAAA,KAAAD,EAAA;CAAA,IAAAI;CAAA,IAAAJ,EAAA,OAAAE,OAAAC,IAAA,2BAAA,GAAA;EACpCC,KAAA;GAAA+B,GAClB,EAAAC,WACU,6DACb;GAACC,GACE,EAAAD,WACU,4DACb;EACF;EAACpC,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAPsB,MAAAM,KAAAF,GAOrB,CAAC,EAAE0B,OAAKQ,WAAa,SAAS;CAAE,IAAA/B;CAAA,IAAAP,EAAA,OAAAM,IAAA;EAR7BC,KAAA,oBAACqC,QAAD;GAAU,GAAK3C;GAClB,UAAA,oBAAC,iBAAD,EAAgB,GAAKK,GAOW,CAAA;EARnB,CAAA;EASHN,EAAA,KAAAM;EAAAN,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CAAA,OATPO;AASO;AAMhB,SAASkB,cAAcK,OAA2B;CAChD,OAAO3E,MAAaW,QAAQyE,OAAOtE,OAAOC,MAAMH,YAAY+D,MAAMU,SAAS,CAAC,CAAC,CAACJ,aAAa;AAC7F"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_c","stylex","useContext","useRef","ComboBoxStateContext","ComboBox","RACComboBox","fieldStyles","invalidFrom","useFieldValidationBehavior","focus","mergeStatefulStyles","overlay","popupOrigin","TOGGLE","styles","list","kWkggS","kaIpWk","kzqmXN","kskxy","ks0D6T","k7Eaqz","kORKVm","$$css","toggle","kGNEyG","kZKoxP","kMzoRj","kB7OPa","kMwMTN","kkrTdU","k1xSpc","kjj79g","kmVPX3","allowsEmptyCollection","container","description","error","floatingLabel","inputRef","label","leadingIcon","options","variant","ChosenValues","$","t0","Symbol","for","t1","t2","isDisabled","t3","t4","props","undefined","validationBehavior","boxRef","T0","t5","t6","root","t7","t8","isRequired","t9","selectionMode","t10","t11","t12","t13","listClassName","t14","ComboBoxBox","isInvalid","multiple","state","selectedItems","length","ComboToggle","ring","0","className","1","isOpen","popup","placement","RACComboBoxValue","ListBox","RACPopover","RACButton"],"sources":["../../../src/components/combo-box/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactElement, ReactNode, Ref, RefAttributes, RefObject } from 'react';\nimport type { PopoverRenderProps, ComboBoxProps as RACComboBoxProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useContext, useRef } from 'react';\nimport { ComboBoxStateContext, Button as RACButton, ComboBox as RACComboBox, ComboBoxValue as RACComboBoxValue, Popover as RACPopover } from 'react-aria-components';\nimport type { FieldVariant } from '../../field';\nimport { FieldBox, FieldInput, FieldMessage, FieldValue } from '../../field';\nimport { fieldStyles, invalidFrom, useFieldValidationBehavior } from '../../field/root';\nimport { ChevronEndGlyph } from '../../glyphs';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport { overlay, popupOrigin } from '../../styles/overlay';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, radii, spacing } from '../../tokens/design.tokens.stylex';\nimport ListBox from '../list-box';\n\n// The text fields page's autocomplete text field: a text field that filters a\n// list as it is typed. Everything above the list is the field chrome in\n// `src/field` — the same box, label, supporting line and error treatment\n// every other field draws — and the list is ListBox on the shared overlay\n// surface, positioned and sized against the box exactly as Select's is.\n//\n// It is Select's shape with two differences.\n//\n// The control is a real input, so the box is not a press target — typing has\n// to reach the input — and only the chevron at the end opens the list. That\n// is what the page draws too: an autocomplete text field is a text field,\n// with a button on it.\n//\n// And the field is an element tree rather than a function of React Aria's\n// render state, which every other component here writes. React Aria builds a\n// combo box's collection by walking its children for options, and a function\n// is opaque to that walk: with one, the collection is empty until the list\n// has been opened, so a `defaultSelectedKey` resolves to no text and the\n// field starts blank. What needed the render state — whether the list is\n// open — reads the combo box's own state from context instead.\n//\n// Two more things are this component's own.\n//\n// **Filtering is React Aria's, and stays theirs.** `defaultFilter` takes a\n// predicate, and the package re-exports `useFilter` for a locale-aware one;\n// `items` with `useAsyncList` is how a list that is fetched rather than\n// listed gets in. None of that is wrapped, because a combo box's whole job\n// is which options it shows and a wrapper would be a second place to decide\n// it.\n//\n// **A value that is not in the list is allowed or refused, not corrected.**\n// `allowsCustomValue` is React Aria's, and with it off the input reverts to\n// the last chosen option on blur rather than keeping text that means nothing.\n//\n// **A search that matches nothing keeps the list open, saying so.** React\n// Aria closes a list its filter has emptied unless `allowsEmptyCollection`\n// says otherwise, and with it closed the field held its text with no list\n// and no word about why — a list that broke and one with no matches looked\n// the same. So the default here is `true`, and the ListBox inside draws the\n// empty state every ListBox does, a muted \"No results\" row in the\n// I18nProvider's locale, as it does under an Autocomplete. `false` is the\n// call site's for a field that would rather close.\n//\n// Choosing more than one is `selectionMode=\"multiple\"`, which draws the\n// chosen options before the input on its line, through React Aria's\n// `ComboBoxValue`, with the label floated over them. For a field that draws\n// each of them as a removable chip, the coverage plan has TokenField.\n\n// Hoisted so it is not a new element on every render, which is what\n// react-perf's jsx-no-jsx-as-prop is after.\nconst TOGGLE = <ComboToggle />;\nconst styles = {\n list: {\n kWkggS: \"x1vnz5z6\",\n kaIpWk: \"x1tfhd1\",\n kzqmXN: \"xlvufjm\",\n kskxy: \"xedcshv\",\n ks0D6T: \"x1x1rfll\",\n k7Eaqz: \"xeuugli\",\n kORKVm: \"x1odjw0f\",\n $$css: true\n },\n toggle: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"xxk0z11\",\n kaIpWk: \"x16fbrrb\",\n kMzoRj: \"xc342km\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x1heor9g\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n kzqmXN: \"xvy4d1p\",\n kjj79g: \"xl56j7k\",\n kmVPX3: \"x1717udv\",\n $$css: true\n }\n};\ntype ComboBoxProps<T extends object = object, M extends ComboBoxSelectionMode = 'single'> = {\n /**\n * Whether the list stays open when a search leaves nothing in it, showing\n * the ListBox's \"No results\" row, rather than closing.\n * @default true\n */\n allowsEmptyCollection?: boolean;\n /**\n * Where to portal the list. Defaults to the container of the `ThemeScope`\n * around it, which keeps the list 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 list\n * renders outside and keeps the page's tokens.\n */\n container?: Element;\n /**\n * A hint shown under the field. Replaced by `error` when there is one, so\n * the two never stack.\n */\n description?: string;\n /**\n * The problem with the current value, in words. Its presence is what puts\n * the field in its error state — the message, the red underline, and\n * `aria-invalid` all follow from it.\n *\n * Outside a `Form` the message line arrives with the message, so the\n * field grows when this does and moves what is under it. A `Form` holds\n * that space from the start; so does a permanent `description`.\n */\n error?: string;\n /**\n * Whether the label sits in the empty box and floats to the top once the\n * field is focused or holds a value. `false` keeps it small at the top in\n * every state.\n * @default true\n */\n floatingLabel?: boolean;\n /**\n * A ref to the field's own `<input>`, which is the element a call site moves\n * focus to — after a server's error, say. `ref` is the field as a whole.\n */\n inputRef?: Ref<HTMLInputElement>;\n /**\n * What the field is for. Required rather than optional: a combo box with\n * no label is a box a screen reader cannot name.\n */\n label: string;\n /**\n * An icon at the start of the box, before the label and the value: the\n * page's 24dp leading icon, in the muted role. An icon drawn in `em` takes\n * that size from the slot.\n */\n leadingIcon?: ReactNode;\n /**\n * The options. `ListBox.Item` for each, and `ListBox.Section` to group\n * them — the list inside is a ListBox, and takes everything one does. With\n * `items` or `defaultItems`, a function from an item to its option, which\n * React Aria calls for each item the list shows.\n */\n options?: ((item: T) => ReactElement) | ReactNode;\n /**\n * The filled box, or the outlined one, as the text fields page draws them.\n * @default 'filled'\n */\n variant?: FieldVariant;\n} & Omit<RACComboBoxProps<T, M>, 'allowsEmptyCollection' | 'children' | 'defaultSelectedKey' | 'isInvalid' | 'onSelectionChange' | 'selectedKey' | 'validationBehavior'>;\n\n// React Aria's combo box takes its own two-value selection mode rather than\n// the collection-wide one, which also has `none`; that type is local to its\n// module, so the two values are named again here.\ntype ComboBoxSelectionMode = 'multiple' | 'single';\n\n/**\n * The chosen options, drawn before the input on its line when more than one\n * may be chosen. The chrome's `FieldValue` is the styled element and React\n * Aria's `ComboBoxValue` sits inside it, as it does in Select.\n */\nfunction ChosenValues() {\n return <FieldValue>\n <RACComboBoxValue className=\"xb3r6kr xlyipyv xuxw1ft\" />\n </FieldValue>;\n}\n\n/**\n * A labelled text field that filters a list as it is typed. Its value is\n * React Aria's: pass `value` with `onChange` to control which option is\n * chosen, `inputValue` with `onInputChange` to control the text, or the\n * `default` forms of either to let it keep its own. React Aria's older\n * `selectedKey` names are deprecated and are left out of this component's\n * props rather than passed through.\n *\n * ```tsx\n * <ComboBox\n * label=\"Label\"\n * options={\n * <>\n * <ListBox.Item id=\"first\">First item</ListBox.Item>\n * <ListBox.Item id=\"second\">Second item</ListBox.Item>\n * </>\n * }\n * />\n * ```\n *\n * Filtering is React Aria's: `defaultFilter` takes a predicate, `useFilter`\n * is re-exported for a locale-aware one, and `items` with `useAsyncList`\n * feeds a list that is fetched rather than listed. `allowsCustomValue` lets\n * the field keep text that matches nothing. A search that matches nothing\n * keeps the list open on a \"No results\" row; `allowsEmptyCollection={false}`\n * closes it instead.\n *\n * The box, label, input, supporting line and error are the field chrome in\n * `src/field`, shared with every other field; the list is ListBox on the\n * overlay surface every anchored panel here draws.\n *\n * The call site's `className` and `style` land on the field as a whole,\n * which is the element a layout positions.\n */\nfunction ComboBox<T extends object = object, M extends ComboBoxSelectionMode = 'single'>({\n allowsEmptyCollection = true,\n container,\n description,\n error,\n floatingLabel = true,\n inputRef,\n isDisabled = false,\n label,\n leadingIcon,\n options,\n variant = 'filled',\n ...props\n}: ComboBoxProps<T, M> & RefAttributes<HTMLDivElement>) {\n const validationBehavior = useFieldValidationBehavior();\n // What the list is anchored to and takes its width from: the box, not the\n // button inside it, which is a 24dp icon.\n const boxRef = useRef<HTMLDivElement>(null);\n return <RACComboBox<T, M> allowsEmptyCollection={allowsEmptyCollection} isDisabled={isDisabled} isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...mergeStatefulStyles(stylex.props(fieldStyles.root), props)}>\n <ComboBoxBox boxRef={boxRef} floatingLabel={floatingLabel} inputRef={inputRef} isDisabled={isDisabled} isInvalid={invalidFrom(error)} isRequired={props.isRequired ?? false} label={label} leadingIcon={leadingIcon} multiple={props.selectionMode === 'multiple'} variant={variant} />\n <FieldMessage description={description} error={error} />\n <RACPopover className={listClassName} triggerRef={boxRef}\n // oxlint-disable-next-line typescript/no-deprecated -- its replacement, UNSAFE_PortalProvider, is not exported by react-aria-components\n UNSTABLE_portalContainer={container}>\n <ListBox<T>>{options}</ListBox>\n </RACPopover>\n </RACComboBox>;\n}\n\n/**\n * The box and what it holds. Its own component so it can read React Aria's\n * state for what is chosen: with more than one option allowed, the input is\n * empty while options are chosen, so it cannot be what says the field holds\n * something. The box is told instead, and the label floats over the chosen\n * options rather than resting on them. Otherwise the box reads the input, as\n * it does for one option, which is what floats the label on typed text.\n */\nfunction ComboBoxBox({\n boxRef,\n floatingLabel,\n inputRef,\n isDisabled,\n isInvalid,\n isRequired,\n label,\n leadingIcon,\n multiple,\n variant\n}: {\n boxRef: RefObject<HTMLDivElement | null>;\n floatingLabel: boolean;\n inputRef: Ref<HTMLInputElement> | undefined;\n isDisabled: boolean;\n isInvalid: boolean | undefined;\n isRequired: boolean;\n label: string;\n leadingIcon: ReactNode;\n multiple: boolean;\n variant: FieldVariant;\n}) {\n const state = useContext(ComboBoxStateContext);\n const chosen = multiple && (state?.selectedItems.length ?? 0) > 0;\n return <FieldBox floatingLabel={floatingLabel}\n // React Aria's `TextField` hands its group the field's disabled and\n // invalid state through context; its `ComboBox` does not, so the box\n // is told outright or its label and its underline never turn.\n isDisabled={isDisabled} isInvalid={isInvalid} isPopulated={chosen ? true : undefined} isRequired={isRequired} label={label} leading={leadingIcon} ref={boxRef} trailing={TOGGLE} variant={variant}>\n {multiple ? <span className=\"xpr5407 xrvj5dj xuptkxw\">\n <ChosenValues />\n <FieldInput ref={inputRef} />\n </span> : <FieldInput ref={inputRef} />}\n </FieldBox>;\n}\n\n/**\n * The button that opens the list. It takes its press behaviour from the\n * combo box around it through React Aria's button context, and reads whether\n * the list is open from the combo box's state rather than from a render prop\n * — the whole field cannot be a render function, since React Aria builds its\n * collection by walking the children and a function is opaque to that walk.\n */\nfunction ComboToggle() {\n const state = useContext(ComboBoxStateContext);\n return <RACButton {...stylex.props(styles.toggle, focus.ring)}>\n <ChevronEndGlyph {...{\n 0: {\n className: \"x12w9bfk xxk0z11 xvy4d1p x1iffjtl xkzkux9 x11xpdln xpc4ca7\"\n },\n 1: {\n className: \"x12w9bfk xxk0z11 xvy4d1p xkzkux9 x11xpdln xpc4ca7 x9tu13d\"\n }\n }[!!(state?.isOpen === true) << 0]} />\n </RACButton>;\n}\n\n// The list's classes, from React Aria's render state: it grows from the\n// edge it is anchored by, as every anchored overlay does, so a list that\n// opens above the field grows upward.\nfunction listClassName(state: PopoverRenderProps) {\n return stylex.props(overlay.popup, styles.list, popupOrigin(state.placement)).className ?? '';\n}\nexport type { ComboBoxProps, ComboBoxSelectionMode };\nexport default ComboBox;"],"mappings":";;;;;;;;;;;;;;AAoEA,MAAMc,SAAS,oBAAC,aAAD,CAAY,CAAA;AAC3B,MAAMC,SAAS;CACbC,MAAM;EACJC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC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,EAAA,OAAAE,OAAAC,IAAA,2BAAA,GAAA;EACzBF,KAAA9C,MAAac,OAAMU,QAASf,MAAKuE,IAAK;EAACnC,EAAA,KAAAC;CAAA,OAAAA,KAAAD,EAAA;CAAA,IAAAI;CAAA,IAAAJ,EAAA,OAAAE,OAAAC,IAAA,2BAAA,GAAA;EACpCC,KAAA;GAAAgC,GAClB,EAAAC,WACU,6DACb;GAACC,GACE,EAAAD,WACU,4DACb;EACF;EAACrC,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAPsB,MAAAK,KAAAD,GAOrB,CAAC,EAAE2B,OAAKQ,WAAa,SAAS;CAAE,IAAAhC;CAAA,IAAAP,EAAA,OAAAK,IAAA;EAR7BE,KAAA,oBAACsC,QAAD;GAAU,GAAK5C;GAClB,UAAA,oBAAC,iBAAD,EAAgB,GAAKI,GAOW,CAAA;EARnB,CAAA;EASHL,EAAA,KAAAK;EAAAL,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CAAA,OATPO;AASO;AAMhB,SAASmB,cAAcK,OAA2B;CAChD,OAAO5E,MAAaW,QAAQ0E,OAAOvE,OAAOC,MAAMH,YAAYgE,MAAMU,SAAS,CAAC,CAAC,CAACJ,aAAa;AAC7F"}
|
|
@@ -101,6 +101,7 @@ function CopyField(t0) {
|
|
|
101
101
|
className: "x139gbkf x1iyjqo2 x1b35g6e xdb2kus x9d6959 xwth0xh xybisxh xeuugli x6mezaz xvrbanz x126k92a",
|
|
102
102
|
children: /* @__PURE__ */ jsx("code", {
|
|
103
103
|
dir: "ltr",
|
|
104
|
+
lang: "en",
|
|
104
105
|
ref: code,
|
|
105
106
|
className: "x9f619 xbppi91 x1qlqyl8 xj0a0fe x4ej8vm",
|
|
106
107
|
children: value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_c","useEffect","useId","useRef","useState","useMessages","mergeStyles","COPIED_RESET_MS","copiedLabel","copyLabel","label","onCopied","value","onCopyFailed","error","selectedLabel","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","selection","window","getSelection","range","document","createRange","selectNodeContents","removeAllRanges","addRange","execCommand"],"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;"],"mappings":";;;;;;;;AAeA,MAAMO,kBAAkB;;;;;;;;;;;;;AAsFxB,SAAAS,UAAAC,IAAA;CAAA,MAAAC,IAAAlB,EAAA,EAAA;CAAmB,MAAA,EAAAQ,aAAAW,iBAAAV,WAAAW,eAAAV,OAAAC,UAAAE,cAAAE,eAAAM,mBAAAT,OAAA,GAAAU,UAAA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AAAyD;EAAAzD,EAAA,MAAAsC;EAAAtC,EAAA,MAAA2C;EAAA3C,EAAA,MAAA0D;CAAA,OAAAA,MAAA1D,EAAA;CAAA,OA3CD0D;AA2CC;;;;;;;;;AAWV,SAASlB,aAAa/C,UAAiDC,OAAe;CACpF,IAAID,aAAaqB,KAAAA,GACf;CAEF,IAAI;EACFrB,SAASC,KAAK;CAChB,SAASiE,QAAQ;EACfC,qBAAqB;GACnB,MAAMD;EACR,CAAC;CACH;AACF;;;;;;;AAQA,SAASpB,cAAcsB,SAA6B;CAClD,MAAMC,YAAYC,OAAOC,aAAa;CACtC,IAAIH,YAAY,QAAQC,cAAc,MACpC,OAAO;CAET,MAAMG,QAAQC,SAASC,YAAY;CACnCF,MAAMG,mBAAmBP,OAAO;CAChCC,UAAUO,gBAAgB;CAC1BP,UAAUQ,SAASL,KAAK;CACxB,IAAI;EAEF,OAAOC,SAASK,YAAY,MAAM;CACpC,QAAQ;EACN,OAAO;CACT;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_c","useEffect","useId","useRef","useState","useMessages","mergeStyles","COPIED_RESET_MS","copiedLabel","copyLabel","label","onCopied","value","onCopyFailed","error","selectedLabel","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","selection","window","getSelection","range","document","createRange","selectNodeContents","removeAllRanges","addRange","execCommand"],"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\" lang=\"en\" 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;"],"mappings":";;;;;;;;AAeA,MAAMO,kBAAkB;;;;;;;;;;;;;AAsFxB,SAAAS,UAAAC,IAAA;CAAA,MAAAC,IAAAlB,EAAA,EAAA;CAAmB,MAAA,EAAAQ,aAAAW,iBAAAV,WAAAW,eAAAV,OAAAC,UAAAE,cAAAE,eAAAM,mBAAAT,OAAA,GAAAU,UAAAL;CAUjB,MAAAM,WAAiBlB,YAAY;CAC7B,MAAAG,cAAoBW,mBAAmBI,SAAQC;CAC/C,MAAAf,YAAkBW,iBAAiBG,SAAQE;CAC3C,MAAAV,gBAAsBM,qBAAqBE,SAAQG;CAQnD,MAAA,CAAAD,MAAAE,WAAwBvB,SAIrB,IAAI;CACP,MAAAwB,QAA8CH,MAAII,SAAWjB,QAAQa,KAAIK,OAA3B;CAC9C,MAAAN,SAAeI,UAAU;CACzB,MAAAG,QAAc5B,OAAkD6B,KAAAA,CAAS;CACzE,MAAAC,OAAa9B,OAAoB,IAAI;CACrC,MAAA+B,cAAoBhC,MAAM;CAC1B,MAAAiC,SAAeb,MAAKc,MAALF;CACf,MAAAG,SAAenC,MAAM;CACrB,MAAAoC,WAAiBpC,MAAM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