@kanso-labs/kanso-ui 0.45.21 → 0.45.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/calendar/index.js +119 -11
- package/dist/calendar/index.js.map +1 -1
- package/dist/calendar/styles.js +19 -1
- package/dist/calendar/styles.js.map +1 -1
- package/dist/components/app-bar/index.d.ts +8 -2
- package/dist/components/app-bar/index.js +123 -73
- package/dist/components/app-bar/index.js.map +1 -1
- package/dist/components/calendar/index.d.ts +3 -3
- package/dist/components/calendar/index.js +8 -19
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/carousel/index.d.ts +22 -3
- package/dist/components/carousel/index.js +26 -14
- package/dist/components/carousel/index.js.map +1 -1
- package/dist/components/chip-group/index.js +3 -0
- package/dist/components/chip-group/index.js.map +1 -1
- package/dist/components/color-picker/index.js +64 -46
- package/dist/components/color-picker/index.js.map +1 -1
- package/dist/components/color-swatch/index.js +20 -16
- package/dist/components/color-swatch/index.js.map +1 -1
- package/dist/components/copy-field/index.js +1 -0
- package/dist/components/copy-field/index.js.map +1 -1
- package/dist/components/date-range-picker/index.js +165 -81
- package/dist/components/date-range-picker/index.js.map +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/popover/index.js +14 -4
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/range-calendar/index.js +53 -80
- package/dist/components/range-calendar/index.js.map +1 -1
- package/dist/components/segmented-button/index.js +261 -145
- package/dist/components/segmented-button/index.js.map +1 -1
- package/dist/components/sheet/index.js +149 -82
- package/dist/components/sheet/index.js.map +1 -1
- package/dist/components/table/index.js +251 -123
- package/dist/components/table/index.js.map +1 -1
- package/dist/hooks/useRipple.js +3 -2
- package/dist/hooks/useRipple.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/segments/index.js +2 -1
- package/dist/segments/index.js.map +1 -1
- package/dist/segments/styles.js +5 -1
- package/dist/segments/styles.js.map +1 -1
- package/dist/styles/focus.js.map +1 -1
- package/dist/styles.css +40 -8
- package/dist/swatch/index.js +19 -0
- package/dist/swatch/index.js.map +1 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","CalendarDate","ReactElement","RefAttributes","CalendarCellRenderProps","CalendarRenderProps","DateValue","CalendarProps","RACCalendarProps","isSameDay","stylex","useContext","CalendarStateContext","Calendar","RACCalendar","CalendarCell","RACCalendarCell","CalendarGrid","RACCalendarGrid","CalendarGridBody","RACCalendarGridBody","Text","RACText","CalendarFrame","CalendarGridHeader","monthOffsets","calendarStyles","dateLayers","invalidFrom","fieldChromeStyles","focus","mergeStatefulStyles","className","T","error","showMonthYearMenus","style","Omit","CalendarStates","isHeldWhileDisabled","isReadOnly","t0","$","T0","props","t1","t2","t3","t4","t5","t6","undefined","root","visibleDuration","months","isInvalid","map","_temp","message","messageError","offset","month","grid","gridCell","cellClassName","state","calendar","cell","ring","isToday","cellToday","isSelected","cellSelected","cellInvalid","cellReadOnly","isHovered","hoveredLayer","isPressed","pressedLayer","isUnavailable","cellUnavailable","isDisabled","cellDisabled","isOutsideMonth","cellSelectedDisabled","cellClassNameIn","DateCell","date","holds","value","held","some","entry","plainHovered","invalidHovered","selectedHovered","plainPressed","invalidPressed","selectedPressed","Calendar","_c","props","RACCalendar","stylex.props","RACText","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 { CalendarCellRenderProps, CalendarRenderProps, DateValue, CalendarProps as RACCalendarProps } from 'react-aria-components';\nimport { isSameDay } from '@internationalized/date';\nimport * as stylex from '@stylexjs/stylex';\nimport { useContext } from 'react';\nimport { CalendarStateContext, Calendar as RACCalendar, CalendarCell as RACCalendarCell, CalendarGrid as RACCalendarGrid, CalendarGridBody as RACCalendarGridBody, Text as RACText } from 'react-aria-components';\nimport { CalendarFrame, CalendarGridHeader } from '../../calendar';\nimport { monthOffsets } from '../../calendar/months';\nimport { calendarStyles, dateLayers } from '../../calendar/styles';\nimport { invalidFrom } from '../../field/root';\nimport { fieldChromeStyles } from '../../field/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// The calendar's own disabled, read-only and invalid states are drawn on its\n// dates, from React Aria's calendar state rather than each date's, since\n// that is the one place all three are known:\n//\n// - **Disabled** fades every date, the weekday row, the chevrons and the\n// menu buttons to the page's 38%, and keeps the date it holds as a\n// disabled filled circle — React Aria stops calling a disabled date\n// selected, which left the calendar looking empty.\n// - **Read-only** keeps every date at full strength, since it still reports\n// a value, but drops the pointer and the state layers from the dates, which\n// a press no longer changes. The chevrons and the menus still move the\n// month, so they keep theirs.\n// - **Invalid** draws the date held in the error container roles, and\n// `error` writes the reason under the months in the field's supporting\n// type and error colour. Each date React Aria marks invalid points\n// `aria-describedby` at it, so a screen reader hears why as well as that.\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 * The message shown under the months, which also marks the calendar\n * invalid: the date it holds turns to the error container colours, and\n * React Aria points that date's description at the message. `isInvalid`\n * on its own marks the date with no message.\n */\n error?: string;\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/** What a date's classes read off the calendar around it. */\ntype CalendarStates = {\n /**\n * Whether this date is the one a disabled calendar holds, inside its\n * bounds. A copy of it in a neighbouring month's grid is told apart by\n * React Aria's own `isOutsideMonth`.\n */\n isHeldWhileDisabled: boolean;\n isReadOnly: boolean;\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 error,\n showMonthYearMenus = false,\n ...props\n}: CalendarProps<T> & RefAttributes<HTMLDivElement>) {\n return <RACCalendar<T> isInvalid={invalidFrom(error)} {...props} {...mergeStatefulStyles(stylex.props(calendarStyles.root), props)}>\n {({\n isInvalid\n }: CalendarRenderProps) => <>\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 {/*\n * Through React Aria's error slot, which gives it the id an\n * invalid date's `aria-describedby` names. Drawn only while the\n * calendar is invalid: React Aria looks for the element when\n * `isInvalid` changes, which is when this appears and goes.\n */}\n {isInvalid && error !== undefined ? <RACText slot=\"errorMessage\" {...stylex.props(fieldChromeStyles.message, fieldChromeStyles.messageError)}>\n {error}\n </RACText> : null}\n </>}\n </RACCalendar>;\n}\n\n// A date's classes, from React Aria's render state and the calendar's.\n// StyleX cannot target `[data-selected]` on the element it is styling, so the\n// state comes from 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 — and `invalid` after `selected`,\n// which it repaints. The hover and pressed layers come next, over whichever\n// ground the date has, a press over a hover. A read-only calendar takes no\n// hover layer, and React Aria reports no press there to draw one for.\n// `unavailable` and `disabled` come last, and StyleX replaces a property\n// whole, so they take the layers with them; the date a disabled calendar\n// holds then puts its disabled circle back.\nfunction cellClassName(state: CalendarCellRenderProps, calendar: CalendarStates) {\n return stylex.props(calendarStyles.cell, focus.ring, state.isToday && calendarStyles.cellToday, state.isSelected && calendarStyles.cellSelected, state.isSelected && state.isInvalid && calendarStyles.cellInvalid, calendar.isReadOnly && calendarStyles.cellReadOnly, !calendar.isReadOnly && state.isHovered && hoveredLayer(state), state.isPressed && pressedLayer(state), state.isUnavailable && calendarStyles.cellUnavailable, state.isDisabled && calendarStyles.cellDisabled, calendar.isHeldWhileDisabled && !state.isOutsideMonth && calendarStyles.cellSelectedDisabled).className ?? '';\n}\n\n// The calendar's part of a date's classes, bound once per date. Built by a\n// call rather than written inline at the prop, which is what react-perf's\n// no-new-function-as-prop is after.\nfunction cellClassNameIn(calendar: CalendarStates) {\n return (state: CalendarCellRenderProps) => cellClassName(state, calendar);\n}\n\n/**\n * One date. React Aria's cell, with what its classes need from the calendar\n * read from React Aria's calendar state: whether it is read-only, and the\n * date it holds, which React Aria hides from the cell itself once the\n * calendar is disabled.\n *\n * Held means what React Aria would have called selected with the calendar\n * enabled: the value, inside the bounds, and in its own month's grid rather\n * than a neighbour's, which the classes check.\n */\nfunction DateCell({\n date\n}: {\n date: CalendarDate;\n}): ReactElement {\n const calendar = useContext(CalendarStateContext);\n const isHeldWhileDisabled = calendar !== null && calendar.isDisabled && !calendar.isInvalid(date) && holds(calendar.value, date);\n return <RACCalendarCell className={cellClassNameIn({\n isHeldWhileDisabled,\n isReadOnly: calendar?.isReadOnly ?? false\n })} date={date} />;\n}\nfunction gridCell(date: CalendarDate): ReactElement {\n return <DateCell date={date} />;\n}\n\n// Whether a calendar's value includes a date: one date, or several where the\n// calendar takes more than one.\nfunction holds(value: CalendarDate | null | readonly (CalendarDate | null)[], date: CalendarDate) {\n const held = value !== null && 'length' in value ? value : [value];\n return held.some(entry => entry !== null && isSameDay(entry, date));\n}\nfunction hoveredLayer(state: CalendarCellRenderProps) {\n if (!state.isSelected) {\n return dateLayers.plainHovered;\n }\n return state.isInvalid ? dateLayers.invalidHovered : dateLayers.selectedHovered;\n}\nfunction pressedLayer(state: CalendarCellRenderProps) {\n if (!state.isSelected) {\n return dateLayers.plainPressed;\n }\n return state.isInvalid ? dateLayers.invalidPressed : dateLayers.selectedPressed;\n}\nexport type { CalendarProps };\nexport default Calendar;"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyJA,SAAAc,WAAA4B,IAAA;CAAA,MAAAC,IAAA1C,EAAA,EAAA;CAAA,IAAA2C;CAAA,IAAAT;CAAA,IAAAU;CAAA,IAAAT;CAAA,IAAAU;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAL,EAAA,OAAAD,IAAA;EAAuC,MAAA,EAAAP,OAAAc,IAAAb,oBAAAc,IAAA,GAAAC,OAAAT;EAAAP,QAAAc;EAAAJ,UAAAM;EAErCf,qBAAAc,OAAAE,KAAAA,IAAA,QAAAF;EAGQN,KAAA7B;EAAW,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MAAMM,YACT,OAAO5C,WAAWkE;CAEpB,OAAO5B,MAAMV,YAAY5B,WAAWmE,iBAAiBnE,WAAWoE;AAClE;AACA,SAASjB,aAAab,OAAgC;CACpD,IAAI,CAACA,MAAMM,YACT,OAAO5C,WAAWqE;CAEpB,OAAO/B,MAAMV,YAAY5B,WAAWsE,iBAAiBtE,WAAWuE;AAClE"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","CalendarDate","ReactElement","RefAttributes","CalendarCellRenderProps","CalendarRenderProps","DateValue","CalendarProps","RACCalendarProps","isSameDay","stylex","useContext","CalendarStateContext","Calendar","RACCalendar","CalendarCell","RACCalendarCell","Text","RACText","CalendarFrame","CalendarMonths","calendarStyles","dateLayers","invalidFrom","fieldChromeStyles","focus","mergeStatefulStyles","className","T","error","showMonthYearMenus","style","Omit","CalendarStates","isHeldWhileDisabled","isReadOnly","t0","$","T0","props","t1","t2","t3","t4","t5","t6","undefined","root","visibleDuration","months","isInvalid","gridCell","message","messageError","cellClassName","state","calendar","cell","ring","isToday","cellToday","isSelected","cellSelected","cellInvalid","cellReadOnly","isHovered","hoveredLayer","isPressed","pressedLayer","isUnavailable","cellUnavailable","isDisabled","cellDisabled","isOutsideMonth","cellSelectedDisabled","cellClassNameIn","DateCell","date","holds","value","held","some","entry","plainHovered","invalidHovered","selectedHovered","plainPressed","invalidPressed","selectedPressed","Calendar","_c","props","RACCalendar","stylex.props","RACText","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 { CalendarCellRenderProps, CalendarRenderProps, DateValue, CalendarProps as RACCalendarProps } from 'react-aria-components';\nimport { isSameDay } from '@internationalized/date';\nimport * as stylex from '@stylexjs/stylex';\nimport { useContext } from 'react';\nimport { CalendarStateContext, Calendar as RACCalendar, CalendarCell as RACCalendarCell, Text as RACText } from 'react-aria-components';\nimport { CalendarFrame, CalendarMonths } from '../../calendar';\nimport { calendarStyles, dateLayers } from '../../calendar/styles';\nimport { invalidFrom } from '../../field/root';\nimport { fieldChromeStyles } from '../../field/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// The calendar's own disabled, read-only and invalid states are drawn on its\n// dates, from React Aria's calendar state rather than each date's, since\n// that is the one place all three are known:\n//\n// - **Disabled** fades every date, the weekday row, the chevrons and the\n// menu buttons to the page's 38%, and keeps the date it holds as a\n// disabled filled circle — React Aria stops calling a disabled date\n// selected, which left the calendar looking empty.\n// - **Read-only** keeps every date at full strength, since it still reports\n// a value, but drops the pointer and the state layers from the dates, which\n// a press no longer changes. The chevrons and the menus still move the\n// month, so they keep theirs.\n// - **Invalid** draws the date held in the error container roles, and\n// `error` writes the reason under the months in the field's supporting\n// type and error colour. Each date React Aria marks invalid points\n// `aria-describedby` at it, so a screen reader hears why as well as that.\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 * The message shown under the months, which also marks the calendar\n * invalid: the date it holds turns to the error container colours, and\n * React Aria points that date's description at the message. `isInvalid`\n * on its own marks the date with no message.\n */\n error?: string;\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/** What a date's classes read off the calendar around it. */\ntype CalendarStates = {\n /**\n * Whether this date is the one a disabled calendar holds, inside its\n * bounds. A copy of it in a neighbouring month's grid is told apart by\n * React Aria's own `isOutsideMonth`.\n */\n isHeldWhileDisabled: boolean;\n isReadOnly: boolean;\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 with each month named over\n * its grid. Name it with `aria-label` or `aria-labelledby`; React Aria\n * composes the visible month into that name 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 error,\n showMonthYearMenus = false,\n ...props\n}: CalendarProps<T> & RefAttributes<HTMLDivElement>) {\n return <RACCalendar<T> isInvalid={invalidFrom(error)} {...props} {...mergeStatefulStyles(stylex.props(calendarStyles.root), props)}>\n {({\n isInvalid\n }: CalendarRenderProps) => <>\n <CalendarFrame months={props.visibleDuration?.months ?? 1} showMonthYearMenus={showMonthYearMenus}>\n <CalendarMonths months={props.visibleDuration?.months ?? 1}>\n {gridCell}\n </CalendarMonths>\n </CalendarFrame>\n {/*\n * Through React Aria's error slot, which gives it the id an\n * invalid date's `aria-describedby` names. Drawn only while the\n * calendar is invalid: React Aria looks for the element when\n * `isInvalid` changes, which is when this appears and goes.\n */}\n {isInvalid && error !== undefined ? <RACText slot=\"errorMessage\" {...stylex.props(fieldChromeStyles.message, fieldChromeStyles.messageError)}>\n {error}\n </RACText> : null}\n </>}\n </RACCalendar>;\n}\n\n// A date's classes, from React Aria's render state and the calendar's.\n// StyleX cannot target `[data-selected]` on the element it is styling, so the\n// state comes from 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 — and `invalid` after `selected`,\n// which it repaints. The hover and pressed layers come next, over whichever\n// ground the date has, a press over a hover. A read-only calendar takes no\n// hover layer, and React Aria reports no press there to draw one for.\n// `unavailable` and `disabled` come last, and StyleX replaces a property\n// whole, so they take the layers with them; the date a disabled calendar\n// holds then puts its disabled circle back.\nfunction cellClassName(state: CalendarCellRenderProps, calendar: CalendarStates) {\n return stylex.props(calendarStyles.cell, focus.ring, state.isToday && calendarStyles.cellToday, state.isSelected && calendarStyles.cellSelected, state.isSelected && state.isInvalid && calendarStyles.cellInvalid, calendar.isReadOnly && calendarStyles.cellReadOnly, !calendar.isReadOnly && state.isHovered && hoveredLayer(state), state.isPressed && pressedLayer(state), state.isUnavailable && calendarStyles.cellUnavailable, state.isDisabled && calendarStyles.cellDisabled, calendar.isHeldWhileDisabled && !state.isOutsideMonth && calendarStyles.cellSelectedDisabled).className ?? '';\n}\n\n// The calendar's part of a date's classes, bound once per date. Built by a\n// call rather than written inline at the prop, which is what react-perf's\n// no-new-function-as-prop is after.\nfunction cellClassNameIn(calendar: CalendarStates) {\n return (state: CalendarCellRenderProps) => cellClassName(state, calendar);\n}\n\n/**\n * One date. React Aria's cell, with what its classes need from the calendar\n * read from React Aria's calendar state: whether it is read-only, and the\n * date it holds, which React Aria hides from the cell itself once the\n * calendar is disabled.\n *\n * Held means what React Aria would have called selected with the calendar\n * enabled: the value, inside the bounds, and in its own month's grid rather\n * than a neighbour's, which the classes check.\n */\nfunction DateCell({\n date\n}: {\n date: CalendarDate;\n}): ReactElement {\n const calendar = useContext(CalendarStateContext);\n const isHeldWhileDisabled = calendar !== null && calendar.isDisabled && !calendar.isInvalid(date) && holds(calendar.value, date);\n return <RACCalendarCell className={cellClassNameIn({\n isHeldWhileDisabled,\n isReadOnly: calendar?.isReadOnly ?? false\n })} date={date} />;\n}\nfunction gridCell(date: CalendarDate): ReactElement {\n return <DateCell date={date} />;\n}\n\n// Whether a calendar's value includes a date: one date, or several where the\n// calendar takes more than one.\nfunction holds(value: CalendarDate | null | readonly (CalendarDate | null)[], date: CalendarDate) {\n const held = value !== null && 'length' in value ? value : [value];\n return held.some(entry => entry !== null && isSameDay(entry, date));\n}\nfunction hoveredLayer(state: CalendarCellRenderProps) {\n if (!state.isSelected) {\n return dateLayers.plainHovered;\n }\n return state.isInvalid ? dateLayers.invalidHovered : dateLayers.selectedHovered;\n}\nfunction pressedLayer(state: CalendarCellRenderProps) {\n if (!state.isSelected) {\n return dateLayers.plainPressed;\n }\n return state.isInvalid ? dateLayers.invalidPressed : dateLayers.selectedPressed;\n}\nexport type { CalendarProps };\nexport default Calendar;"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwJA,SAAAc,WAAAuB,IAAA;CAAA,MAAAC,IAAArC,EAAA,EAAA;CAAA,IAAAsC;CAAA,IAAAT;CAAA,IAAAU;CAAA,IAAAT;CAAA,IAAAU;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAL,EAAA,OAAAD,IAAA;EAAuC,MAAA,EAAAP,OAAAc,IAAAb,oBAAAc,IAAA,GAAAC,OAAAT;EAAAP,QAAAc;EAAAJ,UAAAM;EAErCf,qBAAAc,OAAAE,KAAAA,IAAA,QAAAF;EAGQN,KAAAxB;EAAW,IAAAuB,EAAA,OAAAR,OAAA;GAAeW,KAAAjB,YAAYM,KAAK;GAACQ,EAAA,KAAAR;GAAAQ,EAAA,KAAAG;EAAA,OAAAA,KAAAH,EAAA;EAAME,KAAAA;EAAWG,KAAAhB,oBAAoBhB,MAAaW,eAAc0B,IAAK,GAAGR,OAAK;EAACF,EAAA,KAAAD;EA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,OAAA;EAAAF,KAAAD,EAAA;EAAAG,KAAAH,EAAA;CAAA;CAAA,IAAAI;CAAA,IAAAJ,EAAA,OAAAC,MAAAD,EAAA,OAAAwC,QAAAxC,EAAA,OAAAG,IAAA;EAHKC,KAAA,oBAAC,IAAD;GAA4B,WAAAD;GAGzBqC;EAAI,CAAA;EAAIxC,EAAA,KAAAC;EAAAD,EAAA,KAAAwC;EAAAxC,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,OAHXI;AAGW;AAEpB,SAASU,SAAS0B,MAAkC;CAClD,OAAO,oBAAC,UAAD,EAAgBA,KAAK,CAAA;AAC9B;AAIA,SAASC,MAAMC,OAA+DF,MAAoB;CAEhG,QADaE,UAAU,QAAQ,YAAYA,QAAQA,QAAQ,CAACA,KAAK,EAAA,CACrDE,MAAKC,UAASA,UAAU,QAAQzE,UAAUyE,OAAOL,IAAI,CAAC;AACpE;AACA,SAASX,aAAaX,OAAgC;CACpD,IAAI,CAACA,MAAMM,YACT,OAAOvC,WAAW6D;CAEpB,OAAO5B,MAAML,YAAY5B,WAAW8D,iBAAiB9D,WAAW+D;AAClE;AACA,SAASjB,aAAab,OAAgC;CACpD,IAAI,CAACA,MAAMM,YACT,OAAOvC,WAAWgE;CAEpB,OAAO/B,MAAML,YAAY5B,WAAWiE,iBAAiBjE,WAAWkE;AAClE"}
|
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
import { CarouselLayout } from "../../carousel/arrangement.js";
|
|
2
2
|
import { HTMLAttributes, ReactNode, RefAttributes } from "react";
|
|
3
3
|
type CarouselItemProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* What the item shows: usually an image, which the item masks. A function
|
|
6
|
+
* is handed how much of the item shows, every time that changes, so text
|
|
7
|
+
* the item has no room for can be hidden as the mask closes over it.
|
|
8
|
+
*/
|
|
9
|
+
children?: ((state: CarouselItemRenderProps) => ReactNode) | ReactNode;
|
|
10
|
+
};
|
|
11
|
+
/** How much of a `Carousel.Item` shows, for children written as a function. */
|
|
12
|
+
type CarouselItemRenderProps = {
|
|
13
|
+
/**
|
|
14
|
+
* How much of `width` shows, in pixels. The mask takes the rest evenly
|
|
15
|
+
* from both sides, so `(width - visibleWidth) / 2` is cut off each. It is
|
|
16
|
+
* `width` for an item drawn large, and for every item of an uncontained
|
|
17
|
+
* carousel, which masks nothing.
|
|
18
|
+
*/
|
|
19
|
+
visibleWidth: number;
|
|
20
|
+
/**
|
|
21
|
+
* The width the item is laid out at, in pixels: the large item's, which
|
|
22
|
+
* every item in the carousel shares.
|
|
23
|
+
*/
|
|
24
|
+
width: number;
|
|
6
25
|
};
|
|
7
26
|
type CarouselProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
|
|
8
27
|
/** The items: `Carousel.Item` for each. */
|
|
@@ -62,5 +81,5 @@ declare namespace Carousel {
|
|
|
62
81
|
* The call site's `className` and `style` land on the item.
|
|
63
82
|
*/
|
|
64
83
|
declare function CarouselItem({ children, ref, ...props }: CarouselItemProps & RefAttributes<HTMLDivElement>): import("react").JSX.Element;
|
|
65
|
-
export { CarouselItem, type CarouselItemProps, type CarouselLayout, type CarouselProps, Carousel as default };
|
|
84
|
+
export { CarouselItem, type CarouselItemProps, type CarouselItemRenderProps, type CarouselLayout, type CarouselProps, Carousel as default };
|
|
66
85
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -336,7 +336,7 @@ function Carousel(t0) {
|
|
|
336
336
|
* The call site's `className` and `style` land on the item.
|
|
337
337
|
*/
|
|
338
338
|
function CarouselItem(t0) {
|
|
339
|
-
const $ = c(
|
|
339
|
+
const $ = c(15);
|
|
340
340
|
const { children, ref, ...props$1 } = t0;
|
|
341
341
|
const messages = useMessages();
|
|
342
342
|
const slot = useContext(SlotContext);
|
|
@@ -344,7 +344,8 @@ function CarouselItem(t0) {
|
|
|
344
344
|
const index = slot?.index ?? 0;
|
|
345
345
|
const large = slot?.large ?? 0;
|
|
346
346
|
const placement = slot?.placement;
|
|
347
|
-
const
|
|
347
|
+
const visibleWidth = placement === void 0 ? large : placement.width;
|
|
348
|
+
const inset = (large - visibleWidth) / 2;
|
|
348
349
|
let t1;
|
|
349
350
|
if ($[0] !== count || $[1] !== index || $[2] !== messages) {
|
|
350
351
|
t1 = messages.slideLabel(index + 1, count);
|
|
@@ -357,25 +358,36 @@ function CarouselItem(t0) {
|
|
|
357
358
|
const t3 = "group";
|
|
358
359
|
const t4 = mergeStyles(props(styles.item, slot?.layout === "uncontained" && styles.itemUncontained, slot?.layout === "uncontained" && placed.uncontained(`${large}px`), placement !== void 0 && placed.item(`${large}px`, `${placement.left - inset - index * (large + 8)}px`, `inset(0 ${inset}px round ${radii.xl})`)), props$1);
|
|
359
360
|
let t5;
|
|
360
|
-
if ($[4] !== children || $[5] !==
|
|
361
|
-
t5 =
|
|
361
|
+
if ($[4] !== children || $[5] !== large || $[6] !== visibleWidth) {
|
|
362
|
+
t5 = typeof children === "function" ? children({
|
|
363
|
+
visibleWidth,
|
|
364
|
+
width: large
|
|
365
|
+
}) : children;
|
|
366
|
+
$[4] = children;
|
|
367
|
+
$[5] = large;
|
|
368
|
+
$[6] = visibleWidth;
|
|
369
|
+
$[7] = t5;
|
|
370
|
+
} else t5 = $[7];
|
|
371
|
+
let t6;
|
|
372
|
+
if ($[8] !== messages.slide || $[9] !== props$1 || $[10] !== ref || $[11] !== t1 || $[12] !== t4 || $[13] !== t5) {
|
|
373
|
+
t6 = /* @__PURE__ */ jsx("div", {
|
|
362
374
|
"aria-label": t1,
|
|
363
375
|
"aria-roledescription": t2,
|
|
364
376
|
ref,
|
|
365
377
|
role: t3,
|
|
366
378
|
...props$1,
|
|
367
379
|
...t4,
|
|
368
|
-
children
|
|
380
|
+
children: t5
|
|
369
381
|
});
|
|
370
|
-
$[
|
|
371
|
-
$[
|
|
372
|
-
$[
|
|
373
|
-
$[
|
|
374
|
-
$[
|
|
375
|
-
$[
|
|
376
|
-
$[
|
|
377
|
-
} else
|
|
378
|
-
return
|
|
382
|
+
$[8] = messages.slide;
|
|
383
|
+
$[9] = props$1;
|
|
384
|
+
$[10] = ref;
|
|
385
|
+
$[11] = t1;
|
|
386
|
+
$[12] = t4;
|
|
387
|
+
$[13] = t5;
|
|
388
|
+
$[14] = t6;
|
|
389
|
+
} else t6 = $[14];
|
|
390
|
+
return t6;
|
|
379
391
|
}
|
|
380
392
|
function restRevealing(index, { lastLarge, scrolled, step }) {
|
|
381
393
|
const at = Math.round(scrolled / step);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","FocusEvent","HTMLAttributes","ReactNode","RefAttributes","stylex","Children","createContext","isValidElement","useCallback","useContext","useLayoutEffect","useRef","useState","CarouselLayout","Placement","arrange","GAP","placements","ChevronEndGlyph","useMessages","focus","mergeStyles","radii","spacing","IconButton","PADDING","DEFAULT_ITEM_SIZE","CarouselItemProps","Omit","HTMLDivElement","children","CarouselProps","HTMLElement","itemSize","label","layout","nextLabel","previousLabel","styles","item","kaIpWk","kB7OPa","kzQI83","kmuXW","kAzted","kVQacm","kVAEAm","$$css","itemUncontained","k5xd4v","marker","scroller","kOuLrU","k1xSpc","kXHlph","kORKVm","kvh3hx","k5wCbM","khEr5k","kc424l","scrollerUncontained","katHQp","_temp","kzqmXN","_temp2","_temp3","placed","inlineSize","shift","clip","kz4h6p","kLqNvP","undefined","val","uncontained","Slot","count","index","large","placement","SlotContext","Geometry","end","lastLarge","masked","scrolled","step","along","direction","offset","Math","round","min","max","Carousel","t0","$","t1","t2","ref","props","messages","scrollerRef","width","setWidth","setScrolled","items","toArray","filter","length","room","arrangement","steps","largeCount","position","drawn","t3","Symbol","for","current","clientWidth","abs","scrollLeft","measure","t4","t5","scroller_0","observer","ResizeObserver","observe","disconnect","t6","geometry","scrollAlong","previous","t7","geometry_0","next","t8","event","target","Node","Array","from","currentTarget","findIndex","child","contains","geometry_1","restRevealing","reveal","slots","map","_","index_0","t9","carousel","t10","className","t11","ring","t12","t13","0","1","t14","previousSlide","t15","t16","t17","t18","nextSlide","t19","t20","t21","t22","index_1","key","__0","rest","CarouselItem","slot","inset","slideLabel","slide","left","xl","at","sign","getComputedStyle","scrollTo","Item","_c","props","stylex.props"],"sources":["../../../src/components/carousel/index.tsx"],"sourcesContent":["'use client';\n\nimport type { FocusEvent, HTMLAttributes, ReactNode, RefAttributes } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport { Children, createContext, isValidElement, useCallback, useContext, useLayoutEffect, useRef, useState } from 'react';\nimport type { CarouselLayout, Placement } from '../../carousel/arrangement';\nimport { arrange, GAP, placements } from '../../carousel/arrangement';\nimport { ChevronEndGlyph } from '../../glyphs';\nimport { useMessages } from '../../i18n';\nimport { focus } from '../../styles/focus';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { radii, spacing } from '../../tokens/design.tokens.stylex';\nimport IconButton from '../icon-button';\n\n// The carousel page's carousel: a row of items that scrolls on and off the\n// screen, drawn in three of the page's layouts. Each has the page's 16dp of\n// padding at its ends and 8dp at its top and bottom, 8dp between items and a\n// 28dp corner on every item.\n//\n// - **Multi-browse**, the default, shows as many large items as fit at\n// `itemSize`, then a medium one and a small one, and fills its width\n// exactly; the large width gives way where the preferred one does not fit.\n// - **Hero** shows one large item and one small.\n// - **Uncontained** shows every item at `itemSize`, scrolling past the edge.\n//\n// **Items change size as they move**, as the page draws them. The first two\n// layouts come to rest one item apart, and between two rests every item's\n// place and width are interpolated, so an item shrinks as it leaves and\n// grows as it arrives; the last rests turn the arrangement round a slot at a\n// time, so every item is drawn large at one of them. The arithmetic is\n// `src/carousel/arrangement.ts`.\n// An item is laid out at the large width and masked down to the width it is\n// drawn at, centred, with the page's corner on the mask: what it holds is\n// cut at both sides rather than squeezed, as the page's masked items are.\n//\n// **The scrolling is the browser's.** A scroller holds the items' track,\n// which stays put while it scrolls, and a run of empty markers one item\n// apart after it, which is what gives the scroller its length and its rests:\n// each marker's end is a scroll-snap point, and a mark at the scroller's\n// start is the first. The position the scroller reports is what the items\n// are drawn from. Uncontained has no rests and no masks, so its items scroll\n// in the track themselves, snapping to their own starts.\n//\n// **It is the ARIA carousel pattern**, since React Aria has no carousel: a\n// region named by `label` and described as a carousel, each item a group\n// described as a slide and named by which of how many it is, and a previous\n// and a next button under it, at the end. Focus moving into an item that is\n// not drawn large scrolls the carousel to the nearest rest that draws it\n// large, and the scroller is a tab stop while it scrolls, so the arrow keys\n// move it too. Under reduced motion the scroller jumps rather than scrolling\n// smoothly.\n//\n// The page's large width is \"dynamic, or user-set\", and neither MDC-Android\n// nor Compose has a default for it; `itemSize`'s 240 is this component's own.\n// Uncontained keeps the 16dp at its end as well as its start, where the page\n// gives it a leading padding alone, so its last item does not end flush\n// against the edge.\n\n/** The page's 16dp at a carousel's ends. */\nconst PADDING = 16;\nconst DEFAULT_ITEM_SIZE = 240;\ntype CarouselItemProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {\n /** What the item shows: usually an image, which the item masks. */\n children?: ReactNode;\n};\ntype CarouselProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {\n /** The items: `Carousel.Item` for each. */\n children?: ReactNode;\n /**\n * The large item's preferred width, in pixels. Multi-browse lays out as\n * many as fit and narrows them where they do not; uncontained draws every\n * item at it; hero takes its large item's width from the carousel's.\n * @default 240\n */\n itemSize?: number;\n /**\n * What the carousel shows, for a screen reader. Required rather than\n * optional: a carousel is a region, and a region with no name is one a\n * screen reader cannot introduce.\n */\n label: string;\n /**\n * Which of the page's layouts the carousel draws.\n * @default 'multi-browse'\n */\n layout?: CarouselLayout;\n /**\n * What the next button is called. Left out, the library names it in the\n * reader's locale — \"Next slide\" in English.\n */\n nextLabel?: string;\n /**\n * What the previous button is called. Left out, the library names it in\n * the reader's locale — \"Previous slide\" in English.\n */\n previousLabel?: string;\n};\nconst styles = {\n item: {\n kaIpWk: \"x19pkqky\",\n kB7OPa: \"x9f619\",\n kzQI83: \"x1c4vz4f\",\n kmuXW: \"x2lah0s\",\n kAzted: \"x2lwn1j\",\n kVQacm: \"xb3r6kr\",\n kVAEAm: \"x1n2onr6\",\n $$css: true\n },\n itemUncontained: {\n k5xd4v: \"x1bhewko\",\n $$css: true\n },\n marker: {\n kmuXW: \"x2lah0s\",\n k5xd4v: \"x83psoy\",\n $$css: true\n },\n scroller: {\n kOuLrU: \"xfk6m8\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kXHlph: \"xw2csxc\",\n kORKVm: \"x10wlt62\",\n kvh3hx: \"x7p5m3t\",\n kVAEAm: \"x1n2onr6\",\n k5wCbM: \"x1rohswg\",\n khEr5k: \"xkcv6ua xg83hb1\",\n kc424l: \"xhfbhpw\",\n $$css: true\n },\n scrollerUncontained: {\n katHQp: \"x7jkkja\",\n $$css: true\n }\n};\nconst _temp = {\n kzqmXN: \"x1uyokj7\",\n \"$$css\": true\n};\nconst _temp2 = {\n kzqmXN: \"x1uyokj7\",\n \"$$css\": true\n};\nconst _temp3 = {\n kzqmXN: \"x1uyokj7\",\n \"$$css\": true\n};\nconst placed = {\n item: (inlineSize: string, shift: string, clip: string) => [_temp, {\n kz4h6p: clip != null ? \"xx58lst\" : clip,\n kLqNvP: shift != null ? \"x1lxsm33\" : shift,\n $$css: true\n }, {\n \"--x-clipPath\": clip != null ? clip : undefined,\n \"--x-inlineSize\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(inlineSize),\n \"--x-insetInlineStart\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(shift)\n }],\n marker: (inlineSize: string) => [_temp2, {\n \"--x-inlineSize\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(inlineSize)\n }],\n uncontained: (inlineSize: string) => [_temp3, {\n \"--x-inlineSize\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(inlineSize)\n }]\n};\ntype Slot = {\n count: number;\n index: number;\n /** The width the item is laid out at. */\n large: number;\n layout: CarouselLayout;\n /** Where it is drawn, for a layout that masks. */\n placement: Placement | undefined;\n};\nconst SlotContext = createContext<null | Slot>(null);\n\n/** What the controls and focus scroll by, as numbers read off one render. */\ntype Geometry = {\n /** The offset of the last rest, or for uncontained how far it scrolls. */\n end: number;\n /** How many items past the first large one the last large one is. */\n lastLarge: number;\n masked: boolean;\n scrolled: number;\n /** The distance between two rests, or for uncontained between two items. */\n step: number;\n};\n\n// Where a press of previous or next scrolls to from `scrolled`: the rest\n// either side of the nearest one, or for uncontained an item's width along,\n// kept between the two ends.\nfunction along(direction: -1 | 1, {\n end,\n masked,\n scrolled,\n step\n}: Geometry): number {\n if (step <= 0) {\n return 0;\n }\n const offset = masked ? (Math.round(scrolled / step) + direction) * step : scrolled + direction * step;\n return Math.min(Math.max(offset, 0), end);\n}\n\n/**\n * A row of items that scrolls on and off the screen, in the carousel page's\n * multi-browse, hero or uncontained layout. Name it with `label`, and give it\n * a `Carousel.Item` for each item.\n *\n * ```tsx\n * <Carousel label=\"Label\">\n * <Carousel.Item><img alt=\"First item\" src=\"…\" /></Carousel.Item>\n * <Carousel.Item><img alt=\"Second item\" src=\"…\" /></Carousel.Item>\n * </Carousel>\n * ```\n *\n * The call site's `className` and `style` land on the carousel as a whole,\n * which is the element a layout positions.\n */\nfunction Carousel({\n children,\n itemSize = DEFAULT_ITEM_SIZE,\n label,\n layout = 'multi-browse',\n nextLabel,\n previousLabel,\n ref,\n ...props\n}: CarouselProps & RefAttributes<HTMLElement>) {\n const messages = useMessages();\n const scrollerRef = useRef<HTMLDivElement>(null);\n // The scroller's width and how far it has scrolled along the text:\n // everything drawn is drawn from these two.\n const [width, setWidth] = useState(0);\n const [scrolled, setScrolled] = useState(0);\n const items = Children.toArray(children).filter(isValidElement);\n const count = items.length;\n const room = Math.max(width - 2 * PADDING, 0);\n const arrangement = arrange(layout, room, itemSize, count);\n const masked = layout !== 'uncontained';\n // Read off the arrangement as arithmetic, so each is a number of its own\n // rather than a field of an object the calls below are handed.\n const step = arrangement.large + GAP;\n // The last rest, or how far the uncontained track runs past the scroller.\n const end = masked ? arrangement.steps * step : Math.max(count * step - GAP + 2 * PADDING - width, 0);\n const lastLarge = arrangement.largeCount - 1;\n const position = masked && step > 0 ? scrolled / step : 0;\n const drawn = masked ? placements(layout, arrangement, room, PADDING, count, position) : [];\n\n // Measured before the first paint, again on every scroll, and whenever\n // the scroller's width changes. A right-to-left scroller counts its offset\n // down from zero.\n const measure = useCallback(() => {\n const scroller = scrollerRef.current;\n if (scroller === null) {\n return;\n }\n setWidth(scroller.clientWidth);\n setScrolled(Math.abs(scroller.scrollLeft));\n }, []);\n useLayoutEffect(() => {\n const scroller = scrollerRef.current;\n if (scroller === null) {\n return undefined;\n }\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(scroller);\n return () => {\n observer.disconnect();\n };\n }, [measure]);\n const previous = useCallback(() => {\n const geometry = {\n end,\n lastLarge,\n masked,\n scrolled,\n step\n };\n scrollAlong(scrollerRef.current, along(-1, geometry));\n }, [end, lastLarge, masked, scrolled, step]);\n const next = useCallback(() => {\n const geometry = {\n end,\n lastLarge,\n masked,\n scrolled,\n step\n };\n scrollAlong(scrollerRef.current, along(1, geometry));\n }, [end, lastLarge, masked, scrolled, step]);\n\n // Focus arriving in an item a masking layout is not drawing large.\n // Uncontained items are where they are drawn, so the browser's own\n // scrolling of focus into view is already right for them.\n const reveal = useCallback((event: FocusEvent<HTMLDivElement>) => {\n const {\n target\n } = event;\n if (!masked || step <= 0 || !(target instanceof Node)) {\n return;\n }\n const index = Array.from(event.currentTarget.children).findIndex(child => child.contains(target));\n if (index < 0) {\n return;\n }\n const geometry = {\n end,\n lastLarge,\n masked,\n scrolled,\n step\n };\n const offset = Math.min(restRevealing(index, geometry) * step, end);\n scrollAlong(scrollerRef.current, offset);\n }, [end, lastLarge, masked, scrolled, step]);\n const slots = items.map((_, index): Slot => ({\n count,\n index,\n large: arrangement.large,\n layout,\n placement: drawn[index]\n }));\n return <section aria-label={label} aria-roledescription={messages.carousel} ref={ref} {...props} {...mergeStyles({\n className: \"x9f619 x78zum5 xdt5ytf x126z3so xeuugli\"\n }, props)}>\n <div onScroll={measure} ref={scrollerRef}\n // A tab stop while there is anywhere to scroll, so the arrow keys\n // move it from rest to rest whatever its items hold. A scroll\n // container with nothing focusable inside is otherwise out of a\n // keyboard's reach, which axe's scrollable-region-focusable reports.\n // oxlint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- see above\n tabIndex={end > 0 ? 0 : undefined} {...stylex.props(styles.scroller, focus.ring, !masked && styles.scrollerUncontained)}>\n {masked ? <div aria-hidden=\"true\" className=\"xjm9jq1 x1i1rx1s x13vifvy x1o0tod x47corl x10l6tqk x1bhewko\" /> : null}\n <div onFocus={reveal} {...{\n 0: {\n className: \"x9f619 x78zum5 x2lah0s x126z3so x1cmllll x790zyz\"\n },\n 1: {\n className: \"x9f619 x78zum5 x2lah0s x126z3so x1cmllll x790zyz xh8yej3 x1o0tod x7giv3 x7wzq59\"\n }\n }[!!masked << 0]}>\n {items.map((item, index) => <SlotContext key={item.key ?? index} value={slots[index] ?? null}>\n {item}\n </SlotContext>)}\n </div>\n {masked ? Array.from({\n length: arrangement.steps\n }, (_, rest) => <div aria-hidden=\"true\" key={rest} {...stylex.props(styles.marker, placed.marker(`${step}px`))} />) : null}\n </div>\n <div className=\"x9f619 x78zum5 x126z3so x13a6bvl x790zyz\">\n <IconButton aria-label={previousLabel ?? messages.previousSlide} isDisabled={scrolled <= 0.5} onPress={previous}>\n <ChevronEndGlyph className=\"xlzyvqe x1lliihq x15vhz18 x1pw7kks xpk2tj9\" />\n </IconButton>\n <IconButton aria-label={nextLabel ?? messages.nextSlide} isDisabled={scrolled >= end - 0.5} onPress={next}>\n <ChevronEndGlyph className=\"xlzyvqe x1lliihq x15vhz18 x19axjrm x1c071of\" />\n </IconButton>\n </div>\n </section>;\n}\n\n/**\n * One item. It is named by which of how many it is — \"2 of 6\" — unless it is\n * given an `aria-label` of its own.\n *\n * The call site's `className` and `style` land on the item.\n */\nfunction CarouselItem({\n children,\n ref,\n ...props\n}: CarouselItemProps & RefAttributes<HTMLDivElement>) {\n const messages = useMessages();\n const slot = useContext(SlotContext);\n const count = slot?.count ?? 1;\n const index = slot?.index ?? 0;\n const large = slot?.large ?? 0;\n const placement = slot?.placement;\n const inset = placement === undefined ? 0 : (large - placement.width) / 2;\n return <div aria-label={messages.slideLabel(index + 1, count)} aria-roledescription={messages.slide} ref={ref}\n // The pattern's own role for a slide. Its suggested `fieldset` is a\n // form's grouping, with a legend and a border of its own.\n // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- see above\n role=\"group\" {...props} {...mergeStyles(stylex.props(styles.item, slot?.layout === 'uncontained' && styles.itemUncontained, slot?.layout === 'uncontained' && placed.uncontained(`${large}px`), placement !== undefined && placed.item(`${large}px`, `${placement.left - inset - index * (large + GAP)}px`, `inset(0 ${inset}px round ${radii.xl})`)), props)}>\n {children}\n </div>;\n}\n\n// The nearest rest that draws the item at `index` large, from the rest\n// nearest `scrolled`: the one it starts, for an item before the large ones,\n// or the one it ends, for an item after them. At rest `s` the large items\n// are `s` to `s + lastLarge`.\nfunction restRevealing(index: number, {\n lastLarge,\n scrolled,\n step\n}: Geometry): number {\n const at = Math.round(scrolled / step);\n if (index < at) {\n return index;\n }\n if (index > at + lastLarge) {\n return index - lastLarge;\n }\n return at;\n}\n\n// Scrolls to an offset along the text, whichever way it runs: a\n// right-to-left scroller counts its offset down from zero.\nfunction scrollAlong(scroller: HTMLElement | null, offset: number) {\n if (scroller === null) {\n return;\n }\n const sign = getComputedStyle(scroller).direction === 'rtl' ? -1 : 1;\n scroller.scrollTo({\n left: sign * offset\n });\n}\nCarousel.Item = CarouselItem;\nexport type { CarouselItemProps, CarouselLayout, CarouselProps };\nexport { CarouselItem };\nexport default Carousel;"],"mappings":";;;;;;;;;;;;;;AA4DA,MAAM2B,UAAU;AAChB,MAAMC,oBAAoB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,aAAa,MACf;CAEF,MAAMyI,OAAOC,iBAAiB1I,QAAQ,CAAC,CAACqC,cAAc,QAAQ,KAAK;CACnErC,SAAS2I,SAAS,EAChBL,MAAMG,OAAOnG,OACf,CAAC;AACH;AACAK,SAASiG,OAAOX"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","FocusEvent","HTMLAttributes","ReactNode","RefAttributes","stylex","Children","createContext","isValidElement","useCallback","useContext","useLayoutEffect","useRef","useState","CarouselLayout","Placement","arrange","GAP","placements","ChevronEndGlyph","useMessages","focus","mergeStyles","radii","spacing","IconButton","PADDING","DEFAULT_ITEM_SIZE","CarouselItemProps","Omit","HTMLDivElement","children","state","CarouselItemRenderProps","visibleWidth","width","CarouselProps","HTMLElement","itemSize","label","layout","nextLabel","previousLabel","styles","item","kaIpWk","kB7OPa","kzQI83","kmuXW","kAzted","kVQacm","kVAEAm","$$css","itemUncontained","k5xd4v","marker","scroller","kOuLrU","k1xSpc","kXHlph","kORKVm","kvh3hx","k5wCbM","khEr5k","kc424l","scrollerUncontained","katHQp","_temp","kzqmXN","_temp2","_temp3","placed","inlineSize","shift","clip","kz4h6p","kLqNvP","undefined","val","uncontained","Slot","count","index","large","placement","SlotContext","Geometry","end","lastLarge","masked","scrolled","step","along","direction","offset","Math","round","min","max","Carousel","t0","$","t1","t2","ref","props","messages","scrollerRef","setWidth","setScrolled","items","toArray","filter","length","room","arrangement","steps","largeCount","position","drawn","t3","Symbol","for","current","clientWidth","abs","scrollLeft","measure","t4","t5","scroller_0","observer","ResizeObserver","observe","disconnect","t6","geometry","scrollAlong","previous","t7","geometry_0","next","t8","event","target","Node","Array","from","currentTarget","findIndex","child","contains","geometry_1","restRevealing","reveal","slots","map","_","index_0","t9","carousel","t10","className","t11","ring","t12","t13","0","1","t14","previousSlide","t15","t16","t17","t18","nextSlide","t19","t20","t21","t22","index_1","key","__0","rest","CarouselItem","slot","inset","slideLabel","slide","left","xl","at","sign","getComputedStyle","scrollTo","Item","_c","props","stylex.props"],"sources":["../../../src/components/carousel/index.tsx"],"sourcesContent":["'use client';\n\nimport type { FocusEvent, HTMLAttributes, ReactNode, RefAttributes } from 'react';\nimport * as stylex from '@stylexjs/stylex';\nimport { Children, createContext, isValidElement, useCallback, useContext, useLayoutEffect, useRef, useState } from 'react';\nimport type { CarouselLayout, Placement } from '../../carousel/arrangement';\nimport { arrange, GAP, placements } from '../../carousel/arrangement';\nimport { ChevronEndGlyph } from '../../glyphs';\nimport { useMessages } from '../../i18n';\nimport { focus } from '../../styles/focus';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { radii, spacing } from '../../tokens/design.tokens.stylex';\nimport IconButton from '../icon-button';\n\n// The carousel page's carousel: a row of items that scrolls on and off the\n// screen, drawn in three of the page's layouts. Each has the page's 16dp of\n// padding at its ends and 8dp at its top and bottom, 8dp between items and a\n// 28dp corner on every item.\n//\n// - **Multi-browse**, the default, shows as many large items as fit at\n// `itemSize`, then a medium one and a small one, and fills its width\n// exactly; the large width gives way where the preferred one does not fit.\n// - **Hero** shows one large item and one small.\n// - **Uncontained** shows every item at `itemSize`, scrolling past the edge.\n//\n// **Items change size as they move**, as the page draws them. The first two\n// layouts come to rest one item apart, and between two rests every item's\n// place and width are interpolated, so an item shrinks as it leaves and\n// grows as it arrives; the last rests turn the arrangement round a slot at a\n// time, so every item is drawn large at one of them. The arithmetic is\n// `src/carousel/arrangement.ts`.\n// An item is laid out at the large width and masked down to the width it is\n// drawn at, centred, with the page's corner on the mask: what it holds is\n// cut at both sides rather than squeezed, as the page's masked items are.\n//\n// **What an item holds can see its mask.** The page shows an item's text\n// once the item is wide enough to hold it, and only what the item holds\n// knows where its text is, so `Carousel.Item` takes its children as a\n// function too, handed the width the item is laid out at and the width\n// that shows of it, as MDC-Android's masked items report their mask to a\n// listener. The text can then fade or hide as the mask closes over it.\n//\n// **The scrolling is the browser's.** A scroller holds the items' track,\n// which stays put while it scrolls, and a run of empty markers one item\n// apart after it, which is what gives the scroller its length and its rests:\n// each marker's end is a scroll-snap point, and a mark at the scroller's\n// start is the first. The position the scroller reports is what the items\n// are drawn from. Uncontained has no rests and no masks, so its items scroll\n// in the track themselves, snapping to their own starts.\n//\n// **It is the ARIA carousel pattern**, since React Aria has no carousel: a\n// region named by `label` and described as a carousel, each item a group\n// described as a slide and named by which of how many it is, and a previous\n// and a next button under it, at the end. Focus moving into an item that is\n// not drawn large scrolls the carousel to the nearest rest that draws it\n// large, and the scroller is a tab stop while it scrolls, so the arrow keys\n// move it too. Under reduced motion the scroller jumps rather than scrolling\n// smoothly.\n//\n// The page's large width is \"dynamic, or user-set\", and neither MDC-Android\n// nor Compose has a default for it; `itemSize`'s 240 is this component's own.\n// Uncontained keeps the 16dp at its end as well as its start, where the page\n// gives it a leading padding alone, so its last item does not end flush\n// against the edge.\n\n/** The page's 16dp at a carousel's ends. */\nconst PADDING = 16;\nconst DEFAULT_ITEM_SIZE = 240;\ntype CarouselItemProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {\n /**\n * What the item shows: usually an image, which the item masks. A function\n * is handed how much of the item shows, every time that changes, so text\n * the item has no room for can be hidden as the mask closes over it.\n */\n children?: ((state: CarouselItemRenderProps) => ReactNode) | ReactNode;\n};\n\n/** How much of a `Carousel.Item` shows, for children written as a function. */\ntype CarouselItemRenderProps = {\n /**\n * How much of `width` shows, in pixels. The mask takes the rest evenly\n * from both sides, so `(width - visibleWidth) / 2` is cut off each. It is\n * `width` for an item drawn large, and for every item of an uncontained\n * carousel, which masks nothing.\n */\n visibleWidth: number;\n /**\n * The width the item is laid out at, in pixels: the large item's, which\n * every item in the carousel shares.\n */\n width: number;\n};\ntype CarouselProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {\n /** The items: `Carousel.Item` for each. */\n children?: ReactNode;\n /**\n * The large item's preferred width, in pixels. Multi-browse lays out as\n * many as fit and narrows them where they do not; uncontained draws every\n * item at it; hero takes its large item's width from the carousel's.\n * @default 240\n */\n itemSize?: number;\n /**\n * What the carousel shows, for a screen reader. Required rather than\n * optional: a carousel is a region, and a region with no name is one a\n * screen reader cannot introduce.\n */\n label: string;\n /**\n * Which of the page's layouts the carousel draws.\n * @default 'multi-browse'\n */\n layout?: CarouselLayout;\n /**\n * What the next button is called. Left out, the library names it in the\n * reader's locale — \"Next slide\" in English.\n */\n nextLabel?: string;\n /**\n * What the previous button is called. Left out, the library names it in\n * the reader's locale — \"Previous slide\" in English.\n */\n previousLabel?: string;\n};\nconst styles = {\n item: {\n kaIpWk: \"x19pkqky\",\n kB7OPa: \"x9f619\",\n kzQI83: \"x1c4vz4f\",\n kmuXW: \"x2lah0s\",\n kAzted: \"x2lwn1j\",\n kVQacm: \"xb3r6kr\",\n kVAEAm: \"x1n2onr6\",\n $$css: true\n },\n itemUncontained: {\n k5xd4v: \"x1bhewko\",\n $$css: true\n },\n marker: {\n kmuXW: \"x2lah0s\",\n k5xd4v: \"x83psoy\",\n $$css: true\n },\n scroller: {\n kOuLrU: \"xfk6m8\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kXHlph: \"xw2csxc\",\n kORKVm: \"x10wlt62\",\n kvh3hx: \"x7p5m3t\",\n kVAEAm: \"x1n2onr6\",\n k5wCbM: \"x1rohswg\",\n khEr5k: \"xkcv6ua xg83hb1\",\n kc424l: \"xhfbhpw\",\n $$css: true\n },\n scrollerUncontained: {\n katHQp: \"x7jkkja\",\n $$css: true\n }\n};\nconst _temp = {\n kzqmXN: \"x1uyokj7\",\n \"$$css\": true\n};\nconst _temp2 = {\n kzqmXN: \"x1uyokj7\",\n \"$$css\": true\n};\nconst _temp3 = {\n kzqmXN: \"x1uyokj7\",\n \"$$css\": true\n};\nconst placed = {\n item: (inlineSize: string, shift: string, clip: string) => [_temp, {\n kz4h6p: clip != null ? \"xx58lst\" : clip,\n kLqNvP: shift != null ? \"x1lxsm33\" : shift,\n $$css: true\n }, {\n \"--x-clipPath\": clip != null ? clip : undefined,\n \"--x-inlineSize\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(inlineSize),\n \"--x-insetInlineStart\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(shift)\n }],\n marker: (inlineSize: string) => [_temp2, {\n \"--x-inlineSize\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(inlineSize)\n }],\n uncontained: (inlineSize: string) => [_temp3, {\n \"--x-inlineSize\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(inlineSize)\n }]\n};\ntype Slot = {\n count: number;\n index: number;\n /** The width the item is laid out at. */\n large: number;\n layout: CarouselLayout;\n /** Where it is drawn, for a layout that masks. */\n placement: Placement | undefined;\n};\nconst SlotContext = createContext<null | Slot>(null);\n\n/** What the controls and focus scroll by, as numbers read off one render. */\ntype Geometry = {\n /** The offset of the last rest, or for uncontained how far it scrolls. */\n end: number;\n /** How many items past the first large one the last large one is. */\n lastLarge: number;\n masked: boolean;\n scrolled: number;\n /** The distance between two rests, or for uncontained between two items. */\n step: number;\n};\n\n// Where a press of previous or next scrolls to from `scrolled`: the rest\n// either side of the nearest one, or for uncontained an item's width along,\n// kept between the two ends.\nfunction along(direction: -1 | 1, {\n end,\n masked,\n scrolled,\n step\n}: Geometry): number {\n if (step <= 0) {\n return 0;\n }\n const offset = masked ? (Math.round(scrolled / step) + direction) * step : scrolled + direction * step;\n return Math.min(Math.max(offset, 0), end);\n}\n\n/**\n * A row of items that scrolls on and off the screen, in the carousel page's\n * multi-browse, hero or uncontained layout. Name it with `label`, and give it\n * a `Carousel.Item` for each item.\n *\n * ```tsx\n * <Carousel label=\"Label\">\n * <Carousel.Item><img alt=\"First item\" src=\"…\" /></Carousel.Item>\n * <Carousel.Item><img alt=\"Second item\" src=\"…\" /></Carousel.Item>\n * </Carousel>\n * ```\n *\n * The call site's `className` and `style` land on the carousel as a whole,\n * which is the element a layout positions.\n */\nfunction Carousel({\n children,\n itemSize = DEFAULT_ITEM_SIZE,\n label,\n layout = 'multi-browse',\n nextLabel,\n previousLabel,\n ref,\n ...props\n}: CarouselProps & RefAttributes<HTMLElement>) {\n const messages = useMessages();\n const scrollerRef = useRef<HTMLDivElement>(null);\n // The scroller's width and how far it has scrolled along the text:\n // everything drawn is drawn from these two.\n const [width, setWidth] = useState(0);\n const [scrolled, setScrolled] = useState(0);\n const items = Children.toArray(children).filter(isValidElement);\n const count = items.length;\n const room = Math.max(width - 2 * PADDING, 0);\n const arrangement = arrange(layout, room, itemSize, count);\n const masked = layout !== 'uncontained';\n // Read off the arrangement as arithmetic, so each is a number of its own\n // rather than a field of an object the calls below are handed.\n const step = arrangement.large + GAP;\n // The last rest, or how far the uncontained track runs past the scroller.\n const end = masked ? arrangement.steps * step : Math.max(count * step - GAP + 2 * PADDING - width, 0);\n const lastLarge = arrangement.largeCount - 1;\n const position = masked && step > 0 ? scrolled / step : 0;\n const drawn = masked ? placements(layout, arrangement, room, PADDING, count, position) : [];\n\n // Measured before the first paint, again on every scroll, and whenever\n // the scroller's width changes. A right-to-left scroller counts its offset\n // down from zero.\n const measure = useCallback(() => {\n const scroller = scrollerRef.current;\n if (scroller === null) {\n return;\n }\n setWidth(scroller.clientWidth);\n setScrolled(Math.abs(scroller.scrollLeft));\n }, []);\n useLayoutEffect(() => {\n const scroller = scrollerRef.current;\n if (scroller === null) {\n return undefined;\n }\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(scroller);\n return () => {\n observer.disconnect();\n };\n }, [measure]);\n const previous = useCallback(() => {\n const geometry = {\n end,\n lastLarge,\n masked,\n scrolled,\n step\n };\n scrollAlong(scrollerRef.current, along(-1, geometry));\n }, [end, lastLarge, masked, scrolled, step]);\n const next = useCallback(() => {\n const geometry = {\n end,\n lastLarge,\n masked,\n scrolled,\n step\n };\n scrollAlong(scrollerRef.current, along(1, geometry));\n }, [end, lastLarge, masked, scrolled, step]);\n\n // Focus arriving in an item a masking layout is not drawing large.\n // Uncontained items are where they are drawn, so the browser's own\n // scrolling of focus into view is already right for them.\n const reveal = useCallback((event: FocusEvent<HTMLDivElement>) => {\n const {\n target\n } = event;\n if (!masked || step <= 0 || !(target instanceof Node)) {\n return;\n }\n const index = Array.from(event.currentTarget.children).findIndex(child => child.contains(target));\n if (index < 0) {\n return;\n }\n const geometry = {\n end,\n lastLarge,\n masked,\n scrolled,\n step\n };\n const offset = Math.min(restRevealing(index, geometry) * step, end);\n scrollAlong(scrollerRef.current, offset);\n }, [end, lastLarge, masked, scrolled, step]);\n const slots = items.map((_, index): Slot => ({\n count,\n index,\n large: arrangement.large,\n layout,\n placement: drawn[index]\n }));\n return <section aria-label={label} aria-roledescription={messages.carousel} ref={ref} {...props} {...mergeStyles({\n className: \"x9f619 x78zum5 xdt5ytf x126z3so xeuugli\"\n }, props)}>\n <div onScroll={measure} ref={scrollerRef}\n // A tab stop while there is anywhere to scroll, so the arrow keys\n // move it from rest to rest whatever its items hold. A scroll\n // container with nothing focusable inside is otherwise out of a\n // keyboard's reach, which axe's scrollable-region-focusable reports.\n // oxlint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- see above\n tabIndex={end > 0 ? 0 : undefined} {...stylex.props(styles.scroller, focus.ring, !masked && styles.scrollerUncontained)}>\n {masked ? <div aria-hidden=\"true\" className=\"xjm9jq1 x1i1rx1s x13vifvy x1o0tod x47corl x10l6tqk x1bhewko\" /> : null}\n <div onFocus={reveal} {...{\n 0: {\n className: \"x9f619 x78zum5 x2lah0s x126z3so x1cmllll x790zyz\"\n },\n 1: {\n className: \"x9f619 x78zum5 x2lah0s x126z3so x1cmllll x790zyz xh8yej3 x1o0tod x7giv3 x7wzq59\"\n }\n }[!!masked << 0]}>\n {items.map((item, index) => <SlotContext key={item.key ?? index} value={slots[index] ?? null}>\n {item}\n </SlotContext>)}\n </div>\n {masked ? Array.from({\n length: arrangement.steps\n }, (_, rest) => <div aria-hidden=\"true\" key={rest} {...stylex.props(styles.marker, placed.marker(`${step}px`))} />) : null}\n </div>\n <div className=\"x9f619 x78zum5 x126z3so x13a6bvl x790zyz\">\n <IconButton aria-label={previousLabel ?? messages.previousSlide} isDisabled={scrolled <= 0.5} onPress={previous}>\n <ChevronEndGlyph className=\"xlzyvqe x1lliihq x15vhz18 x1pw7kks xpk2tj9\" />\n </IconButton>\n <IconButton aria-label={nextLabel ?? messages.nextSlide} isDisabled={scrolled >= end - 0.5} onPress={next}>\n <ChevronEndGlyph className=\"xlzyvqe x1lliihq x15vhz18 x19axjrm x1c071of\" />\n </IconButton>\n </div>\n </section>;\n}\n\n/**\n * One item. It is named by which of how many it is — \"2 of 6\" — unless it is\n * given an `aria-label` of its own.\n *\n * The call site's `className` and `style` land on the item.\n */\nfunction CarouselItem({\n children,\n ref,\n ...props\n}: CarouselItemProps & RefAttributes<HTMLDivElement>) {\n const messages = useMessages();\n const slot = useContext(SlotContext);\n const count = slot?.count ?? 1;\n const index = slot?.index ?? 0;\n const large = slot?.large ?? 0;\n const placement = slot?.placement;\n const visibleWidth = placement === undefined ? large : placement.width;\n const inset = (large - visibleWidth) / 2;\n return <div aria-label={messages.slideLabel(index + 1, count)} aria-roledescription={messages.slide} ref={ref}\n // The pattern's own role for a slide. Its suggested `fieldset` is a\n // form's grouping, with a legend and a border of its own.\n // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- see above\n role=\"group\" {...props} {...mergeStyles(stylex.props(styles.item, slot?.layout === 'uncontained' && styles.itemUncontained, slot?.layout === 'uncontained' && placed.uncontained(`${large}px`), placement !== undefined && placed.item(`${large}px`, `${placement.left - inset - index * (large + GAP)}px`, `inset(0 ${inset}px round ${radii.xl})`)), props)}>\n {typeof children === 'function' ? children({\n visibleWidth,\n width: large\n }) : children}\n </div>;\n}\n\n// The nearest rest that draws the item at `index` large, from the rest\n// nearest `scrolled`: the one it starts, for an item before the large ones,\n// or the one it ends, for an item after them. At rest `s` the large items\n// are `s` to `s + lastLarge`.\nfunction restRevealing(index: number, {\n lastLarge,\n scrolled,\n step\n}: Geometry): number {\n const at = Math.round(scrolled / step);\n if (index < at) {\n return index;\n }\n if (index > at + lastLarge) {\n return index - lastLarge;\n }\n return at;\n}\n\n// Scrolls to an offset along the text, whichever way it runs: a\n// right-to-left scroller counts its offset down from zero.\nfunction scrollAlong(scroller: HTMLElement | null, offset: number) {\n if (scroller === null) {\n return;\n }\n const sign = getComputedStyle(scroller).direction === 'rtl' ? -1 : 1;\n scroller.scrollTo({\n left: sign * offset\n });\n}\nCarousel.Item = CarouselItem;\nexport type { CarouselItemProps, CarouselItemRenderProps, CarouselLayout, CarouselProps };\nexport { CarouselItem };\nexport default Carousel;"],"mappings":";;;;;;;;;;;;;;AAmEA,MAAM2B,UAAU;AAChB,MAAMC,oBAAoB;AAyD1B,MAAMgB,SAAS;CACbC,MAAM;EACJC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;EACPC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;CACT;CACAC,iBAAiB;EACfC,QAAQ;EACRF,OAAO;CACT;CACAG,QAAQ;EACNP,OAAO;EACPM,QAAQ;EACRF,OAAO;CACT;CACAI,UAAU;EACRC,QAAQ;EACRX,QAAQ;EACRY,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRV,QAAQ;EACRW,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRZ,OAAO;CACT;CACAa,qBAAqB;EACnBC,QAAQ;EACRd,OAAO;CACT;AACF;AACA,MAAMe,QAAQ;CACZC,QAAQ;CACR,SAAS;AACX;AACA,MAAMC,SAAS;CACbD,QAAQ;CACR,SAAS;AACX;AACA,MAAME,SAAS;CACbF,QAAQ;CACR,SAAS;AACX;AACA,MAAMG,SAAS;CACb3B,OAAO4B,YAAoBC,OAAeC,SAAiB;EAACP;EAAO;GACjEQ,QAAQD,QAAQ,OAAO,YAAYA;GACnCE,QAAQH,SAAS,OAAO,aAAaA;GACrCrB,OAAO;EACT;EAAG;GACD,gBAAgBsB,QAAQ,OAAOA,OAAOG,KAAAA;GACtC,oBAAmBC,QA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,EAAA,OAAAK,SAAAkF,SAAAvF,EAAA,OAAAI,WAAAJ,EAAA,QAAAG,OAAAH,EAAA,QAAAC,MAAAD,EAAA,QAAA2B,MAAA3B,EAAA,QAAA4B,IAAA;EARRM,KAAA,oBAAA,OAAA;GAAiB,cAAAjC;GAA6D,wBAAAC;GAAqBC;GAIrG,MAAAgB;GAAO,GAAKf;GAAK,GAAMuB;GACvBC,UAAAA;EAIG,CAAA;EAAA5B,EAAA,KAAAK,SAAAkF;EAAAvF,EAAA,KAAAI;EAAAJ,EAAA,MAAAG;EAAAH,EAAA,MAAAC;EAAAD,EAAA,MAAA2B;EAAA3B,EAAA,MAAA4B;EAAA5B,EAAA,MAAAkC;CAAA,OAAAA,KAAAlC,EAAA;CAAA,OATDkC;AASC;AAOV,SAASkB,cAAcvE,OAAe,EACpCM,WACAE,UACAC,QACmB;CACnB,MAAMoG,KAAKhG,KAAKC,MAAMN,WAAWC,IAAI;CACrC,IAAIT,QAAQ6G,IACV,OAAO7G;CAET,IAAIA,QAAQ6G,KAAKvG,WACf,OAAON,QAAQM;CAEjB,OAAOuG;AACT;AAIA,SAAStD,YAAYjF,UAA8BsC,QAAgB;CACjE,IAAItC,aAAa,MACf;CAEF,MAAMwI,OAAOC,iBAAiBzI,QAAQ,CAAC,CAACqC,cAAc,QAAQ,KAAK;CACnErC,SAAS0I,SAAS,EAChBL,MAAMG,OAAOlG,OACf,CAAC;AACH;AACAK,SAASgG,OAAOX"}
|
|
@@ -16,11 +16,14 @@ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
|
16
16
|
import { Button, Tag, TagGroup, TagList } from "react-aria-components";
|
|
17
17
|
// src/components/chip-group/index.tsx
|
|
18
18
|
const styles = { list: {
|
|
19
|
+
kGNEyG: "x6s0dn4",
|
|
20
|
+
kaIpWk: "x1xdvaa9",
|
|
19
21
|
kB7OPa: "x9f619",
|
|
20
22
|
k1xSpc: "x78zum5",
|
|
21
23
|
kwnvtZ: "x1a02dak",
|
|
22
24
|
kOIVth: "x126z3so",
|
|
23
25
|
kAzted: "xlzjxrf",
|
|
26
|
+
kg3NbH: "x91pird xnjsko4",
|
|
24
27
|
$$css: true
|
|
25
28
|
} };
|
|
26
29
|
function chipContent(children, icon, removeLabel, surface, acts) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","ReactElement","ReactNode","RefAttributes","TagGroupProps","RACTagGroupProps","TagListProps","RACTagListProps","TagProps","RACTagProps","TagRenderProps","stylex","createContext","useContext","Button","RACButton","Tag","RACTag","TagGroup","RACTagGroup","TagList","RACTagList","chipGlyph","chipLabel","chipPropsFor","chipRemoveClassName","chipStyles","textOf","FieldLabel","FieldMessage","invalidFrom","groupStyles","CloseGlyph","useRipple","focus","mergeStatefulStyles","mergeStyles","sizing","spacing","styles","list","kB7OPa","k1xSpc","kwnvtZ","kOIVth","kAzted","$$css","ChipGroupChipProps","children","className","icon","style","textValue","Omit","ChipGroupProps","item","T","description","error","escapeKeyBehavior","label","removeLabel","Pick","chipContent","surface","acts","state","selectionMode","isDisabled","props","surfaceCorners","allowsRemoving","removeGlyph","RemoveLabelContext","undefined","GroupActionContext","LABEL_STATE_VALID","isInvalid","LABEL_STATE_INVALID","actingChipPropsFor","kind","kindOf","ChipGroup","t0","$","T0","invalid","items","renderEmptyState","t1","t2","t3","t4","t5","t6","t7","t8","t9","t10","t11","t12","root","onAction","Symbol","for","ring","ChipGroupChip","onContextMenu","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","href","ripple","handlers","groupChipPropsFor","inert","Chip","stylex.props","RACButton","_c","props","RACTagGroup","RACTagList","RACTag"],"sources":["../../../src/components/chip-group/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactElement, ReactNode, RefAttributes } from 'react';\nimport type { TagGroupProps as RACTagGroupProps, TagListProps as RACTagListProps, TagProps as RACTagProps, TagRenderProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { createContext, useContext } from 'react';\nimport { Button as RACButton, Tag as RACTag, TagGroup as RACTagGroup, TagList as RACTagList } from 'react-aria-components';\nimport { chipGlyph, chipLabel, chipPropsFor, chipRemoveClassName } from '../../chip';\nimport { chipStyles } from '../../chip/styles';\nimport { textOf } from '../../collection/text';\nimport { FieldLabel, FieldMessage } from '../../field';\nimport { invalidFrom } from '../../field/root';\nimport { groupStyles } from '../../field/styles';\nimport { CloseGlyph } from '../../glyphs';\nimport { useRipple } from '../../hooks/useRipple';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles, mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { sizing, spacing } from '../../tokens/design.tokens.stylex';\n\n// The chips page's filter and input chips as a set: one or more chosen from a\n// row, each one removable. The pill is the chip module's in `src/chip`,\n// shared with the standalone Chip, so the two cannot drift; what is here is\n// the group around them.\n//\n// Three things it adds over a row of Chips.\n//\n// **It is a group, not a row of buttons.** React Aria's `TagGroup` names the\n// set, describes it, points it at its error, and moves between its chips\n// with the arrow keys rather than making each one a tab stop — which\n// is what a set of a dozen filters needs. The label, the supporting line and\n// the error are the field chrome's, so a group reads like the fields beside\n// it, exactly as CheckboxGroup and RadioGroup do.\n//\n// **A chip can be removed.** Give the group `onRemove` and each chip draws\n// the page's trailing close target, an 18dp glyph in a target of its own so a\n// press there removes rather than toggles. Backspace and Delete remove the\n// focused chip too, which is React Aria's. A chosen chip's check sits at the\n// other end, so a chip that is both selected and removable carries one glyph\n// on each side of its label.\n//\n// **Selection is the group's, not each chip's.** `selectionMode` and\n// `selectedKeys` live on the group, so a set that chooses one of its chips\n// and a set that chooses several are the same component with a different\n// word. A chip on its own that toggles nothing else is still Chip.\n//\n// **Escape leaves the selection alone.** React Aria's collections clear the\n// selection on Escape and stop the key there, which suits a list whose\n// selection is what an action is about to act on. A set of chips holds a\n// value, as a checkbox group does, and usually sits in a Sheet, Dialog or\n// Popover, where Escape is what dismisses it: clearing it there wiped the\n// reader's filters and took a second press to close. So the group passes\n// React Aria's `escapeKeyBehavior` as `none` unless told `clearSelection`.\n//\n// **A chip a press does nothing to does not look pressable.** In a group\n// that selects nothing, a chip with no action of its own or the group's is\n// a control only for its close target. It draws the arrow cursor, no layer\n// and no ripple, and its close target keeps the pointer. A disabled chip's\n// close target takes the chip's `not-allowed` with it.\n//\n// One thing is worth knowing about how this maps onto React Aria. A chip's\n// text value is read off its children and found only when they are a plain\n// string, and a chip here is always an element — the label sits beside a\n// close target. So a plain-string label is passed through as the text value,\n// which is what typeahead and a screen reader's announcement are made of;\n// see ListBox.Item, where the same thing bit.\n\nconst styles = {\n list: {\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kwnvtZ: \"x1a02dak\",\n kOIVth: \"x126z3so\",\n kAzted: \"xlzjxrf\",\n $$css: true\n }\n};\ntype ChipGroupChipProps = {\n /**\n * The chip's label. Text, numbers, or a mix of the two — `Label {3}` —\n * also name the chip; a label holding an element needs `textValue`.\n */\n children?: ReactNode;\n /** A function may compute the class from the chip's render state. */\n className?: RACTagProps['className'];\n /**\n * An icon before the label, in the page's 18dp slot and the primary role.\n * The check takes its place while the chip is chosen, so the chip keeps\n * its width. An icon drawn in `em` takes its size from the slot.\n */\n icon?: ReactNode;\n /** A function may compute the style from the chip's render state. */\n style?: RACTagProps['style'];\n /**\n * The chip's name as text, which is what a screen reader announces for\n * its row. Read from the label when that is text or numbers, so it is\n * needed only when the label holds an element — emphasis, a count in a\n * badge — and React Aria warns in the console when such a chip has none.\n * Given, it wins over the text read from the label.\n */\n textValue?: string;\n} & Omit<RACTagProps, 'children' | 'className' | 'style' | 'textValue'>;\ntype ChipGroupProps<T extends object = object> = {\n /**\n * The chips, each with an `id` of its own. With `items`, a function from an\n * item to its chip, which React Aria calls for each item in turn.\n */\n children?: ((item: T) => ReactElement) | ReactNode;\n /**\n * A hint under the group. Replaced by `error` when there is one, so the\n * two never stack.\n */\n description?: string;\n /**\n * The problem with the current selection, in words. Its presence is what\n * puts the group in its error state: the label and the message take the\n * error colour, the grid's `aria-describedby` names the message, and the\n * message is read out politely as it appears. The grid carries no\n * `aria-invalid`, which ARIA does not allow on a grid, so the message is\n * the whole of what a screen reader is told.\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 * What Escape does on a chip. `none`, the default, keeps the selection and\n * lets the key through to whatever is around the group, so a group in a\n * Sheet, Dialog or Popover closes it on the first press. `clearSelection`\n * empties the selection first, as React Aria's own default does, and lets\n * a second press through.\n *\n * @default 'none'\n */\n escapeKeyBehavior?: 'clearSelection' | 'none';\n /**\n * What the group is for. Required rather than optional: a set of chips\n * with no name is a row a screen reader cannot introduce.\n */\n label: string;\n /**\n * What the close target on each chip is called, for a screen reader. React\n * Aria adds the chip's own label after it, so this is the verb rather than\n * the whole phrase — \"Remove\" becomes \"Remove First item\". Left out, React\n * Aria names it in the reader's locale — \"Remove\" in English.\n */\n removeLabel?: string;\n} & Omit<RACTagGroupProps, 'children' | 'escapeKeyBehavior'> & Pick<RACTagListProps<T>, 'items' | 'renderEmptyState'>;\n\n// What the chip draws, from React Aria's render state. Built by a call rather\n// than written inline at the prop, which is what react-perf's\n// no-new-function-as-prop is after; the React Compiler memoises the result on\n// its inputs.\n//\n// The check and the icon it replaces are the chip module's, so a chip in a\n// group and a chip on its own draw the same ones. The close target is drawn\n// only where the group allows removing, which React Aria reports rather than\n// the call site saying so on every chip.\n//\n// The ripple is drawn only on a chip a press does something to, and not\n// disabled: one the group lets be selected, or one with an action, its own\n// or the group's. Any other chip in a group that selects nothing is a\n// control only for its close target, and React Aria reports neither hover\n// nor press on it, so a ripple there would answer a press that changes\n// nothing. `acts` is the action half, which the render state does not carry.\n//\n// It sits in a box of its own carrying the chip's corner, since React Aria's\n// cell between the chip and this content would otherwise hand the ripple a\n// square one to inherit; see the header of src/chip/styles.ts.\nfunction chipContent(children: ReactNode, icon: ReactNode, removeLabel: string | undefined, surface: ReactNode, acts: boolean) {\n return (state: TagRenderProps) => <>\n {chipGlyph(state, icon, state.selectionMode !== 'none')}\n {chipLabel(children)}\n {(acts || state.selectionMode !== 'none') && !state.isDisabled ? <span {...stylex.props(chipStyles.surfaceCorners)}>{surface}</span> : null}\n {state.allowsRemoving ? <RACButton aria-label={removeLabel} className={chipRemoveClassName} slot=\"remove\">\n <CloseGlyph {...stylex.props(chipStyles.removeGlyph)} />\n </RACButton> : null}\n </>;\n}\n\n// What each chip calls its close target. A context rather than a prop on the\n// chip, since it is the group's decision and repeating it on every chip is\n// how the two drift. Undefined unless the group is given one, which leaves\n// the name React Aria gives in the reader's locale.\nconst RemoveLabelContext = createContext<string | undefined>(undefined);\n\n// Whether the group was given `onAction`, which makes every chip in it\n// pressable whether or not it selects. A context for the reason the close\n// target's name is one.\nconst GroupActionContext = createContext(false);\n\n// Hoisted so neither is a new object on every render.\nconst LABEL_STATE_VALID = {\n isInvalid: false\n};\nconst LABEL_STATE_INVALID = {\n isInvalid: true\n};\n\n// The pill of a chip with an action, which a press always reaches.\nfunction actingChipPropsFor(state: TagRenderProps) {\n return chipPropsFor(state, {\n kind: kindOf(state)\n });\n}\n\n/**\n * A labelled set of chips, one or more of which can be chosen, each of which\n * can be removed. Selection is React Aria's: set `selectionMode` to `single`\n * or `multiple` and pass `selectedKeys` with `onSelectionChange` to control\n * it, or `defaultSelectedKeys` to let it keep its own.\n *\n * ```tsx\n * <ChipGroup label=\"Label\" selectionMode=\"multiple\" onRemove={remove}>\n * <ChipGroup.Chip id=\"first\">First item</ChipGroup.Chip>\n * </ChipGroup>\n * ```\n *\n * Give the group `onRemove` and each chip draws a close target. The arrow\n * keys move between chips, so a set of many is one tab stop rather than many.\n *\n * A chip is never wider than its row, so a label with no room ends in an\n * ellipsis rather than wrapping, and shows its full text in the browser's\n * tooltip on hover.\n *\n * Escape on a chip keeps the selection and reaches whatever is around the\n * group, so a group in a Sheet, Dialog or Popover closes it. Pass\n * `escapeKeyBehavior=\"clearSelection\"` for React Aria's own default, which\n * empties the selection on the first press and lets the second through.\n *\n * A chip that toggles nothing else is Chip; this is for a set that shares a\n * value.\n *\n * The call site's `className` and `style` land on the group as a whole,\n * which is the element a layout positions.\n */\nfunction ChipGroup<T extends object = object>({\n children,\n description,\n error,\n escapeKeyBehavior = 'none',\n items,\n label,\n removeLabel,\n renderEmptyState,\n ...props\n}: ChipGroupProps<T> & RefAttributes<HTMLDivElement>) {\n const invalid = invalidFrom(error);\n return <RACTagGroup escapeKeyBehavior={escapeKeyBehavior} {...props} {...mergeStyles(stylex.props(groupStyles.root), props)}>\n {/* React Aria's tag group has no disabled state of its own — a chip is\n disabled through the group's `disabledKeys` — so the label follows\n validity alone. */}\n <FieldLabel state={invalid ? LABEL_STATE_INVALID : LABEL_STATE_VALID} variant=\"group\">\n {label}\n </FieldLabel>\n <RemoveLabelContext value={removeLabel}>\n <GroupActionContext value={props.onAction !== undefined}>\n <RACTagList<T> items={items} renderEmptyState={renderEmptyState} {...stylex.props(styles.list, focus.ring)}>\n {children}\n </RACTagList>\n </GroupActionContext>\n </RemoveLabelContext>\n <FieldMessage description={description} error={error} inset={false} />\n </RACTagGroup>;\n}\n\n/**\n * One chip. Give every chip an `id` — that is the key selection and removal\n * are reported by.\n */\nfunction ChipGroupChip({\n children,\n icon,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n ...props\n}: ChipGroupChipProps & RefAttributes<HTMLDivElement>) {\n const removeLabel = useContext(RemoveLabelContext);\n // An action of its own, a link or the group's makes a chip pressable even\n // in a group that selects nothing, as React Aria treats it.\n const acts = useContext(GroupActionContext) || props.onAction !== undefined || props.href !== undefined;\n // The press ripple a list's rows draw — see ListItem there. A chip in a\n // group is a collection row, whose clicks React Aria keeps for itself, so\n // the press ends when the pointer is released rather than on a click.\n const ripple = useRipple<HTMLDivElement>(true, {\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp\n }, true);\n return <RACTag textValue={props.textValue ?? textOf(children)} {...ripple.handlers} {...props} {...mergeStatefulStyles(acts ? actingChipPropsFor : groupChipPropsFor, props)}>\n {chipContent(children, icon, removeLabel, ripple.surface, acts)}\n </RACTag>;\n}\n\n// The pill a standalone Chip draws, from `src/chip`, touch target included:\n// every chip's reaches halfway across the gap its rows wrap at. Inert where\n// the group selects nothing and the chip has no action — see the header.\nfunction groupChipPropsFor(state: TagRenderProps) {\n return chipPropsFor(state, {\n inert: state.selectionMode === 'none',\n kind: kindOf(state)\n });\n}\n\n// Which of the page's chips a group's chip is: an input chip once it can be\n// removed, and a filter chip until then, which is what decides whether a\n// selected one lifts under a hovering pointer.\nfunction kindOf(state: TagRenderProps) {\n return state.allowsRemoving ? 'input' : 'filter';\n}\nChipGroup.Chip = ChipGroupChip;\nexport type { ChipGroupChipProps, ChipGroupProps };\nexport { ChipGroupChip };\nexport default ChipGroup;"],"mappings":";;;;;;;;;;;;;;;;;AAmEA,MAAMwC,SAAS,EACbC,MAAM;CACJC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,OAAO;AACT,EACF;AA8FA,SAASiB,YAAYf,UAAqBE,MAAiBW,aAAiCG,SAAoBC,MAAe;CAC7H,QAAQC,UAA0B,qBAAA,YAAA,EAAA,UAAA;EAC7B5C,UAAU4C,OAAOhB,MAAMgB,MAAMC,kBAAkB,MAAM;EACrD5C,UAAUyB,QAAQ;GACjBiB,QAAQC,MAAMC,kBAAkB,WAAW,CAACD,MAAME,aAAa,oBAAC,QAAD;GAAM,GAAIzD,MAAae,WAAW4C,cAAc;GAAIN,UAAAA;EAAc,CAAA,IAAI;EACtIE,MAAMK,iBAAiB,oBAACgD,QAAD;GAAW,cAAY1D;GAAa,WAAWpC;GAAqB,MAAK;GAC7F,UAAA,oBAAC,YAAD,EAAY,GAAId,MAAae,WAAW8C,WAAW,EAAE,CAAA;EAC5C,CAAA,IAAI;CACnB,EAAA,CAAA;AACJ;AAM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V,EAAA,QAAAC,MAAAD,EAAA,QAAAf,SAAAe,EAAA,QAAA6B,OAAAC,YAAA9B,EAAA,QAAAM,MAAAN,EAAA,QAAAQ,MAAAR,EAAA,QAAAS,IAAA;EAD5DC,KAAA,oBAAC,IAAD;GAAmB,WAAAJ;GAAmC,GAAMC;GAAe,GAAMtB;GAAK,GAAMuB;GAC9FC,UAAAA;EADS,CAAA;EAEHT,EAAA,MAAAC;EAAAD,EAAA,MAAAf;EAAAe,EAAA,MAAA6B,OAAAC;EAAA9B,EAAA,MAAAM;EAAAN,EAAA,MAAAQ;EAAAR,EAAA,MAAAS;EAAAT,EAAA,MAAAU;CAAA,OAAAA,KAAAV,EAAA;CAAA,OAFJU;AAEI;AAMb,SAASqB,kBAAkBjD,OAAuB;CAChD,OAAO1C,aAAa0C,OAAO;EACzBkD,OAAOlD,MAAMC,kBAAkB;EAC/Ba,MAAMC,OAAOf,KAAK;CACpB,CAAC;AACH;AAKA,SAASe,OAAOf,OAAuB;CACrC,OAAOA,MAAMK,iBAAiB,UAAU;AAC1C;AACAW,UAAUmC,OAAOX"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","ReactElement","ReactNode","RefAttributes","TagGroupProps","RACTagGroupProps","TagListProps","RACTagListProps","TagProps","RACTagProps","TagRenderProps","stylex","createContext","useContext","Button","RACButton","Tag","RACTag","TagGroup","RACTagGroup","TagList","RACTagList","chipGlyph","chipLabel","chipPropsFor","chipRemoveClassName","chipStyles","textOf","FieldLabel","FieldMessage","invalidFrom","groupStyles","CloseGlyph","useRipple","focus","mergeStatefulStyles","mergeStyles","radii","sizing","spacing","styles","list","kGNEyG","kaIpWk","kB7OPa","k1xSpc","kwnvtZ","kOIVth","kAzted","kg3NbH","$$css","ChipGroupChipProps","children","className","icon","style","textValue","Omit","ChipGroupProps","item","T","description","error","escapeKeyBehavior","label","removeLabel","Pick","chipContent","surface","acts","state","selectionMode","isDisabled","props","surfaceCorners","allowsRemoving","removeGlyph","RemoveLabelContext","undefined","GroupActionContext","LABEL_STATE_VALID","isInvalid","LABEL_STATE_INVALID","actingChipPropsFor","kind","kindOf","ChipGroup","t0","$","T0","invalid","items","renderEmptyState","t1","t2","t3","t4","t5","t6","t7","t8","t9","t10","t11","t12","root","onAction","Symbol","for","ring","ChipGroupChip","onContextMenu","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","href","ripple","handlers","groupChipPropsFor","inert","Chip","stylex.props","RACButton","_c","props","RACTagGroup","RACTagList","RACTag"],"sources":["../../../src/components/chip-group/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactElement, ReactNode, RefAttributes } from 'react';\nimport type { TagGroupProps as RACTagGroupProps, TagListProps as RACTagListProps, TagProps as RACTagProps, TagRenderProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { createContext, useContext } from 'react';\nimport { Button as RACButton, Tag as RACTag, TagGroup as RACTagGroup, TagList as RACTagList } from 'react-aria-components';\nimport { chipGlyph, chipLabel, chipPropsFor, chipRemoveClassName } from '../../chip';\nimport { chipStyles } from '../../chip/styles';\nimport { textOf } from '../../collection/text';\nimport { FieldLabel, FieldMessage } from '../../field';\nimport { invalidFrom } from '../../field/root';\nimport { groupStyles } from '../../field/styles';\nimport { CloseGlyph } from '../../glyphs';\nimport { useRipple } from '../../hooks/useRipple';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles, mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { radii, sizing, spacing } from '../../tokens/design.tokens.stylex';\n\n// The chips page's filter and input chips as a set: one or more chosen from a\n// row, each one removable. The pill is the chip module's in `src/chip`,\n// shared with the standalone Chip, so the two cannot drift; what is here is\n// the group around them.\n//\n// Three things it adds over a row of Chips.\n//\n// **It is a group, not a row of buttons.** React Aria's `TagGroup` names the\n// set, describes it, points it at its error, and moves between its chips\n// with the arrow keys rather than making each one a tab stop — which\n// is what a set of a dozen filters needs. The label, the supporting line and\n// the error are the field chrome's, so a group reads like the fields beside\n// it, exactly as CheckboxGroup and RadioGroup do.\n//\n// **A chip can be removed.** Give the group `onRemove` and each chip draws\n// the page's trailing close target, an 18dp glyph in a target of its own so a\n// press there removes rather than toggles. Backspace and Delete remove the\n// focused chip too, which is React Aria's. A chosen chip's check sits at the\n// other end, so a chip that is both selected and removable carries one glyph\n// on each side of its label.\n//\n// **Selection is the group's, not each chip's.** `selectionMode` and\n// `selectedKeys` live on the group, so a set that chooses one of its chips\n// and a set that chooses several are the same component with a different\n// word. A chip on its own that toggles nothing else is still Chip.\n//\n// **Escape leaves the selection alone.** React Aria's collections clear the\n// selection on Escape and stop the key there, which suits a list whose\n// selection is what an action is about to act on. A set of chips holds a\n// value, as a checkbox group does, and usually sits in a Sheet, Dialog or\n// Popover, where Escape is what dismisses it: clearing it there wiped the\n// reader's filters and took a second press to close. So the group passes\n// React Aria's `escapeKeyBehavior` as `none` unless told `clearSelection`.\n//\n// **A chip a press does nothing to does not look pressable.** In a group\n// that selects nothing, a chip with no action of its own or the group's is\n// a control only for its close target. It draws the arrow cursor, no layer\n// and no ripple, and its close target keeps the pointer. A disabled chip's\n// close target takes the chip's `not-allowed` with it.\n//\n// One thing is worth knowing about how this maps onto React Aria. A chip's\n// text value is read off its children and found only when they are a plain\n// string, and a chip here is always an element — the label sits beside a\n// close target. So a plain-string label is passed through as the text value,\n// which is what typeahead and a screen reader's announcement are made of;\n// see ListBox.Item, where the same thing bit.\n\nconst styles = {\n list: {\n kGNEyG: \"x6s0dn4\",\n kaIpWk: \"x1xdvaa9\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kwnvtZ: \"x1a02dak\",\n kOIVth: \"x126z3so\",\n kAzted: \"xlzjxrf\",\n kg3NbH: \"x91pird xnjsko4\",\n $$css: true\n }\n};\ntype ChipGroupChipProps = {\n /**\n * The chip's label. Text, numbers, or a mix of the two — `Label {3}` —\n * also name the chip; a label holding an element needs `textValue`.\n */\n children?: ReactNode;\n /** A function may compute the class from the chip's render state. */\n className?: RACTagProps['className'];\n /**\n * An icon before the label, in the page's 18dp slot and the primary role.\n * The check takes its place while the chip is chosen, so the chip keeps\n * its width. An icon drawn in `em` takes its size from the slot.\n */\n icon?: ReactNode;\n /** A function may compute the style from the chip's render state. */\n style?: RACTagProps['style'];\n /**\n * The chip's name as text, which is what a screen reader announces for\n * its row. Read from the label when that is text or numbers, so it is\n * needed only when the label holds an element — emphasis, a count in a\n * badge — and React Aria warns in the console when such a chip has none.\n * Given, it wins over the text read from the label.\n */\n textValue?: string;\n} & Omit<RACTagProps, 'children' | 'className' | 'style' | 'textValue'>;\ntype ChipGroupProps<T extends object = object> = {\n /**\n * The chips, each with an `id` of its own. With `items`, a function from an\n * item to its chip, which React Aria calls for each item in turn.\n */\n children?: ((item: T) => ReactElement) | ReactNode;\n /**\n * A hint under the group. Replaced by `error` when there is one, so the\n * two never stack.\n */\n description?: string;\n /**\n * The problem with the current selection, in words. Its presence is what\n * puts the group in its error state: the label and the message take the\n * error colour, the grid's `aria-describedby` names the message, and the\n * message is read out politely as it appears. The grid carries no\n * `aria-invalid`, which ARIA does not allow on a grid, so the message is\n * the whole of what a screen reader is told.\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 * What Escape does on a chip. `none`, the default, keeps the selection and\n * lets the key through to whatever is around the group, so a group in a\n * Sheet, Dialog or Popover closes it on the first press. `clearSelection`\n * empties the selection first, as React Aria's own default does, and lets\n * a second press through.\n *\n * @default 'none'\n */\n escapeKeyBehavior?: 'clearSelection' | 'none';\n /**\n * What the group is for. Required rather than optional: a set of chips\n * with no name is a row a screen reader cannot introduce.\n */\n label: string;\n /**\n * What the close target on each chip is called, for a screen reader. React\n * Aria adds the chip's own label after it, so this is the verb rather than\n * the whole phrase — \"Remove\" becomes \"Remove First item\". Left out, React\n * Aria names it in the reader's locale — \"Remove\" in English.\n */\n removeLabel?: string;\n} & Omit<RACTagGroupProps, 'children' | 'escapeKeyBehavior'> & Pick<RACTagListProps<T>, 'items' | 'renderEmptyState'>;\n\n// What the chip draws, from React Aria's render state. Built by a call rather\n// than written inline at the prop, which is what react-perf's\n// no-new-function-as-prop is after; the React Compiler memoises the result on\n// its inputs.\n//\n// The check and the icon it replaces are the chip module's, so a chip in a\n// group and a chip on its own draw the same ones. The close target is drawn\n// only where the group allows removing, which React Aria reports rather than\n// the call site saying so on every chip.\n//\n// The ripple is drawn only on a chip a press does something to, and not\n// disabled: one the group lets be selected, or one with an action, its own\n// or the group's. Any other chip in a group that selects nothing is a\n// control only for its close target, and React Aria reports neither hover\n// nor press on it, so a ripple there would answer a press that changes\n// nothing. `acts` is the action half, which the render state does not carry.\n//\n// It sits in a box of its own carrying the chip's corner, since React Aria's\n// cell between the chip and this content would otherwise hand the ripple a\n// square one to inherit; see the header of src/chip/styles.ts.\nfunction chipContent(children: ReactNode, icon: ReactNode, removeLabel: string | undefined, surface: ReactNode, acts: boolean) {\n return (state: TagRenderProps) => <>\n {chipGlyph(state, icon, state.selectionMode !== 'none')}\n {chipLabel(children)}\n {(acts || state.selectionMode !== 'none') && !state.isDisabled ? <span {...stylex.props(chipStyles.surfaceCorners)}>{surface}</span> : null}\n {state.allowsRemoving ? <RACButton aria-label={removeLabel} className={chipRemoveClassName} slot=\"remove\">\n <CloseGlyph {...stylex.props(chipStyles.removeGlyph)} />\n </RACButton> : null}\n </>;\n}\n\n// What each chip calls its close target. A context rather than a prop on the\n// chip, since it is the group's decision and repeating it on every chip is\n// how the two drift. Undefined unless the group is given one, which leaves\n// the name React Aria gives in the reader's locale.\nconst RemoveLabelContext = createContext<string | undefined>(undefined);\n\n// Whether the group was given `onAction`, which makes every chip in it\n// pressable whether or not it selects. A context for the reason the close\n// target's name is one.\nconst GroupActionContext = createContext(false);\n\n// Hoisted so neither is a new object on every render.\nconst LABEL_STATE_VALID = {\n isInvalid: false\n};\nconst LABEL_STATE_INVALID = {\n isInvalid: true\n};\n\n// The pill of a chip with an action, which a press always reaches.\nfunction actingChipPropsFor(state: TagRenderProps) {\n return chipPropsFor(state, {\n kind: kindOf(state)\n });\n}\n\n/**\n * A labelled set of chips, one or more of which can be chosen, each of which\n * can be removed. Selection is React Aria's: set `selectionMode` to `single`\n * or `multiple` and pass `selectedKeys` with `onSelectionChange` to control\n * it, or `defaultSelectedKeys` to let it keep its own.\n *\n * ```tsx\n * <ChipGroup label=\"Label\" selectionMode=\"multiple\" onRemove={remove}>\n * <ChipGroup.Chip id=\"first\">First item</ChipGroup.Chip>\n * </ChipGroup>\n * ```\n *\n * Give the group `onRemove` and each chip draws a close target. The arrow\n * keys move between chips, so a set of many is one tab stop rather than many.\n *\n * A chip is never wider than its row, so a label with no room ends in an\n * ellipsis rather than wrapping, and shows its full text in the browser's\n * tooltip on hover.\n *\n * Escape on a chip keeps the selection and reaches whatever is around the\n * group, so a group in a Sheet, Dialog or Popover closes it. Pass\n * `escapeKeyBehavior=\"clearSelection\"` for React Aria's own default, which\n * empties the selection on the first press and lets the second through.\n *\n * A chip that toggles nothing else is Chip; this is for a set that shares a\n * value.\n *\n * The call site's `className` and `style` land on the group as a whole,\n * which is the element a layout positions.\n */\nfunction ChipGroup<T extends object = object>({\n children,\n description,\n error,\n escapeKeyBehavior = 'none',\n items,\n label,\n removeLabel,\n renderEmptyState,\n ...props\n}: ChipGroupProps<T> & RefAttributes<HTMLDivElement>) {\n const invalid = invalidFrom(error);\n return <RACTagGroup escapeKeyBehavior={escapeKeyBehavior} {...props} {...mergeStyles(stylex.props(groupStyles.root), props)}>\n {/* React Aria's tag group has no disabled state of its own — a chip is\n disabled through the group's `disabledKeys` — so the label follows\n validity alone. */}\n <FieldLabel state={invalid ? LABEL_STATE_INVALID : LABEL_STATE_VALID} variant=\"group\">\n {label}\n </FieldLabel>\n <RemoveLabelContext value={removeLabel}>\n <GroupActionContext value={props.onAction !== undefined}>\n <RACTagList<T> items={items} renderEmptyState={renderEmptyState} {...stylex.props(styles.list, focus.ring)}>\n {children}\n </RACTagList>\n </GroupActionContext>\n </RemoveLabelContext>\n <FieldMessage description={description} error={error} inset={false} />\n </RACTagGroup>;\n}\n\n/**\n * One chip. Give every chip an `id` — that is the key selection and removal\n * are reported by.\n */\nfunction ChipGroupChip({\n children,\n icon,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n ...props\n}: ChipGroupChipProps & RefAttributes<HTMLDivElement>) {\n const removeLabel = useContext(RemoveLabelContext);\n // An action of its own, a link or the group's makes a chip pressable even\n // in a group that selects nothing, as React Aria treats it.\n const acts = useContext(GroupActionContext) || props.onAction !== undefined || props.href !== undefined;\n // The press ripple a list's rows draw — see ListItem there. A chip in a\n // group is a collection row, whose clicks React Aria keeps for itself, so\n // the press ends when the pointer is released rather than on a click.\n const ripple = useRipple<HTMLDivElement>(true, {\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp\n }, true);\n return <RACTag textValue={props.textValue ?? textOf(children)} {...ripple.handlers} {...props} {...mergeStatefulStyles(acts ? actingChipPropsFor : groupChipPropsFor, props)}>\n {chipContent(children, icon, removeLabel, ripple.surface, acts)}\n </RACTag>;\n}\n\n// The pill a standalone Chip draws, from `src/chip`, touch target included:\n// every chip's reaches halfway across the gap its rows wrap at. Inert where\n// the group selects nothing and the chip has no action — see the header.\nfunction groupChipPropsFor(state: TagRenderProps) {\n return chipPropsFor(state, {\n inert: state.selectionMode === 'none',\n kind: kindOf(state)\n });\n}\n\n// Which of the page's chips a group's chip is: an input chip once it can be\n// removed, and a filter chip until then, which is what decides whether a\n// selected one lifts under a hovering pointer.\nfunction kindOf(state: TagRenderProps) {\n return state.allowsRemoving ? 'input' : 'filter';\n}\nChipGroup.Chip = ChipGroupChip;\nexport type { ChipGroupChipProps, ChipGroupProps };\nexport { ChipGroupChip };\nexport default ChipGroup;"],"mappings":";;;;;;;;;;;;;;;;;AAmEA,MAAMyC,SAAS,EACbC,MAAM;CACJC,QAAQ;CAC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