@kanso-labs/kanso-ui 0.40.4 → 0.40.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/button/hooks.js +37 -1
- package/dist/button/hooks.js.map +1 -1
- package/dist/button/index.d.ts +57 -1
- package/dist/button/index.js +153 -96
- package/dist/button/index.js.map +1 -1
- package/dist/button/toggle.js +17 -0
- package/dist/button/toggle.js.map +1 -0
- package/dist/calendar/index.js +69 -58
- package/dist/calendar/index.js.map +1 -1
- package/dist/calendar/styles.js +29 -6
- package/dist/calendar/styles.js.map +1 -1
- package/dist/chip/index.js +3 -4
- package/dist/chip/index.js.map +1 -1
- package/dist/chip/styles.js +2 -6
- package/dist/chip/styles.js.map +1 -1
- package/dist/collection/empty.js +7 -0
- package/dist/collection/empty.js.map +1 -0
- package/dist/collection/index.js +125 -2
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/styles.js +14 -0
- package/dist/collection/styles.js.map +1 -1
- package/dist/components/app-bar/index.d.ts +26 -23
- package/dist/components/app-bar/index.js +89 -72
- package/dist/components/app-bar/index.js.map +1 -1
- package/dist/components/autocomplete/index.d.ts +6 -4
- package/dist/components/autocomplete/index.js +23 -14
- package/dist/components/autocomplete/index.js.map +1 -1
- package/dist/components/button/index.d.ts +15 -35
- package/dist/components/button/index.js +102 -74
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/calendar/index.d.ts +9 -3
- package/dist/components/calendar/index.js +51 -42
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/card/index.js +43 -27
- package/dist/components/card/index.js.map +1 -1
- package/dist/components/carousel/index.js +1 -1
- package/dist/components/checkbox/index.d.ts +9 -0
- package/dist/components/checkbox/index.js +47 -35
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/checkbox-group/index.js +1 -1
- package/dist/components/chip/index.d.ts +9 -4
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/chip-group/index.js +51 -37
- package/dist/components/chip-group/index.js.map +1 -1
- package/dist/components/copy-field/index.d.ts +28 -6
- package/dist/components/copy-field/index.js +140 -54
- package/dist/components/copy-field/index.js.map +1 -1
- package/dist/components/currency/index.d.ts +6 -2
- package/dist/components/currency/index.js +74 -46
- package/dist/components/currency/index.js.map +1 -1
- package/dist/components/disclosure/index.js +1 -1
- package/dist/components/icon-button/index.d.ts +6 -31
- package/dist/components/icon-button/index.js +64 -52
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/list/index.js +2 -2
- package/dist/components/list-box/index.d.ts +14 -2
- package/dist/components/list-box/index.js +16 -8
- package/dist/components/list-box/index.js.map +1 -1
- package/dist/components/list-item/index.js +1 -1
- package/dist/components/menu/index.d.ts +14 -1
- package/dist/components/menu/index.js +32 -17
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/navigation-tree/index.js +2 -2
- package/dist/components/radio-group/index.d.ts +4 -0
- package/dist/components/radio-group/index.js +2 -2
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/range-calendar/index.d.ts +9 -3
- package/dist/components/range-calendar/index.js +51 -42
- package/dist/components/range-calendar/index.js.map +1 -1
- package/dist/components/search-view/index.js +1 -1
- package/dist/components/segmented-button/index.d.ts +5 -4
- package/dist/components/segmented-button/index.js +3 -3
- package/dist/components/segmented-button/index.js.map +1 -1
- package/dist/components/split-button/index.d.ts +1 -1
- package/dist/components/split-button/index.js.map +1 -1
- package/dist/components/switch/index.d.ts +9 -2
- package/dist/components/switch/index.js +2 -2
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/table/index.js +3 -3
- package/dist/components/time-picker/index.js +1 -1
- package/dist/components/tree/index.js +2 -2
- package/dist/control/index.js +55 -17
- package/dist/control/index.js.map +1 -1
- package/dist/field/index.js +59 -51
- package/dist/field/index.js.map +1 -1
- package/dist/hooks/useAppBarScroll.d.ts +52 -0
- package/dist/hooks/useAppBarScroll.js +75 -0
- package/dist/hooks/useAppBarScroll.js.map +1 -0
- package/dist/i18n/index.js +2 -0
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.js +68 -0
- package/dist/i18n/messages.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -2
- package/dist/render/name.d.ts +22 -0
- package/dist/styles.css +83 -24
- package/package.json +4 -4
|
@@ -31,7 +31,7 @@ import { Calendar, CalendarCell, CalendarGrid, CalendarGridBody } from "react-ar
|
|
|
31
31
|
* element a layout positions.
|
|
32
32
|
*/
|
|
33
33
|
function Calendar$1(t0) {
|
|
34
|
-
const $ = c(
|
|
34
|
+
const $ = c(23);
|
|
35
35
|
let T0;
|
|
36
36
|
let T1;
|
|
37
37
|
let t1;
|
|
@@ -39,18 +39,20 @@ function Calendar$1(t0) {
|
|
|
39
39
|
let t3;
|
|
40
40
|
let t4;
|
|
41
41
|
let t5;
|
|
42
|
+
let t6;
|
|
42
43
|
if ($[0] !== t0) {
|
|
43
|
-
const { showMonthYearMenus:
|
|
44
|
-
const showMonthYearMenus =
|
|
44
|
+
const { showMonthYearMenus: t7, ...props$1 } = t0;
|
|
45
|
+
const showMonthYearMenus = t7 === void 0 ? false : t7;
|
|
45
46
|
T1 = Calendar;
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
t5 = props$1;
|
|
48
|
+
t6 = mergeStatefulStyles(props(calendarStyles.root), props$1);
|
|
48
49
|
T0 = CalendarFrame;
|
|
49
|
-
t3 =
|
|
50
|
-
|
|
50
|
+
t3 = props$1.visibleDuration?.months ?? 1;
|
|
51
|
+
t4 = showMonthYearMenus;
|
|
52
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
51
53
|
t1 = props(calendarStyles.months);
|
|
52
|
-
$[
|
|
53
|
-
} else t1 = $[
|
|
54
|
+
$[9] = t1;
|
|
55
|
+
} else t1 = $[9];
|
|
54
56
|
t2 = monthOffsets(props$1.visibleDuration?.months ?? 1).map(_temp);
|
|
55
57
|
$[0] = t0;
|
|
56
58
|
$[1] = T0;
|
|
@@ -60,6 +62,7 @@ function Calendar$1(t0) {
|
|
|
60
62
|
$[5] = t3;
|
|
61
63
|
$[6] = t4;
|
|
62
64
|
$[7] = t5;
|
|
65
|
+
$[8] = t6;
|
|
63
66
|
} else {
|
|
64
67
|
T0 = $[1];
|
|
65
68
|
T1 = $[2];
|
|
@@ -68,48 +71,54 @@ function Calendar$1(t0) {
|
|
|
68
71
|
t3 = $[5];
|
|
69
72
|
t4 = $[6];
|
|
70
73
|
t5 = $[7];
|
|
74
|
+
t6 = $[8];
|
|
71
75
|
}
|
|
72
|
-
let
|
|
73
|
-
if ($[
|
|
74
|
-
|
|
76
|
+
let t7;
|
|
77
|
+
if ($[10] !== t1 || $[11] !== t2) {
|
|
78
|
+
t7 = /* @__PURE__ */ jsx("div", {
|
|
75
79
|
...t1,
|
|
76
80
|
children: t2
|
|
77
81
|
});
|
|
78
|
-
$[
|
|
79
|
-
$[
|
|
80
|
-
$[
|
|
81
|
-
} else
|
|
82
|
-
let t7;
|
|
83
|
-
if ($[12] !== T0 || $[13] !== t3 || $[14] !== t6) {
|
|
84
|
-
t7 = /* @__PURE__ */ jsx(T0, {
|
|
85
|
-
showMonthYearMenus: t3,
|
|
86
|
-
children: t6
|
|
87
|
-
});
|
|
88
|
-
$[12] = T0;
|
|
89
|
-
$[13] = t3;
|
|
90
|
-
$[14] = t6;
|
|
91
|
-
$[15] = t7;
|
|
92
|
-
} else t7 = $[15];
|
|
82
|
+
$[10] = t1;
|
|
83
|
+
$[11] = t2;
|
|
84
|
+
$[12] = t7;
|
|
85
|
+
} else t7 = $[12];
|
|
93
86
|
let t8;
|
|
94
|
-
if ($[
|
|
95
|
-
t8 = /* @__PURE__ */ jsx(
|
|
96
|
-
|
|
97
|
-
|
|
87
|
+
if ($[13] !== T0 || $[14] !== t3 || $[15] !== t4 || $[16] !== t7) {
|
|
88
|
+
t8 = /* @__PURE__ */ jsx(T0, {
|
|
89
|
+
months: t3,
|
|
90
|
+
showMonthYearMenus: t4,
|
|
98
91
|
children: t7
|
|
99
92
|
});
|
|
100
|
-
$[
|
|
101
|
-
$[
|
|
102
|
-
$[
|
|
103
|
-
$[
|
|
104
|
-
$[
|
|
105
|
-
} else t8 = $[
|
|
106
|
-
|
|
93
|
+
$[13] = T0;
|
|
94
|
+
$[14] = t3;
|
|
95
|
+
$[15] = t4;
|
|
96
|
+
$[16] = t7;
|
|
97
|
+
$[17] = t8;
|
|
98
|
+
} else t8 = $[17];
|
|
99
|
+
let t9;
|
|
100
|
+
if ($[18] !== T1 || $[19] !== t5 || $[20] !== t6 || $[21] !== t8) {
|
|
101
|
+
t9 = /* @__PURE__ */ jsx(T1, {
|
|
102
|
+
...t5,
|
|
103
|
+
...t6,
|
|
104
|
+
children: t8
|
|
105
|
+
});
|
|
106
|
+
$[18] = T1;
|
|
107
|
+
$[19] = t5;
|
|
108
|
+
$[20] = t6;
|
|
109
|
+
$[21] = t8;
|
|
110
|
+
$[22] = t9;
|
|
111
|
+
} else t9 = $[22];
|
|
112
|
+
return t9;
|
|
107
113
|
}
|
|
108
114
|
function _temp(offset) {
|
|
109
|
-
return /* @__PURE__ */
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
115
|
+
return /* @__PURE__ */ jsx("div", {
|
|
116
|
+
...props(calendarStyles.month),
|
|
117
|
+
children: /* @__PURE__ */ jsxs(CalendarGrid, {
|
|
118
|
+
offset,
|
|
119
|
+
...props(calendarStyles.grid),
|
|
120
|
+
children: [/* @__PURE__ */ jsx(CalendarGridHeader$1, {}), /* @__PURE__ */ jsx(CalendarGridBody, { children: gridCell })]
|
|
121
|
+
})
|
|
113
122
|
}, offset.months);
|
|
114
123
|
}
|
|
115
124
|
function cellClassName(state) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","CalendarDate","ReactElement","RefAttributes","DateValue","CalendarProps","RACCalendarProps","stylex","Calendar","RACCalendar","CalendarCell","RACCalendarCell","CalendarGrid","RACCalendarGrid","CalendarGridBody","RACCalendarGridBody","CalendarFrame","CalendarGridHeader","monthOffsets","calendarStyles","dateLayers","focus","mergeStatefulStyles","Omit","T","className","showMonthYearMenus","style","t0","$","T0","T1","t1","t2","t3","t4","t5","t6","props","undefined","root","Symbol","for","months","visibleDuration","map","_temp","t7","t8","offset","grid","gridCell","cellClassName","state","isDisabled","isHovered","isPressed","isSelected","isToday","isUnavailable","cell","ring","cellToday","cellSelected","selectedHovered","plainHovered","selectedPressed","plainPressed","cellUnavailable","cellDisabled","date","Calendar","_c","props","RACCalendar","stylex.props","RACCalendarGrid","CalendarGridHeader","RACCalendarGridBody","RACCalendarCell"],"sources":["../../../src/components/calendar/index.tsx"],"sourcesContent":["'use client';\n\nimport type { CalendarDate } from '@internationalized/date';\nimport type { ReactElement, RefAttributes } from 'react';\nimport type { DateValue, CalendarProps as RACCalendarProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { Calendar as RACCalendar, CalendarCell as RACCalendarCell, CalendarGrid as RACCalendarGrid, CalendarGridBody as RACCalendarGridBody } from 'react-aria-components';\nimport { CalendarFrame, CalendarGridHeader } from '../../calendar';\nimport { monthOffsets } from '../../calendar/months';\nimport { calendarStyles, dateLayers } from '../../calendar/styles';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\n\n// The date pickers page's docked calendar: a month grid with a circle on the\n// selected date and an outline on today. Its values are that page's — a\n// 360dp container on the high surface container, 48dp date cells with a 40dp\n// state layer inside them, body-large for both the weekday row and the dates,\n// primary for the selected circle and for today's outline.\n//\n// The page's container is 456dp tall, which this does not take: that height\n// is a picker's, counting a headline and an action row the calendar itself\n// does not draw. What is held instead is the grid, at six weeks — the most\n// any month occupies — so the calendar keeps its height as the month moves\n// and a shorter month leaves its last rows empty. `months` in\n// `src/calendar/styles.ts` is where the room is reserved.\n//\n// `showMonthYearMenus` draws the page's docked header instead of one heading:\n// the month's menu button between the chevrons that step it and the year's\n// after them, each opening its list where the grid was. The parts are in\n// `src/calendar`, shared with RangeCalendar.\n//\n// Five things are this component's own.\n//\n// **The year menu has no chevrons of its own.** The page draws a pair either\n// side of it that step a year, which would need two names React Aria has no\n// message for — the library writes a word of its own only behind a prop that\n// can replace it, and it would take a pair on four components. The year list\n// reaches any year the bounds allow in one press, and Shift with Page Up or\n// Page Down steps a year from the keyboard.\n//\n// **The cell is a circle in a square.** The page gives the date a 48dp\n// container and a 40dp state layer, which is a 40dp circle with 4dp of room\n// around it. Each date's own inline margin supplies that room, with the\n// grid's `border-spacing` left at zero, so the circle is the element and the\n// square is the room around it — rather than a 48dp box with a 40dp box\n// inside it.\n//\n// **A date from the month either side is faded because it is disabled, not\n// because it is outside.** React Aria marks those cells `data-outside-month`\n// and disables them in the same breath, so a treatment keyed on the first\n// would never draw anything the second had not already drawn. The disabled\n// fade is the page's 38% either way.\n//\n// **Today reads as today whether or not it is selected.** The page gives it\n// an outline and the primary label; selected gives it a filled circle and the\n// on-primary label. A selected today takes the fill, since a circle already\n// says where you are and two rings would say it twice.\n//\n// **The month is moved by IconButton's shape rather than by IconButton.**\n// React Aria wires `slot=\"previous\"` and `slot=\"next\"` on its own `Button`,\n// and IconButton renders React Aria's `Button` too — so nesting one inside\n// the slot would put two buttons where the page draws one. The chevrons take\n// the standard icon button's 40dp square and its state layer instead.\n\ntype CalendarProps<T extends DateValue = DateValue> = Omit<RACCalendarProps<T>, 'children' | 'className' | 'style'> & {\n /** A function may compute the class from the calendar's render state. */\n className?: RACCalendarProps<T>['className'];\n /**\n * Whether the header draws the month and the year as menu buttons, each\n * opening a list of them in the grid's place, as the docked date picker's\n * header does, rather than one heading between the chevrons. For a date\n * far from the one shown, such as a date of birth.\n * @default false\n */\n showMonthYearMenus?: boolean;\n /** A function may compute the style from the calendar's render state. */\n style?: RACCalendarProps<T>['style'];\n};\n\n/**\n * A month calendar for picking a date. The value is React Aria's: pass\n * `value` with `onChange` to control it, or `defaultValue` to let it keep its\n * own, both as an `@internationalized/date` value from this package's\n * `./date` subpath.\n *\n * ```tsx\n * import { today, getLocalTimeZone } from '@kanso-labs/kanso-ui/date'\n *\n * <Calendar aria-label=\"Label\" defaultValue={today(getLocalTimeZone())} />\n * ```\n *\n * `minValue` and `maxValue` bound it, `isDateUnavailable` rules individual\n * dates out, and `visibleDuration` of `{ months: 2 }` draws two months side\n * by side, stacked below the expanded breakpoint. Name it with `aria-label`\n * or `aria-labelledby`; React Aria composes the visible month into that name\n * itself.\n *\n * The call site's `className` and `style` land on the container, which is the\n * element a layout positions.\n */\nfunction Calendar<T extends DateValue>({\n showMonthYearMenus = false,\n ...props\n}: CalendarProps<T> & RefAttributes<HTMLDivElement>) {\n return <RACCalendar<T> {...props} {...mergeStatefulStyles(stylex.props(calendarStyles.root), props)}>\n <CalendarFrame showMonthYearMenus={showMonthYearMenus}>\n <div {...stylex.props(calendarStyles.months)}>\n {monthOffsets(props.visibleDuration?.months ?? 1).map(offset => <RACCalendarGrid key={offset.months} offset={offset} {...stylex.props(calendarStyles.grid)}>\n <CalendarGridHeader />\n <RACCalendarGridBody>{gridCell}</RACCalendarGridBody>\n </RACCalendarGrid>)}\n </div>\n </CalendarFrame>\n </RACCalendar>;\n}\n\n// A date's classes, from React Aria's render state. StyleX cannot target\n// `[data-selected]` on the element it is styling, so the state comes from\n// what React Aria hands the className.\n//\n// The order matters. `selected` is applied after `today`, so a selected today\n// takes the fill rather than the outline — a circle already says where you\n// are, and two rings would say it twice. The hover and pressed layers come\n// next, over whichever ground the date has, a press over a hover.\n// `unavailable` and `disabled` come last, and StyleX replaces a property\n// whole, so they take the layers with them.\nfunction cellClassName(state: {\n isDisabled: boolean;\n isHovered: boolean;\n isPressed: boolean;\n isSelected: boolean;\n isToday: boolean;\n isUnavailable: boolean;\n}) {\n return stylex.props(calendarStyles.cell, focus.ring, state.isToday && calendarStyles.cellToday, state.isSelected && calendarStyles.cellSelected, state.isHovered && (state.isSelected ? dateLayers.selectedHovered : dateLayers.plainHovered), state.isPressed && (state.isSelected ? dateLayers.selectedPressed : dateLayers.plainPressed), state.isUnavailable && calendarStyles.cellUnavailable, state.isDisabled && calendarStyles.cellDisabled).className ?? '';\n}\nfunction gridCell(date: CalendarDate): ReactElement {\n return <RACCalendarCell className={cellClassName} date={date} />;\n}\nexport type { CalendarProps };\nexport default Calendar;"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoGA,SAAAS,WAAAoB,IAAA;CAAA,MAAAC,IAAA7B,EAAA,EAAA;CAAA,IAAA8B;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAP,EAAA,OAAAD,IAAA;EAAuC,MAAA,EAAAF,oBAAAW,IAAA,GAAAC,YAAAV;EACrC,MAAAF,qBAAAW,OAAAE,KAAAA,IAAA,QAAAF;EAGQN,KAAAtB;EAAmB6B,KAAAA;EAAWF,KAAAd,oBAAoBf,MAAaY,eAAcqB,IAAK,GAAGF,OAAK;EAC7FR,KAAAd;EAAkCU,KAAAA;EAAkB,IAAAG,EAAA,OAAAY,OAAAC,IAAA,2BAAA,GAAA;GAC1CV,KAAAzB,MAAaY,eAAcwB,MAAO;GAACd,EAAA,KAAAG;EAAA,OAAAA,KAAAH,EAAA;EACzCI,KAAAf,aAAaoB,QAAKM,iBAAwBD,UAA7B,CAAkC,CAAC,CAAAE,IAAKC,KAGlC;EAACjB,EAAA,KAAAD;EAAAC,EAAA,KAAAC;EAAAD,EAAA,KAAAE;EAAAF,EAAA,KAAAG;EAAAH,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;EAAAL,EAAA,KAAAM;EAAAN,EAAA,KAAAO;CAAA,OAAA;EAAAN,KAAAD,EAAA;EAAAE,KAAAF,EAAA;EAAAG,KAAAH,EAAA;EAAAI,KAAAJ,EAAA;EAAAK,KAAAL,EAAA;EAAAM,KAAAN,EAAA;EAAAO,KAAAP,EAAA;CAAA;CAAA,IAAAQ;CAAA,IAAAR,EAAA,OAAAG,MAA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eZ,MAAMG,cAAcH,MAAMI,aAAarC,WAAW8C,kBAAkB9C,WAAW+C,eAAed,MAAMM,iBAAiBxC,eAAeiD,iBAAiBf,MAAMC,cAAcnC,eAAekD,YAAY,CAAC,CAAC5C,aAAa;AACpc;AACA,SAAS0B,SAASmB,MAAkC;CAClD,OAAO,oBAACS,cAAD;EAAiB,WAAW3B;EAAqBkB;CAAK,CAAA;AAC/D"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","CalendarDate","ReactElement","RefAttributes","DateValue","CalendarProps","RACCalendarProps","stylex","Calendar","RACCalendar","CalendarCell","RACCalendarCell","CalendarGrid","RACCalendarGrid","CalendarGridBody","RACCalendarGridBody","CalendarFrame","CalendarGridHeader","monthOffsets","calendarStyles","dateLayers","focus","mergeStatefulStyles","className","T","showMonthYearMenus","style","Omit","t0","$","T0","T1","t1","t2","t3","t4","t5","t6","t7","props","undefined","root","visibleDuration","months","Symbol","for","map","_temp","t8","t9","offset","month","grid","gridCell","cellClassName","state","isDisabled","isHovered","isPressed","isSelected","isToday","isUnavailable","cell","ring","cellToday","cellSelected","selectedHovered","plainHovered","selectedPressed","plainPressed","cellUnavailable","cellDisabled","date","Calendar","_c","props","RACCalendar","stylex.props","RACCalendarGrid","CalendarGridHeader","RACCalendarGridBody","RACCalendarCell"],"sources":["../../../src/components/calendar/index.tsx"],"sourcesContent":["'use client';\n\nimport type { CalendarDate } from '@internationalized/date';\nimport type { ReactElement, RefAttributes } from 'react';\nimport type { DateValue, CalendarProps as RACCalendarProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { Calendar as RACCalendar, CalendarCell as RACCalendarCell, CalendarGrid as RACCalendarGrid, CalendarGridBody as RACCalendarGridBody } from 'react-aria-components';\nimport { CalendarFrame, CalendarGridHeader } from '../../calendar';\nimport { monthOffsets } from '../../calendar/months';\nimport { calendarStyles, dateLayers } from '../../calendar/styles';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\n\n// The date pickers page's docked calendar: a month grid with a circle on the\n// selected date and an outline on today. Its values are that page's — a\n// 360dp container on the high surface container, 48dp date cells with a 40dp\n// state layer inside them, body-large for both the weekday row and the dates,\n// primary for the selected circle and for today's outline.\n//\n// The page's container is 456dp tall, which this does not take: that height\n// is a picker's, counting a headline and an action row the calendar itself\n// does not draw. What is held instead is the grid, at six weeks — the most\n// any month occupies — so the calendar keeps its height as the month moves\n// and a shorter month leaves its last rows empty. `months` in\n// `src/calendar/styles.ts` is where the room is reserved.\n//\n// `showMonthYearMenus` draws the page's docked header instead of one heading:\n// the month's menu button between the chevrons that step it and the year's\n// after them, each opening its list where the grid was. The parts are in\n// `src/calendar`, shared with RangeCalendar.\n//\n// Five things are this component's own.\n//\n// **The year menu has no chevrons of its own.** The page draws a pair either\n// side of it that step a year, which would need two names React Aria has no\n// message for — the library writes a word of its own only behind a prop that\n// can replace it, and it would take a pair on four components. The year list\n// reaches any year within a century of the one shown in one press, or any\n// the bounds allow where they are closer, and Shift with Page Up or Page\n// Down steps a year from the keyboard.\n//\n// **The cell is a circle in a square.** The page gives the date a 48dp\n// container and a 40dp state layer, which is a 40dp circle with 4dp of room\n// around it. The circle is the element, centred in a 48dp column and a 48dp\n// row — the pitch Compose lays its days at — and a transparent box reaching\n// the 4dp past it on every side makes the whole square the press target,\n// rather than a 48dp box with a 40dp box inside it. The chevrons and the\n// month and year menu buttons reach a 48dp target the same way.\n//\n// **It narrows to its container.** The page's docked calendar is 360dp, and\n// a compact window leaves 328dp between its margins, so the calendar is 360\n// at most and the columns share whatever is left below that. Under about\n// 304dp of content a column is narrower than its 40dp circle, and the\n// circles of neighbouring dates meet.\n//\n// **A date from the month either side is faded because it is disabled, not\n// because it is outside.** React Aria marks those cells `data-outside-month`\n// and disables them in the same breath, so a treatment keyed on the first\n// would never draw anything the second had not already drawn. The disabled\n// fade is the page's 38% either way.\n//\n// **Today reads as today whether or not it is selected.** The page gives it\n// an outline and the primary label; selected gives it a filled circle and the\n// on-primary label. A selected today takes the fill, since a circle already\n// says where you are and two rings would say it twice.\n//\n// **The month is moved by IconButton's shape rather than by IconButton.**\n// React Aria wires `slot=\"previous\"` and `slot=\"next\"` on its own `Button`,\n// and IconButton renders React Aria's `Button` too — so nesting one inside\n// the slot would put two buttons where the page draws one. The chevrons take\n// the standard icon button's 40dp square and its state layer instead.\n\ntype CalendarProps<T extends DateValue = DateValue> = {\n /** A function may compute the class from the calendar's render state. */\n className?: RACCalendarProps<T>['className'];\n /**\n * Whether the header draws the month and the year as menu buttons, each\n * opening a list of them in the grid's place, as the docked date picker's\n * header does, rather than one heading between the chevrons. For a date\n * far from the one shown, such as a date of birth: the year list runs a\n * century either side of the year shown, or to `minValue` and `maxValue`\n * where they are closer.\n *\n * For one visible month. With `visibleDuration` of more than one, the\n * header is the plain one, whose heading names every month shown — the\n * menus name only the first, which would leave the others unlabelled.\n * @default false\n */\n showMonthYearMenus?: boolean;\n /** A function may compute the style from the calendar's render state. */\n style?: RACCalendarProps<T>['style'];\n} & Omit<RACCalendarProps<T>, 'children' | 'className' | 'style'>;\n\n/**\n * A month calendar for picking a date. The value is React Aria's: pass\n * `value` with `onChange` to control it, or `defaultValue` to let it keep its\n * own, both as an `@internationalized/date` value from this package's\n * `./date` subpath.\n *\n * ```tsx\n * import { today, getLocalTimeZone } from '@kanso-labs/kanso-ui/date'\n *\n * <Calendar aria-label=\"Label\" defaultValue={today(getLocalTimeZone())} />\n * ```\n *\n * `minValue` and `maxValue` bound it, `isDateUnavailable` rules individual\n * dates out, and `visibleDuration` of `{ months: 2 }` draws two months side\n * by side, stacked below the expanded breakpoint. Name it with `aria-label`\n * or `aria-labelledby`; React Aria composes the visible month into that name\n * itself.\n *\n * The call site's `className` and `style` land on the container, which is the\n * element a layout positions.\n */\nfunction Calendar<T extends DateValue>({\n showMonthYearMenus = false,\n ...props\n}: CalendarProps<T> & RefAttributes<HTMLDivElement>) {\n return <RACCalendar<T> {...props} {...mergeStatefulStyles(stylex.props(calendarStyles.root), props)}>\n <CalendarFrame months={props.visibleDuration?.months ?? 1} showMonthYearMenus={showMonthYearMenus}>\n <div {...stylex.props(calendarStyles.months)}>\n {monthOffsets(props.visibleDuration?.months ?? 1).map(offset => <div key={offset.months} {...stylex.props(calendarStyles.month)}>\n <RACCalendarGrid offset={offset} {...stylex.props(calendarStyles.grid)}>\n <CalendarGridHeader />\n <RACCalendarGridBody>{gridCell}</RACCalendarGridBody>\n </RACCalendarGrid>\n </div>)}\n </div>\n </CalendarFrame>\n </RACCalendar>;\n}\n\n// A date's classes, from React Aria's render state. StyleX cannot target\n// `[data-selected]` on the element it is styling, so the state comes from\n// what React Aria hands the className.\n//\n// The order matters. `selected` is applied after `today`, so a selected today\n// takes the fill rather than the outline — a circle already says where you\n// are, and two rings would say it twice. The hover and pressed layers come\n// next, over whichever ground the date has, a press over a hover.\n// `unavailable` and `disabled` come last, and StyleX replaces a property\n// whole, so they take the layers with them.\nfunction cellClassName(state: {\n isDisabled: boolean;\n isHovered: boolean;\n isPressed: boolean;\n isSelected: boolean;\n isToday: boolean;\n isUnavailable: boolean;\n}) {\n return stylex.props(calendarStyles.cell, focus.ring, state.isToday && calendarStyles.cellToday, state.isSelected && calendarStyles.cellSelected, state.isHovered && (state.isSelected ? dateLayers.selectedHovered : dateLayers.plainHovered), state.isPressed && (state.isSelected ? dateLayers.selectedPressed : dateLayers.plainPressed), state.isUnavailable && calendarStyles.cellUnavailable, state.isDisabled && calendarStyles.cellDisabled).className ?? '';\n}\nfunction gridCell(date: CalendarDate): ReactElement {\n return <RACCalendarCell className={cellClassName} date={date} />;\n}\nexport type { CalendarProps };\nexport default Calendar;"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkHA,SAAAS,WAAAoB,IAAA;CAAA,MAAAC,IAAA7B,EAAA,EAAA;CAAA,IAAA8B;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAA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AClD,OAAO,oBAACS,cAAD;EAAiB,WAAW3B;EAAqBkB;CAAK,CAAA;AAC/D"}
|
|
@@ -5,7 +5,7 @@ import { mergeStyles } from "../../styles/merge.js";
|
|
|
5
5
|
import { focus } from "../../styles/focus.js";
|
|
6
6
|
import { useRipple } from "../../hooks/useRipple.js";
|
|
7
7
|
import { c } from "react/compiler-runtime";
|
|
8
|
-
import { Fragment, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
//#region src/components/card/index.tsx
|
|
10
10
|
const styles = {
|
|
11
11
|
base: {
|
|
@@ -20,6 +20,12 @@ const styles = {
|
|
|
20
20
|
kybGjl: "x1hl2dhg",
|
|
21
21
|
$$css: true
|
|
22
22
|
},
|
|
23
|
+
content: {
|
|
24
|
+
kB7OPa: "x9f619",
|
|
25
|
+
k1xSpc: "x1lliihq",
|
|
26
|
+
kAzted: "x1us19tq",
|
|
27
|
+
$$css: true
|
|
28
|
+
},
|
|
23
29
|
elevated: {
|
|
24
30
|
kWkggS: "x1vnz5z6",
|
|
25
31
|
kGVxlE: "x19efjv6",
|
|
@@ -86,7 +92,7 @@ const interactionStyles = {
|
|
|
86
92
|
* navigates.
|
|
87
93
|
*/
|
|
88
94
|
function Card(t0) {
|
|
89
|
-
const $ = c(
|
|
95
|
+
const $ = c(26);
|
|
90
96
|
const { children, interactive: t1, onClick, onContextMenu, onPointerCancel, onPointerDown, onPointerLeave, onPointerUp, padding: t2, render, variant: t3, ...props$1 } = t0;
|
|
91
97
|
const interactive = t1 === void 0 ? false : t1;
|
|
92
98
|
const padding = t2 === void 0 ? "default" : t2;
|
|
@@ -121,42 +127,52 @@ function Card(t0) {
|
|
|
121
127
|
} else t6 = $[9];
|
|
122
128
|
const t7 = ripple.handlers;
|
|
123
129
|
let t8;
|
|
124
|
-
if ($[10] !== children || $[11] !==
|
|
125
|
-
t8 = /* @__PURE__ */
|
|
130
|
+
if ($[10] !== children || $[11] !== interactive) {
|
|
131
|
+
t8 = interactive ? /* @__PURE__ */ jsx("span", {
|
|
132
|
+
className: "x9f619 x1lliihq x1us19tq",
|
|
133
|
+
children
|
|
134
|
+
}) : children;
|
|
126
135
|
$[10] = children;
|
|
127
|
-
$[11] =
|
|
136
|
+
$[11] = interactive;
|
|
128
137
|
$[12] = t8;
|
|
129
138
|
} else t8 = $[12];
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
139
|
+
let t9;
|
|
140
|
+
if ($[13] !== ripple.surface || $[14] !== t8) {
|
|
141
|
+
t9 = /* @__PURE__ */ jsxs(Fragment, { children: [t8, ripple.surface] });
|
|
142
|
+
$[13] = ripple.surface;
|
|
143
|
+
$[14] = t8;
|
|
144
|
+
$[15] = t9;
|
|
145
|
+
} else t9 = $[15];
|
|
146
|
+
const t10 = mergeStyles(props(styles.base, styles[variant], padded, interactive && styles.interactive, interactive && variant !== "outlined" && styles.interactiveBoundary, interactive && focus.ring, interactive && interactionStyles[variant]), props$1);
|
|
147
|
+
let t11;
|
|
148
|
+
if ($[16] !== props$1 || $[17] !== ripple.handlers || $[18] !== t10 || $[19] !== t6 || $[20] !== t9) {
|
|
149
|
+
t11 = {
|
|
134
150
|
...props$1,
|
|
135
151
|
...t6,
|
|
136
152
|
...t7,
|
|
137
|
-
children:
|
|
138
|
-
...
|
|
153
|
+
children: t9,
|
|
154
|
+
...t10
|
|
139
155
|
};
|
|
140
|
-
$[
|
|
141
|
-
$[
|
|
142
|
-
$[15] = t6;
|
|
143
|
-
$[16] = t8;
|
|
144
|
-
$[17] = t9;
|
|
156
|
+
$[16] = props$1;
|
|
157
|
+
$[17] = ripple.handlers;
|
|
145
158
|
$[18] = t10;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
159
|
+
$[19] = t6;
|
|
160
|
+
$[20] = t9;
|
|
161
|
+
$[21] = t11;
|
|
162
|
+
} else t11 = $[21];
|
|
163
|
+
let t12;
|
|
164
|
+
if ($[22] !== render || $[23] !== t11 || $[24] !== t5) {
|
|
165
|
+
t12 = {
|
|
150
166
|
defaultTagName: t5,
|
|
151
|
-
props:
|
|
167
|
+
props: t11,
|
|
152
168
|
render
|
|
153
169
|
};
|
|
154
|
-
$[
|
|
155
|
-
$[
|
|
156
|
-
$[
|
|
157
|
-
$[
|
|
158
|
-
} else
|
|
159
|
-
return useRender(
|
|
170
|
+
$[22] = render;
|
|
171
|
+
$[23] = t11;
|
|
172
|
+
$[24] = t5;
|
|
173
|
+
$[25] = t12;
|
|
174
|
+
} else t12 = $[25];
|
|
175
|
+
return useRender(t12);
|
|
160
176
|
}
|
|
161
177
|
//#endregion
|
|
162
178
|
export { Card as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","stylex","RenderComponentProps","useRipple","useRender","focus","mergeStyles","colors","radii","shadows","spacing","stateLayerOpacity","FORCED_COLORS","styles","base","kaIpWk","kMzoRj","kB7OPa","kMwMTN","k1xSpc","kVQacm","kHjlTd","kVAEAm","kybGjl","$$css","elevated","kWkggS","kGVxlE","filled","interactive","kkrTdU","kVVagm","kzqmXN","k9WMMc","interactiveBoundary","kVAM5u","ksu8eU","outlined","paddingDefault","kmVPX3","paddingNone","HOVER_CAPABLE","interactionStyles","CardProps","padding","variant","CardVariant","Card","t0","$","children","t1","onClick","onContextMenu","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","t2","render","t3","props","undefined","t4","ripple","padded","t5","t6","type","t7","handlers","t8","surface","t9","ring","t10","t11","defaultTagName","_c","props","stylex.props"],"sources":["../../../src/components/card/index.tsx"],"sourcesContent":["'use client';\n\nimport * as stylex from '@stylexjs/stylex';\nimport type { RenderComponentProps } from '../../render/useRender';\nimport { useRipple } from '../../hooks/useRipple';\nimport { useRender } from '../../render/useRender';\nimport { focus } from '../../styles/focus';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, shadows, spacing, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\n\n// The three variants differ only in how they separate themselves from the\n// page: a shadow, a darker fill, or a border. Each therefore sits on a\n// different background, which is why the interaction styles below are keyed\n// by variant too — a state layer composites an 'on-color' over whatever the\n// container already is, so it cannot be written once for all three.\n//\n// color-mix() is inlined at each property rather than factored into a helper:\n// @stylexjs/babel-plugin only statically recognizes expressions written\n// directly as property values. Button's header comment records the same\n// constraint.\n// Windows High Contrast and the rest of the forced-colours modes. Spelled\n// here rather than imported, for the reason src/field/styles.ts records: the\n// StyleX compiler resolves a constant across files only out of a `.stylex.ts`\n// module, and the generated one holds design tokens rather than queries.\nconst FORCED_COLORS = '@media (forced-colors: active)';\nconst styles = {\n base: {\n kaIpWk: \"x62ce2h\",\n kMzoRj: \"xc342km\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x1heor9g\",\n k1xSpc: \"x1lliihq\",\n kVQacm: \"x7giv3\",\n kHjlTd: \"xj0a0fe\",\n kVAEAm: \"x1n2onr6\",\n kybGjl: \"x1hl2dhg\",\n $$css: true\n },\n elevated: {\n kWkggS: \"x1vnz5z6\",\n kGVxlE: \"x19efjv6\",\n $$css: true\n },\n filled: {\n kWkggS: \"x1rrhr5q\",\n $$css: true\n },\n interactive: {\n kkrTdU: \"x1ypdohk\",\n kVVagm: \"xln7xf2\",\n kzqmXN: \"xh8yej3\",\n k9WMMc: \"x1yc453h\",\n $$css: true\n },\n interactiveBoundary: {\n kVAM5u: \"x1ylmb6m\",\n ksu8eU: \"xx61lck\",\n kMzoRj: \"xc342km x13rsnn2\",\n $$css: true\n },\n outlined: {\n kWkggS: \"x14s9m32\",\n kVAM5u: \"x133yhug\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xmkeg23\",\n $$css: true\n },\n paddingDefault: {\n kmVPX3: \"xgc26li\",\n $$css: true\n },\n paddingNone: {\n kmVPX3: \"x1717udv\",\n $$css: true\n }\n};\n\n// A pointer that can hover: a mouse or a trackpad, not a finger. An\n// interactive card is a plain element React Aria does not host, so it has no\n// `isHovered` to draw its hover layer from, and Chromium leaves `:hover` on\n// whatever a touch last tapped — a card tapped and then navigated back to\n// stayed lifted. Inside this query a touch screen draws no hover at all. A\n// touchscreen laptop still matches it for its trackpad, which is the limit of\n// asking the device rather than the event.\nconst HOVER_CAPABLE = '@media (hover: hover)';\n\n// The state layers, from pseudo-classes, since the card has no render state\n// to read — see `HOVER_CAPABLE`.\n// `:active` is written twice, bare for a touch and again inside the query.\n// StyleX orders a rule by the sum of its conditions, so a hover inside the\n// query would otherwise come after a bare press and win while both held.\nconst interactionStyles = {\n elevated: {\n kWkggS: \"xu5m21g x17zbzf9 x1ru19e0 x1vnz5z6\",\n kGVxlE: \"x1g60mc1 x14zlms8 xqmo4o3 x19efjv6\",\n $$css: true\n },\n filled: {\n kWkggS: \"x1w49kxs x10l1pcx xt0lj0h x1rrhr5q\",\n $$css: true\n },\n outlined: {\n kWkggS: \"x1jqfdmz x1ie1ydn x1dau0i7 x14s9m32\",\n $$css: true\n }\n};\n\n// Typed as the attributes a <div> accepts, because that is the surface every\n// element this can render shares. Anything element-specific — a button's\n// `type`, an anchor's `href` — would be wrong for the others, and does not\n// need to be here anyway: those are written on the element handed to\n// `render`, where TypeScript checks them against that element's own props.\ntype CardProps = {\n /**\n * Makes the card the thing you press: it ripples, lifts on hover, and takes\n * a focus ring. Renders a `<button>` unless `render` says otherwise. Leave\n * it off for a card that merely holds content, including one containing its\n * own buttons.\n * @default false\n */\n interactive?: boolean;\n /**\n * `none` removes the card's own padding, for a card whose children run to\n * its edges — a list of rows separated by rules.\n * @default 'default'\n */\n padding?: 'default' | 'none';\n /**\n * How the card separates itself from the page: `elevated` casts a shadow,\n * `filled` sits on a darker surface, `outlined` draws a border.\n * @default 'elevated'\n */\n variant?: CardVariant;\n} & RenderComponentProps<'div'>;\ntype CardVariant = 'elevated' | 'filled' | 'outlined';\n\n/**\n * A surface holding related content. `render` decides which element that\n * surface is, so a card that navigates can be a real `<a href>` — announced\n * as a link and opening in a new tab on a modifier click, which a `<button>`\n * with an onClick does neither of.\n *\n * `interactive` and `render` are separate axes. `interactive` says the card\n * is pressable and gives it the ripple, the hover lift, and a focus ring;\n * `render` says what it is. A pressable card with no `render` is a\n * `<button>`, which is the right default for one that acts rather than\n * navigates.\n */\nfunction Card({\n children,\n interactive = false,\n onClick,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n padding = 'default',\n render,\n variant = 'elevated',\n ...props\n}: CardProps) {\n // The consumer's own pointer handlers are handed to useRipple to merge\n // rather than spread over its handlers afterwards, which is what Button\n // does and for the same reason: a plain spread means whichever object\n // comes last silently wins, so an onPointerDown on the call site would\n // replace the one driving the ripple and the card would stop rippling.\n const ripple = useRipple(interactive, {\n onClick,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp\n });\n const padded = padding === 'none' ? styles.paddingNone : styles.paddingDefault;\n return useRender({\n defaultTagName: interactive ? 'button' : 'div',\n props: {\n ...props,\n // Only when the default <button> is what renders. On an element the\n // call site chose, `type` is either meaningless or wrong — an <a>'s\n // `type` is a hint about the MIME type of what it links to — and that\n // element's own attributes are the call site's to write.\n ...(interactive && render === undefined ? {\n type: 'button'\n } : undefined),\n ...ripple.handlers,\n children: <>\n {children}\n {ripple.surface}\n </>,\n ...mergeStyles(stylex.props(styles.base, styles[variant], padded, interactive && styles.interactive, interactive && variant !== 'outlined' && styles.interactiveBoundary, interactive && focus.ring, interactive && interactionStyles[variant]), props)\n },\n render\n });\n}\nexport type { CardProps, CardVariant };\nexport default Card;"],"mappings":";;;;;;;;;AA0BA,MAAMc,SAAS;CACbC,MAAM;EACJC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;CACT;CACAC,UAAU;EACRC,QAAQ;EACRC,QAAQ;EACRH,OAAO;CAC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AAAlB,EAAA,MAAAsB;EAAAtB,EAAA,MAAAwB;EAAAxB,EAAA,MAAA0B;CAAA,OAAAA,MAAA1B,EAAA;CAAA,IAAA2B;CAAA,IAAA3B,EAAA,QAAAU,UAAAV,EAAA,QAAA0B,OAAA1B,EAAA,QAAAiB,IAAA;EAjBcU,MAAA;GAAAC,gBACCX;GAA8BL,OACvCc;GAeNhB;EAEH;EAACV,EAAA,MAAAU;EAAAV,EAAA,MAAA0B;EAAA1B,EAAA,MAAAiB;EAAAjB,EAAA,MAAA2B;CAAA,OAAAA,MAAA3B,EAAA;CAAA,OAnBM7C,UAAUwE,GAmBhB;AAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","stylex","RenderComponentProps","useRipple","useRender","focus","mergeStyles","colors","radii","shadows","spacing","stateLayerOpacity","FORCED_COLORS","styles","base","kaIpWk","kMzoRj","kB7OPa","kMwMTN","k1xSpc","kVQacm","kHjlTd","kVAEAm","kybGjl","$$css","content","kAzted","elevated","kWkggS","kGVxlE","filled","interactive","kkrTdU","kVVagm","kzqmXN","k9WMMc","interactiveBoundary","kVAM5u","ksu8eU","outlined","paddingDefault","kmVPX3","paddingNone","HOVER_CAPABLE","interactionStyles","CardProps","padding","variant","CardVariant","Card","t0","$","children","t1","onClick","onContextMenu","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","t2","render","t3","props","undefined","t4","ripple","padded","t5","t6","type","t7","handlers","t8","t9","surface","t10","ring","t11","t12","defaultTagName","_c","props","stylex.props"],"sources":["../../../src/components/card/index.tsx"],"sourcesContent":["'use client';\n\nimport * as stylex from '@stylexjs/stylex';\nimport type { RenderComponentProps } from '../../render/useRender';\nimport { useRipple } from '../../hooks/useRipple';\nimport { useRender } from '../../render/useRender';\nimport { focus } from '../../styles/focus';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, shadows, spacing, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\n\n// The three variants differ only in how they separate themselves from the\n// page: a shadow, a darker fill, or a border. Each therefore sits on a\n// different background, which is why the interaction styles below are keyed\n// by variant too — a state layer composites an 'on-color' over whatever the\n// container already is, so it cannot be written once for all three.\n//\n// color-mix() is inlined at each property rather than factored into a helper:\n// @stylexjs/babel-plugin only statically recognizes expressions written\n// directly as property values. Button's header comment records the same\n// constraint.\n// Windows High Contrast and the rest of the forced-colours modes. Spelled\n// here rather than imported, for the reason src/field/styles.ts records: the\n// StyleX compiler resolves a constant across files only out of a `.stylex.ts`\n// module, and the generated one holds design tokens rather than queries.\nconst FORCED_COLORS = '@media (forced-colors: active)';\nconst styles = {\n base: {\n kaIpWk: \"x62ce2h\",\n kMzoRj: \"xc342km\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x1heor9g\",\n k1xSpc: \"x1lliihq\",\n kVQacm: \"x7giv3\",\n kHjlTd: \"xj0a0fe\",\n kVAEAm: \"x1n2onr6\",\n kybGjl: \"x1hl2dhg\",\n $$css: true\n },\n content: {\n kB7OPa: \"x9f619\",\n k1xSpc: \"x1lliihq\",\n kAzted: \"x1us19tq\",\n $$css: true\n },\n elevated: {\n kWkggS: \"x1vnz5z6\",\n kGVxlE: \"x19efjv6\",\n $$css: true\n },\n filled: {\n kWkggS: \"x1rrhr5q\",\n $$css: true\n },\n interactive: {\n kkrTdU: \"x1ypdohk\",\n kVVagm: \"xln7xf2\",\n kzqmXN: \"xh8yej3\",\n k9WMMc: \"x1yc453h\",\n $$css: true\n },\n interactiveBoundary: {\n kVAM5u: \"x1ylmb6m\",\n ksu8eU: \"xx61lck\",\n kMzoRj: \"xc342km x13rsnn2\",\n $$css: true\n },\n outlined: {\n kWkggS: \"x14s9m32\",\n kVAM5u: \"x133yhug\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xmkeg23\",\n $$css: true\n },\n paddingDefault: {\n kmVPX3: \"xgc26li\",\n $$css: true\n },\n paddingNone: {\n kmVPX3: \"x1717udv\",\n $$css: true\n }\n};\n\n// A pointer that can hover: a mouse or a trackpad, not a finger. An\n// interactive card is a plain element React Aria does not host, so it has no\n// `isHovered` to draw its hover layer from, and Chromium leaves `:hover` on\n// whatever a touch last tapped — a card tapped and then navigated back to\n// stayed lifted. Inside this query a touch screen draws no hover at all. A\n// touchscreen laptop still matches it for its trackpad, which is the limit of\n// asking the device rather than the event.\nconst HOVER_CAPABLE = '@media (hover: hover)';\n\n// The state layers, from pseudo-classes, since the card has no render state\n// to read — see `HOVER_CAPABLE`.\n// `:active` is written twice, bare for a touch and again inside the query.\n// StyleX orders a rule by the sum of its conditions, so a hover inside the\n// query would otherwise come after a bare press and win while both held.\nconst interactionStyles = {\n elevated: {\n kWkggS: \"xu5m21g x17zbzf9 x1ru19e0 x1vnz5z6\",\n kGVxlE: \"x1g60mc1 x14zlms8 xqmo4o3 x19efjv6\",\n $$css: true\n },\n filled: {\n kWkggS: \"x1w49kxs x10l1pcx xt0lj0h x1rrhr5q\",\n $$css: true\n },\n outlined: {\n kWkggS: \"x1jqfdmz x1ie1ydn x1dau0i7 x14s9m32\",\n $$css: true\n }\n};\n\n// Typed as the attributes a <div> accepts, because that is the surface every\n// element this can render shares. Anything element-specific — a button's\n// `type`, an anchor's `href` — would be wrong for the others, and does not\n// need to be here anyway: those are written on the element handed to\n// `render`, where TypeScript checks them against that element's own props.\ntype CardProps = {\n /**\n * Makes the card the thing you press: it ripples, lifts on hover, and takes\n * a focus ring. Renders a `<button>` unless `render` says otherwise. Leave\n * it off for a card that merely holds content, including one containing its\n * own buttons.\n * @default false\n */\n interactive?: boolean;\n /**\n * `none` removes the card's own padding, for a card whose children run to\n * its edges — a list of rows separated by rules.\n * @default 'default'\n */\n padding?: 'default' | 'none';\n /**\n * How the card separates itself from the page: `elevated` casts a shadow,\n * `filled` sits on a darker surface, `outlined` draws a border.\n * @default 'elevated'\n */\n variant?: CardVariant;\n} & RenderComponentProps<'div'>;\ntype CardVariant = 'elevated' | 'filled' | 'outlined';\n\n/**\n * A surface holding related content. `render` decides which element that\n * surface is, so a card that navigates can be a real `<a href>` — announced\n * as a link and opening in a new tab on a modifier click, which a `<button>`\n * with an onClick does neither of.\n *\n * `interactive` and `render` are separate axes. `interactive` says the card\n * is pressable and gives it the ripple, the hover lift, and a focus ring;\n * `render` says what it is. A pressable card with no `render` is a\n * `<button>`, which is the right default for one that acts rather than\n * navigates.\n */\nfunction Card({\n children,\n interactive = false,\n onClick,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n padding = 'default',\n render,\n variant = 'elevated',\n ...props\n}: CardProps) {\n // The consumer's own pointer handlers are handed to useRipple to merge\n // rather than spread over its handlers afterwards, which is what Button\n // does and for the same reason: a plain spread means whichever object\n // comes last silently wins, so an onPointerDown on the call site would\n // replace the one driving the ripple and the card would stop rippling.\n const ripple = useRipple(interactive, {\n onClick,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp\n });\n const padded = padding === 'none' ? styles.paddingNone : styles.paddingDefault;\n return useRender({\n defaultTagName: interactive ? 'button' : 'div',\n props: {\n ...props,\n // Only when the default <button> is what renders. On an element the\n // call site chose, `type` is either meaningless or wrong — an <a>'s\n // `type` is a hint about the MIME type of what it links to — and that\n // element's own attributes are the call site's to write.\n ...(interactive && render === undefined ? {\n type: 'button'\n } : undefined),\n ...ripple.handlers,\n children: <>\n {interactive ? <span className=\"x9f619 x1lliihq x1us19tq\">{children}</span> : children}\n {ripple.surface}\n </>,\n ...mergeStyles(stylex.props(styles.base, styles[variant], padded, interactive && styles.interactive, interactive && variant !== 'outlined' && styles.interactiveBoundary, interactive && focus.ring, interactive && interactionStyles[variant]), props)\n },\n render\n });\n}\nexport type { CardProps, CardVariant };\nexport default Card;"],"mappings":";;;;;;;;;AA0BA,MAAMc,SAAS;CACbC,MAAM;EACJC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,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AegB,YAAY,cAAclC,OAAMuB,qBAAsBL,eAAe1B,MAAKwE,MAAO9C,eAAea,kBAAkBG,QAAQ,GAAGgB,OAAK;CAAC,IAAAe;CAAA,IAAA3B,EAAA,QAAAY,WAAAZ,EAAA,QAAAe,OAAAM,YAAArB,EAAA,QAAAyB,OAAAzB,EAAA,QAAAkB,MAAAlB,EAAA,QAAAuB,IAAA;EAdlPI,MAAA;GAAA,GACFf;GAAK,GAKJM;GAES,GACVE;GAAenB,UACRsB;GAGL,GACFE;EACL;EAACzB,EAAA,MAAAY;EAAAZ,EAAA,MAAAe,OAAAM;EAAArB,EAAA,MAAAyB;EAAAzB,EAAA,MAAAkB;EAAAlB,EAAA,MAAAuB;EAAAvB,EAAA,MAAA2B;CAAA,OAAAA,MAAA3B,EAAA;CAAA,IAAA4B;CAAA,IAAA5B,EAAA,QAAAU,UAAAV,EAAA,QAAA2B,OAAA3B,EAAA,QAAAiB,IAAA;EAjBcW,MAAA;GAAAC,gBACCZ;GAA8BL,OACvCe;GAeNjB;EAEH;EAACV,EAAA,MAAAU;EAAAV,EAAA,MAAA2B;EAAA3B,EAAA,MAAAiB;EAAAjB,EAAA,MAAA4B;CAAA,OAAAA,MAAA5B,EAAA;CAAA,OAnBM/C,UAAU2E,GAmBhB;AAAC"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { props } from "../../node_modules/@stylexjs/stylex/lib/es/stylex.js";
|
|
3
3
|
import { radii } from "../../tokens/design.tokens.stylex.js";
|
|
4
4
|
import { mergeStyles } from "../../styles/merge.js";
|
|
5
|
+
import { useMessages } from "../../i18n/index.js";
|
|
5
6
|
import { ChevronEndGlyph } from "../../glyphs/index.js";
|
|
6
7
|
import { focus } from "../../styles/focus.js";
|
|
7
|
-
import { useMessages } from "../../i18n/index.js";
|
|
8
8
|
import { arrange, placements } from "../../carousel/arrangement.js";
|
|
9
9
|
import IconButton from "../icon-button/index.js";
|
|
10
10
|
import { c } from "react/compiler-runtime";
|
|
@@ -5,6 +5,11 @@ type CheckboxProps = {
|
|
|
5
5
|
/**
|
|
6
6
|
* The label, beside the box. A checkbox that a row labels some other way
|
|
7
7
|
* leaves it out and passes `aria-label` instead.
|
|
8
|
+
*
|
|
9
|
+
* A link or a button in it acts on its own, as in a native label: a press
|
|
10
|
+
* or Enter on "the terms" in "I agree to the terms" follows the link and
|
|
11
|
+
* leaves the checkbox as it was. A press anywhere else in the label
|
|
12
|
+
* toggles it.
|
|
8
13
|
*/
|
|
9
14
|
children?: ReactNode;
|
|
10
15
|
/**
|
|
@@ -30,6 +35,10 @@ type CheckboxProps = {
|
|
|
30
35
|
* draws the dash for a box that stands for a partly selected set. Inside a
|
|
31
36
|
* `CheckboxGroup` it takes its `value` and the group's selection instead.
|
|
32
37
|
*
|
|
38
|
+
* `isRequired` ends the label in the asterisk every required field's label
|
|
39
|
+
* ends in. Inside a `CheckboxGroup` the group's label carries it instead,
|
|
40
|
+
* since the group is what must have a choice made in it.
|
|
41
|
+
*
|
|
33
42
|
* The call site's `className` and `style` land on the field as a whole,
|
|
34
43
|
* which is the element a layout positions.
|
|
35
44
|
*/
|
|
@@ -4,13 +4,14 @@ import { mergeStatefulStyles } from "../../styles/merge.js";
|
|
|
4
4
|
import { CheckGlyph, IndeterminateGlyph } from "../../glyphs/index.js";
|
|
5
5
|
import { focus } from "../../styles/focus.js";
|
|
6
6
|
import { useRipple } from "../../hooks/useRipple.js";
|
|
7
|
-
import { controlStyles } from "../../control/styles.js";
|
|
8
|
-
import { ControlLabel } from "../../control/index.js";
|
|
9
7
|
import { invalidFrom, useFieldValidationBehavior } from "../../field/root.js";
|
|
10
8
|
import { FieldMessage } from "../../field/index.js";
|
|
9
|
+
import { controlStyles } from "../../control/styles.js";
|
|
10
|
+
import { ControlLabel } from "../../control/index.js";
|
|
11
11
|
import { c } from "react/compiler-runtime";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { useContext } from "react";
|
|
13
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { CheckboxButton, CheckboxField, CheckboxGroupStateContext } from "react-aria-components";
|
|
14
15
|
//#region src/components/checkbox/index.tsx
|
|
15
16
|
const styles = {
|
|
16
17
|
box: {
|
|
@@ -108,13 +109,14 @@ const pressedLayers = {
|
|
|
108
109
|
$$css: true
|
|
109
110
|
}
|
|
110
111
|
};
|
|
111
|
-
function buttonContent(children, ripple) {
|
|
112
|
+
function buttonContent(children, ripple, inGroup) {
|
|
112
113
|
return (state) => {
|
|
114
|
+
const required = state.isRequired && !inGroup;
|
|
113
115
|
const marked = state.isSelected || state.isIndeterminate;
|
|
114
116
|
const interactive = !state.isDisabled && !state.isReadOnly;
|
|
115
117
|
const tone = state.isInvalid ? "error" : marked ? "marked" : "unmarked";
|
|
116
118
|
const active = state.isHovered || state.isPressed || state.isFocusVisible;
|
|
117
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("span", {
|
|
119
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("span", {
|
|
118
120
|
...interactive ? ripple.handlers : {},
|
|
119
121
|
...props(controlStyles.disc, styles.control, state.isReadOnly && controlStyles.controlReadOnly, state.isDisabled && controlStyles.controlDisabled, interactive && state.isHovered && hoverLayers[tone], interactive && state.isFocusVisible && focusLayers[tone], interactive && state.isPressed && pressedLayers[tone], state.isFocusVisible && focus.ringVisible),
|
|
120
122
|
children: [/* @__PURE__ */ jsx("span", {
|
|
@@ -122,6 +124,7 @@ function buttonContent(children, ripple) {
|
|
|
122
124
|
children: state.isIndeterminate ? /* @__PURE__ */ jsx(IndeterminateGlyph, { className: "xmix8c7 x1lliihq x1xp8n7a" }) : state.isSelected ? /* @__PURE__ */ jsx(CheckGlyph, { className: "xmix8c7 x1lliihq x1xp8n7a" }) : null
|
|
123
125
|
}), interactive ? ripple.surface : null]
|
|
124
126
|
}), /* @__PURE__ */ jsx(ControlLabel, {
|
|
127
|
+
isRequired: required,
|
|
125
128
|
state,
|
|
126
129
|
children
|
|
127
130
|
})] });
|
|
@@ -134,14 +137,20 @@ function buttonContent(children, ripple) {
|
|
|
134
137
|
* draws the dash for a box that stands for a partly selected set. Inside a
|
|
135
138
|
* `CheckboxGroup` it takes its `value` and the group's selection instead.
|
|
136
139
|
*
|
|
140
|
+
* `isRequired` ends the label in the asterisk every required field's label
|
|
141
|
+
* ends in. Inside a `CheckboxGroup` the group's label carries it instead,
|
|
142
|
+
* since the group is what must have a choice made in it.
|
|
143
|
+
*
|
|
137
144
|
* The call site's `className` and `style` land on the field as a whole,
|
|
138
145
|
* which is the element a layout positions.
|
|
139
146
|
*/
|
|
140
147
|
function Checkbox(t0) {
|
|
141
|
-
const $ = c(
|
|
148
|
+
const $ = c(21);
|
|
142
149
|
const { children, description, error, ...props$1 } = t0;
|
|
143
150
|
const ripple = useRipple();
|
|
144
151
|
const validationBehavior = useFieldValidationBehavior();
|
|
152
|
+
const inGroup = useContext(CheckboxGroupStateContext) !== null;
|
|
153
|
+
const reachable = !inGroup && (props$1.isRequired === true || props$1.validate !== void 0 || props$1.name !== void 0);
|
|
145
154
|
const T0 = CheckboxField;
|
|
146
155
|
let t1;
|
|
147
156
|
if ($[0] !== error) {
|
|
@@ -151,42 +160,45 @@ function Checkbox(t0) {
|
|
|
151
160
|
} else t1 = $[1];
|
|
152
161
|
const t2 = mergeStatefulStyles(props(controlStyles.field), props$1);
|
|
153
162
|
let t3;
|
|
154
|
-
if ($[2] !== children || $[3] !== ripple) {
|
|
155
|
-
t3 = buttonContent(children, ripple);
|
|
163
|
+
if ($[2] !== children || $[3] !== inGroup || $[4] !== ripple) {
|
|
164
|
+
t3 = buttonContent(children, ripple, inGroup);
|
|
156
165
|
$[2] = children;
|
|
157
|
-
$[3] =
|
|
158
|
-
$[4] =
|
|
159
|
-
|
|
166
|
+
$[3] = inGroup;
|
|
167
|
+
$[4] = ripple;
|
|
168
|
+
$[5] = t3;
|
|
169
|
+
} else t3 = $[5];
|
|
160
170
|
let t4;
|
|
161
|
-
if ($[
|
|
171
|
+
if ($[6] !== t3) {
|
|
162
172
|
t4 = /* @__PURE__ */ jsx(CheckboxButton, {
|
|
163
173
|
className: "xjp7ctv",
|
|
164
174
|
children: t3
|
|
165
175
|
});
|
|
166
|
-
$[
|
|
167
|
-
$[
|
|
168
|
-
} else t4 = $[
|
|
176
|
+
$[6] = t3;
|
|
177
|
+
$[7] = t4;
|
|
178
|
+
} else t4 = $[7];
|
|
169
179
|
let t5;
|
|
170
|
-
if ($[
|
|
180
|
+
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
171
181
|
t5 = props(controlStyles.messages);
|
|
172
|
-
$[
|
|
173
|
-
} else t5 = $[
|
|
182
|
+
$[8] = t5;
|
|
183
|
+
} else t5 = $[8];
|
|
174
184
|
let t6;
|
|
175
|
-
if ($[
|
|
185
|
+
if ($[9] !== description || $[10] !== error || $[11] !== reachable) {
|
|
176
186
|
t6 = /* @__PURE__ */ jsx("div", {
|
|
177
187
|
...t5,
|
|
178
188
|
children: /* @__PURE__ */ jsx(FieldMessage, {
|
|
179
189
|
description,
|
|
180
190
|
error,
|
|
181
|
-
inset: false
|
|
191
|
+
inset: false,
|
|
192
|
+
reserve: reachable
|
|
182
193
|
})
|
|
183
194
|
});
|
|
184
|
-
$[
|
|
185
|
-
$[
|
|
186
|
-
$[
|
|
187
|
-
|
|
195
|
+
$[9] = description;
|
|
196
|
+
$[10] = error;
|
|
197
|
+
$[11] = reachable;
|
|
198
|
+
$[12] = t6;
|
|
199
|
+
} else t6 = $[12];
|
|
188
200
|
let t7;
|
|
189
|
-
if ($[
|
|
201
|
+
if ($[13] !== T0 || $[14] !== props$1 || $[15] !== t1 || $[16] !== t2 || $[17] !== t4 || $[18] !== t6 || $[19] !== validationBehavior) {
|
|
190
202
|
t7 = /* @__PURE__ */ jsxs(T0, {
|
|
191
203
|
isInvalid: t1,
|
|
192
204
|
validationBehavior,
|
|
@@ -194,15 +206,15 @@ function Checkbox(t0) {
|
|
|
194
206
|
...t2,
|
|
195
207
|
children: [t4, t6]
|
|
196
208
|
});
|
|
197
|
-
$[
|
|
198
|
-
$[
|
|
199
|
-
$[
|
|
200
|
-
$[
|
|
201
|
-
$[
|
|
202
|
-
$[
|
|
203
|
-
$[
|
|
204
|
-
$[
|
|
205
|
-
} else t7 = $[
|
|
209
|
+
$[13] = T0;
|
|
210
|
+
$[14] = props$1;
|
|
211
|
+
$[15] = t1;
|
|
212
|
+
$[16] = t2;
|
|
213
|
+
$[17] = t4;
|
|
214
|
+
$[18] = t6;
|
|
215
|
+
$[19] = validationBehavior;
|
|
216
|
+
$[20] = t7;
|
|
217
|
+
} else t7 = $[20];
|
|
206
218
|
return t7;
|
|
207
219
|
}
|
|
208
220
|
//#endregion
|