@kanso-labs/kanso-ui 0.35.0 → 0.37.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/README.md +90 -9
- package/dist/button/context.js +7 -0
- package/dist/button/context.js.map +1 -0
- package/dist/button/group.js +25 -0
- package/dist/button/group.js.map +1 -0
- package/dist/button/hooks.js +81 -0
- package/dist/button/hooks.js.map +1 -0
- package/dist/button/index.d.ts +11 -0
- package/dist/button/index.js +273 -0
- package/dist/button/index.js.map +1 -0
- package/dist/button/styles.js +23 -0
- package/dist/button/styles.js.map +1 -0
- package/dist/calendar/index.js +473 -7
- package/dist/calendar/index.js.map +1 -1
- package/dist/calendar/styles.js +132 -4
- package/dist/calendar/styles.js.map +1 -1
- package/dist/chip/index.js +74 -9
- package/dist/chip/index.js.map +1 -1
- package/dist/chip/styles.js +78 -4
- package/dist/chip/styles.js.map +1 -1
- package/dist/collection/index.js +12 -9
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/styles.js +21 -2
- package/dist/collection/styles.js.map +1 -1
- package/dist/color-scheme.d.ts +29 -0
- package/dist/color-scheme.js +32 -0
- package/dist/color-scheme.js.map +1 -0
- package/dist/components/avatar/index.js +35 -22
- package/dist/components/avatar/index.js.map +1 -1
- package/dist/components/badge/index.d.ts +40 -0
- package/dist/components/badge/index.js +102 -0
- package/dist/components/badge/index.js.map +1 -0
- package/dist/components/breadcrumbs/index.d.ts +1 -1
- package/dist/components/breadcrumbs/index.js +1 -1
- package/dist/components/breadcrumbs/index.js.map +1 -1
- package/dist/components/button/index.d.ts +58 -14
- package/dist/components/button/index.js +400 -147
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/button-group/index.d.ts +54 -0
- package/dist/components/button-group/index.js +272 -0
- package/dist/components/button-group/index.js.map +1 -0
- package/dist/components/calendar/index.d.ts +9 -1
- package/dist/components/calendar/index.js +71 -44
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/card/index.d.ts +1 -1
- package/dist/components/card/index.js +4 -4
- package/dist/components/card/index.js.map +1 -1
- package/dist/components/checkbox/index.js +15 -1
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/checkbox-group/index.js +1 -0
- package/dist/components/checkbox-group/index.js.map +1 -1
- package/dist/components/chip/index.d.ts +55 -8
- package/dist/components/chip/index.js +174 -63
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/chip-group/index.d.ts +16 -7
- package/dist/components/chip-group/index.js +58 -35
- package/dist/components/chip-group/index.js.map +1 -1
- package/dist/components/color-field/index.js +25 -23
- package/dist/components/color-field/index.js.map +1 -1
- package/dist/components/color-picker/index.js +42 -31
- package/dist/components/color-picker/index.js.map +1 -1
- package/dist/components/color-swatch-picker/index.d.ts +1 -1
- package/dist/components/color-swatch-picker/index.js +17 -13
- package/dist/components/color-swatch-picker/index.js.map +1 -1
- package/dist/components/combo-box/index.d.ts +5 -3
- package/dist/components/combo-box/index.js +63 -58
- package/dist/components/combo-box/index.js.map +1 -1
- package/dist/components/copy-field/index.d.ts +7 -6
- package/dist/components/copy-field/index.js +92 -90
- package/dist/components/copy-field/index.js.map +1 -1
- package/dist/components/currency/index.d.ts +8 -7
- package/dist/components/currency/index.js +43 -65
- package/dist/components/currency/index.js.map +1 -1
- package/dist/components/date-field/index.js +24 -22
- package/dist/components/date-field/index.js.map +1 -1
- package/dist/components/date-picker/index.d.ts +10 -2
- package/dist/components/date-picker/index.js +76 -69
- package/dist/components/date-picker/index.js.map +1 -1
- package/dist/components/date-range-picker/index.d.ts +10 -2
- package/dist/components/date-range-picker/index.js +93 -86
- package/dist/components/date-range-picker/index.js.map +1 -1
- package/dist/components/dialog/index.d.ts +1 -1
- package/dist/components/dialog/index.js +2 -2
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/disclosure/index.d.ts +1 -1
- package/dist/components/disclosure/index.js +6 -6
- package/dist/components/disclosure/index.js.map +1 -1
- package/dist/components/fab/index.d.ts +72 -0
- package/dist/components/fab/index.js +89 -0
- package/dist/components/fab/index.js.map +1 -0
- package/dist/components/fab-menu/index.d.ts +90 -0
- package/dist/components/fab-menu/index.js +297 -0
- package/dist/components/fab-menu/index.js.map +1 -0
- package/dist/components/feed/index.d.ts +2 -1
- package/dist/components/feed/index.js +1 -1
- package/dist/components/feed/index.js.map +1 -1
- package/dist/components/icon-button/index.d.ts +11 -8
- package/dist/components/icon-button/index.js +244 -181
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/index.d.ts +30 -21
- package/dist/components/list/index.d.ts +15 -13
- package/dist/components/list/index.js +60 -61
- package/dist/components/list/index.js.map +1 -1
- package/dist/components/list-box/index.d.ts +3 -2
- package/dist/components/list-box/index.js +16 -16
- package/dist/components/list-box/index.js.map +1 -1
- package/dist/components/list-item/index.js +1 -1
- package/dist/components/list-item/index.js.map +1 -1
- package/dist/components/menu/index.d.ts +3 -2
- package/dist/components/menu/index.js +2 -2
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/navigation-bar/index.d.ts +50 -0
- package/dist/components/navigation-bar/index.js +129 -0
- package/dist/components/navigation-bar/index.js.map +1 -0
- package/dist/components/navigation-rail/index.d.ts +59 -0
- package/dist/components/navigation-rail/index.js +166 -0
- package/dist/components/navigation-rail/index.js.map +1 -0
- package/dist/components/navigation-tree/index.d.ts +1 -5
- package/dist/components/navigation-tree/index.js +3 -3
- package/dist/components/navigation-tree/index.js.map +1 -1
- package/dist/components/number-field/index.d.ts +6 -4
- package/dist/components/number-field/index.js +84 -84
- package/dist/components/number-field/index.js.map +1 -1
- package/dist/components/popover/index.d.ts +1 -1
- package/dist/components/popover/index.js +1 -1
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/radio-group/index.js +22 -11
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/range-calendar/index.d.ts +7 -1
- package/dist/components/range-calendar/index.js +71 -44
- package/dist/components/range-calendar/index.js.map +1 -1
- package/dist/components/search-field/index.d.ts +2 -1
- package/dist/components/search-field/index.js +24 -25
- package/dist/components/search-field/index.js.map +1 -1
- package/dist/components/search-view/index.d.ts +79 -0
- package/dist/components/search-view/index.js +255 -0
- package/dist/components/search-view/index.js.map +1 -0
- package/dist/components/segmented-button/index.d.ts +2 -2
- package/dist/components/segmented-button/index.js +60 -31
- package/dist/components/segmented-button/index.js.map +1 -1
- package/dist/components/select/index.js +1 -0
- package/dist/components/select/index.js.map +1 -1
- package/dist/components/sheet/index.d.ts +1 -1
- package/dist/components/sheet/index.js +2 -2
- package/dist/components/sheet/index.js.map +1 -1
- package/dist/components/slider/index.js +1 -1
- package/dist/components/slider/index.js.map +1 -1
- package/dist/components/snackbar/index.d.ts +2 -2
- package/dist/components/snackbar/index.js +28 -13
- package/dist/components/snackbar/index.js.map +1 -1
- package/dist/components/split-button/index.d.ts +83 -0
- package/dist/components/split-button/index.js +341 -0
- package/dist/components/split-button/index.js.map +1 -0
- package/dist/components/switch/index.js +11 -1
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/table/index.d.ts +11 -9
- package/dist/components/table/index.js +87 -31
- package/dist/components/table/index.js.map +1 -1
- package/dist/components/tabs/index.d.ts +35 -4
- package/dist/components/tabs/index.js +403 -93
- package/dist/components/tabs/index.js.map +1 -1
- package/dist/components/tag/index.d.ts +1 -1
- package/dist/components/tag/index.js.map +1 -1
- package/dist/components/text-area/index.d.ts +7 -5
- package/dist/components/text-area/index.js +28 -26
- package/dist/components/text-area/index.js.map +1 -1
- package/dist/components/text-field/index.d.ts +7 -5
- package/dist/components/text-field/index.js +28 -26
- package/dist/components/text-field/index.js.map +1 -1
- package/dist/components/time-field/index.js +24 -22
- package/dist/components/time-field/index.js.map +1 -1
- package/dist/components/tree/index.d.ts +7 -9
- package/dist/components/tree/index.js +15 -16
- package/dist/components/tree/index.js.map +1 -1
- package/dist/drag/index.js.map +1 -1
- package/dist/drag/styles.js +4 -1
- package/dist/drag/styles.js.map +1 -1
- package/dist/fab/styles.js +161 -0
- package/dist/fab/styles.js.map +1 -0
- package/dist/field/index.js +260 -214
- package/dist/field/index.js.map +1 -1
- package/dist/field/styles.js +10 -2
- package/dist/field/styles.js.map +1 -1
- package/dist/glyphs/index.js +55 -1
- package/dist/glyphs/index.js.map +1 -1
- package/dist/hooks/useRipple.js +199 -162
- package/dist/hooks/useRipple.js.map +1 -1
- package/dist/hooks/useToggleGroupDisabled.js +24 -0
- package/dist/hooks/useToggleGroupDisabled.js.map +1 -0
- package/dist/i18n/index.js +43 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/messages.js +387 -0
- package/dist/i18n/messages.js.map +1 -0
- package/dist/index.d.ts +31 -21
- package/dist/index.js +25 -16
- package/dist/navigation/context.js +7 -0
- package/dist/navigation/context.js.map +1 -0
- package/dist/navigation/index.d.ts +28 -0
- package/dist/navigation/index.js +96 -0
- package/dist/navigation/index.js.map +1 -0
- package/dist/navigation/styles.js +312 -0
- package/dist/navigation/styles.js.map +1 -0
- package/dist/react-aria.d.ts +2 -2
- package/dist/react-aria.js +2 -2
- package/dist/render/useRender.js +0 -1
- package/dist/render/useRender.js.map +1 -1
- package/dist/row/styles.js +33 -11
- package/dist/row/styles.js.map +1 -1
- package/dist/styles/focus.js.map +1 -1
- package/dist/styles/icon-button.js +9 -1
- package/dist/styles/icon-button.js.map +1 -1
- package/dist/styles/overlay.js +1 -0
- package/dist/styles/overlay.js.map +1 -1
- package/dist/styles/picker.js +1 -1
- package/dist/styles/picker.js.map +1 -1
- package/dist/styles.css +1104 -336
- package/dist/tokens/design.tokens.stylex.js +42 -1
- package/dist/tokens/design.tokens.stylex.js.map +1 -1
- package/dist/tokens.css +166 -53
- package/package.json +9 -5
|
@@ -7,8 +7,9 @@ type CurrencyProps = Omit<RenderComponentProps<'span'>, 'children'> & {
|
|
|
7
7
|
*/
|
|
8
8
|
currency?: string;
|
|
9
9
|
/**
|
|
10
|
-
* BCP 47 locale to format for. Defaults to
|
|
11
|
-
*
|
|
10
|
+
* BCP 47 locale to format for. Defaults to React Aria's `I18nProvider`, as
|
|
11
|
+
* the date and number fields do, so an amount reads in the locale the app
|
|
12
|
+
* set — and to the browser's language where there is no provider.
|
|
12
13
|
*/
|
|
13
14
|
locale?: string;
|
|
14
15
|
/**
|
|
@@ -18,7 +19,7 @@ type CurrencyProps = Omit<RenderComponentProps<'span'>, 'children'> & {
|
|
|
18
19
|
* only where the direction is already stated some other way.
|
|
19
20
|
* @default 'auto'
|
|
20
21
|
*/
|
|
21
|
-
sign?:
|
|
22
|
+
sign?: CurrencySignDisplay;
|
|
22
23
|
/**
|
|
23
24
|
* Which colour role to render in. `auto` follows the sign of `value`, with
|
|
24
25
|
* zero reading as neutral.
|
|
@@ -30,13 +31,13 @@ type CurrencyProps = Omit<RenderComponentProps<'span'>, 'children'> & {
|
|
|
30
31
|
* a custom theme placing one there has to check that pair itself.
|
|
31
32
|
* @default 'auto'
|
|
32
33
|
*/
|
|
33
|
-
tone?:
|
|
34
|
+
tone?: CurrencyTone;
|
|
34
35
|
/** The amount, in the currency's major units. */
|
|
35
36
|
value: number;
|
|
36
37
|
};
|
|
37
|
-
type
|
|
38
|
-
type
|
|
38
|
+
type CurrencySignDisplay = 'always' | 'auto' | 'never';
|
|
39
|
+
type CurrencyTone = 'auto' | 'negative' | 'neutral' | 'positive';
|
|
39
40
|
declare function Currency({ currency, locale, render, sign, tone, value, ...props }: CurrencyProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
40
41
|
//#endregion
|
|
41
|
-
export { type CurrencyProps, Currency as default };
|
|
42
|
+
export { type CurrencyProps, type CurrencySignDisplay, type CurrencyTone, Currency as default };
|
|
42
43
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -3,6 +3,7 @@ import { props } from "../../node_modules/@stylexjs/stylex/lib/es/stylex.js";
|
|
|
3
3
|
import { useRender } from "../../render/useRender.js";
|
|
4
4
|
import { mergeStyles } from "../../styles/merge.js";
|
|
5
5
|
import { c } from "react/compiler-runtime";
|
|
6
|
+
import { useLocale } from "react-aria-components";
|
|
6
7
|
//#region src/components/currency/index.tsx
|
|
7
8
|
const styles = { base: {
|
|
8
9
|
kB7OPa: "x9f619",
|
|
@@ -27,82 +28,59 @@ const tones = {
|
|
|
27
28
|
};
|
|
28
29
|
const MINUS_SIGN = "−";
|
|
29
30
|
function Currency(t0) {
|
|
30
|
-
const $ = c(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const { currency: t6, locale, render: t7, sign: t8, tone: t9, value, ...props$1 } = t0;
|
|
39
|
-
render = t7;
|
|
40
|
-
const currency = t6 === void 0 ? "USD" : t6;
|
|
41
|
-
const sign = t8 === void 0 ? "auto" : t8;
|
|
42
|
-
const tone = t9 === void 0 ? "auto" : t9;
|
|
43
|
-
t5 = useRender;
|
|
44
|
-
t4 = "span";
|
|
45
|
-
t1 = props$1;
|
|
46
|
-
if ($[7] !== currency || $[8] !== locale || $[9] !== sign || $[10] !== value) {
|
|
47
|
-
t2 = formatCurrency(value, {
|
|
48
|
-
currency,
|
|
49
|
-
locale,
|
|
50
|
-
sign
|
|
51
|
-
});
|
|
52
|
-
$[7] = currency;
|
|
53
|
-
$[8] = locale;
|
|
54
|
-
$[9] = sign;
|
|
55
|
-
$[10] = value;
|
|
56
|
-
$[11] = t2;
|
|
57
|
-
} else t2 = $[11];
|
|
58
|
-
t3 = mergeStyles(props(styles.base, tones[resolveTone(value, tone)]), props$1);
|
|
59
|
-
$[0] = t0;
|
|
60
|
-
$[1] = render;
|
|
61
|
-
$[2] = t1;
|
|
62
|
-
$[3] = t2;
|
|
63
|
-
$[4] = t3;
|
|
64
|
-
$[5] = t4;
|
|
65
|
-
$[6] = t5;
|
|
66
|
-
} else {
|
|
67
|
-
render = $[1];
|
|
68
|
-
t1 = $[2];
|
|
69
|
-
t2 = $[3];
|
|
70
|
-
t3 = $[4];
|
|
71
|
-
t4 = $[5];
|
|
72
|
-
t5 = $[6];
|
|
73
|
-
}
|
|
31
|
+
const $ = c(12);
|
|
32
|
+
const { currency: t1, locale, render, sign: t2, tone: t3, value, ...props$1 } = t0;
|
|
33
|
+
const currency = t1 === void 0 ? "USD" : t1;
|
|
34
|
+
const sign = t2 === void 0 ? "auto" : t2;
|
|
35
|
+
const tone = t3 === void 0 ? "auto" : t3;
|
|
36
|
+
const provided = useLocale().locale;
|
|
37
|
+
const t4 = "span";
|
|
38
|
+
const t5 = locale ?? provided;
|
|
74
39
|
let t6;
|
|
75
|
-
if ($[
|
|
76
|
-
t6 = {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
40
|
+
if ($[0] !== currency || $[1] !== sign || $[2] !== t5 || $[3] !== value) {
|
|
41
|
+
t6 = formatCurrency(value, {
|
|
42
|
+
currency,
|
|
43
|
+
locale: t5,
|
|
44
|
+
sign
|
|
45
|
+
});
|
|
46
|
+
$[0] = currency;
|
|
47
|
+
$[1] = sign;
|
|
48
|
+
$[2] = t5;
|
|
49
|
+
$[3] = value;
|
|
50
|
+
$[4] = t6;
|
|
51
|
+
} else t6 = $[4];
|
|
52
|
+
const t7 = mergeStyles(props(styles.base, tones[resolveTone(value, tone)]), props$1);
|
|
53
|
+
let t8;
|
|
54
|
+
if ($[5] !== props$1 || $[6] !== t6 || $[7] !== t7) {
|
|
55
|
+
t8 = {
|
|
56
|
+
...props$1,
|
|
57
|
+
children: t6,
|
|
58
|
+
...t7
|
|
80
59
|
};
|
|
81
|
-
$[
|
|
82
|
-
$[
|
|
83
|
-
$[
|
|
84
|
-
$[
|
|
85
|
-
} else
|
|
86
|
-
let
|
|
87
|
-
if ($[
|
|
88
|
-
|
|
60
|
+
$[5] = props$1;
|
|
61
|
+
$[6] = t6;
|
|
62
|
+
$[7] = t7;
|
|
63
|
+
$[8] = t8;
|
|
64
|
+
} else t8 = $[8];
|
|
65
|
+
let t9;
|
|
66
|
+
if ($[9] !== render || $[10] !== t8) {
|
|
67
|
+
t9 = {
|
|
89
68
|
defaultTagName: t4,
|
|
90
|
-
props:
|
|
69
|
+
props: t8,
|
|
91
70
|
render
|
|
92
71
|
};
|
|
93
|
-
$[
|
|
94
|
-
$[
|
|
95
|
-
$[
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return t5(t7);
|
|
72
|
+
$[9] = render;
|
|
73
|
+
$[10] = t8;
|
|
74
|
+
$[11] = t9;
|
|
75
|
+
} else t9 = $[11];
|
|
76
|
+
return useRender(t9);
|
|
99
77
|
}
|
|
100
78
|
const formatters = /* @__PURE__ */ new Map();
|
|
101
79
|
function formatCurrency(value, options) {
|
|
102
80
|
return formatterFor(options.locale, options.currency, options.sign).formatToParts(value).map((part) => part.type === "minusSign" ? MINUS_SIGN : part.value).join("");
|
|
103
81
|
}
|
|
104
82
|
function formatterFor(locale, currency, sign) {
|
|
105
|
-
const key = `${locale
|
|
83
|
+
const key = `${locale}|${currency}|${sign}`;
|
|
106
84
|
const cached = formatters.get(key);
|
|
107
85
|
if (cached) return cached;
|
|
108
86
|
const formatter = new Intl.NumberFormat(locale, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","stylex","RenderComponentProps","useRender","mergeStyles","colors","typography","styles","base","kB7OPa","kMv6JI","kcqcaj","k63SB2","$$css","tones","negative","kMwMTN","neutral","positive","MINUS_SIGN","CurrencyProps","Omit","currency","locale","sign","
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","stylex","useLocale","RenderComponentProps","useRender","mergeStyles","colors","typography","styles","base","kB7OPa","kMv6JI","kcqcaj","k63SB2","$$css","tones","negative","kMwMTN","neutral","positive","MINUS_SIGN","CurrencyProps","Omit","currency","locale","sign","CurrencySignDisplay","tone","CurrencyTone","value","Currency","t0","$","t1","render","t2","t3","props","undefined","provided","t4","t5","t6","formatCurrency","t7","resolveTone","t8","children","t9","defaultTagName","formatters","Map","Intl","NumberFormat","options","formatterFor","formatToParts","map","part","type","join","key","cached","get","formatter","signDisplay","style","set","_c","props","stylex.props"],"sources":["../../../src/components/currency/index.tsx"],"sourcesContent":["'use client';\n\nimport * as stylex from '@stylexjs/stylex';\nimport { useLocale } from 'react-aria-components';\nimport type { RenderComponentProps } from '../../render/useRender';\nimport { useRender } from '../../render/useRender';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, typography } from '../../tokens/design.tokens.stylex';\n\n// Deliberately sets no font-size. The same value turns up at several sizes —\n// inside a list row, as a heading-scale figure, as a total — differing in\n// nothing else, so the size is the container's decision. What must never vary\n// is here: the mono face, tabular figures so a column of them lines up on the\n// decimal point, and the medium weight that separates a figure from the prose\n// around it.\n//\n// No Material Design page draws an amount. It is type alone: the mono face\n// and medium weight from the type tokens, tabular figures, and the on surface\n// role for the neutral tone. Positive and negative are the library's own\n// roles, the pair Tag draws from as well.\nconst styles = {\n base: {\n kB7OPa: \"x9f619\",\n kMv6JI: \"xbppi91\",\n kcqcaj: \"xss6m8b\",\n k63SB2: \"x1bf3uqz\",\n $$css: true\n }\n};\nconst tones = {\n negative: {\n kMwMTN: \"x12gp0t\",\n $$css: true\n },\n neutral: {\n kMwMTN: \"x139gbkf\",\n $$css: true\n },\n positive: {\n kMwMTN: \"x4no3js\",\n $$css: true\n }\n};\n\n// U+2212 MINUS SIGN, not the U+002D hyphen Intl actually emits. The hyphen is\n// a typographic stand-in: it is narrower than the plus it pairs with and does\n// not sit on the same optical centre as the digits, which shows up as a\n// wobbling column the moment amounts are stacked.\nconst MINUS_SIGN = '−';\ntype CurrencyProps = Omit<RenderComponentProps<'span'>, 'children'> & {\n /**\n * ISO 4217 code for the currency to format in.\n * @default 'USD'\n */\n currency?: string;\n /**\n * BCP 47 locale to format for. Defaults to React Aria's `I18nProvider`, as\n * the date and number fields do, so an amount reads in the locale the app\n * set — and to the browser's language where there is no provider.\n */\n locale?: string;\n /**\n * When to show the sign. `auto` shows one only on negatives, `always` also\n * prefixes positives with a plus, and `never` shows neither — which leaves\n * colour as the only thing separating a credit from a debt, so reach for it\n * only where the direction is already stated some other way.\n * @default 'auto'\n */\n sign?: CurrencySignDisplay;\n /**\n * Which colour role to render in. `auto` follows the sign of `value`, with\n * zero reading as neutral.\n *\n * The positive and negative roles are guaranteed legible on the surface\n * family, which is what the library's own tokens and every demo scheme are\n * held to. Over a container of its own — a selected row, a filled card —\n * the pair is one colour family on top of another and is not guaranteed, so\n * a custom theme placing one there has to check that pair itself.\n * @default 'auto'\n */\n tone?: CurrencyTone;\n /** The amount, in the currency's major units. */\n value: number;\n};\ntype CurrencySignDisplay = 'always' | 'auto' | 'never';\ntype CurrencyTone = 'auto' | 'negative' | 'neutral' | 'positive';\nfunction Currency({\n currency = 'USD',\n locale,\n render,\n sign = 'auto',\n tone = 'auto',\n value,\n ...props\n}: CurrencyProps) {\n // React Aria holds the locale steady through hydration, where the runtime's\n // default differs between the server and the browser and the amount's text\n // would not match.\n const provided = useLocale().locale;\n return useRender({\n defaultTagName: 'span',\n props: {\n ...props,\n children: formatCurrency(value, {\n currency,\n locale: locale ?? provided,\n sign\n }),\n ...mergeStyles(stylex.props(styles.base, tones[resolveTone(value, tone)]), props)\n },\n render\n });\n}\n\n// Constructing an Intl.NumberFormat resolves the locale, loads the currency's\n// data and builds the pattern; formatToParts on one already built skips all\n// three, which measures about ten times cheaper per value. An instance is\n// stateless once constructed, so one can be shared across every component\n// asking for the same three options.\n//\n// What this saves is a mount and a changing amount, not an idle re-render:\n// the React Compiler already memoises the call below on the four things it\n// reads, so a component re-rendered with the same props never reaches here.\n// That cache belongs to one component instance and counts `value` among its\n// keys, which leaves two cases it cannot cover — a column of rows, where every\n// instance has a cache of its own and each builds a formatter, and a single\n// amount that ticks, where each new value misses.\n//\n// Unbounded on purpose. The keys are the option sets an app actually uses —\n// its locales times its currencies times the three sign settings — so the map\n// settles at that size rather than growing with renders or with values.\nconst formatters = new Map<string, Intl.NumberFormat>();\n\n// formatToParts rather than a replace over the formatted string, so only the\n// sign is substituted. A blind replace would also hit a hyphen inside a\n// locale's currency name or grouping, and locales that wrap negatives in\n// parentheses have no minus to swap at all — both of which this leaves alone.\nfunction formatCurrency(value: number, options: {\n currency: string;\n locale: string;\n sign: CurrencySignDisplay;\n}) {\n return formatterFor(options.locale, options.currency, options.sign).formatToParts(value).map(part => part.type === 'minusSign' ? MINUS_SIGN : part.value).join('');\n}\nfunction formatterFor(locale: string, currency: string, sign: CurrencySignDisplay) {\n // Neither a BCP 47 locale nor an ISO 4217 code can contain a vertical bar\n // and `sign` is one of three known words, so joining on one cannot make two\n // different option sets share a key.\n const key = `${locale}|${currency}|${sign}`;\n const cached = formatters.get(key);\n if (cached) {\n return cached;\n }\n const formatter = new Intl.NumberFormat(locale, {\n currency,\n signDisplay: sign,\n style: 'currency'\n });\n formatters.set(key, formatter);\n return formatter;\n}\n\n// Zero is neither owed nor owing, so it takes the neutral role rather than\n// being forced into one of the two. Negative zero lands here too, which is\n// what a rounded-away debt should read as.\nfunction resolveTone(value: number, tone: CurrencyTone) {\n if (tone !== 'auto') {\n return tone;\n }\n if (value > 0) {\n return 'positive';\n }\n if (value < 0) {\n return 'negative';\n }\n return 'neutral';\n}\nexport type { CurrencyProps, CurrencySignDisplay, CurrencyTone };\nexport default Currency;"],"mappings":";;;;;;;AAqBA,MAAMS,SAAS,EACbC,MAAM;CACJC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,OAAO;AACT,EACF;AACA,MAAMC,QAAQ;CACZC,UAAU;EACRC,QAAQ;EACRH,OAAO;CACT;CACAI,SAAS;EACPD,QAAQ;EACRH,OAAO;CACT;CACAK,UAAU;EACRF,QAAQ;EACRH,OAAO;CACT;AACF;AAMA,MAAMM,aAAa;AAsCnB,SAAAU,SAAAC,IAAA;CAAA,MAAAC,IAAAhC,EAAA,EAAA;CAAkB,MAAA,EAAAuB,UAAAU,IAAAT,QAAAU,QAAAT,MAAAU,IAAAR,MAAAS,IAAAP,OAAA,GAAAQ,YAAAN;CAChB,MAAAR,WAAAU,OAAAK,KAAAA,IAAA,QAAAL;CAGA,MAAAR,OAAAU,OAAAG,KAAAA,IAAA,SAAAH;CACA,MAAAR,OAAAS,OAAAE,KAAAA,IAAA,SAAAF;CAOA,MAAAG,WAAiBrC,UAAU,CAAC,CAAAsB;CAEV,MAAAgB,KAAA;CAKJ,MAAAC,KAAAjB,UAAAe;CAAkB,IAAAG;CAAA,IAAAV,EAAA,OAAAT,YAAAS,EAAA,OAAAP,QAAAO,EAAA,OAAAS,MAAAT,EAAA,OAAAH,OAAA;EAFlBa,KAAAC,eAAed,OAAO;GAAAN;GAAAC,QAEtBiB;GAAkBhB;EAE5B,CAAC;EAACO,EAAA,KAAAT;EAAAS,EAAA,KAAAP;EAAAO,EAAA,KAAAS;EAAAT,EAAA,KAAAH;EAAAG,EAAA,KAAAU;CAAA,OAAAA,KAAAV,EAAA;CACC,MAAAY,KAAAvC,YAAYJ,MAAaO,OAAMC,MAAOM,MAAM8B,YAAYhB,OAAOF,IAAI,EAAE,GAAGU,OAAK;CAAC,IAAAS;CAAA,IAAAd,EAAA,OAAAK,WAAAL,EAAA,OAAAU,MAAAV,EAAA,OAAAY,IAAA;EAP5EE,KAAA;GAAA,GACFT;GAAKU,UACEL;GAIR,GACCE;EACL;EAACZ,EAAA,KAAAK;EAAAL,EAAA,KAAAU;EAAAV,EAAA,KAAAY;EAAAZ,EAAA,KAAAc;CAAA,OAAAA,KAAAd,EAAA;CAAA,IAAAgB;CAAA,IAAAhB,EAAA,OAAAE,UAAAF,EAAA,QAAAc,IAAA;EAVcE,KAAA;GAAAC,gBACCT;GAAMH,OACfS;GAQNZ;EAEH;EAACF,EAAA,KAAAE;EAAAF,EAAA,MAAAc;EAAAd,EAAA,MAAAgB;CAAA,OAAAA,KAAAhB,EAAA;CAAA,OAZM5B,UAAU4C,EAYhB;AAAC;AAoBJ,MAAME,6BAAa,IAAIC,IAA+B;AAMtD,SAASR,eAAed,OAAeyB,SAIpC;CACD,OAAOC,aAAaD,QAAQ9B,QAAQ8B,QAAQ/B,UAAU+B,QAAQ7B,IAAI,CAAC,CAAC+B,cAAc3B,KAAK,CAAC,CAAC4B,KAAIC,SAAQA,KAAKC,SAAS,cAAcvC,aAAasC,KAAK7B,KAAK,CAAC,CAAC+B,KAAK,EAAE;AACnK;AACA,SAASL,aAAa/B,QAAgBD,UAAkBE,MAA2B;CAIjF,MAAMoC,MAAM,GAAGrC,OAAM,GAAID,SAAQ,GAAIE;CACrC,MAAMqC,SAASZ,WAAWa,IAAIF,GAAG;CACjC,IAAIC,QACF,OAAOA;CAET,MAAME,YAAY,IAAIZ,KAAKC,aAAa7B,QAAQ;EAC9CD;EACA0C,aAAaxC;EACbyC,OAAO;CACT,CAAC;CACDhB,WAAWiB,IAAIN,KAAKG,SAAS;CAC7B,OAAOA;AACT;AAKA,SAASnB,YAAYhB,OAAeF,MAAoB;CACtD,IAAIA,SAAS,QACX,OAAOA;CAET,IAAIE,QAAQ,GACV,OAAO;CAET,IAAIA,QAAQ,GACV,OAAO;CAET,OAAO;AACT"}
|
|
@@ -30,7 +30,7 @@ import { DateField, DateInput } from "react-aria-components";
|
|
|
30
30
|
* the field as a whole, which is the element a layout positions.
|
|
31
31
|
*/
|
|
32
32
|
function DateField$1(t0) {
|
|
33
|
-
const $ = c(
|
|
33
|
+
const $ = c(22);
|
|
34
34
|
const { description, error, floatingLabel: t1, isDisabled: t2, label, leadingIcon, trailingIcon, variant: t3, ...props$1 } = t0;
|
|
35
35
|
const floatingLabel = t1 === void 0 ? true : t1;
|
|
36
36
|
const isDisabled = t2 === void 0 ? false : t2;
|
|
@@ -53,10 +53,11 @@ function DateField$1(t0) {
|
|
|
53
53
|
$[2] = t6;
|
|
54
54
|
} else t6 = $[2];
|
|
55
55
|
let t7;
|
|
56
|
-
if ($[3] !== floatingLabel || $[4] !== label || $[5] !== leadingIcon || $[6] !==
|
|
56
|
+
if ($[3] !== floatingLabel || $[4] !== label || $[5] !== leadingIcon || $[6] !== props$1.isRequired || $[7] !== trailingIcon || $[8] !== variant) {
|
|
57
57
|
t7 = /* @__PURE__ */ jsx(FieldBox, {
|
|
58
58
|
floatingLabel,
|
|
59
59
|
isPopulated: true,
|
|
60
|
+
isRequired: props$1.isRequired,
|
|
60
61
|
label,
|
|
61
62
|
leading: leadingIcon,
|
|
62
63
|
trailing: trailingIcon,
|
|
@@ -66,22 +67,23 @@ function DateField$1(t0) {
|
|
|
66
67
|
$[3] = floatingLabel;
|
|
67
68
|
$[4] = label;
|
|
68
69
|
$[5] = leadingIcon;
|
|
69
|
-
$[6] =
|
|
70
|
-
$[7] =
|
|
71
|
-
$[8] =
|
|
72
|
-
|
|
70
|
+
$[6] = props$1.isRequired;
|
|
71
|
+
$[7] = trailingIcon;
|
|
72
|
+
$[8] = variant;
|
|
73
|
+
$[9] = t7;
|
|
74
|
+
} else t7 = $[9];
|
|
73
75
|
let t8;
|
|
74
|
-
if ($[
|
|
76
|
+
if ($[10] !== description || $[11] !== error) {
|
|
75
77
|
t8 = /* @__PURE__ */ jsx(FieldMessage, {
|
|
76
78
|
description,
|
|
77
79
|
error
|
|
78
80
|
});
|
|
79
|
-
$[
|
|
80
|
-
$[
|
|
81
|
-
$[
|
|
82
|
-
} else t8 = $[
|
|
81
|
+
$[10] = description;
|
|
82
|
+
$[11] = error;
|
|
83
|
+
$[12] = t8;
|
|
84
|
+
} else t8 = $[12];
|
|
83
85
|
let t9;
|
|
84
|
-
if ($[
|
|
86
|
+
if ($[13] !== T0 || $[14] !== isDisabled || $[15] !== props$1 || $[16] !== t4 || $[17] !== t5 || $[18] !== t7 || $[19] !== t8 || $[20] !== validationBehavior) {
|
|
85
87
|
t9 = /* @__PURE__ */ jsxs(T0, {
|
|
86
88
|
isDisabled,
|
|
87
89
|
isInvalid: t4,
|
|
@@ -90,16 +92,16 @@ function DateField$1(t0) {
|
|
|
90
92
|
...t5,
|
|
91
93
|
children: [t7, t8]
|
|
92
94
|
});
|
|
93
|
-
$[
|
|
94
|
-
$[
|
|
95
|
-
$[
|
|
96
|
-
$[
|
|
97
|
-
$[
|
|
98
|
-
$[
|
|
99
|
-
$[
|
|
100
|
-
$[
|
|
101
|
-
$[
|
|
102
|
-
} else t9 = $[
|
|
95
|
+
$[13] = T0;
|
|
96
|
+
$[14] = isDisabled;
|
|
97
|
+
$[15] = props$1;
|
|
98
|
+
$[16] = t4;
|
|
99
|
+
$[17] = t5;
|
|
100
|
+
$[18] = t7;
|
|
101
|
+
$[19] = t8;
|
|
102
|
+
$[20] = validationBehavior;
|
|
103
|
+
$[21] = t9;
|
|
104
|
+
} else t9 = $[21];
|
|
103
105
|
return t9;
|
|
104
106
|
}
|
|
105
107
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","ReactNode","RefAttributes","DateValue","DateFieldProps","RACDateFieldProps","stylex","DateField","RACDateField","DateInput","RACDateInput","FieldVariant","FieldBox","FieldMessage","FieldSegments","fieldStyles","invalidFrom","useFieldValidationBehavior","renderSegment","segmentStyles","mergeStatefulStyles","Omit","T","className","description","error","floatingLabel","label","leadingIcon","style","trailingIcon","variant","t0","$","t1","isDisabled","t2","t3","props","undefined","validationBehavior","T0","t4","t5","root","t6","Symbol","for","input","t7","t8","t9","DateField","_c","props","RACDateField","stylex.props","RACDateInput"],"sources":["../../../src/components/date-field/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { DateValue, DateFieldProps as RACDateFieldProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { DateField as RACDateField, DateInput as RACDateInput } from 'react-aria-components';\nimport type { FieldVariant } from '../../field';\nimport { FieldBox, FieldMessage, FieldSegments } 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 date typed a segment at a time, rather than picked from a calendar. The\n// box, label and message are the field chrome in `src/field`, shared with\n// every other field, so a date field on a form is the same box as the text\n// field beside it — which is what the date pickers page means by a date in a\n// text field.\n//\n// Three things are this component's own.\n//\n// **Each segment is its own focus stop, and React Aria decides how many.**\n// The order and the count come from the locale rather than from here: a\n// reader under `I18nProvider` with a British locale gets day before month,\n// and `granularity` of `minute` adds two more. So the segments are rendered\n// from what React Aria hands the input, never written out.\n//\n// **A segment not yet filled is muted, and the field still counts as\n// empty.** The placeholder text is the segment's own — `mm`, `dd`, `yyyy` —\n// and it takes the muted role so a half-typed date reads as half-typed. The\n// floating label stays down until a segment holds a real value.\n//\n// **A focused segment is a filled shape rather than a ring.** A caret cannot\n// show which of three spinbuttons has focus, since React Aria hides it — the\n// segment is what has to say so, and it does it the way a selected row does.\n\ntype DateFieldProps<T extends DateValue = DateValue> = Omit<RACDateFieldProps<T>, 'children' | 'className' | 'style'> & {\n /** A function may compute the class from the field's render state. */\n className?: RACDateFieldProps<T>['className'];\n /** Supporting text under the field. */\n description?: string;\n /**\n * The message shown instead of the description, which also marks the\n * field invalid.\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 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 /**\n * An icon at the box's leading end, in the page's 24dp size. An icon drawn\n * in `em` takes that size from the slot.\n */\n leadingIcon?: ReactNode;\n /** A function may compute the style from the field's render state. */\n style?: RACDateFieldProps<T>['style'];\n /**\n * An icon at the box's trailing end, in the page's 24dp size. An icon\n * drawn in `em` takes that size from the slot.\n */\n trailingIcon?: ReactNode;\n /**\n * Which of the text fields page's two boxes to draw.\n * @default 'filled'\n */\n variant?: FieldVariant;\n};\n\n/**\n * A date typed 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 an `@internationalized/date` value from this\n * package's `./date` subpath.\n *\n * ```tsx\n * import { CalendarDate } from '@kanso-labs/kanso-ui/date'\n *\n * <DateField defaultValue={new CalendarDate(2026, 9, 15)} label=\"Label\" />\n * ```\n *\n * How many segments there are and what order they come in is the reader's\n * locale, through React Aria's `I18nProvider` — `granularity` adds time\n * segments, and `minValue` and `maxValue` bound what may be typed.\n *\n * The box, label and message are the field chrome in `src/field`, shared\n * with every other field. The call site's `className` and `style` land on\n * the field as a whole, which is the element a layout positions.\n */\nfunction DateField<T extends DateValue>({\n description,\n error,\n floatingLabel = true,\n isDisabled = false,\n label,\n leadingIcon,\n trailingIcon,\n variant = 'filled',\n ...props\n}: DateFieldProps<T> & RefAttributes<HTMLDivElement>) {\n const validationBehavior = useFieldValidationBehavior();\n return <RACDateField<T> isDisabled={isDisabled} isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...mergeStatefulStyles(stylex.props(fieldStyles.root), props)}>\n <FieldBox floatingLabel={floatingLabel}\n // Always populated, which buys the outlined notch. The box decides\n // populated twice over — in CSS for the label's type, and in React\n // for the notch, since CSS cannot cut an outline to a width it has\n // no way to measure. React Aria renders a hidden\n // `<input type=\"date\">` carrying no placeholder, so the CSS half\n // reads as populated on its own; the React half reads React Aria's\n // input context, which a date field does not provide. Without this\n // the notch stays shut across segments already showing `mm/dd/yyyy`.\n isPopulated label={label} leading={leadingIcon} trailing={trailingIcon} variant={variant}>\n <FieldSegments>\n <RACDateInput {...stylex.props(segmentStyles.input)}>\n {renderSegment}\n </RACDateInput>\n </FieldSegments>\n </FieldBox>\n <FieldMessage description={description} error={error} />\n </RACDateField>;\n}\nexport type { DateFieldProps };\nexport default DateField;"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiGA,SAAAQ,YAAAyB,IAAA;CAAA,MAAAC,IAAAjC,EAAA,EAAA;CAAwC,MAAA,EAAAwB,aAAAC,OAAAC,eAAAQ,IAAAC,YAAAC,IAAAT,OAAAC,aAAAE,cAAAC,SAAAM,IAAA,GAAAC,YAAAN;CAGtC,MAAAN,gBAAAQ,OAAAK,KAAAA,IAAA,OAAAL;CACA,MAAAC,aAAAC,OAAAG,KAAAA,IAAA,QAAAH;CAIA,MAAAL,UAAAM,OAAAE,KAAAA,IAAA,WAAAF;CAGA,MAAAG,qBAA2BvB,2BAA2B;CAC9C,MAAAwB,KAAAjC;CAAY,IAAAkC;CAAA,IAAAT,EAAA,OAAAR,OAAA;EAAuCiB,KAAA1B,YAAYS,KAAK;EAACQ,EAAA,KAAAR;EAAAQ,EAAA,KAAAS;CAAA,OAAAA,KAAAT,EAAA;CAAyD,MAAAU,KAAAvB,oBAAoBd,MAAaS,YAAW6B,IAAK,GAAGN,OAAK;CAAC,IAAAO;CAAA,IAAAZ,EAAA,OAAAa,OAAAC,IAAA,2BAAA,GAAA;EAW1LF,KAAA,oBAAC,eAAD,EAAA,UACE,
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","ReactNode","RefAttributes","DateValue","DateFieldProps","RACDateFieldProps","stylex","DateField","RACDateField","DateInput","RACDateInput","FieldVariant","FieldBox","FieldMessage","FieldSegments","fieldStyles","invalidFrom","useFieldValidationBehavior","renderSegment","segmentStyles","mergeStatefulStyles","Omit","T","className","description","error","floatingLabel","label","leadingIcon","style","trailingIcon","variant","t0","$","t1","isDisabled","t2","t3","props","undefined","validationBehavior","T0","t4","t5","root","t6","Symbol","for","input","t7","isRequired","t8","t9","DateField","_c","props","RACDateField","stylex.props","RACDateInput"],"sources":["../../../src/components/date-field/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { DateValue, DateFieldProps as RACDateFieldProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { DateField as RACDateField, DateInput as RACDateInput } from 'react-aria-components';\nimport type { FieldVariant } from '../../field';\nimport { FieldBox, FieldMessage, FieldSegments } 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 date typed a segment at a time, rather than picked from a calendar. The\n// box, label and message are the field chrome in `src/field`, shared with\n// every other field, so a date field on a form is the same box as the text\n// field beside it — which is what the date pickers page means by a date in a\n// text field.\n//\n// Three things are this component's own.\n//\n// **Each segment is its own focus stop, and React Aria decides how many.**\n// The order and the count come from the locale rather than from here: a\n// reader under `I18nProvider` with a British locale gets day before month,\n// and `granularity` of `minute` adds two more. So the segments are rendered\n// from what React Aria hands the input, never written out.\n//\n// **A segment not yet filled is muted, and the field still counts as\n// empty.** The placeholder text is the segment's own — `mm`, `dd`, `yyyy` —\n// and it takes the muted role so a half-typed date reads as half-typed. The\n// floating label stays down until a segment holds a real value.\n//\n// **A focused segment is a filled shape rather than a ring.** A caret cannot\n// show which of three spinbuttons has focus, since React Aria hides it — the\n// segment is what has to say so, and it does it the way a selected row does.\n\ntype DateFieldProps<T extends DateValue = DateValue> = Omit<RACDateFieldProps<T>, 'children' | 'className' | 'style'> & {\n /** A function may compute the class from the field's render state. */\n className?: RACDateFieldProps<T>['className'];\n /** Supporting text under the field. */\n description?: string;\n /**\n * The message shown instead of the description, which also marks the\n * field invalid.\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 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 /**\n * An icon at the box's leading end, in the page's 24dp size. An icon drawn\n * in `em` takes that size from the slot.\n */\n leadingIcon?: ReactNode;\n /** A function may compute the style from the field's render state. */\n style?: RACDateFieldProps<T>['style'];\n /**\n * An icon at the box's trailing end, in the page's 24dp size. An icon\n * drawn in `em` takes that size from the slot.\n */\n trailingIcon?: ReactNode;\n /**\n * Which of the text fields page's two boxes to draw.\n * @default 'filled'\n */\n variant?: FieldVariant;\n};\n\n/**\n * A date typed 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 an `@internationalized/date` value from this\n * package's `./date` subpath.\n *\n * ```tsx\n * import { CalendarDate } from '@kanso-labs/kanso-ui/date'\n *\n * <DateField defaultValue={new CalendarDate(2026, 9, 15)} label=\"Label\" />\n * ```\n *\n * How many segments there are and what order they come in is the reader's\n * locale, through React Aria's `I18nProvider` — `granularity` adds time\n * segments, and `minValue` and `maxValue` bound what may be typed.\n *\n * The box, label and message are the field chrome in `src/field`, shared\n * with every other field. The call site's `className` and `style` land on\n * the field as a whole, which is the element a layout positions.\n */\nfunction DateField<T extends DateValue>({\n description,\n error,\n floatingLabel = true,\n isDisabled = false,\n label,\n leadingIcon,\n trailingIcon,\n variant = 'filled',\n ...props\n}: DateFieldProps<T> & RefAttributes<HTMLDivElement>) {\n const validationBehavior = useFieldValidationBehavior();\n return <RACDateField<T> isDisabled={isDisabled} isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...mergeStatefulStyles(stylex.props(fieldStyles.root), props)}>\n <FieldBox floatingLabel={floatingLabel}\n // Always populated, which buys the outlined notch. The box decides\n // populated twice over — in CSS for the label's type, and in React\n // for the notch, since CSS cannot cut an outline to a width it has\n // no way to measure. React Aria renders a hidden\n // `<input type=\"date\">` carrying no placeholder, so the CSS half\n // reads as populated on its own; the React half reads React Aria's\n // input context, which a date field does not provide. Without this\n // the notch stays shut across segments already showing `mm/dd/yyyy`.\n isPopulated isRequired={props.isRequired} label={label} leading={leadingIcon} trailing={trailingIcon} variant={variant}>\n <FieldSegments>\n <RACDateInput {...stylex.props(segmentStyles.input)}>\n {renderSegment}\n </RACDateInput>\n </FieldSegments>\n </FieldBox>\n <FieldMessage description={description} error={error} />\n </RACDateField>;\n}\nexport type { DateFieldProps };\nexport default DateField;"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiGA,SAAAQ,YAAAyB,IAAA;CAAA,MAAAC,IAAAjC,EAAA,EAAA;CAAwC,MAAA,EAAAwB,aAAAC,OAAAC,eAAAQ,IAAAC,YAAAC,IAAAT,OAAAC,aAAAE,cAAAC,SAAAM,IAAA,GAAAC,YAAAN;CAGtC,MAAAN,gBAAAQ,OAAAK,KAAAA,IAAA,OAAAL;CACA,MAAAC,aAAAC,OAAAG,KAAAA,IAAA,QAAAH;CAIA,MAAAL,UAAAM,OAAAE,KAAAA,IAAA,WAAAF;CAGA,MAAAG,qBAA2BvB,2BAA2B;CAC9C,MAAAwB,KAAAjC;CAAY,IAAAkC;CAAA,IAAAT,EAAA,OAAAR,OAAA;EAAuCiB,KAAA1B,YAAYS,KAAK;EAACQ,EAAA,KAAAR;EAAAQ,EAAA,KAAAS;CAAA,OAAAA,KAAAT,EAAA;CAAyD,MAAAU,KAAAvB,oBAAoBd,MAAaS,YAAW6B,IAAK,GAAGN,OAAK;CAAC,IAAAO;CAAA,IAAAZ,EAAA,OAAAa,OAAAC,IAAA,2BAAA,GAAA;EAW1LF,KAAA,oBAAC,eAAD,EAAA,UACE,oBAACa,WAAD;GAAa,GAAKpD,MAAaa,cAAa6B,KAAM;GAC/C9B,UAAAA;EADU,CAAA,EADD,CAAA;EAIEe,EAAA,KAAAY;CAAA,OAAAA,KAAAZ,EAAA;CAAA,IAAAgB;CAAA,IAAAhB,EAAA,OAAAP,iBAAAO,EAAA,OAAAN,SAAAM,EAAA,OAAAL,eAAAK,EAAA,OAAAK,QAAAY,cAAAjB,EAAA,OAAAH,gBAAAG,EAAA,OAAAF,SAAA;EAdlBkB,KAAA,oBAAC,UAAD;GAAyBvB;GAS3B,aAAA;GAAwB,YAAAY,QAAKY;GAAoBvB;GAAgBC,SAAAA;GAAuBE,UAAAA;GAAuBC;GAC3Gc,UAAAA;EAVO,CAAA;EAeEZ,EAAA,KAAAP;EAAAO,EAAA,KAAAN;EAAAM,EAAA,KAAAL;EAAAK,EAAA,KAAAK,QAAAY;EAAAjB,EAAA,KAAAH;EAAAG,EAAA,KAAAF;EAAAE,EAAA,KAAAgB;CAAA,OAAAA,KAAAhB,EAAA;CAAA,IAAAkB;CAAA,IAAAlB,EAAA,QAAAT,eAAAS,EAAA,QAAAR,OAAA;EACX0B,KAAA,oBAAC,cAAD;GAA2B3B;GAAoBC;EAAK,CAAA;EAAIQ,EAAA,MAAAT;EAAAS,EAAA,MAAAR;EAAAQ,EAAA,MAAAkB;CAAA,OAAAA,KAAAlB,EAAA;CAAA,IAAAmB;CAAA,IAAAnB,EAAA,QAAAQ,MAAAR,EAAA,QAAAE,cAAAF,EAAA,QAAAK,WAAAL,EAAA,QAAAS,MAAAT,EAAA,QAAAU,MAAAV,EAAA,QAAAgB,MAAAhB,EAAA,QAAAkB,MAAAlB,EAAA,QAAAO,oBAAA;EAjBrDY,KAAA,qBAAC,IAAD;GAA6BjB;GAAuB,WAAAO;GAAwCF;GAAkB,GAAMF;GAAK,GAAMK;GAA/H,UAAA,CACHM,IAgBAE,EAjBgB;;EAkBHlB,EAAA,MAAAQ;EAAAR,EAAA,MAAAE;EAAAF,EAAA,MAAAK;EAAAL,EAAA,MAAAS;EAAAT,EAAA,MAAAU;EAAAV,EAAA,MAAAgB;EAAAhB,EAAA,MAAAkB;EAAAlB,EAAA,MAAAO;EAAAP,EAAA,MAAAmB;CAAA,OAAAA,KAAAnB,EAAA;CAAA,OAlBVmB;AAkBU"}
|
|
@@ -37,11 +37,19 @@ type DatePickerProps$1<T extends DateValue = DateValue> = Omit<DatePickerProps<T
|
|
|
37
37
|
* in `em` takes that size from the slot.
|
|
38
38
|
*/
|
|
39
39
|
leadingIcon?: ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the calendar's header draws the month and the year as menu
|
|
42
|
+
* buttons, each opening a list of them in the grid's place — see
|
|
43
|
+
* `Calendar`.
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
showMonthYearMenus?: boolean;
|
|
40
47
|
/** A function may compute the style from the picker's render state. */
|
|
41
48
|
style?: DatePickerProps<T>['style'];
|
|
42
49
|
/**
|
|
43
50
|
* What the button that opens the calendar is called, for a screen reader.
|
|
44
|
-
*
|
|
51
|
+
* Left out, React Aria names it in the reader's locale — "Calendar" in
|
|
52
|
+
* English, followed by the field's own label.
|
|
45
53
|
*/
|
|
46
54
|
triggerLabel?: string;
|
|
47
55
|
/**
|
|
@@ -70,7 +78,7 @@ type DatePickerProps$1<T extends DateValue = DateValue> = Omit<DatePickerProps<T
|
|
|
70
78
|
* The call site's `className` and `style` land on the picker as a whole,
|
|
71
79
|
* which is the element a layout positions.
|
|
72
80
|
*/
|
|
73
|
-
declare function DatePicker$1<T extends DateValue>({ container, description, error, floatingLabel, isDisabled, label, leadingIcon, triggerLabel, variant, ...props }: DatePickerProps$1<T> & RefAttributes<HTMLDivElement>): import("react").JSX.Element;
|
|
81
|
+
declare function DatePicker$1<T extends DateValue>({ container, description, error, floatingLabel, isDisabled, label, leadingIcon, showMonthYearMenus, triggerLabel, variant, ...props }: DatePickerProps$1<T> & RefAttributes<HTMLDivElement>): import("react").JSX.Element;
|
|
74
82
|
//#endregion
|
|
75
83
|
export { type DatePickerProps$1 as DatePickerProps, DatePicker$1 as default };
|
|
76
84
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -42,11 +42,11 @@ function calendarTrigger(triggerLabel) {
|
|
|
42
42
|
* which is the element a layout positions.
|
|
43
43
|
*/
|
|
44
44
|
function DatePicker$1(t0) {
|
|
45
|
-
const $ = c(
|
|
46
|
-
const { container, description, error, floatingLabel: t1, isDisabled: t2, label, leadingIcon,
|
|
45
|
+
const $ = c(34);
|
|
46
|
+
const { container, description, error, floatingLabel: t1, isDisabled: t2, label, leadingIcon, showMonthYearMenus: t3, triggerLabel, variant: t4, ...props$1 } = t0;
|
|
47
47
|
const floatingLabel = t1 === void 0 ? true : t1;
|
|
48
48
|
const isDisabled = t2 === void 0 ? false : t2;
|
|
49
|
-
const
|
|
49
|
+
const showMonthYearMenus = t3 === void 0 ? false : t3;
|
|
50
50
|
const variant = t4 === void 0 ? "filled" : t4;
|
|
51
51
|
const validationBehavior = useFieldValidationBehavior();
|
|
52
52
|
const T0 = DatePicker;
|
|
@@ -57,112 +57,119 @@ function DatePicker$1(t0) {
|
|
|
57
57
|
$[1] = t5;
|
|
58
58
|
} else t5 = $[1];
|
|
59
59
|
const t6 = mergeStatefulStyles(props(fieldStyles.root), props$1);
|
|
60
|
-
|
|
60
|
+
const t7 = props$1.isRequired;
|
|
61
|
+
let t8;
|
|
61
62
|
if ($[2] !== triggerLabel) {
|
|
62
|
-
|
|
63
|
+
t8 = calendarTrigger(triggerLabel);
|
|
63
64
|
$[2] = triggerLabel;
|
|
64
|
-
$[3] =
|
|
65
|
-
} else
|
|
66
|
-
let t8;
|
|
67
|
-
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
68
|
-
t8 = props(picker.group);
|
|
69
|
-
$[4] = t8;
|
|
70
|
-
} else t8 = $[4];
|
|
65
|
+
$[3] = t8;
|
|
66
|
+
} else t8 = $[3];
|
|
71
67
|
let t9;
|
|
68
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
69
|
+
t9 = props(picker.group);
|
|
70
|
+
$[4] = t9;
|
|
71
|
+
} else t9 = $[4];
|
|
72
|
+
let t10;
|
|
72
73
|
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
73
|
-
|
|
74
|
-
...
|
|
74
|
+
t10 = /* @__PURE__ */ jsx(FieldSegments, { children: /* @__PURE__ */ jsx(Group, {
|
|
75
|
+
...t9,
|
|
75
76
|
children: /* @__PURE__ */ jsx(DateInput, {
|
|
76
77
|
...props(segmentStyles.input),
|
|
77
78
|
children: renderSegment
|
|
78
79
|
})
|
|
79
80
|
}) });
|
|
80
|
-
$[5] =
|
|
81
|
-
} else
|
|
82
|
-
let
|
|
83
|
-
if ($[6] !== floatingLabel || $[7] !== label || $[8] !== leadingIcon || $[9] !==
|
|
84
|
-
|
|
81
|
+
$[5] = t10;
|
|
82
|
+
} else t10 = $[5];
|
|
83
|
+
let t11;
|
|
84
|
+
if ($[6] !== floatingLabel || $[7] !== label || $[8] !== leadingIcon || $[9] !== props$1.isRequired || $[10] !== t8 || $[11] !== variant) {
|
|
85
|
+
t11 = /* @__PURE__ */ jsx(FieldBox, {
|
|
85
86
|
floatingLabel,
|
|
86
87
|
isPopulated: true,
|
|
88
|
+
isRequired: t7,
|
|
87
89
|
label,
|
|
88
90
|
leading: leadingIcon,
|
|
89
|
-
trailing:
|
|
91
|
+
trailing: t8,
|
|
90
92
|
variant,
|
|
91
|
-
children:
|
|
93
|
+
children: t10
|
|
92
94
|
});
|
|
93
95
|
$[6] = floatingLabel;
|
|
94
96
|
$[7] = label;
|
|
95
97
|
$[8] = leadingIcon;
|
|
96
|
-
$[9] =
|
|
97
|
-
$[10] =
|
|
98
|
-
$[11] =
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
$[9] = props$1.isRequired;
|
|
99
|
+
$[10] = t8;
|
|
100
|
+
$[11] = variant;
|
|
101
|
+
$[12] = t11;
|
|
102
|
+
} else t11 = $[12];
|
|
103
|
+
let t12;
|
|
104
|
+
if ($[13] !== description || $[14] !== error) {
|
|
105
|
+
t12 = /* @__PURE__ */ jsx(FieldMessage, {
|
|
103
106
|
description,
|
|
104
107
|
error
|
|
105
108
|
});
|
|
106
|
-
$[
|
|
107
|
-
$[
|
|
108
|
-
$[14] = t11;
|
|
109
|
-
} else t11 = $[14];
|
|
110
|
-
let t12;
|
|
111
|
-
if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
|
|
112
|
-
t12 = props(overlay.popup, picker.popover);
|
|
109
|
+
$[13] = description;
|
|
110
|
+
$[14] = error;
|
|
113
111
|
$[15] = t12;
|
|
114
112
|
} else t12 = $[15];
|
|
115
113
|
let t13;
|
|
116
114
|
if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
|
|
117
|
-
t13 = props(overlay.
|
|
115
|
+
t13 = props(overlay.popup, picker.popover);
|
|
118
116
|
$[16] = t13;
|
|
119
117
|
} else t13 = $[16];
|
|
120
118
|
let t14;
|
|
121
|
-
if ($[17]
|
|
122
|
-
t14 =
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
});
|
|
126
|
-
$[17] = label;
|
|
127
|
-
$[18] = t14;
|
|
128
|
-
} else t14 = $[18];
|
|
119
|
+
if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
|
|
120
|
+
t14 = props(overlay.popupDialog, focus.ring);
|
|
121
|
+
$[17] = t14;
|
|
122
|
+
} else t14 = $[17];
|
|
129
123
|
let t15;
|
|
130
|
-
if ($[
|
|
131
|
-
t15 = /* @__PURE__ */ jsx(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
124
|
+
if ($[18] !== label || $[19] !== showMonthYearMenus) {
|
|
125
|
+
t15 = /* @__PURE__ */ jsx(Dialog, {
|
|
126
|
+
...t14,
|
|
127
|
+
children: /* @__PURE__ */ jsx(Calendar$1, {
|
|
128
|
+
"aria-label": label,
|
|
129
|
+
showMonthYearMenus
|
|
130
|
+
})
|
|
135
131
|
});
|
|
136
|
-
$[
|
|
137
|
-
$[
|
|
138
|
-
$[
|
|
139
|
-
} else t15 = $[
|
|
132
|
+
$[18] = label;
|
|
133
|
+
$[19] = showMonthYearMenus;
|
|
134
|
+
$[20] = t15;
|
|
135
|
+
} else t15 = $[20];
|
|
140
136
|
let t16;
|
|
141
|
-
if ($[
|
|
142
|
-
t16 = /* @__PURE__ */
|
|
137
|
+
if ($[21] !== container || $[22] !== t15) {
|
|
138
|
+
t16 = /* @__PURE__ */ jsx(Popover, {
|
|
139
|
+
UNSTABLE_portalContainer: container,
|
|
140
|
+
...t13,
|
|
141
|
+
children: t15
|
|
142
|
+
});
|
|
143
|
+
$[21] = container;
|
|
144
|
+
$[22] = t15;
|
|
145
|
+
$[23] = t16;
|
|
146
|
+
} else t16 = $[23];
|
|
147
|
+
let t17;
|
|
148
|
+
if ($[24] !== T0 || $[25] !== isDisabled || $[26] !== props$1 || $[27] !== t11 || $[28] !== t12 || $[29] !== t16 || $[30] !== t5 || $[31] !== t6 || $[32] !== validationBehavior) {
|
|
149
|
+
t17 = /* @__PURE__ */ jsxs(T0, {
|
|
143
150
|
isDisabled,
|
|
144
151
|
isInvalid: t5,
|
|
145
152
|
validationBehavior,
|
|
146
153
|
...props$1,
|
|
147
154
|
...t6,
|
|
148
155
|
children: [
|
|
149
|
-
t10,
|
|
150
156
|
t11,
|
|
151
|
-
|
|
157
|
+
t12,
|
|
158
|
+
t16
|
|
152
159
|
]
|
|
153
160
|
});
|
|
154
|
-
$[
|
|
155
|
-
$[
|
|
156
|
-
$[
|
|
157
|
-
$[
|
|
158
|
-
$[
|
|
159
|
-
$[
|
|
160
|
-
$[
|
|
161
|
-
$[
|
|
162
|
-
$[
|
|
163
|
-
$[
|
|
164
|
-
} else
|
|
165
|
-
return
|
|
161
|
+
$[24] = T0;
|
|
162
|
+
$[25] = isDisabled;
|
|
163
|
+
$[26] = props$1;
|
|
164
|
+
$[27] = t11;
|
|
165
|
+
$[28] = t12;
|
|
166
|
+
$[29] = t16;
|
|
167
|
+
$[30] = t5;
|
|
168
|
+
$[31] = t6;
|
|
169
|
+
$[32] = validationBehavior;
|
|
170
|
+
$[33] = t17;
|
|
171
|
+
} else t17 = $[33];
|
|
172
|
+
return t17;
|
|
166
173
|
}
|
|
167
174
|
//#endregion
|
|
168
175
|
export { DatePicker$1 as default };
|