@kanso-labs/kanso-ui 0.26.2 → 0.26.3
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/calendar/index.js +1 -1
- package/dist/calendar/index.js.map +1 -1
- package/dist/calendar/months.js.map +1 -1
- package/dist/calendar/styles.js.map +1 -1
- package/dist/chip/styles.js.map +1 -1
- package/dist/components/app-bar/index.js +148 -40
- package/dist/components/app-bar/index.js.map +1 -1
- package/dist/components/autocomplete/index.js +1 -1
- package/dist/components/autocomplete/index.js.map +1 -1
- package/dist/components/avatar/index.js +46 -14
- package/dist/components/avatar/index.js.map +1 -1
- package/dist/components/breadcrumbs/index.js +1 -1
- package/dist/components/breadcrumbs/index.js.map +1 -1
- package/dist/components/button/index.js +67 -18
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/calendar/index.js +1 -1
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/card/index.js +71 -19
- package/dist/components/card/index.js.map +1 -1
- package/dist/components/checkbox/index.js +1 -1
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/checkbox-group/index.js +1 -1
- package/dist/components/checkbox-group/index.js.map +1 -1
- package/dist/components/chip/index.js +1 -1
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/chip-group/index.js +118 -28
- package/dist/components/chip-group/index.js.map +1 -1
- package/dist/components/code/index.js.map +1 -1
- package/dist/components/color-area/index.js +66 -12
- package/dist/components/color-area/index.js.map +1 -1
- package/dist/components/color-field/index.js +61 -12
- package/dist/components/color-field/index.js.map +1 -1
- package/dist/components/color-picker/index.js +146 -43
- package/dist/components/color-picker/index.js.map +1 -1
- package/dist/components/color-slider/index.js +116 -21
- package/dist/components/color-slider/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 +1 -1
- package/dist/components/color-swatch-picker/index.js.map +1 -1
- package/dist/components/color-wheel/index.js +75 -11
- package/dist/components/color-wheel/index.js.map +1 -1
- package/dist/components/combo-box/index.js +113 -32
- package/dist/components/combo-box/index.js.map +1 -1
- package/dist/components/container/index.js +53 -10
- package/dist/components/container/index.js.map +1 -1
- package/dist/components/copy-field/index.js +95 -40
- package/dist/components/copy-field/index.js.map +1 -1
- package/dist/components/currency/index.js +68 -11
- package/dist/components/currency/index.js.map +1 -1
- package/dist/components/date-field/index.js +64 -15
- package/dist/components/date-field/index.js.map +1 -1
- package/dist/components/date-picker/index.js +121 -38
- package/dist/components/date-picker/index.js.map +1 -1
- package/dist/components/date-range-picker/index.js +154 -52
- package/dist/components/date-range-picker/index.js.map +1 -1
- package/dist/components/dialog/index.js +87 -19
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/disclosure/index.js +43 -10
- package/dist/components/disclosure/index.js.map +1 -1
- package/dist/components/disclosure-group/index.js +49 -6
- package/dist/components/disclosure-group/index.js.map +1 -1
- package/dist/components/drop-zone/index.js +1 -1
- package/dist/components/drop-zone/index.js.map +1 -1
- package/dist/components/drop-zone/styles.js.map +1 -1
- package/dist/components/feed/index.js +52 -9
- package/dist/components/feed/index.js.map +1 -1
- package/dist/components/form/index.js +39 -6
- package/dist/components/form/index.js.map +1 -1
- package/dist/components/icon-button/index.js +89 -29
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/keycap/index.js.map +1 -1
- package/dist/components/link/index.js +52 -11
- package/dist/components/link/index.js.map +1 -1
- package/dist/components/list/index.js +96 -16
- package/dist/components/list/index.js.map +1 -1
- package/dist/components/list-box/index.js +45 -8
- package/dist/components/list-box/index.js.map +1 -1
- package/dist/components/list-detail/index.js +99 -20
- package/dist/components/list-detail/index.js.map +1 -1
- package/dist/components/list-item/index.js +42 -15
- package/dist/components/list-item/index.js.map +1 -1
- package/dist/components/menu/index.js +139 -23
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/meter/index.js +68 -8
- package/dist/components/meter/index.js.map +1 -1
- package/dist/components/navigation-tree/index.js +1 -1
- package/dist/components/navigation-tree/index.js.map +1 -1
- package/dist/components/number-field/index.js +135 -47
- package/dist/components/number-field/index.js.map +1 -1
- package/dist/components/popover/index.js +226 -49
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/product-icon/index.js +50 -17
- package/dist/components/product-icon/index.js.map +1 -1
- package/dist/components/progress-indicator/index.js +92 -9
- package/dist/components/progress-indicator/index.js.map +1 -1
- package/dist/components/radio-group/index.js +44 -10
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/range-calendar/index.js +1 -1
- package/dist/components/range-calendar/index.js.map +1 -1
- package/dist/components/search-field/index.js +44 -9
- package/dist/components/search-field/index.js.map +1 -1
- package/dist/components/segmented-button/index.js +111 -19
- package/dist/components/segmented-button/index.js.map +1 -1
- package/dist/components/select/index.js +48 -10
- package/dist/components/select/index.js.map +1 -1
- package/dist/components/separator/index.js +21 -6
- package/dist/components/separator/index.js.map +1 -1
- package/dist/components/sheet/index.js +87 -19
- package/dist/components/sheet/index.js.map +1 -1
- package/dist/components/slider/index.js +90 -18
- package/dist/components/slider/index.js.map +1 -1
- package/dist/components/snackbar/index.js +1 -1
- package/dist/components/snackbar/index.js.map +1 -1
- package/dist/components/stack/index.js +54 -9
- package/dist/components/stack/index.js.map +1 -1
- package/dist/components/supporting-pane/index.js +91 -20
- package/dist/components/supporting-pane/index.js.map +1 -1
- package/dist/components/switch/index.js +57 -12
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/table/index.js +229 -46
- package/dist/components/table/index.js.map +1 -1
- package/dist/components/tabs/index.js +1 -1
- package/dist/components/tabs/index.js.map +1 -1
- package/dist/components/tag/index.js +53 -10
- package/dist/components/tag/index.js.map +1 -1
- package/dist/components/text/index.js +54 -9
- package/dist/components/text/index.js.map +1 -1
- package/dist/components/text-area/index.js +70 -15
- package/dist/components/text-area/index.js.map +1 -1
- package/dist/components/text-field/index.js +73 -16
- package/dist/components/text-field/index.js.map +1 -1
- package/dist/components/time-field/index.js +64 -15
- package/dist/components/time-field/index.js.map +1 -1
- package/dist/components/token-field/index.js +133 -18
- package/dist/components/token-field/index.js.map +1 -1
- package/dist/components/toolbar/index.js +68 -11
- package/dist/components/toolbar/index.js.map +1 -1
- package/dist/components/tooltip/index.js +87 -11
- package/dist/components/tooltip/index.js.map +1 -1
- package/dist/components/tree/index.js +96 -16
- package/dist/components/tree/index.js.map +1 -1
- package/dist/drag/hooks.js +1 -1
- package/dist/drag/hooks.js.map +1 -1
- package/dist/drag/index.js +1 -1
- package/dist/drag/index.js.map +1 -1
- package/dist/drag/styles.js.map +1 -1
- package/dist/field/index.js +338 -96
- package/dist/field/index.js.map +1 -1
- package/dist/field/root.js.map +1 -1
- package/dist/glyphs/index.js +1 -1
- package/dist/glyphs/index.js.map +1 -1
- package/dist/hooks/useImageLoadingStatus.js +1 -1
- package/dist/hooks/useImageLoadingStatus.js.map +1 -1
- package/dist/hooks/useRipple.js +1 -1
- package/dist/hooks/useRipple.js.map +1 -1
- package/dist/indicator/index.js +1 -1
- package/dist/indicator/index.js.map +1 -1
- package/dist/indicator/styles.js.map +1 -1
- package/dist/layout.js.map +1 -1
- package/dist/render/aria.js.map +1 -1
- package/dist/render/useRender.js +66 -21
- package/dist/render/useRender.js.map +1 -1
- package/dist/row/index.js +97 -23
- package/dist/row/index.js.map +1 -1
- package/dist/row/styles.js.map +1 -1
- package/dist/segments/index.js.map +1 -1
- package/dist/segments/styles.js.map +1 -1
- package/dist/styles/chequer.js.map +1 -1
- package/dist/styles/color.js.map +1 -1
- package/dist/styles/merge.js.map +1 -1
- package/dist/styles/overlay.js.map +1 -1
- package/dist/styles/picker.js.map +1 -1
- package/dist/styles/ripple.js.map +1 -1
- package/dist/tokens/design.tokens.stylex.js.map +1 -1
- package/dist/tokens/values.js.map +1 -1
- package/package.json +8 -6
|
@@ -4,6 +4,7 @@ import { fieldStyles, invalidFrom, useFieldValidationBehavior } from "../../fiel
|
|
|
4
4
|
import { FieldBox, FieldMessage, FieldValue } from "../../field/index.js";
|
|
5
5
|
import { segmentStyles } from "../../segments/styles.js";
|
|
6
6
|
import { renderSegment } from "../../segments/index.js";
|
|
7
|
+
import { c } from "react/compiler-runtime";
|
|
7
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
9
|
import { DateInput, TimeField } from "react-aria-components";
|
|
9
10
|
//#region src/components/time-field/index.tsx
|
|
@@ -26,30 +27,78 @@ import { DateInput, TimeField } from "react-aria-components";
|
|
|
26
27
|
* field chrome in `src/field`. The call site's `className` and `style` land
|
|
27
28
|
* on the field as a whole, which is the element a layout positions.
|
|
28
29
|
*/
|
|
29
|
-
function TimeField$1(
|
|
30
|
+
function TimeField$1(t0) {
|
|
31
|
+
const $ = c(21);
|
|
32
|
+
const { description, error, floatingLabel: t1, isDisabled: t2, label, leadingIcon, trailingIcon, variant: t3, ...props$1 } = t0;
|
|
33
|
+
const floatingLabel = t1 === void 0 ? true : t1;
|
|
34
|
+
const isDisabled = t2 === void 0 ? false : t2;
|
|
35
|
+
const variant = t3 === void 0 ? "filled" : t3;
|
|
30
36
|
const validationBehavior = useFieldValidationBehavior();
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
const T0 = TimeField;
|
|
38
|
+
let t4;
|
|
39
|
+
if ($[0] !== error) {
|
|
40
|
+
t4 = invalidFrom(error);
|
|
41
|
+
$[0] = error;
|
|
42
|
+
$[1] = t4;
|
|
43
|
+
} else t4 = $[1];
|
|
44
|
+
const t5 = mergeStatefulStyles(props(fieldStyles.root), props$1);
|
|
45
|
+
let t6;
|
|
46
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
47
|
+
t6 = /* @__PURE__ */ jsx(FieldValue, { children: /* @__PURE__ */ jsx(DateInput, {
|
|
48
|
+
...props(segmentStyles.input),
|
|
49
|
+
children: renderSegment
|
|
50
|
+
}) });
|
|
51
|
+
$[2] = t6;
|
|
52
|
+
} else t6 = $[2];
|
|
53
|
+
let t7;
|
|
54
|
+
if ($[3] !== floatingLabel || $[4] !== label || $[5] !== leadingIcon || $[6] !== trailingIcon || $[7] !== variant) {
|
|
55
|
+
t7 = /* @__PURE__ */ jsx(FieldBox, {
|
|
38
56
|
floatingLabel,
|
|
39
57
|
isPopulated: true,
|
|
40
58
|
label,
|
|
41
59
|
leading: leadingIcon,
|
|
42
60
|
trailing: trailingIcon,
|
|
43
61
|
variant,
|
|
44
|
-
children:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
62
|
+
children: t6
|
|
63
|
+
});
|
|
64
|
+
$[3] = floatingLabel;
|
|
65
|
+
$[4] = label;
|
|
66
|
+
$[5] = leadingIcon;
|
|
67
|
+
$[6] = trailingIcon;
|
|
68
|
+
$[7] = variant;
|
|
69
|
+
$[8] = t7;
|
|
70
|
+
} else t7 = $[8];
|
|
71
|
+
let t8;
|
|
72
|
+
if ($[9] !== description || $[10] !== error) {
|
|
73
|
+
t8 = /* @__PURE__ */ jsx(FieldMessage, {
|
|
49
74
|
description,
|
|
50
75
|
error
|
|
51
|
-
})
|
|
52
|
-
|
|
76
|
+
});
|
|
77
|
+
$[9] = description;
|
|
78
|
+
$[10] = error;
|
|
79
|
+
$[11] = t8;
|
|
80
|
+
} else t8 = $[11];
|
|
81
|
+
let t9;
|
|
82
|
+
if ($[12] !== T0 || $[13] !== isDisabled || $[14] !== props$1 || $[15] !== t4 || $[16] !== t5 || $[17] !== t7 || $[18] !== t8 || $[19] !== validationBehavior) {
|
|
83
|
+
t9 = /* @__PURE__ */ jsxs(T0, {
|
|
84
|
+
isDisabled,
|
|
85
|
+
isInvalid: t4,
|
|
86
|
+
validationBehavior,
|
|
87
|
+
...props$1,
|
|
88
|
+
...t5,
|
|
89
|
+
children: [t7, t8]
|
|
90
|
+
});
|
|
91
|
+
$[12] = T0;
|
|
92
|
+
$[13] = isDisabled;
|
|
93
|
+
$[14] = props$1;
|
|
94
|
+
$[15] = t4;
|
|
95
|
+
$[16] = t5;
|
|
96
|
+
$[17] = t7;
|
|
97
|
+
$[18] = t8;
|
|
98
|
+
$[19] = validationBehavior;
|
|
99
|
+
$[20] = t9;
|
|
100
|
+
} else t9 = $[20];
|
|
101
|
+
return t9;
|
|
53
102
|
}
|
|
54
103
|
//#endregion
|
|
55
104
|
export { TimeField$1 as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/time-field/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { TimeFieldProps as RACTimeFieldProps, TimeValue } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { DateInput as RACDateInput, TimeField as RACTimeField } from 'react-aria-components';\nimport { FieldBox, FieldMessage, FieldValue } from '../../field';\nimport { fieldStyles, invalidFrom, useFieldValidationBehavior } from '../../field/root';\nimport { renderSegment } from '../../segments';\nimport { segmentStyles } from '../../segments/styles';\nimport { mergeStatefulStyles } from '../../styles/merge';\n\n// A time typed a segment at a time. Every part of it is DateField's, from\n// `src/segments` — the segment treatment, the muted placeholder, the filled\n// focus and the punctuation between — so a time on a form and a date on the\n// same form cannot come apart.\n//\n// What differs is the value it holds and nothing else. The time pickers page\n// gives its input the text field's own box, which is what the shared field\n// chrome already draws, so there is no measurement here that the date field's\n// comment does not already name.\n//\n// **Twelve or twenty-four hours is the reader's locale, not a prop.** React\n// Aria decides from the locale whether there is a day-period segment at all,\n// so a field under `I18nProvider` with `en-GB` shows a 24-hour clock and the\n// same field under `en-US` shows AM and PM. Nothing here overrides it, and\n// `hourCycle` is React Aria's own for a page that has to.\n\ntype TimeFieldProps<T extends TimeValue> = Omit<RACTimeFieldProps<T>, 'children' | 'className' | 'style'> & {\n /** A function may compute the class from the field's render state. */\n className?: RACTimeFieldProps<T>['className'];\n /** Supporting text under the field. */\n description?: string;\n /** The message shown instead of the description, which also marks the field invalid. */\n error?: string;\n /**\n * Whether the label floats into the box's top once the field holds a\n * value, rather than sitting above it.\n * @default true\n */\n floatingLabel?: boolean;\n /** What the field is for. Always rendered; never a placeholder. */\n label: string;\n /** An icon at the box's leading end. */\n leadingIcon?: ReactNode;\n /** A function may compute the style from the field's render state. */\n style?: RACTimeFieldProps<T>['style'];\n /** An icon at the box's trailing end. */\n trailingIcon?: ReactNode;\n /**\n * Which of the text fields page's two boxes to draw.\n * @default 'filled'\n */\n variant?: 'filled' | 'outlined';\n};\n\n/**\n * A time typed rather than picked: one segment per part, each its own focus\n * stop. The value is React Aria's — pass `value` with `onChange` to control\n * it, or `defaultValue` — as a `Time` from this package's `./date` subpath.\n *\n * ```tsx\n * import { Time } from '@kanso-labs/kanso-ui/date'\n *\n * <TimeField defaultValue={new Time(9, 30)} label=\"Label\" />\n * ```\n *\n * Whether it shows a twelve or twenty-four hour clock is the reader's\n * locale, through React Aria's `I18nProvider`. `granularity` takes it down\n * to seconds, and `minValue` and `maxValue` bound what may be typed.\n *\n * The segments are `DateField`'s, and the box, label and message are the\n * field chrome in `src/field`. The call site's `className` and `style` land\n * on the field as a whole, which is the element a layout positions.\n */\nfunction TimeField<T extends TimeValue>({\n description,\n error,\n floatingLabel = true,\n isDisabled = false,\n label,\n leadingIcon,\n trailingIcon,\n variant = 'filled',\n ...props\n}: TimeFieldProps<T>) {\n const validationBehavior = useFieldValidationBehavior();\n return <RACTimeField<T> isDisabled={isDisabled} isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...mergeStatefulStyles(stylex.props(fieldStyles.root), props)}>\n <FieldBox floatingLabel={floatingLabel}\n // Always populated, for the reason DateField's own comment gives: the\n // box reads an `<input>` to decide, and a segmented field has none —\n // its segments hold the value's line from the first render.\n isPopulated label={label} leading={leadingIcon} trailing={trailingIcon} variant={variant}>\n <FieldValue>\n <RACDateInput {...stylex.props(segmentStyles.input)}>\n {renderSegment}\n </RACDateInput>\n </FieldValue>\n </FieldBox>\n <FieldMessage description={description} error={error} />\n </RACTimeField>;\n}\nexport type { TimeFieldProps };\nexport default TimeField;"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["ReactNode","TimeFieldProps","RACTimeFieldProps","TimeValue","stylex","DateInput","RACDateInput","TimeField","RACTimeField","FieldBox","FieldMessage","FieldValue","fieldStyles","invalidFrom","useFieldValidationBehavior","renderSegment","segmentStyles","mergeStatefulStyles","Omit","T","className","description","error","floatingLabel","label","leadingIcon","style","trailingIcon","variant","t0","$","_c","t1","isDisabled","t2","t3","props","undefined","validationBehavior","T0","t4","t5","root","t6","Symbol","for","input","t7","t8","t9"],"sources":["../../../src/components/time-field/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { TimeFieldProps as RACTimeFieldProps, TimeValue } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { DateInput as RACDateInput, TimeField as RACTimeField } from 'react-aria-components';\nimport { FieldBox, FieldMessage, FieldValue } from '../../field';\nimport { fieldStyles, invalidFrom, useFieldValidationBehavior } from '../../field/root';\nimport { renderSegment } from '../../segments';\nimport { segmentStyles } from '../../segments/styles';\nimport { mergeStatefulStyles } from '../../styles/merge';\n\n// A time typed a segment at a time. Every part of it is DateField's, from\n// `src/segments` — the segment treatment, the muted placeholder, the filled\n// focus and the punctuation between — so a time on a form and a date on the\n// same form cannot come apart.\n//\n// What differs is the value it holds and nothing else. The time pickers page\n// gives its input the text field's own box, which is what the shared field\n// chrome already draws, so there is no measurement here that the date field's\n// comment does not already name.\n//\n// **Twelve or twenty-four hours is the reader's locale, not a prop.** React\n// Aria decides from the locale whether there is a day-period segment at all,\n// so a field under `I18nProvider` with `en-GB` shows a 24-hour clock and the\n// same field under `en-US` shows AM and PM. Nothing here overrides it, and\n// `hourCycle` is React Aria's own for a page that has to.\n\ntype TimeFieldProps<T extends TimeValue> = Omit<RACTimeFieldProps<T>, 'children' | 'className' | 'style'> & {\n /** A function may compute the class from the field's render state. */\n className?: RACTimeFieldProps<T>['className'];\n /** Supporting text under the field. */\n description?: string;\n /** The message shown instead of the description, which also marks the field invalid. */\n error?: string;\n /**\n * Whether the label floats into the box's top once the field holds a\n * value, rather than sitting above it.\n * @default true\n */\n floatingLabel?: boolean;\n /** What the field is for. Always rendered; never a placeholder. */\n label: string;\n /** An icon at the box's leading end. */\n leadingIcon?: ReactNode;\n /** A function may compute the style from the field's render state. */\n style?: RACTimeFieldProps<T>['style'];\n /** An icon at the box's trailing end. */\n trailingIcon?: ReactNode;\n /**\n * Which of the text fields page's two boxes to draw.\n * @default 'filled'\n */\n variant?: 'filled' | 'outlined';\n};\n\n/**\n * A time typed rather than picked: one segment per part, each its own focus\n * stop. The value is React Aria's — pass `value` with `onChange` to control\n * it, or `defaultValue` — as a `Time` from this package's `./date` subpath.\n *\n * ```tsx\n * import { Time } from '@kanso-labs/kanso-ui/date'\n *\n * <TimeField defaultValue={new Time(9, 30)} label=\"Label\" />\n * ```\n *\n * Whether it shows a twelve or twenty-four hour clock is the reader's\n * locale, through React Aria's `I18nProvider`. `granularity` takes it down\n * to seconds, and `minValue` and `maxValue` bound what may be typed.\n *\n * The segments are `DateField`'s, and the box, label and message are the\n * field chrome in `src/field`. The call site's `className` and `style` land\n * on the field as a whole, which is the element a layout positions.\n */\nfunction TimeField<T extends TimeValue>({\n description,\n error,\n floatingLabel = true,\n isDisabled = false,\n label,\n leadingIcon,\n trailingIcon,\n variant = 'filled',\n ...props\n}: TimeFieldProps<T>) {\n const validationBehavior = useFieldValidationBehavior();\n return <RACTimeField<T> isDisabled={isDisabled} isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...mergeStatefulStyles(stylex.props(fieldStyles.root), props)}>\n <FieldBox floatingLabel={floatingLabel}\n // Always populated, for the reason DateField's own comment gives: the\n // box reads an `<input>` to decide, and a segmented field has none —\n // its segments hold the value's line from the first render.\n isPopulated label={label} leading={leadingIcon} trailing={trailingIcon} variant={variant}>\n <FieldValue>\n <RACDateInput {...stylex.props(segmentStyles.input)}>\n {renderSegment}\n </RACDateInput>\n </FieldValue>\n </FieldBox>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AA,KAAAN;EAAAM,EAAA,KAAAL;EAAAK,EAAA,KAAAH;EAAAG,EAAA,KAAAF;EAAAE,EAAA,KAAAiB;CAAA,OAAAA,KAAAjB,EAAA;CAAA,IAAAkB;CAAA,IAAAlB,EAAA,OAAAT,eAAAS,EAAA,QAAAR,OAAA;EACX0B,KAAA,oBAAC,cAAD;GAA2B3B;GAAoBC;EAAK,CAAA;EAAIQ,EAAA,KAAAT;EAAAS,EAAA,MAAAR;EAAAQ,EAAA,MAAAkB;CAAA,OAAAA,KAAAlB,EAAA;CAAA,IAAAmB;CAAA,IAAAnB,EAAA,QAAAS,MAAAT,EAAA,QAAAG,cAAAH,EAAA,QAAAM,WAAAN,EAAA,QAAAU,MAAAV,EAAA,QAAAW,MAAAX,EAAA,QAAAiB,MAAAjB,EAAA,QAAAkB,MAAAlB,EAAA,QAAAQ,oBAAA;EAZrDW,KAAA,qBAAC,IAAD;GAA6BhB;GAAuB,WAAAO;GAAwCF;GAAkB,GAAMF;GAAK,GAAMK;GAA/H,UAAA,CACHM,IAWAC,EAZgB;;EAaHlB,EAAA,MAAAS;EAAAT,EAAA,MAAAG;EAAAH,EAAA,MAAAM;EAAAN,EAAA,MAAAU;EAAAV,EAAA,MAAAW;EAAAX,EAAA,MAAAiB;EAAAjB,EAAA,MAAAkB;EAAAlB,EAAA,MAAAQ;EAAAR,EAAA,MAAAmB;CAAA,OAAAA,KAAAnB,EAAA;CAAA,OAbVmB;AAaU"}
|
|
@@ -3,6 +3,7 @@ import { mergeStatefulStyles } from "../../styles/merge.js";
|
|
|
3
3
|
import { fieldStyles, invalidFrom } from "../../field/root.js";
|
|
4
4
|
import { FieldBox, FieldMessage } from "../../field/index.js";
|
|
5
5
|
import { chipStyles } from "../../chip/styles.js";
|
|
6
|
+
import { c } from "react/compiler-runtime";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import { Token, TokenField, TokenInput } from "react-aria-components";
|
|
8
9
|
//#region src/components/token-field/index.tsx
|
|
@@ -44,33 +45,147 @@ function tokenContent(renderToken) {
|
|
|
44
45
|
* The call site's `className` and `style` land on the field as a whole,
|
|
45
46
|
* which is the element a layout positions.
|
|
46
47
|
*/
|
|
47
|
-
function TokenField$1(
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
function TokenField$1(t0) {
|
|
49
|
+
const $ = c(41);
|
|
50
|
+
let T0;
|
|
51
|
+
let description;
|
|
52
|
+
let error;
|
|
53
|
+
let floatingLabel;
|
|
54
|
+
let label;
|
|
55
|
+
let leadingIcon;
|
|
56
|
+
let populated;
|
|
57
|
+
let props$1;
|
|
58
|
+
let renderToken;
|
|
59
|
+
let t1;
|
|
60
|
+
let t2;
|
|
61
|
+
let trailingIcon;
|
|
62
|
+
let variant;
|
|
63
|
+
if ($[0] !== t0) {
|
|
64
|
+
const { description: t3, error: t4, floatingLabel: t5, label: t6, leadingIcon: t7, renderToken: t8, trailingIcon: t9, variant: t10, ...t11 } = t0;
|
|
65
|
+
description = t3;
|
|
66
|
+
error = t4;
|
|
67
|
+
label = t6;
|
|
68
|
+
leadingIcon = t7;
|
|
69
|
+
renderToken = t8;
|
|
70
|
+
trailingIcon = t9;
|
|
71
|
+
props$1 = t11;
|
|
72
|
+
floatingLabel = t5 === void 0 ? true : t5;
|
|
73
|
+
variant = t10 === void 0 ? "filled" : t10;
|
|
74
|
+
populated = isPopulated(props$1.value ?? props$1.defaultValue);
|
|
75
|
+
T0 = TokenField;
|
|
76
|
+
t1 = props$1;
|
|
77
|
+
t2 = mergeStatefulStyles(props(fieldStyles.root), props$1);
|
|
78
|
+
$[0] = t0;
|
|
79
|
+
$[1] = T0;
|
|
80
|
+
$[2] = description;
|
|
81
|
+
$[3] = error;
|
|
82
|
+
$[4] = floatingLabel;
|
|
83
|
+
$[5] = label;
|
|
84
|
+
$[6] = leadingIcon;
|
|
85
|
+
$[7] = populated;
|
|
86
|
+
$[8] = props$1;
|
|
87
|
+
$[9] = renderToken;
|
|
88
|
+
$[10] = t1;
|
|
89
|
+
$[11] = t2;
|
|
90
|
+
$[12] = trailingIcon;
|
|
91
|
+
$[13] = variant;
|
|
92
|
+
} else {
|
|
93
|
+
T0 = $[1];
|
|
94
|
+
description = $[2];
|
|
95
|
+
error = $[3];
|
|
96
|
+
floatingLabel = $[4];
|
|
97
|
+
label = $[5];
|
|
98
|
+
leadingIcon = $[6];
|
|
99
|
+
populated = $[7];
|
|
100
|
+
props$1 = $[8];
|
|
101
|
+
renderToken = $[9];
|
|
102
|
+
t1 = $[10];
|
|
103
|
+
t2 = $[11];
|
|
104
|
+
trailingIcon = $[12];
|
|
105
|
+
variant = $[13];
|
|
106
|
+
}
|
|
107
|
+
const t3 = props$1.isDisabled;
|
|
108
|
+
let t4;
|
|
109
|
+
if ($[14] !== error) {
|
|
110
|
+
t4 = invalidFrom(error);
|
|
111
|
+
$[14] = error;
|
|
112
|
+
$[15] = t4;
|
|
113
|
+
} else t4 = $[15];
|
|
114
|
+
let t5;
|
|
115
|
+
if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
|
|
116
|
+
t5 = {
|
|
117
|
+
0: { className: "x9f619 x139gbkf x1lliihq x16svsjw x1848etk x1c52epr xh8yej3 x1qn8t5l xcgk4ki x21xpn4 x1t137rt xqf7pud x126k92a" },
|
|
118
|
+
1: { className: "x9f619 x139gbkf x1lliihq x16svsjw x1848etk x1c52epr xh8yej3 x1qn8t5l xcgk4ki x21xpn4 x1t137rt xqf7pud x126k92a xwuztrq" }
|
|
119
|
+
};
|
|
120
|
+
$[16] = t5;
|
|
121
|
+
} else t5 = $[16];
|
|
122
|
+
const t6 = t5[!!(variant === "filled") << 0];
|
|
123
|
+
let t7;
|
|
124
|
+
if ($[17] !== renderToken) {
|
|
125
|
+
t7 = tokenContent(renderToken);
|
|
126
|
+
$[17] = renderToken;
|
|
127
|
+
$[18] = t7;
|
|
128
|
+
} else t7 = $[18];
|
|
129
|
+
let t8;
|
|
130
|
+
if ($[19] !== t6 || $[20] !== t7) {
|
|
131
|
+
t8 = /* @__PURE__ */ jsx(TokenInput, {
|
|
132
|
+
...t6,
|
|
133
|
+
children: t7
|
|
134
|
+
});
|
|
135
|
+
$[19] = t6;
|
|
136
|
+
$[20] = t7;
|
|
137
|
+
$[21] = t8;
|
|
138
|
+
} else t8 = $[21];
|
|
139
|
+
let t9;
|
|
140
|
+
if ($[22] !== floatingLabel || $[23] !== label || $[24] !== leadingIcon || $[25] !== populated || $[26] !== props$1.isDisabled || $[27] !== t4 || $[28] !== t8 || $[29] !== trailingIcon || $[30] !== variant) {
|
|
141
|
+
t9 = /* @__PURE__ */ jsx(FieldBox, {
|
|
53
142
|
floatingLabel,
|
|
54
|
-
isDisabled:
|
|
55
|
-
isInvalid:
|
|
143
|
+
isDisabled: t3,
|
|
144
|
+
isInvalid: t4,
|
|
56
145
|
isPopulated: populated,
|
|
57
146
|
label,
|
|
58
147
|
leading: leadingIcon,
|
|
59
148
|
multiline: true,
|
|
60
149
|
trailing: trailingIcon,
|
|
61
150
|
variant,
|
|
62
|
-
children:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
151
|
+
children: t8
|
|
152
|
+
});
|
|
153
|
+
$[22] = floatingLabel;
|
|
154
|
+
$[23] = label;
|
|
155
|
+
$[24] = leadingIcon;
|
|
156
|
+
$[25] = populated;
|
|
157
|
+
$[26] = props$1.isDisabled;
|
|
158
|
+
$[27] = t4;
|
|
159
|
+
$[28] = t8;
|
|
160
|
+
$[29] = trailingIcon;
|
|
161
|
+
$[30] = variant;
|
|
162
|
+
$[31] = t9;
|
|
163
|
+
} else t9 = $[31];
|
|
164
|
+
let t10;
|
|
165
|
+
if ($[32] !== description || $[33] !== error) {
|
|
166
|
+
t10 = /* @__PURE__ */ jsx(FieldMessage, {
|
|
70
167
|
description,
|
|
71
168
|
error
|
|
72
|
-
})
|
|
73
|
-
|
|
169
|
+
});
|
|
170
|
+
$[32] = description;
|
|
171
|
+
$[33] = error;
|
|
172
|
+
$[34] = t10;
|
|
173
|
+
} else t10 = $[34];
|
|
174
|
+
let t11;
|
|
175
|
+
if ($[35] !== T0 || $[36] !== t1 || $[37] !== t10 || $[38] !== t2 || $[39] !== t9) {
|
|
176
|
+
t11 = /* @__PURE__ */ jsxs(T0, {
|
|
177
|
+
...t1,
|
|
178
|
+
...t2,
|
|
179
|
+
children: [t9, t10]
|
|
180
|
+
});
|
|
181
|
+
$[35] = T0;
|
|
182
|
+
$[36] = t1;
|
|
183
|
+
$[37] = t10;
|
|
184
|
+
$[38] = t2;
|
|
185
|
+
$[39] = t9;
|
|
186
|
+
$[40] = t11;
|
|
187
|
+
} else t11 = $[40];
|
|
188
|
+
return t11;
|
|
74
189
|
}
|
|
75
190
|
//#endregion
|
|
76
191
|
export { TokenField$1 as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/token-field/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { TokenFieldProps as RACTokenFieldProps, TokenInputProps as RACTokenInputProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { Token as RACToken, TokenField as RACTokenField, TokenInput as RACTokenInput, TokenFieldValue } from 'react-aria-components';\nimport type { FieldVariant } from '../../field';\nimport { chipStyles } from '../../chip/styles';\nimport { FieldBox, FieldMessage } from '../../field';\nimport { fieldStyles, invalidFrom } from '../../field/root';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, spacing, typography } from '../../tokens/design.tokens.stylex';\n\n// The chips page's input chips inside a text field: a field whose value is\n// text with pills in it — a tag input, a mention field, a structured search\n// box. The box, label, supporting line and error are the field chrome in\n// `src/field`, shared with every other field; the pill is the chip module's\n// in `src/chip`, shared with Chip and ChipGroup. What is here is React Aria's\n// `TokenField` around them.\n//\n// The value is React Aria's `TokenFieldValue`, a list of text and token\n// segments rather than a string, and this component does not wrap it. What\n// counts as a token is the whole question a token field exists to answer — a\n// hash tag, an @ mention, a chosen contact — and a wrapper would be a second\n// place to decide it. The class is re-exported from the package so a call\n// site can subclass it and override `tokenize`.\n//\n// Three things are worth knowing.\n//\n// **The editable area is not an input.** React Aria draws a contenteditable\n// element, since a token cannot live inside an `<input>`. So the box is drawn\n// `multiline` and grows with what it holds, and the chrome is told whether it\n// is populated rather than reading an input's value — a token field is the\n// third control the chrome cannot ask, after a select and a picker.\n//\n// **The box's whole height is the editable area.** A press anywhere in the\n// box has to put the caret in the text, so the box is not covered by a press\n// target the way Select's is; React Aria's own element fills the control's\n// place and takes the press.\n//\n// **A token is drawn by the call site, or by this.** `renderToken` takes a\n// segment and returns what the pill holds; without it the pill holds the\n// segment's own text. Either way the pill is the page's, so a token here and\n// a chip elsewhere cannot drift.\n\nconst styles = {\n token: {\n kfSwDN: \"x87ps6o\",\n kXLuUW: \"xxymvpz\",\n $$css: true\n }\n};\ntype TokenFieldProps<T extends TokenFieldValue = TokenFieldValue> = {\n /** A function may compute the class from the field's render state. */\n className?: RACTokenFieldProps<T>['className'];\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 and the red underline both\n * follow from it.\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 something. `false` keeps it small at the top in\n * every state.\n * @default true\n */\n floatingLabel?: boolean;\n /**\n * What the field is for. Required rather than optional: a field with no\n * 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.\n */\n leadingIcon?: ReactNode;\n /**\n * What each token holds. Given a segment, return what to draw inside its\n * pill; without it the pill holds the segment's own text.\n */\n renderToken?: (segment: TokenSegment) => ReactNode;\n /** A function may compute the style from the field's render state. */\n style?: RACTokenFieldProps<T>['style'];\n /**\n * An icon at the end of the box, after the value: the page's 24dp trailing\n * icon, in the muted role and the error role once the field has an error.\n */\n trailingIcon?: 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<RACTokenFieldProps<T>, 'children' | 'className' | 'style'>;\n\n// One token, as React Aria hands it to the editable area's render function.\n// Taken from that prop rather than imported, since the type lives in\n// `react-stately`, which this package does not depend on directly.\ntype TokenSegment = Parameters<RACTokenInputProps['children']>[0];\n\n// Whether the field holds anything, for the floating label. A token field's\n// editable area is a contenteditable element rather than an input, so the\n// chrome cannot read a value off it and is told instead.\nfunction isPopulated(value: TokenFieldValue | undefined) {\n if (value === undefined) {\n return undefined;\n }\n return value.segments.some(segment => segment.text.length > 0);\n}\n\n// What each token draws. Built by a call rather than written inline at the\n// prop, which is what react-perf's no-new-function-as-prop is after; the\n// React Compiler memoises the result on its input.\nfunction tokenContent(renderToken: TokenFieldProps['renderToken']) {\n return (segment: TokenSegment) => <RACToken {...stylex.props(chipStyles.base, chipStyles.unselected, styles.token)}>\n {renderToken === undefined ? segment.text : renderToken(segment)}\n </RACToken>;\n}\n\n/**\n * A labelled field whose value is text with inline tokens — a tag input, a\n * mention field, a structured search box. Its value is React Aria's\n * `TokenFieldValue`: pass `value` with `onChange` to control it, or\n * `defaultValue` to let it keep its own.\n *\n * ```tsx\n * const [value, setValue] = useState(new TokenFieldValue([]))\n *\n * <TokenField label=\"Label\" onChange={setValue} value={value} />\n * ```\n *\n * What counts as a token is the call site's: subclass `TokenFieldValue` and\n * override `tokenize`, which the package re-exports for that. `renderToken`\n * decides what each pill holds; without it, the segment's own text.\n *\n * The box, label, supporting line and error are the field chrome in\n * `src/field`, and the pill is the chip module's, shared with Chip and\n * ChipGroup.\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 TokenField<T extends TokenFieldValue = TokenFieldValue>({\n description,\n error,\n floatingLabel = true,\n label,\n leadingIcon,\n renderToken,\n trailingIcon,\n variant = 'filled',\n ...props\n}: TokenFieldProps<T>) {\n const populated = isPopulated(props.value ?? props.defaultValue);\n return <RACTokenField<T> {...props} {...mergeStatefulStyles(stylex.props(fieldStyles.root), props)}>\n <FieldBox floatingLabel={floatingLabel}\n // React Aria's `TextField` hands its group the field's disabled and\n // invalid state through context; its `TokenField` does not, so the\n // box is told outright or its label and its underline never turn.\n isDisabled={props.isDisabled} isInvalid={invalidFrom(error)} isPopulated={populated} label={label} leading={leadingIcon} multiline trailing={trailingIcon} variant={variant}>\n <RACTokenInput<T> {...{\n 0: {\n className: \"x9f619 x139gbkf x1lliihq x16svsjw x1848etk x1c52epr xh8yej3 x1qn8t5l xcgk4ki x21xpn4 x1t137rt xqf7pud x126k92a\"\n },\n 1: {\n className: \"x9f619 x139gbkf x1lliihq x16svsjw x1848etk x1c52epr xh8yej3 x1qn8t5l xcgk4ki x21xpn4 x1t137rt xqf7pud x126k92a xwuztrq\"\n }\n }[!!(variant === 'filled') << 0]}>\n {tokenContent(renderToken)}\n </RACTokenInput>\n </FieldBox>\n <FieldMessage description={description} error={error} />\n </RACTokenField>;\n}\nexport type { TokenFieldProps, TokenSegment };\nexport default TokenField;"],"mappings":";;;;;;;;AA4CA,MAAM,SAAS,EACb,OAAO;CACL,QAAQ;CACR,QAAQ;CACR,OAAO;AACT,EACF;AA2DA,SAAS,YAAY,OAAoC;CACvD,IAAI,UAAU,KAAA,GACZ;CAEF,OAAO,MAAM,SAAS,MAAK,YAAW,QAAQ,KAAK,SAAS,CAAC;AAC/D;AAKA,SAAS,aAAa,aAA6C;CACjE,QAAQ,YAA0B,oBAAC,OAAD;EAAU,GAAI,MAAa,WAAW,MAAM,WAAW,YAAY,OAAO,KAAK;EAC5G,UAAA,gBAAgB,KAAA,IAAY,QAAQ,OAAO,YAAY,OAAO;CACvD,CAAA;AACd;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAS,aAAwD,EAC/D,aACA,OACA,gBAAgB,MAChB,OACA,aACA,aACA,cACA,UAAU,UACV,GAAG,WACkB;CACrB,MAAM,YAAY,YAAY,QAAM,SAAS,QAAM,YAAY;CAC/D,OAAO,qBAAC,YAAD;EAAkB,GAAI;EAAO,GAAI,oBAAoB,MAAa,YAAY,IAAI,GAAG,OAAK;EAA1F,UAAA,CACH,oBAAC,UAAD;GAAyB;GAI3B,YAAY,QAAM;GAAY,WAAW,YAAY,KAAK;GAAG,aAAa;GAAkB;GAAO,SAAS;GAAa,WAAA;GAAU,UAAU;GAAuB;GAChK,UAAA,oBAAC,YAAD;IAAkB,GAAI;KACtB,GAAG,EACD,WAAW,iHACb;KACA,GAAG,EACD,WAAW,yHACb;IACF,EAAE,CAAC,EAAE,YAAY,aAAa;IACzB,UAAA,aAAa,WAAW;GACZ,CAAA;EACP,CAAA,GACV,oBAAC,cAAD;GAA2B;GAAoB;EAAM,CAAA,CACxC;;AACnB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["ReactNode","TokenFieldProps","RACTokenFieldProps","TokenInputProps","RACTokenInputProps","stylex","Token","RACToken","TokenField","RACTokenField","TokenInput","RACTokenInput","TokenFieldValue","FieldVariant","chipStyles","FieldBox","FieldMessage","fieldStyles","invalidFrom","mergeStatefulStyles","colors","spacing","typography","styles","token","kfSwDN","kXLuUW","$$css","className","T","description","error","floatingLabel","label","leadingIcon","renderToken","segment","TokenSegment","style","trailingIcon","variant","Omit","Parameters","isPopulated","value","undefined","segments","some","text","length","tokenContent","props","base","unselected","t0","$","_c","T0","populated","t1","t2","t3","t4","t5","t6","t7","t8","t9","t10","t11","defaultValue","root","isDisabled","Symbol","for","0","1"],"sources":["../../../src/components/token-field/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { TokenFieldProps as RACTokenFieldProps, TokenInputProps as RACTokenInputProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { Token as RACToken, TokenField as RACTokenField, TokenInput as RACTokenInput, TokenFieldValue } from 'react-aria-components';\nimport type { FieldVariant } from '../../field';\nimport { chipStyles } from '../../chip/styles';\nimport { FieldBox, FieldMessage } from '../../field';\nimport { fieldStyles, invalidFrom } from '../../field/root';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, spacing, typography } from '../../tokens/design.tokens.stylex';\n\n// The chips page's input chips inside a text field: a field whose value is\n// text with pills in it — a tag input, a mention field, a structured search\n// box. The box, label, supporting line and error are the field chrome in\n// `src/field`, shared with every other field; the pill is the chip module's\n// in `src/chip`, shared with Chip and ChipGroup. What is here is React Aria's\n// `TokenField` around them.\n//\n// The value is React Aria's `TokenFieldValue`, a list of text and token\n// segments rather than a string, and this component does not wrap it. What\n// counts as a token is the whole question a token field exists to answer — a\n// hash tag, an @ mention, a chosen contact — and a wrapper would be a second\n// place to decide it. The class is re-exported from the package so a call\n// site can subclass it and override `tokenize`.\n//\n// Three things are worth knowing.\n//\n// **The editable area is not an input.** React Aria draws a contenteditable\n// element, since a token cannot live inside an `<input>`. So the box is drawn\n// `multiline` and grows with what it holds, and the chrome is told whether it\n// is populated rather than reading an input's value — a token field is the\n// third control the chrome cannot ask, after a select and a picker.\n//\n// **The box's whole height is the editable area.** A press anywhere in the\n// box has to put the caret in the text, so the box is not covered by a press\n// target the way Select's is; React Aria's own element fills the control's\n// place and takes the press.\n//\n// **A token is drawn by the call site, or by this.** `renderToken` takes a\n// segment and returns what the pill holds; without it the pill holds the\n// segment's own text. Either way the pill is the page's, so a token here and\n// a chip elsewhere cannot drift.\n\nconst styles = {\n token: {\n kfSwDN: \"x87ps6o\",\n kXLuUW: \"xxymvpz\",\n $$css: true\n }\n};\ntype TokenFieldProps<T extends TokenFieldValue = TokenFieldValue> = {\n /** A function may compute the class from the field's render state. */\n className?: RACTokenFieldProps<T>['className'];\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 and the red underline both\n * follow from it.\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 something. `false` keeps it small at the top in\n * every state.\n * @default true\n */\n floatingLabel?: boolean;\n /**\n * What the field is for. Required rather than optional: a field with no\n * 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.\n */\n leadingIcon?: ReactNode;\n /**\n * What each token holds. Given a segment, return what to draw inside its\n * pill; without it the pill holds the segment's own text.\n */\n renderToken?: (segment: TokenSegment) => ReactNode;\n /** A function may compute the style from the field's render state. */\n style?: RACTokenFieldProps<T>['style'];\n /**\n * An icon at the end of the box, after the value: the page's 24dp trailing\n * icon, in the muted role and the error role once the field has an error.\n */\n trailingIcon?: 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<RACTokenFieldProps<T>, 'children' | 'className' | 'style'>;\n\n// One token, as React Aria hands it to the editable area's render function.\n// Taken from that prop rather than imported, since the type lives in\n// `react-stately`, which this package does not depend on directly.\ntype TokenSegment = Parameters<RACTokenInputProps['children']>[0];\n\n// Whether the field holds anything, for the floating label. A token field's\n// editable area is a contenteditable element rather than an input, so the\n// chrome cannot read a value off it and is told instead.\nfunction isPopulated(value: TokenFieldValue | undefined) {\n if (value === undefined) {\n return undefined;\n }\n return value.segments.some(segment => segment.text.length > 0);\n}\n\n// What each token draws. Built by a call rather than written inline at the\n// prop, which is what react-perf's no-new-function-as-prop is after; the\n// React Compiler memoises the result on its input.\nfunction tokenContent(renderToken: TokenFieldProps['renderToken']) {\n return (segment: TokenSegment) => <RACToken {...stylex.props(chipStyles.base, chipStyles.unselected, styles.token)}>\n {renderToken === undefined ? segment.text : renderToken(segment)}\n </RACToken>;\n}\n\n/**\n * A labelled field whose value is text with inline tokens — a tag input, a\n * mention field, a structured search box. Its value is React Aria's\n * `TokenFieldValue`: pass `value` with `onChange` to control it, or\n * `defaultValue` to let it keep its own.\n *\n * ```tsx\n * const [value, setValue] = useState(new TokenFieldValue([]))\n *\n * <TokenField label=\"Label\" onChange={setValue} value={value} />\n * ```\n *\n * What counts as a token is the call site's: subclass `TokenFieldValue` and\n * override `tokenize`, which the package re-exports for that. `renderToken`\n * decides what each pill holds; without it, the segment's own text.\n *\n * The box, label, supporting line and error are the field chrome in\n * `src/field`, and the pill is the chip module's, shared with Chip and\n * ChipGroup.\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 TokenField<T extends TokenFieldValue = TokenFieldValue>({\n description,\n error,\n floatingLabel = true,\n label,\n leadingIcon,\n renderToken,\n trailingIcon,\n variant = 'filled',\n ...props\n}: TokenFieldProps<T>) {\n const populated = isPopulated(props.value ?? props.defaultValue);\n return <RACTokenField<T> {...props} {...mergeStatefulStyles(stylex.props(fieldStyles.root), props)}>\n <FieldBox floatingLabel={floatingLabel}\n // React Aria's `TextField` hands its group the field's disabled and\n // invalid state through context; its `TokenField` does not, so the\n // box is told outright or its label and its underline never turn.\n isDisabled={props.isDisabled} isInvalid={invalidFrom(error)} isPopulated={populated} label={label} leading={leadingIcon} multiline trailing={trailingIcon} variant={variant}>\n <RACTokenInput<T> {...{\n 0: {\n className: \"x9f619 x139gbkf x1lliihq x16svsjw x1848etk x1c52epr xh8yej3 x1qn8t5l xcgk4ki x21xpn4 x1t137rt xqf7pud x126k92a\"\n },\n 1: {\n className: \"x9f619 x139gbkf x1lliihq x16svsjw x1848etk x1c52epr xh8yej3 x1qn8t5l xcgk4ki x21xpn4 x1t137rt xqf7pud x126k92a xwuztrq\"\n }\n }[!!(variant === 'filled') << 0]}>\n {tokenContent(renderToken)}\n </RACTokenInput>\n </FieldBox>\n <FieldMessage description={description} error={error} />\n </RACTokenField>;\n}\nexport type { TokenFieldProps, TokenSegment };\nexport default TokenField;"],"mappings":";;;;;;;;;AA4CA,MAAMuB,SAAS,EACbC,OAAO;CACLC,QAAQ;CACRC,QAAQ;CACRC,OAAO;AACT,EACF;AA2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;EAAAF,EAAA,MAAAI;EAAAJ,EAAA,MAAAa;EAAAb,EAAA,MAAAK;EAAAL,EAAA,MAAAY;EAAAZ,EAAA,MAAAc;CAAA,OAAAA,MAAAd,EAAA;CAAA,OAlBXc;AAkBW"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { props } from "../../node_modules/@stylexjs/stylex/lib/es/stylex.js";
|
|
2
2
|
import { mergeStatefulStyles } from "../../styles/merge.js";
|
|
3
|
-
import {
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
4
|
+
import "react";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
import { SeparatorContext, Toolbar } from "react-aria-components";
|
|
6
7
|
//#region src/components/toolbar/index.tsx
|
|
@@ -68,16 +69,72 @@ const styles = {
|
|
|
68
69
|
* The call site's `className` and `style` land on the container, which is
|
|
69
70
|
* the element a layout positions.
|
|
70
71
|
*/
|
|
71
|
-
function Toolbar$1(
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
72
|
+
function Toolbar$1(t0) {
|
|
73
|
+
const $ = c(18);
|
|
74
|
+
let T0;
|
|
75
|
+
let T1;
|
|
76
|
+
let t1;
|
|
77
|
+
let t2;
|
|
78
|
+
let t3;
|
|
79
|
+
let t4;
|
|
80
|
+
if ($[0] !== t0) {
|
|
81
|
+
const { orientation: t5, tone: t6, ...props$1 } = t0;
|
|
82
|
+
const orientation = t5 === void 0 ? "horizontal" : t5;
|
|
83
|
+
const tone = t6 === void 0 ? "standard" : t6;
|
|
84
|
+
const t7 = orientation === "horizontal" ? "vertical" : "horizontal";
|
|
85
|
+
let t8;
|
|
86
|
+
if ($[7] !== t7) {
|
|
87
|
+
t8 = { orientation: t7 };
|
|
88
|
+
$[7] = t7;
|
|
89
|
+
$[8] = t8;
|
|
90
|
+
} else t8 = $[8];
|
|
91
|
+
const separator = t8;
|
|
92
|
+
T1 = SeparatorContext;
|
|
93
|
+
t4 = separator;
|
|
94
|
+
T0 = Toolbar;
|
|
95
|
+
t1 = orientation;
|
|
96
|
+
t2 = props$1;
|
|
97
|
+
t3 = mergeStatefulStyles(props(styles.base, styles[orientation], styles[tone]), props$1);
|
|
98
|
+
$[0] = t0;
|
|
99
|
+
$[1] = T0;
|
|
100
|
+
$[2] = T1;
|
|
101
|
+
$[3] = t1;
|
|
102
|
+
$[4] = t2;
|
|
103
|
+
$[5] = t3;
|
|
104
|
+
$[6] = t4;
|
|
105
|
+
} else {
|
|
106
|
+
T0 = $[1];
|
|
107
|
+
T1 = $[2];
|
|
108
|
+
t1 = $[3];
|
|
109
|
+
t2 = $[4];
|
|
110
|
+
t3 = $[5];
|
|
111
|
+
t4 = $[6];
|
|
112
|
+
}
|
|
113
|
+
let t5;
|
|
114
|
+
if ($[9] !== T0 || $[10] !== t1 || $[11] !== t2 || $[12] !== t3) {
|
|
115
|
+
t5 = /* @__PURE__ */ jsx(T0, {
|
|
116
|
+
orientation: t1,
|
|
117
|
+
...t2,
|
|
118
|
+
...t3
|
|
119
|
+
});
|
|
120
|
+
$[9] = T0;
|
|
121
|
+
$[10] = t1;
|
|
122
|
+
$[11] = t2;
|
|
123
|
+
$[12] = t3;
|
|
124
|
+
$[13] = t5;
|
|
125
|
+
} else t5 = $[13];
|
|
126
|
+
let t6;
|
|
127
|
+
if ($[14] !== T1 || $[15] !== t4 || $[16] !== t5) {
|
|
128
|
+
t6 = /* @__PURE__ */ jsx(T1, {
|
|
129
|
+
value: t4,
|
|
130
|
+
children: t5
|
|
131
|
+
});
|
|
132
|
+
$[14] = T1;
|
|
133
|
+
$[15] = t4;
|
|
134
|
+
$[16] = t5;
|
|
135
|
+
$[17] = t6;
|
|
136
|
+
} else t6 = $[17];
|
|
137
|
+
return t6;
|
|
81
138
|
}
|
|
82
139
|
//#endregion
|
|
83
140
|
export { Toolbar$1 as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/toolbar/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { ToolbarProps as RACToolbarProps, SeparatorProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useMemo } from 'react';\nimport { Toolbar as RACToolbar, SeparatorContext } from 'react-aria-components';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, spacing } from '../../tokens/design.tokens.stylex';\n\n// The toolbars page's container: a row of frequently used controls, on a\n// surface of its own, with the arrow keys moving between them rather than\n// Tab. The page calls it \"a container with configurable slots\", so nothing\n// here says what goes in one — an icon button, a button, a field or a rule\n// are all the call site's to place.\n//\n// The measurements are the page's, stated there in words: 64dp tall,\n// centred, 8dp between items and 16dp of padding outside them. The two\n// colour schemes are its own too — standard on surface container, vibrant on\n// primary container — and both put the muted content role on what they hold.\n//\n// Two things are this component's own.\n//\n// **A rule inside it runs across the row, not along it.** React Aria's\n// `Toolbar` sets its orientation on itself and nowhere else, so a\n// `Separator` written among the controls would draw the way it does anywhere\n// else — along the row, where it is invisible. This provides React Aria's\n// separator context with the perpendicular orientation, and `Separator`\n// reads it, so a rule between two controls is correct without the call site\n// saying which way it runs.\n//\n// **Arrow-key navigation is React Aria's and is not wrapped.** The arrows\n// move between the controls, and — worth knowing, since the pattern usually\n// implies otherwise — React Aria leaves every control tabbable rather than\n// giving the bar a roving tabindex, so Tab still steps through them one by\n// one. What the bar adds is the toolbar role, which tells a screen reader\n// the controls belong together, and a second way to move between them.\n//\n// One departure, and it is about the shape. The page gives the container's\n// corner as a token its widget draws rather than writes, so there is no\n// value to read: what it states in words is the height, the alignment and\n// the padding, and nothing else. The fully rounded corner here, and the\n// inline box that goes with it, are the library's own choice for a bar that\n// floats over a page rather than docking to its edge — a docked one spans\n// its container and squares its corner, both from the call site.\n\nconst styles = {\n base: {\n kGNEyG: \"x6s0dn4\",\n kaIpWk: \"x3y1ksm\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x1w5n3ug\",\n k1xSpc: \"x3nfvp2\",\n kOIVth: \"x126z3so\",\n kjj79g: \"xl56j7k\",\n k3XXqK: \"x1t137rt\",\n $$css: true\n },\n horizontal: {\n kXwgrk: \"x1q0g3np\",\n kAzted: \"x8nclml\",\n k8WAf4: \"x1cmllll\",\n kg3NbH: \"x790zyz\",\n $$css: true\n },\n standard: {\n kWkggS: \"x1mjdul6\",\n $$css: true\n },\n vertical: {\n kXwgrk: \"xdt5ytf\",\n k7Eaqz: \"x4m7ku4\",\n k8WAf4: \"xp6hjv6\",\n kg3NbH: \"xn60lsn\",\n $$css: true\n },\n vibrant: {\n kWkggS: \"xp89om9\",\n kMwMTN: \"xscdzaa\",\n $$css: true\n }\n};\ntype ToolbarProps = Omit<RACToolbarProps, 'children' | 'className' | 'style'> & {\n /** The controls, and any rule between them. */\n children?: ReactNode;\n /** A function may compute the class from the toolbar's render state. */\n className?: RACToolbarProps['className'];\n /** A function may compute the style from the toolbar's render state. */\n style?: RACToolbarProps['style'];\n /**\n * Which of the page's two colour schemes the bar takes. `standard` is the\n * surface container it draws by default; `vibrant` moves it to primary\n * container, for a bar meant to carry the page's accent.\n * @default 'standard'\n */\n tone?: ToolbarTone;\n};\ntype ToolbarTone = 'standard' | 'vibrant';\n\n/**\n * A container for a set of controls, announced as a toolbar so a screen\n * reader reads them as one group, with the arrow keys moving between them.\n * Tab still steps through each control: React Aria's toolbar adds the arrows\n * rather than replacing what Tab does.\n *\n * ```tsx\n * <Toolbar aria-label=\"Label\">\n * <IconButton aria-label=\"First item\">\n * <FirstIcon />\n * </IconButton>\n * <Separator />\n * <IconButton aria-label=\"Second item\">\n * <SecondIcon />\n * </IconButton>\n * </Toolbar>\n * ```\n *\n * Name it with `aria-label` or `aria-labelledby` — nothing here labels it for\n * you, and a toolbar with no name is a group a screen reader cannot announce.\n *\n * `orientation` is React Aria's, and it decides both which arrows move and\n * which way the bar runs. A `Separator` inside draws across that direction\n * without being told.\n *\n * The call site's `className` and `style` land on the container, which is\n * the element a layout positions.\n */\nfunction Toolbar({\n orientation = 'horizontal',\n tone = 'standard',\n ...props\n}: ToolbarProps) {\n // The rule runs across the toolbar rather than along it. Memoised because\n // a fresh object here would be a new context value on every render, which\n // is what react-perf's no-new-object-as-prop is after.\n const separator = useMemo<SeparatorProps>(() => ({\n orientation: orientation === 'horizontal' ? 'vertical' : 'horizontal'\n }), [orientation]);\n return <SeparatorContext value={separator}>\n <RACToolbar orientation={orientation} {...props} {...mergeStatefulStyles(stylex.props(styles.base, styles[orientation], styles[tone]), props)} />\n </SeparatorContext>;\n}\nexport type { ToolbarProps, ToolbarTone };\nexport default Toolbar;"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["ReactNode","ToolbarProps","RACToolbarProps","SeparatorProps","stylex","useMemo","Toolbar","RACToolbar","SeparatorContext","mergeStatefulStyles","colors","radii","spacing","styles","base","kGNEyG","kaIpWk","kB7OPa","kMwMTN","k1xSpc","kOIVth","kjj79g","k3XXqK","$$css","horizontal","kXwgrk","kAzted","k8WAf4","kg3NbH","standard","kWkggS","vertical","k7Eaqz","vibrant","Omit","children","className","style","tone","ToolbarTone","t0","$","_c","T0","T1","t1","t2","t3","t4","orientation","t5","t6","props","undefined","t7","t8","separator"],"sources":["../../../src/components/toolbar/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { ToolbarProps as RACToolbarProps, SeparatorProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useMemo } from 'react';\nimport { Toolbar as RACToolbar, SeparatorContext } from 'react-aria-components';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, spacing } from '../../tokens/design.tokens.stylex';\n\n// The toolbars page's container: a row of frequently used controls, on a\n// surface of its own, with the arrow keys moving between them rather than\n// Tab. The page calls it \"a container with configurable slots\", so nothing\n// here says what goes in one — an icon button, a button, a field or a rule\n// are all the call site's to place.\n//\n// The measurements are the page's, stated there in words: 64dp tall,\n// centred, 8dp between items and 16dp of padding outside them. The two\n// colour schemes are its own too — standard on surface container, vibrant on\n// primary container — and both put the muted content role on what they hold.\n//\n// Two things are this component's own.\n//\n// **A rule inside it runs across the row, not along it.** React Aria's\n// `Toolbar` sets its orientation on itself and nowhere else, so a\n// `Separator` written among the controls would draw the way it does anywhere\n// else — along the row, where it is invisible. This provides React Aria's\n// separator context with the perpendicular orientation, and `Separator`\n// reads it, so a rule between two controls is correct without the call site\n// saying which way it runs.\n//\n// **Arrow-key navigation is React Aria's and is not wrapped.** The arrows\n// move between the controls, and — worth knowing, since the pattern usually\n// implies otherwise — React Aria leaves every control tabbable rather than\n// giving the bar a roving tabindex, so Tab still steps through them one by\n// one. What the bar adds is the toolbar role, which tells a screen reader\n// the controls belong together, and a second way to move between them.\n//\n// One departure, and it is about the shape. The page gives the container's\n// corner as a token its widget draws rather than writes, so there is no\n// value to read: what it states in words is the height, the alignment and\n// the padding, and nothing else. The fully rounded corner here, and the\n// inline box that goes with it, are the library's own choice for a bar that\n// floats over a page rather than docking to its edge — a docked one spans\n// its container and squares its corner, both from the call site.\n\nconst styles = {\n base: {\n kGNEyG: \"x6s0dn4\",\n kaIpWk: \"x3y1ksm\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x1w5n3ug\",\n k1xSpc: \"x3nfvp2\",\n kOIVth: \"x126z3so\",\n kjj79g: \"xl56j7k\",\n k3XXqK: \"x1t137rt\",\n $$css: true\n },\n horizontal: {\n kXwgrk: \"x1q0g3np\",\n kAzted: \"x8nclml\",\n k8WAf4: \"x1cmllll\",\n kg3NbH: \"x790zyz\",\n $$css: true\n },\n standard: {\n kWkggS: \"x1mjdul6\",\n $$css: true\n },\n vertical: {\n kXwgrk: \"xdt5ytf\",\n k7Eaqz: \"x4m7ku4\",\n k8WAf4: \"xp6hjv6\",\n kg3NbH: \"xn60lsn\",\n $$css: true\n },\n vibrant: {\n kWkggS: \"xp89om9\",\n kMwMTN: \"xscdzaa\",\n $$css: true\n }\n};\ntype ToolbarProps = Omit<RACToolbarProps, 'children' | 'className' | 'style'> & {\n /** The controls, and any rule between them. */\n children?: ReactNode;\n /** A function may compute the class from the toolbar's render state. */\n className?: RACToolbarProps['className'];\n /** A function may compute the style from the toolbar's render state. */\n style?: RACToolbarProps['style'];\n /**\n * Which of the page's two colour schemes the bar takes. `standard` is the\n * surface container it draws by default; `vibrant` moves it to primary\n * container, for a bar meant to carry the page's accent.\n * @default 'standard'\n */\n tone?: ToolbarTone;\n};\ntype ToolbarTone = 'standard' | 'vibrant';\n\n/**\n * A container for a set of controls, announced as a toolbar so a screen\n * reader reads them as one group, with the arrow keys moving between them.\n * Tab still steps through each control: React Aria's toolbar adds the arrows\n * rather than replacing what Tab does.\n *\n * ```tsx\n * <Toolbar aria-label=\"Label\">\n * <IconButton aria-label=\"First item\">\n * <FirstIcon />\n * </IconButton>\n * <Separator />\n * <IconButton aria-label=\"Second item\">\n * <SecondIcon />\n * </IconButton>\n * </Toolbar>\n * ```\n *\n * Name it with `aria-label` or `aria-labelledby` — nothing here labels it for\n * you, and a toolbar with no name is a group a screen reader cannot announce.\n *\n * `orientation` is React Aria's, and it decides both which arrows move and\n * which way the bar runs. A `Separator` inside draws across that direction\n * without being told.\n *\n * The call site's `className` and `style` land on the container, which is\n * the element a layout positions.\n */\nfunction Toolbar({\n orientation = 'horizontal',\n tone = 'standard',\n ...props\n}: ToolbarProps) {\n // The rule runs across the toolbar rather than along it. Memoised because\n // a fresh object here would be a new context value on every render, which\n // is what react-perf's no-new-object-as-prop is after.\n const separator = useMemo<SeparatorProps>(() => ({\n orientation: orientation === 'horizontal' ? 'vertical' : 'horizontal'\n }), [orientation]);\n return <SeparatorContext value={separator}>\n <RACToolbar orientation={orientation} {...props} {...mergeStatefulStyles(stylex.props(styles.base, styles[orientation], styles[tone]), props)} />\n </SeparatorContext>;\n}\nexport type { ToolbarProps, ToolbarTone };\nexport default Toolbar;"],"mapp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EAAA,KAAAG;EAAAH,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;EAAAL,EAAA,KAAAM;EAAAN,EAAA,KAAAO;CAAA,OAAA;EAAAL,KAAAF,EAAA;EAAAG,KAAAH,EAAA;EAAAI,KAAAJ,EAAA;EAAAK,KAAAL,EAAA;EAAAM,KAAAN,EAAA;EAAAO,KAAAP,EAAA;CAAA;CAAA,IAAAS;CAAA,IAAAT,EAAA,OAAAE,MAAAF,EAAA,QAAAI,MAAAJ,EAAA,QAAAK,MAAAL,EAAA,QAAAM,IAAA;EAA7IG,KAAA,oBAAC,IAAD;GAAyBD,aAAAA;GAAW,GAAMG;GAAK,GAAML;EAAwF,CAAA;EAAIN,EAAA,KAAAE;EAAAF,EAAA,MAAAI;EAAAJ,EAAA,MAAAK;EAAAL,EAAA,MAAAM;EAAAN,EAAA,MAAAS;CAAA,OAAAA,KAAAT,EAAA;CAAA,IAAAU;CAAA,IAAAV,EAAA,QAAAG,MAAAH,EAAA,QAAAO,MAAAP,EAAA,QAAAS,IAAA;EAD9IC,KAAA,oBAAC,IAAD;GAAyBK,OAAAA;GAC5BN,UAAAA;EADoB,CAAA;EAEHT,EAAA,MAAAG;EAAAH,EAAA,MAAAO;EAAAP,EAAA,MAAAS;EAAAT,EAAA,MAAAU;CAAA,OAAAA,KAAAV,EAAA;CAAA,OAFdU;AAEc"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { props } from "../../node_modules/@stylexjs/stylex/lib/es/stylex.js";
|
|
2
2
|
import { mergeStatefulStyles } from "../../styles/merge.js";
|
|
3
3
|
import { overlay, popupOrigin } from "../../styles/overlay.js";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
4
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
import { Tooltip, TooltipTrigger } from "react-aria-components";
|
|
6
7
|
//#region src/components/tooltip/index.tsx
|
|
@@ -40,21 +41,96 @@ function placementOf(side, align) {
|
|
|
40
41
|
*
|
|
41
42
|
* The call site's `className` and `style` land on the tooltip itself.
|
|
42
43
|
*/
|
|
43
|
-
function Tooltip$1(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
function Tooltip$1(t0) {
|
|
45
|
+
const $ = c(28);
|
|
46
|
+
let alignOffset;
|
|
47
|
+
let children;
|
|
48
|
+
let className;
|
|
49
|
+
let container;
|
|
50
|
+
let label;
|
|
51
|
+
let props;
|
|
52
|
+
let style;
|
|
53
|
+
let t1;
|
|
54
|
+
let t2;
|
|
55
|
+
let t3;
|
|
56
|
+
if ($[0] !== t0) {
|
|
57
|
+
({align: t1, alignOffset, children, className, container, label, side: t2, sideOffset: t3, style, ...props} = t0);
|
|
58
|
+
$[0] = t0;
|
|
59
|
+
$[1] = alignOffset;
|
|
60
|
+
$[2] = children;
|
|
61
|
+
$[3] = className;
|
|
62
|
+
$[4] = container;
|
|
63
|
+
$[5] = label;
|
|
64
|
+
$[6] = props;
|
|
65
|
+
$[7] = style;
|
|
66
|
+
$[8] = t1;
|
|
67
|
+
$[9] = t2;
|
|
68
|
+
$[10] = t3;
|
|
69
|
+
} else {
|
|
70
|
+
alignOffset = $[1];
|
|
71
|
+
children = $[2];
|
|
72
|
+
className = $[3];
|
|
73
|
+
container = $[4];
|
|
74
|
+
label = $[5];
|
|
75
|
+
props = $[6];
|
|
76
|
+
style = $[7];
|
|
77
|
+
t1 = $[8];
|
|
78
|
+
t2 = $[9];
|
|
79
|
+
t3 = $[10];
|
|
80
|
+
}
|
|
81
|
+
const align = t1 === void 0 ? "center" : t1;
|
|
82
|
+
const side = t2 === void 0 ? "top" : t2;
|
|
83
|
+
const sideOffset = t3 === void 0 ? DEFAULT_SIDE_OFFSET : t3;
|
|
84
|
+
let t4;
|
|
85
|
+
if ($[11] !== align || $[12] !== side) {
|
|
86
|
+
t4 = placementOf(side, align);
|
|
87
|
+
$[11] = align;
|
|
88
|
+
$[12] = side;
|
|
89
|
+
$[13] = t4;
|
|
90
|
+
} else t4 = $[13];
|
|
91
|
+
let t5;
|
|
92
|
+
if ($[14] !== className || $[15] !== style) {
|
|
93
|
+
t5 = mergeStatefulStyles(_temp, {
|
|
94
|
+
className,
|
|
95
|
+
style
|
|
96
|
+
});
|
|
97
|
+
$[14] = className;
|
|
98
|
+
$[15] = style;
|
|
99
|
+
$[16] = t5;
|
|
100
|
+
} else t5 = $[16];
|
|
101
|
+
let t6;
|
|
102
|
+
if ($[17] !== alignOffset || $[18] !== container || $[19] !== label || $[20] !== sideOffset || $[21] !== t4 || $[22] !== t5) {
|
|
103
|
+
t6 = /* @__PURE__ */ jsx(Tooltip, {
|
|
47
104
|
crossOffset: alignOffset,
|
|
48
105
|
offset: sideOffset,
|
|
49
|
-
placement:
|
|
106
|
+
placement: t4,
|
|
50
107
|
UNSTABLE_portalContainer: container,
|
|
51
|
-
...
|
|
52
|
-
className,
|
|
53
|
-
style
|
|
54
|
-
}),
|
|
108
|
+
...t5,
|
|
55
109
|
children: label
|
|
56
|
-
})
|
|
57
|
-
|
|
110
|
+
});
|
|
111
|
+
$[17] = alignOffset;
|
|
112
|
+
$[18] = container;
|
|
113
|
+
$[19] = label;
|
|
114
|
+
$[20] = sideOffset;
|
|
115
|
+
$[21] = t4;
|
|
116
|
+
$[22] = t5;
|
|
117
|
+
$[23] = t6;
|
|
118
|
+
} else t6 = $[23];
|
|
119
|
+
let t7;
|
|
120
|
+
if ($[24] !== children || $[25] !== props || $[26] !== t6) {
|
|
121
|
+
t7 = /* @__PURE__ */ jsxs(TooltipTrigger, {
|
|
122
|
+
...props,
|
|
123
|
+
children: [children, t6]
|
|
124
|
+
});
|
|
125
|
+
$[24] = children;
|
|
126
|
+
$[25] = props;
|
|
127
|
+
$[26] = t6;
|
|
128
|
+
$[27] = t7;
|
|
129
|
+
} else t7 = $[27];
|
|
130
|
+
return t7;
|
|
131
|
+
}
|
|
132
|
+
function _temp(state) {
|
|
133
|
+
return props(overlay.popup, styles.container, popupOrigin(state.placement));
|
|
58
134
|
}
|
|
59
135
|
//#endregion
|
|
60
136
|
export { Tooltip$1 as default };
|