@cimpress-ui/react 1.31.0 → 1.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/components/date-picker/views/multi-year/use-multi-year-view-state.js.map +1 -1
- package/dist/commonjs/components/date-picker/views/year/use-year-view-state.js.map +1 -1
- package/dist/commonjs/components/slider/slider.d.ts.map +1 -1
- package/dist/commonjs/components/slider/slider.js +1 -10
- package/dist/commonjs/components/slider/slider.js.map +1 -1
- package/dist/commonjs/components/table/contexts/refs.d.ts +10 -0
- package/dist/commonjs/components/table/contexts/refs.d.ts.map +1 -0
- package/dist/commonjs/components/table/contexts/refs.js +22 -0
- package/dist/commonjs/components/table/contexts/refs.js.map +1 -0
- package/dist/commonjs/components/table/table-body.d.ts.map +1 -1
- package/dist/commonjs/components/table/table-body.js +13 -2
- package/dist/commonjs/components/table/table-body.js.map +1 -1
- package/dist/commonjs/components/table/table-container.d.ts +1 -1
- package/dist/commonjs/components/table/table-container.d.ts.map +1 -1
- package/dist/commonjs/components/table/table-container.js +43 -1
- package/dist/commonjs/components/table/table-container.js.map +1 -1
- package/dist/commonjs/components/table/table-header.d.ts +1 -1
- package/dist/commonjs/components/table/table-header.d.ts.map +1 -1
- package/dist/commonjs/components/table/table-header.js +6 -1
- package/dist/commonjs/components/table/table-header.js.map +1 -1
- package/dist/commonjs/icons/app-window-previous.d.ts +8 -0
- package/dist/commonjs/icons/app-window-previous.d.ts.map +1 -0
- package/dist/commonjs/icons/app-window-previous.js +24 -0
- package/dist/commonjs/icons/app-window-previous.js.map +1 -0
- package/dist/commonjs/icons/identification-card.d.ts +8 -0
- package/dist/commonjs/icons/identification-card.d.ts.map +1 -0
- package/dist/commonjs/icons/identification-card.js +24 -0
- package/dist/commonjs/icons/identification-card.js.map +1 -0
- package/dist/commonjs/icons/index.d.ts +7 -0
- package/dist/commonjs/icons/index.d.ts.map +1 -1
- package/dist/commonjs/icons/index.js +19 -5
- package/dist/commonjs/icons/index.js.map +1 -1
- package/dist/commonjs/icons/pause.d.ts +8 -0
- package/dist/commonjs/icons/pause.d.ts.map +1 -0
- package/dist/commonjs/icons/pause.js +24 -0
- package/dist/commonjs/icons/pause.js.map +1 -0
- package/dist/commonjs/icons/text-format.d.ts +8 -0
- package/dist/commonjs/icons/text-format.d.ts.map +1 -0
- package/dist/commonjs/icons/text-format.js +24 -0
- package/dist/commonjs/icons/text-format.js.map +1 -0
- package/dist/commonjs/icons/thumbs-down.d.ts +8 -0
- package/dist/commonjs/icons/thumbs-down.d.ts.map +1 -0
- package/dist/commonjs/icons/thumbs-down.js +24 -0
- package/dist/commonjs/icons/thumbs-down.js.map +1 -0
- package/dist/commonjs/icons/thumbs-up.d.ts +8 -0
- package/dist/commonjs/icons/thumbs-up.d.ts.map +1 -0
- package/dist/commonjs/icons/thumbs-up.js +24 -0
- package/dist/commonjs/icons/thumbs-up.js.map +1 -0
- package/dist/commonjs/icons/user-replace.d.ts +8 -0
- package/dist/commonjs/icons/user-replace.d.ts.map +1 -0
- package/dist/commonjs/icons/user-replace.js +24 -0
- package/dist/commonjs/icons/user-replace.js.map +1 -0
- package/dist/commonjs/icons.figma.batch.json +953 -0
- package/dist/esm/components/date-picker/views/multi-year/use-multi-year-view-state.js +1 -1
- package/dist/esm/components/date-picker/views/multi-year/use-multi-year-view-state.js.map +1 -1
- package/dist/esm/components/date-picker/views/year/use-year-view-state.js +1 -1
- package/dist/esm/components/date-picker/views/year/use-year-view-state.js.map +1 -1
- package/dist/esm/components/slider/slider.d.ts.map +1 -1
- package/dist/esm/components/slider/slider.js +2 -11
- package/dist/esm/components/slider/slider.js.map +1 -1
- package/dist/esm/components/table/contexts/refs.d.ts +10 -0
- package/dist/esm/components/table/contexts/refs.d.ts.map +1 -0
- package/dist/esm/components/table/contexts/refs.js +18 -0
- package/dist/esm/components/table/contexts/refs.js.map +1 -0
- package/dist/esm/components/table/table-body.d.ts.map +1 -1
- package/dist/esm/components/table/table-body.js +14 -3
- package/dist/esm/components/table/table-body.js.map +1 -1
- package/dist/esm/components/table/table-container.d.ts +1 -1
- package/dist/esm/components/table/table-container.d.ts.map +1 -1
- package/dist/esm/components/table/table-container.js +43 -1
- package/dist/esm/components/table/table-container.js.map +1 -1
- package/dist/esm/components/table/table-header.d.ts +1 -1
- package/dist/esm/components/table/table-header.d.ts.map +1 -1
- package/dist/esm/components/table/table-header.js +6 -1
- package/dist/esm/components/table/table-header.js.map +1 -1
- package/dist/esm/icons/app-window-previous.d.ts +8 -0
- package/dist/esm/icons/app-window-previous.d.ts.map +1 -0
- package/dist/esm/icons/app-window-previous.js +19 -0
- package/dist/esm/icons/app-window-previous.js.map +1 -0
- package/dist/esm/icons/identification-card.d.ts +8 -0
- package/dist/esm/icons/identification-card.d.ts.map +1 -0
- package/dist/esm/icons/identification-card.js +19 -0
- package/dist/esm/icons/identification-card.js.map +1 -0
- package/dist/esm/icons/index.d.ts +7 -0
- package/dist/esm/icons/index.d.ts.map +1 -1
- package/dist/esm/icons/index.js +7 -0
- package/dist/esm/icons/index.js.map +1 -1
- package/dist/esm/icons/pause.d.ts +8 -0
- package/dist/esm/icons/pause.d.ts.map +1 -0
- package/dist/esm/icons/pause.js +19 -0
- package/dist/esm/icons/pause.js.map +1 -0
- package/dist/esm/icons/text-format.d.ts +8 -0
- package/dist/esm/icons/text-format.d.ts.map +1 -0
- package/dist/esm/icons/text-format.js +19 -0
- package/dist/esm/icons/text-format.js.map +1 -0
- package/dist/esm/icons/thumbs-down.d.ts +8 -0
- package/dist/esm/icons/thumbs-down.d.ts.map +1 -0
- package/dist/esm/icons/thumbs-down.js +19 -0
- package/dist/esm/icons/thumbs-down.js.map +1 -0
- package/dist/esm/icons/thumbs-up.d.ts +8 -0
- package/dist/esm/icons/thumbs-up.d.ts.map +1 -0
- package/dist/esm/icons/thumbs-up.js +19 -0
- package/dist/esm/icons/thumbs-up.js.map +1 -0
- package/dist/esm/icons/user-replace.d.ts +8 -0
- package/dist/esm/icons/user-replace.d.ts.map +1 -0
- package/dist/esm/icons/user-replace.js +19 -0
- package/dist/esm/icons/user-replace.js.map +1 -0
- package/dist/esm/icons.figma.batch.json +953 -0
- package/dist-styles/core.css +1 -1
- package/dist-styles/styles.css +1 -1
- package/package.json +17 -15
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { endOfYear, isSameDay, isSameYear, startOfYear, today } from '@internationalized/date';
|
|
2
2
|
import { useContext, useMemo, useState } from 'react';
|
|
3
3
|
import { useDateFormatter } from 'react-aria';
|
|
4
|
-
import { CalendarStateContext as RACCalendarStateContext } from 'react-aria-components';
|
|
4
|
+
import { CalendarStateContext as RACCalendarStateContext, } from 'react-aria-components';
|
|
5
5
|
import { useLocalizedMessages } from '../../../../i18n/index.js';
|
|
6
6
|
import { constrainValue, getEraFormat, isDateInvalid } from '../../utils.js';
|
|
7
7
|
import { useDatePickerView } from '../view-provider.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-multi-year-view-state.js","sourceRoot":"","sources":["../../../../../../src/components/date-picker/views/multi-year/use-multi-year-view-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAqB,MAAM,yBAAyB,CAAC;AAClH,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,oBAAoB,IAAI,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACxF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,iBAAiB,GAAG,EAAE,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,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;YAC9D,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;YAEtC,OAAO,CACL,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,QAAQ,EAAE,aAAa,CAAC,QAAQ,CAAC;gBACtE,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,QAAQ,EAAE,aAAa,CAAC,QAAQ,CAAC;gBACnE,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CACzB,CAAC;QACJ,CAAC;QACD,iBAAiB;YACf,YAAY,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;QACD,cAAc,CAAC,IAAI;YACjB,OAAO,CACL,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC;gBAC5D,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,QAAQ,CAAC,CAC/D,CAAC;QACJ,CAAC;QACD,cAAc,CAAC,IAAI;YACjB,OAAO,aAAa,CAAC,KAAK,KAAK,IAAI,IAAI,UAAU,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;QAC/E,CAAC;QACD,cAAc,CAAC,IAAI;YACjB,OAAO,UAAU,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QACvC,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { endOfYear, isSameDay, isSameYear, startOfYear, today, type CalendarDate } from '@internationalized/date';\nimport { useContext, useMemo, useState } from 'react';\nimport { useDateFormatter } from 'react-aria';\nimport { CalendarStateContext as RACCalendarStateContext } from 'react-aria-components';\nimport { useLocalizedMessages } from '../../../../i18n/index.js';\nimport { constrainValue, getEraFormat, isDateInvalid } from '../../utils.js';\nimport type { ViewGridCellData, ViewGridState } from '../types.js';\nimport { useDatePickerView } from '../view-provider.js';\n\nconst ITEMS_PER_ROW = 4;\nconst YEARS_PER_SECTION = 20;\nconst YEARS_SKIP_AMOUNT = 100;\n\n/** @internal */\nexport function useMultiYearViewState(): ViewGridState {\n const calendarState = useContext(RACCalendarStateContext)!;\n const { switchToView, focusedDate, setFocusedDate } = useDatePickerView();\n const messages = useLocalizedMessages('datePicker');\n const [isFocused, setIsFocused] = useState(true);\n\n const currentDate = useMemo(() => today(calendarState.timeZone), [calendarState.timeZone]);\n\n const yearFormatter = useDateFormatter({\n year: 'numeric',\n era: getEraFormat(focusedDate),\n calendar: focusedDate.calendar.identifier,\n timeZone: calendarState.timeZone,\n });\n\n const lowerYear = (Math.ceil(focusedDate.year / YEARS_PER_SECTION) - 1) * YEARS_PER_SECTION + 1;\n const higherYear = lowerYear + YEARS_PER_SECTION - 1;\n\n // Years are always represented by positive numbers.\n // If era implies negative years, flip start and end.\n const isNegativeEra = focusedDate.era === 'BC';\n const startYear = isNegativeEra ? higherYear : lowerYear;\n const endYear = isNegativeEra ? lowerYear : higherYear;\n\n const data: (ViewGridCellData | null)[][] = useMemo(() => {\n const rowCount = Math.ceil(YEARS_PER_SECTION / ITEMS_PER_ROW);\n const result: (ViewGridCellData | null)[][] = new Array(rowCount);\n\n for (let rowIdx = 0; rowIdx < rowCount; rowIdx++) {\n result[rowIdx] = new Array(ITEMS_PER_ROW).fill(null);\n }\n\n for (let yearIdx = 0; yearIdx < YEARS_PER_SECTION; yearIdx++) {\n const rowIdx = Math.floor(yearIdx / ITEMS_PER_ROW);\n const colIdx = yearIdx % ITEMS_PER_ROW;\n\n const yearToSet = startYear + (isNegativeEra ? -yearIdx : yearIdx);\n const date = focusedDate.set({ year: yearToSet });\n\n if (date.year !== yearToSet) {\n // Reached minimum/maximum date\n continue;\n }\n\n const content = yearFormatter.format(date.toDate(calendarState.timeZone));\n\n result[rowIdx]![colIdx] = {\n date,\n content,\n ariaLabel: content,\n isCurrent: isSameYear(date, currentDate),\n };\n }\n\n return result;\n }, [startYear, calendarState.timeZone, focusedDate, yearFormatter, isNegativeEra, currentDate]);\n\n const focusCell = (date: CalendarDate) => {\n setFocusedDate(constrainValue(date, calendarState.minValue, calendarState.maxValue));\n };\n\n return {\n header: yearFormatter.formatRange(\n focusedDate.set({ year: startYear }).toDate(calendarState.timeZone),\n focusedDate.set({ year: endYear }).toDate(calendarState.timeZone),\n ),\n previousLabel: messages.format('previousMultiYearSection', { yearCount: 20 }),\n nextLabel: messages.format('nextMultiYearSection', { yearCount: 20 }),\n data,\n isReadOnly: calendarState.isReadOnly,\n isDisabled: calendarState.isDisabled,\n isFocused,\n setIsFocused,\n focusedDate,\n setFocusedDate,\n timeZone: calendarState.timeZone,\n focusPreviousItem() {\n focusCell(focusedDate.subtract({ years: 1 }));\n },\n focusNextItem() {\n focusCell(focusedDate.add({ years: 1 }));\n },\n focusPreviousRow() {\n focusCell(focusedDate.subtract({ years: ITEMS_PER_ROW }));\n },\n focusNextRow() {\n focusCell(focusedDate.add({ years: ITEMS_PER_ROW }));\n },\n focusSectionStart() {\n focusCell(focusedDate.set({ year: startYear }));\n },\n focusSectionEnd() {\n focusCell(focusedDate.set({ year: endYear }));\n },\n focusPreviousSection(shouldSkip) {\n focusCell(focusedDate.subtract({ years: shouldSkip ? YEARS_SKIP_AMOUNT : YEARS_PER_SECTION }));\n },\n focusNextSection(shouldSkip) {\n focusCell(focusedDate.add({ years: shouldSkip ? YEARS_SKIP_AMOUNT : YEARS_PER_SECTION }));\n },\n isPreviousSectionInvalid() {\n const current = startOfYear(focusedDate.set({ year: startYear }));\n const prev = current.subtract({ days: 1 });\n\n return (\n isDateInvalid(current, calendarState.minValue, calendarState.maxValue) ||\n isDateInvalid(prev, calendarState.minValue, calendarState.maxValue) ||\n isSameDay(prev, current)\n );\n },\n isNextSectionInvalid() {\n const current = endOfYear(focusedDate.set({ year: endYear }));\n const next = current.add({ days: 1 });\n\n return (\n isDateInvalid(current, calendarState.minValue, calendarState.maxValue) ||\n isDateInvalid(next, calendarState.minValue, calendarState.maxValue) ||\n isSameDay(next, current)\n );\n },\n selectFocusedDate() {\n switchToView('year');\n },\n isCellDisabled(date) {\n return (\n isDateInvalid(endOfYear(date), calendarState.minValue, null) ||\n isDateInvalid(startOfYear(date), null, calendarState.maxValue)\n );\n },\n isCellSelected(date) {\n return calendarState.value !== null && isSameYear(date, calendarState.value);\n },\n isCellTabbable(date) {\n return isSameYear(date, focusedDate);\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"use-multi-year-view-state.js","sourceRoot":"","sources":["../../../../../../src/components/date-picker/views/multi-year/use-multi-year-view-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAqB,MAAM,yBAAyB,CAAC;AAClH,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAEL,oBAAoB,IAAI,uBAAuB,GAChD,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAE9B,gBAAgB;AAChB,MAAM,UAAU,qBAAqB;IACnC,MAAM,aAAa,GAAG,UAAU,CAAC,uBAAuB,CAAgC,CAAC;IACzF,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,iBAAiB,EAAE,CAAC;IAC1E,MAAM,QAAQ,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAC;IACpD,MAAM,CAAC,SAAS,EAAE,YA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AAS,CAAC,IAAI,EAAE,OAAO,CAAC,CACzB,CAAC;QACJ,CAAC;QACD,iBAAiB;YACf,YAAY,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;QACD,cAAc,CAAC,IAAI;YACjB,OAAO,CACL,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC;gBAC5D,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,QAAQ,CAAC,CAC/D,CAAC;QACJ,CAAC;QACD,cAAc,CAAC,IAAI;YACjB,OAAO,aAAa,CAAC,KAAK,KAAK,IAAI,IAAI,UAAU,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;QAC/E,CAAC;QACD,cAAc,CAAC,IAAI;YACjB,OAAO,UAAU,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QACvC,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { endOfYear, isSameDay, isSameYear, startOfYear, today, type CalendarDate } from '@internationalized/date';\nimport { useContext, useMemo, useState } from 'react';\nimport { useDateFormatter } from 'react-aria';\nimport {\n type CalendarState as RACCalendarState,\n CalendarStateContext as RACCalendarStateContext,\n} from 'react-aria-components';\nimport { useLocalizedMessages } from '../../../../i18n/index.js';\nimport { constrainValue, getEraFormat, isDateInvalid } from '../../utils.js';\nimport type { ViewGridCellData, ViewGridState } from '../types.js';\nimport { useDatePickerView } from '../view-provider.js';\n\nconst ITEMS_PER_ROW = 4;\nconst YEARS_PER_SECTION = 20;\nconst YEARS_SKIP_AMOUNT = 100;\n\n/** @internal */\nexport function useMultiYearViewState(): ViewGridState {\n const calendarState = useContext(RACCalendarStateContext)! as RACCalendarState<'single'>;\n const { switchToView, focusedDate, setFocusedDate } = useDatePickerView();\n const messages = useLocalizedMessages('datePicker');\n const [isFocused, setIsFocused] = useState(true);\n\n const currentDate = useMemo(() => today(calendarState.timeZone), [calendarState.timeZone]);\n\n const yearFormatter = useDateFormatter({\n year: 'numeric',\n era: getEraFormat(focusedDate),\n calendar: focusedDate.calendar.identifier,\n timeZone: calendarState.timeZone,\n });\n\n const lowerYear = (Math.ceil(focusedDate.year / YEARS_PER_SECTION) - 1) * YEARS_PER_SECTION + 1;\n const higherYear = lowerYear + YEARS_PER_SECTION - 1;\n\n // Years are always represented by positive numbers.\n // If era implies negative years, flip start and end.\n const isNegativeEra = focusedDate.era === 'BC';\n const startYear = isNegativeEra ? higherYear : lowerYear;\n const endYear = isNegativeEra ? lowerYear : higherYear;\n\n const data: (ViewGridCellData | null)[][] = useMemo(() => {\n const rowCount = Math.ceil(YEARS_PER_SECTION / ITEMS_PER_ROW);\n const result: (ViewGridCellData | null)[][] = new Array(rowCount);\n\n for (let rowIdx = 0; rowIdx < rowCount; rowIdx++) {\n result[rowIdx] = new Array(ITEMS_PER_ROW).fill(null);\n }\n\n for (let yearIdx = 0; yearIdx < YEARS_PER_SECTION; yearIdx++) {\n const rowIdx = Math.floor(yearIdx / ITEMS_PER_ROW);\n const colIdx = yearIdx % ITEMS_PER_ROW;\n\n const yearToSet = startYear + (isNegativeEra ? -yearIdx : yearIdx);\n const date = focusedDate.set({ year: yearToSet });\n\n if (date.year !== yearToSet) {\n // Reached minimum/maximum date\n continue;\n }\n\n const content = yearFormatter.format(date.toDate(calendarState.timeZone));\n\n result[rowIdx]![colIdx] = {\n date,\n content,\n ariaLabel: content,\n isCurrent: isSameYear(date, currentDate),\n };\n }\n\n return result;\n }, [startYear, calendarState.timeZone, focusedDate, yearFormatter, isNegativeEra, currentDate]);\n\n const focusCell = (date: CalendarDate) => {\n setFocusedDate(constrainValue(date, calendarState.minValue, calendarState.maxValue));\n };\n\n return {\n header: yearFormatter.formatRange(\n focusedDate.set({ year: startYear }).toDate(calendarState.timeZone),\n focusedDate.set({ year: endYear }).toDate(calendarState.timeZone),\n ),\n previousLabel: messages.format('previousMultiYearSection', { yearCount: 20 }),\n nextLabel: messages.format('nextMultiYearSection', { yearCount: 20 }),\n data,\n isReadOnly: calendarState.isReadOnly,\n isDisabled: calendarState.isDisabled,\n isFocused,\n setIsFocused,\n focusedDate,\n setFocusedDate,\n timeZone: calendarState.timeZone,\n focusPreviousItem() {\n focusCell(focusedDate.subtract({ years: 1 }));\n },\n focusNextItem() {\n focusCell(focusedDate.add({ years: 1 }));\n },\n focusPreviousRow() {\n focusCell(focusedDate.subtract({ years: ITEMS_PER_ROW }));\n },\n focusNextRow() {\n focusCell(focusedDate.add({ years: ITEMS_PER_ROW }));\n },\n focusSectionStart() {\n focusCell(focusedDate.set({ year: startYear }));\n },\n focusSectionEnd() {\n focusCell(focusedDate.set({ year: endYear }));\n },\n focusPreviousSection(shouldSkip) {\n focusCell(focusedDate.subtract({ years: shouldSkip ? YEARS_SKIP_AMOUNT : YEARS_PER_SECTION }));\n },\n focusNextSection(shouldSkip) {\n focusCell(focusedDate.add({ years: shouldSkip ? YEARS_SKIP_AMOUNT : YEARS_PER_SECTION }));\n },\n isPreviousSectionInvalid() {\n const current = startOfYear(focusedDate.set({ year: startYear }));\n const prev = current.subtract({ days: 1 });\n\n return (\n isDateInvalid(current, calendarState.minValue, calendarState.maxValue) ||\n isDateInvalid(prev, calendarState.minValue, calendarState.maxValue) ||\n isSameDay(prev, current)\n );\n },\n isNextSectionInvalid() {\n const current = endOfYear(focusedDate.set({ year: endYear }));\n const next = current.add({ days: 1 });\n\n return (\n isDateInvalid(current, calendarState.minValue, calendarState.maxValue) ||\n isDateInvalid(next, calendarState.minValue, calendarState.maxValue) ||\n isSameDay(next, current)\n );\n },\n selectFocusedDate() {\n switchToView('year');\n },\n isCellDisabled(date) {\n return (\n isDateInvalid(endOfYear(date), calendarState.minValue, null) ||\n isDateInvalid(startOfYear(date), null, calendarState.maxValue)\n );\n },\n isCellSelected(date) {\n return calendarState.value !== null && isSameYear(date, calendarState.value);\n },\n isCellTabbable(date) {\n return isSameYear(date, focusedDate);\n },\n };\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { endOfMonth, endOfYear, isSameDay, isSameMonth, isSameYear, startOfMonth, startOfYear, today, } from '@internationalized/date';
|
|
2
2
|
import { useContext, useMemo, useState } from 'react';
|
|
3
3
|
import { useDateFormatter } from 'react-aria';
|
|
4
|
-
import { CalendarStateContext as RACCalendarStateContext } from 'react-aria-components';
|
|
4
|
+
import { CalendarStateContext as RACCalendarStateContext, } from 'react-aria-components';
|
|
5
5
|
import { useLocalizedMessages } from '../../../../i18n/index.js';
|
|
6
6
|
import { constrainValue, getEraFormat, isDateInvalid } from '../../utils.js';
|
|
7
7
|
import { useDatePickerView } from './../view-provider.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-year-view-state.js","sourceRoot":"","sources":["../../../../../../src/components/date-picker/views/year/use-year-view-state.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,UAAU,EACV,YAAY,EACZ,WAAW,EAEX,KAAK,GACN,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,oBAAoB,IAAI,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACxF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,gBAAgB;AAChB,MAAM,UAAU,gBAAgB;IAC9B,MAAM,aAAa,GAAG,UAAU,CAAC,uBAAuB,CAAE,CAAC;IAC3D,MAAM,EAAE,YAAY,EAA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,cAAc,CAAC,IAAI;YACjB,OAAO,UAAU,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QACzE,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n endOfMonth,\n endOfYear,\n isSameDay,\n isSameMonth,\n isSameYear,\n startOfMonth,\n startOfYear,\n type CalendarDate,\n today,\n} from '@internationalized/date';\nimport { useContext, useMemo, useState } from 'react';\nimport { useDateFormatter } from 'react-aria';\nimport { CalendarStateContext as RACCalendarStateContext } from 'react-aria-components';\nimport { useLocalizedMessages } from '../../../../i18n/index.js';\nimport { constrainValue, getEraFormat, isDateInvalid } from '../../utils.js';\nimport type { ViewGridCellData, ViewGridState } from './../types.js';\nimport { useDatePickerView } from './../view-provider.js';\n\nconst ITEMS_PER_ROW = 3;\nconst YEARS_SKIP_AMOUNT = 10;\n\n/** @internal */\nexport function useYearViewState(): ViewGridState {\n const calendarState = useContext(RACCalendarStateContext)!;\n const { switchToView, focusedDate, setFocusedDate } = useDatePickerView();\n const messages = useLocalizedMessages('datePicker');\n const [isFocused, setIsFocused] = useState(true);\n\n const currentDate = useMemo(() => today(calendarState.timeZone), [calendarState.timeZone]);\n\n const monthFormatter = useDateFormatter({\n month: 'short',\n calendar: focusedDate.calendar.identifier,\n timeZone: calendarState.timeZone,\n });\n\n const monthAriaLabelFormatter = useDateFormatter({\n month: 'long',\n year: 'numeric',\n calendar: focusedDate.calendar.identifier,\n timeZone: calendarState.timeZone,\n });\n\n const yearFormatter = useDateFormatter({\n year: 'numeric',\n era: getEraFormat(focusedDate),\n calendar: focusedDate.calendar.identifier,\n timeZone: calendarState.timeZone,\n });\n\n // Some calendars have more than 12 months, and in some calendars the number of months varies per year.\n // This can result in partially filled grid rows.\n // Detect this to keep keyboard navigation between rows consistent.\n const monthCount = focusedDate.calendar.getMonthsInYear(focusedDate);\n const previousYearMonthCount = focusedDate.calendar.getMonthsInYear(focusedDate.subtract({ years: 1 }));\n const partialRowMonthCount = monthCount % ITEMS_PER_ROW;\n const previousYearPartialRowMonthCount = previousYearMonthCount % ITEMS_PER_ROW;\n\n const data: (ViewGridCellData | null)[][] = useMemo(() => {\n const rowCount = Math.ceil(monthCount / ITEMS_PER_ROW);\n const result: (ViewGridCellData | null)[][] = new Array(rowCount);\n\n for (let rowIdx = 0; rowIdx < rowCount; rowIdx++) {\n result[rowIdx] = new Array(ITEMS_PER_ROW).fill(null);\n }\n\n for (let monthIdx = 0; monthIdx < monthCount; monthIdx++) {\n const rowIdx = Math.floor(monthIdx / ITEMS_PER_ROW);\n const colIdx = monthIdx % ITEMS_PER_ROW;\n\n const date = focusedDate.set({ month: monthIdx + 1 });\n const nativeDate = date.toDate(calendarState.timeZone);\n\n result[rowIdx]![colIdx] = {\n date,\n content: monthFormatter.format(nativeDate),\n ariaLabel: monthAriaLabelFormatter.format(nativeDate),\n isCurrent: isSameYear(date, currentDate) && isSameMonth(date, currentDate),\n };\n }\n\n return result;\n }, [monthCount, calendarState.timeZone, focusedDate, monthFormatter, monthAriaLabelFormatter, currentDate]);\n\n const focusCell = (date: CalendarDate) => {\n setFocusedDate(constrainValue(date, calendarState.minValue, calendarState.maxValue));\n };\n\n return {\n header: yearFormatter.format(focusedDate.toDate(calendarState.timeZone)),\n previousLabel: messages.format('previousYear'),\n nextLabel: messages.format('nextYear'),\n data,\n isReadOnly: calendarState.isReadOnly,\n isDisabled: calendarState.isDisabled,\n isFocused,\n setIsFocused,\n focusedDate,\n setFocusedDate,\n timeZone: calendarState.timeZone,\n focusPreviousItem() {\n focusCell(focusedDate.subtract({ months: 1 }));\n },\n focusNextItem() {\n focusCell(focusedDate.add({ months: 1 }));\n },\n focusPreviousRow() {\n const currentMonth = focusedDate.month;\n let monthsToSubtract: number;\n\n if (currentMonth <= previousYearPartialRowMonthCount) {\n monthsToSubtract = previousYearPartialRowMonthCount;\n } else if (currentMonth <= ITEMS_PER_ROW) {\n monthsToSubtract = ITEMS_PER_ROW + previousYearPartialRowMonthCount;\n } else {\n monthsToSubtract = ITEMS_PER_ROW;\n }\n\n focusCell(\n focusedDate.subtract({\n months: monthsToSubtract,\n }),\n );\n },\n focusNextRow() {\n const currentMonth = focusedDate.month;\n let monthsToAdd: number;\n\n if (currentMonth > monthCount - partialRowMonthCount) {\n monthsToAdd = partialRowMonthCount;\n } else if (currentMonth + ITEMS_PER_ROW > monthCount) {\n monthsToAdd = ITEMS_PER_ROW + partialRowMonthCount;\n } else {\n monthsToAdd = ITEMS_PER_ROW;\n }\n\n focusCell(\n focusedDate.add({\n months: monthsToAdd,\n }),\n );\n },\n focusSectionStart() {\n focusCell(startOfYear(focusedDate).set({ day: focusedDate.day }));\n },\n focusSectionEnd() {\n focusCell(endOfYear(focusedDate).set({ day: focusedDate.day }));\n },\n focusPreviousSection(shouldSkip) {\n focusCell(focusedDate.subtract({ years: shouldSkip ? YEARS_SKIP_AMOUNT : 1 }));\n },\n focusNextSection(shouldSkip) {\n focusCell(focusedDate.add({ years: shouldSkip ? YEARS_SKIP_AMOUNT : 1 }));\n },\n isPreviousSectionInvalid() {\n const current = startOfYear(focusedDate);\n const prev = current.subtract({ days: 1 });\n\n return (\n isDateInvalid(current, calendarState.minValue, calendarState.maxValue) ||\n isDateInvalid(prev, calendarState.minValue, calendarState.maxValue) ||\n isSameDay(prev, current)\n );\n },\n isNextSectionInvalid() {\n const current = endOfYear(focusedDate);\n const next = current.add({ days: 1 });\n\n return (\n isDateInvalid(current, calendarState.minValue, calendarState.maxValue) ||\n isDateInvalid(next, calendarState.minValue, calendarState.maxValue) ||\n isSameDay(next, current)\n );\n },\n selectFocusedDate() {\n switchToView('month');\n },\n isCellDisabled(date) {\n return (\n isDateInvalid(endOfMonth(date), calendarState.minValue, null) ||\n isDateInvalid(startOfMonth(date), null, calendarState.maxValue)\n );\n },\n isCellSelected(date) {\n return (\n calendarState.value !== null && isSameYear(date, calendarState.value) && isSameMonth(date, calendarState.value)\n );\n },\n isCellTabbable(date) {\n return isSameYear(date, focusedDate) && isSameMonth(date, focusedDate);\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"use-year-view-state.js","sourceRoot":"","sources":["../../../../../../src/components/date-picker/views/year/use-year-view-state.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,UAAU,EACV,YAAY,EACZ,WAAW,EAEX,KAAK,GACN,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAEL,oBAAoB,IAAI,uBAAuB,GAChD,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,gBAAgB;AAChB,MAAM,UAAU,gBAAgB;IAC9B,MAAM,aAAa,GAAG,UAAU,CAAC,uBAAuB,CAAgC,CAAC;IACzF,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,iBAAiB,EAAE,CAAC;IAC1E,MAAM,QAAQ,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAC;IACpD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEjD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE3F,MAAM,cAAc,GAAG,gBAAgB,CAAC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,SAAS,CAAC,WAAW,CAAC,CAAC;YACvC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;YAEtC,OAAO,CACL,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,QAAQ,EAAE,aAAa,CAAC,QAAQ,CAAC;gBACtE,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,QAAQ,EAAE,aAAa,CAAC,QAAQ,CAAC;gBACnE,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CACzB,CAAC;QACJ,CAAC;QACD,iBAAiB;YACf,YAAY,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC;QACD,cAAc,CAAC,IAAI;YACjB,OAAO,CACL,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC;gBAC7D,aAAa,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,QAAQ,CAAC,CAChE,CAAC;QACJ,CAAC;QACD,cAAc,CAAC,IAAI;YACjB,OAAO,CACL,aAAa,CAAC,KAAK,KAAK,IAAI,IAAI,UAAU,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,CAChH,CAAC;QACJ,CAAC;QACD,cAAc,CAAC,IAAI;YACjB,OAAO,UAAU,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QACzE,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n endOfMonth,\n endOfYear,\n isSameDay,\n isSameMonth,\n isSameYear,\n startOfMonth,\n startOfYear,\n type CalendarDate,\n today,\n} from '@internationalized/date';\nimport { useContext, useMemo, useState } from 'react';\nimport { useDateFormatter } from 'react-aria';\nimport {\n type CalendarState as RACCalendarState,\n CalendarStateContext as RACCalendarStateContext,\n} from 'react-aria-components';\nimport { useLocalizedMessages } from '../../../../i18n/index.js';\nimport { constrainValue, getEraFormat, isDateInvalid } from '../../utils.js';\nimport type { ViewGridCellData, ViewGridState } from './../types.js';\nimport { useDatePickerView } from './../view-provider.js';\n\nconst ITEMS_PER_ROW = 3;\nconst YEARS_SKIP_AMOUNT = 10;\n\n/** @internal */\nexport function useYearViewState(): ViewGridState {\n const calendarState = useContext(RACCalendarStateContext)! as RACCalendarState<'single'>;\n const { switchToView, focusedDate, setFocusedDate } = useDatePickerView();\n const messages = useLocalizedMessages('datePicker');\n const [isFocused, setIsFocused] = useState(true);\n\n const currentDate = useMemo(() => today(calendarState.timeZone), [calendarState.timeZone]);\n\n const monthFormatter = useDateFormatter({\n month: 'short',\n calendar: focusedDate.calendar.identifier,\n timeZone: calendarState.timeZone,\n });\n\n const monthAriaLabelFormatter = useDateFormatter({\n month: 'long',\n year: 'numeric',\n calendar: focusedDate.calendar.identifier,\n timeZone: calendarState.timeZone,\n });\n\n const yearFormatter = useDateFormatter({\n year: 'numeric',\n era: getEraFormat(focusedDate),\n calendar: focusedDate.calendar.identifier,\n timeZone: calendarState.timeZone,\n });\n\n // Some calendars have more than 12 months, and in some calendars the number of months varies per year.\n // This can result in partially filled grid rows.\n // Detect this to keep keyboard navigation between rows consistent.\n const monthCount = focusedDate.calendar.getMonthsInYear(focusedDate);\n const previousYearMonthCount = focusedDate.calendar.getMonthsInYear(focusedDate.subtract({ years: 1 }));\n const partialRowMonthCount = monthCount % ITEMS_PER_ROW;\n const previousYearPartialRowMonthCount = previousYearMonthCount % ITEMS_PER_ROW;\n\n const data: (ViewGridCellData | null)[][] = useMemo(() => {\n const rowCount = Math.ceil(monthCount / ITEMS_PER_ROW);\n const result: (ViewGridCellData | null)[][] = new Array(rowCount);\n\n for (let rowIdx = 0; rowIdx < rowCount; rowIdx++) {\n result[rowIdx] = new Array(ITEMS_PER_ROW).fill(null);\n }\n\n for (let monthIdx = 0; monthIdx < monthCount; monthIdx++) {\n const rowIdx = Math.floor(monthIdx / ITEMS_PER_ROW);\n const colIdx = monthIdx % ITEMS_PER_ROW;\n\n const date = focusedDate.set({ month: monthIdx + 1 });\n const nativeDate = date.toDate(calendarState.timeZone);\n\n result[rowIdx]![colIdx] = {\n date,\n content: monthFormatter.format(nativeDate),\n ariaLabel: monthAriaLabelFormatter.format(nativeDate),\n isCurrent: isSameYear(date, currentDate) && isSameMonth(date, currentDate),\n };\n }\n\n return result;\n }, [monthCount, calendarState.timeZone, focusedDate, monthFormatter, monthAriaLabelFormatter, currentDate]);\n\n const focusCell = (date: CalendarDate) => {\n setFocusedDate(constrainValue(date, calendarState.minValue, calendarState.maxValue));\n };\n\n return {\n header: yearFormatter.format(focusedDate.toDate(calendarState.timeZone)),\n previousLabel: messages.format('previousYear'),\n nextLabel: messages.format('nextYear'),\n data,\n isReadOnly: calendarState.isReadOnly,\n isDisabled: calendarState.isDisabled,\n isFocused,\n setIsFocused,\n focusedDate,\n setFocusedDate,\n timeZone: calendarState.timeZone,\n focusPreviousItem() {\n focusCell(focusedDate.subtract({ months: 1 }));\n },\n focusNextItem() {\n focusCell(focusedDate.add({ months: 1 }));\n },\n focusPreviousRow() {\n const currentMonth = focusedDate.month;\n let monthsToSubtract: number;\n\n if (currentMonth <= previousYearPartialRowMonthCount) {\n monthsToSubtract = previousYearPartialRowMonthCount;\n } else if (currentMonth <= ITEMS_PER_ROW) {\n monthsToSubtract = ITEMS_PER_ROW + previousYearPartialRowMonthCount;\n } else {\n monthsToSubtract = ITEMS_PER_ROW;\n }\n\n focusCell(\n focusedDate.subtract({\n months: monthsToSubtract,\n }),\n );\n },\n focusNextRow() {\n const currentMonth = focusedDate.month;\n let monthsToAdd: number;\n\n if (currentMonth > monthCount - partialRowMonthCount) {\n monthsToAdd = partialRowMonthCount;\n } else if (currentMonth + ITEMS_PER_ROW > monthCount) {\n monthsToAdd = ITEMS_PER_ROW + partialRowMonthCount;\n } else {\n monthsToAdd = ITEMS_PER_ROW;\n }\n\n focusCell(\n focusedDate.add({\n months: monthsToAdd,\n }),\n );\n },\n focusSectionStart() {\n focusCell(startOfYear(focusedDate).set({ day: focusedDate.day }));\n },\n focusSectionEnd() {\n focusCell(endOfYear(focusedDate).set({ day: focusedDate.day }));\n },\n focusPreviousSection(shouldSkip) {\n focusCell(focusedDate.subtract({ years: shouldSkip ? YEARS_SKIP_AMOUNT : 1 }));\n },\n focusNextSection(shouldSkip) {\n focusCell(focusedDate.add({ years: shouldSkip ? YEARS_SKIP_AMOUNT : 1 }));\n },\n isPreviousSectionInvalid() {\n const current = startOfYear(focusedDate);\n const prev = current.subtract({ days: 1 });\n\n return (\n isDateInvalid(current, calendarState.minValue, calendarState.maxValue) ||\n isDateInvalid(prev, calendarState.minValue, calendarState.maxValue) ||\n isSameDay(prev, current)\n );\n },\n isNextSectionInvalid() {\n const current = endOfYear(focusedDate);\n const next = current.add({ days: 1 });\n\n return (\n isDateInvalid(current, calendarState.minValue, calendarState.maxValue) ||\n isDateInvalid(next, calendarState.minValue, calendarState.maxValue) ||\n isSameDay(next, current)\n );\n },\n selectFocusedDate() {\n switchToView('month');\n },\n isCellDisabled(date) {\n return (\n isDateInvalid(endOfMonth(date), calendarState.minValue, null) ||\n isDateInvalid(startOfMonth(date), null, calendarState.maxValue)\n );\n },\n isCellSelected(date) {\n return (\n calendarState.value !== null && isSameYear(date, calendarState.value) && isSameMonth(date, calendarState.value)\n );\n },\n isCellTabbable(date) {\n return isSameYear(date, focusedDate) && isSameMonth(date, focusedDate);\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slider.d.ts","sourceRoot":"","sources":["../../../../src/components/slider/slider.tsx"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"slider.d.ts","sourceRoot":"","sources":["../../../../src/components/slider/slider.tsx"],"names":[],"mappings":"AAKA,OAAO,EAaL,KAAK,WAAW,IAAI,cAAc,EACnC,MAAM,uBAAuB,CAAC;AAO/B,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGhE,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CACvE,SACE,WAAW,EACX,eAAe,EACf,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,GAAG,eAAe,CAAC;IAC5F,qGAAqG;IACrG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,wCAAwC;IACxC,YAAY,CAAC,EAAE,CAAC,CAAC;IACjB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC9B,2DAA2D;IAC3D,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IACjC;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC;IAC9D;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;SAGK;IACL,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AA4ID;;;;GAIG;AACH,QAAA,MAAM,OAAO,GA/IG,CAAC,SAAS,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,wKA+IS,CAAC;AAE7D,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { useContext } from 'react';
|
|
5
5
|
import { useId } from 'react-aria';
|
|
6
|
-
import { LabelContext as RACLabelContext, NumberField as RACNumberField, Provider as RACProvider, Slider as RACSlider, SliderOutput as RACSliderOutput, SliderStateContext as RACSliderStateContext, SliderThumb as RACSliderThumb, SliderTrack as RACSliderTrack, TextContext as RACTextContext, useSlottedContext, } from 'react-aria-components';
|
|
6
|
+
import { LabelContext as RACLabelContext, NumberField as RACNumberField, Provider as RACProvider, Slider as RACSlider, SliderFill as RACSliderFill, SliderOutput as RACSliderOutput, SliderStateContext as RACSliderStateContext, SliderThumb as RACSliderThumb, SliderTrack as RACSliderTrack, TextContext as RACTextContext, useSlottedContext, } from 'react-aria-components';
|
|
7
7
|
import { forwardRef } from '../../forward-ref.js';
|
|
8
8
|
import { useLocalizedMessages } from '../../i18n/localization-provider.js';
|
|
9
9
|
import { useProductionWarning } from '../../utils/use-production-warning.js';
|
|
@@ -23,16 +23,7 @@ function Slider({ label, description, UNSAFE_className, UNSAFE_style, form, name
|
|
|
23
23
|
}, [label, ariaLabel, ariaLabelledBy]);
|
|
24
24
|
return (_jsx(RACProvider, { values: [[RACTextContext, { slots: { description: { id: descriptionId } } }]], children: _jsx(RACSlider, { ...props, ref: ref, className: clsx('cim-slider', UNSAFE_className), style: UNSAFE_style, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, orientation: "horizontal", "aria-describedby": [description && descriptionId, props['aria-describedby']].filter(Boolean).join(' '), children: ({ state, isDisabled }) => {
|
|
25
25
|
const isRangeSlider = state.values.length === 2;
|
|
26
|
-
return (_jsxs(_Fragment, { children: [_jsx(FormFieldLabel, { isRequired: false, isDisabled: isDisabled, children: label }), !withInput && label != null && (_jsx(RACSliderOutput, { className: "cim-slider-output", children: _jsx(Text, { as: "span", variant: "medium", children: state.values.map((_, i) => state.getThumbValueLabel(i)).join(' – ') }) })), _jsxs("div", { className: "cim-slider-track-container", children: [showLabels && (_jsx(Text, { as: "span", variant: "medium", UNSAFE_className: "cim-slider-label-min", children: state.getThumbMinValue(0) })), _jsx(RACSliderTrack, { className: "cim-slider-track", children: ({ state: trackState, isDisabled: trackIsDisabled }) => (_jsxs(_Fragment, { children: [_jsx("div", { className: "cim-slider-track-background", "data-disabled": trackIsDisabled || undefined }), _jsx("div", { className: "cim-slider-
|
|
27
|
-
? {
|
|
28
|
-
'--cim-slider-fill-size': trackState.getThumbPercent(0) * 100 + '%',
|
|
29
|
-
}
|
|
30
|
-
: isRangeSlider
|
|
31
|
-
? {
|
|
32
|
-
'--cim-slider-fill-start': trackState.getThumbPercent(0) * 100 + '%',
|
|
33
|
-
'--cim-slider-fill-size': (trackState.getThumbPercent(1) - trackState.getThumbPercent(0)) * 100 + '%',
|
|
34
|
-
}
|
|
35
|
-
: {}) }), trackState.values.map((_, i) => (_jsx(RACSliderThumb, { index: i, className: "cim-slider-thumb", name: typeof name === 'string' ? name : name?.[i], form: form, "aria-labelledby": isRangeSlider ? (i === 0 ? rangeStartLabelId : rangeEndLabelId) : undefined }, i)))] })) }), showLabels && (_jsx(Text, { as: "span", variant: "medium", UNSAFE_className: "cim-slider-label-max", children: state.getThumbMaxValue(state.values.length - 1) })), withInput && (_jsx("div", { className: "cim-slider-inputs-container-wide", children: state.values.map((_, i) => (_jsx(SliderNumberField, { index: i, "aria-labelledby": isRangeSlider ? (i === 0 ? rangeStartLabelId : rangeEndLabelId) : undefined, style: { order: isRangeSlider ? (i === 0 ? -1 : 1) : undefined }, formatOptions: props.formatOptions }, i))) }))] }), withInput && (_jsx("div", { className: "cim-slider-inputs-container-narrow", children: state.values.map((_, i) => (_jsx(SliderNumberField, { index: i, "aria-labelledby": isRangeSlider ? (i === 0 ? rangeStartLabelId : rangeEndLabelId) : undefined, formatOptions: props.formatOptions }, i))) })), _jsx(FormFieldDescription, { children: description }), isRangeSlider && (_jsxs(_Fragment, { children: [_jsx("span", { style: { display: 'none' }, id: rangeStartLabelId, children: messages.format('rangeStart') }), _jsx("span", { style: { display: 'none' }, id: rangeEndLabelId, children: messages.format('rangeEnd') })] }))] }));
|
|
26
|
+
return (_jsxs(_Fragment, { children: [_jsx(FormFieldLabel, { isRequired: false, isDisabled: isDisabled, children: label }), !withInput && label != null && (_jsx(RACSliderOutput, { className: "cim-slider-output", children: _jsx(Text, { as: "span", variant: "medium", children: state.values.map((_, i) => state.getThumbValueLabel(i)).join(' – ') }) })), _jsxs("div", { className: "cim-slider-track-container", children: [showLabels && (_jsx(Text, { as: "span", variant: "medium", UNSAFE_className: "cim-slider-label-min", children: state.getThumbMinValue(0) })), _jsx(RACSliderTrack, { className: "cim-slider-track", children: ({ state: trackState, isDisabled: trackIsDisabled }) => (_jsxs(_Fragment, { children: [_jsx("div", { className: "cim-slider-track-background", "data-disabled": trackIsDisabled || undefined, children: _jsx(RACSliderFill, { className: "cim-slider-fill" }) }), trackState.values.map((_, i) => (_jsx(RACSliderThumb, { index: i, className: "cim-slider-thumb", name: typeof name === 'string' ? name : name?.[i], form: form, "aria-labelledby": isRangeSlider ? (i === 0 ? rangeStartLabelId : rangeEndLabelId) : undefined }, i)))] })) }), showLabels && (_jsx(Text, { as: "span", variant: "medium", UNSAFE_className: "cim-slider-label-max", children: state.getThumbMaxValue(state.values.length - 1) })), withInput && (_jsx("div", { className: "cim-slider-inputs-container-wide", children: state.values.map((_, i) => (_jsx(SliderNumberField, { index: i, "aria-labelledby": isRangeSlider ? (i === 0 ? rangeStartLabelId : rangeEndLabelId) : undefined, style: { order: isRangeSlider ? (i === 0 ? -1 : 1) : undefined }, formatOptions: props.formatOptions }, i))) }))] }), withInput && (_jsx("div", { className: "cim-slider-inputs-container-narrow", children: state.values.map((_, i) => (_jsx(SliderNumberField, { index: i, "aria-labelledby": isRangeSlider ? (i === 0 ? rangeStartLabelId : rangeEndLabelId) : undefined, formatOptions: props.formatOptions }, i))) })), _jsx(FormFieldDescription, { children: description }), isRangeSlider && (_jsxs(_Fragment, { children: [_jsx("span", { style: { display: 'none' }, id: rangeStartLabelId, children: messages.format('rangeStart') }), _jsx("span", { style: { display: 'none' }, id: rangeEndLabelId, children: messages.format('rangeEnd') })] }))] }));
|
|
36
27
|
} }) }));
|
|
37
28
|
}
|
|
38
29
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slider.js","sourceRoot":"","sources":["../../../../src/components/slider/slider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAqB,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACL,YAAY,IAAI,eAAe,EAC/B,WAAW,IAAI,cAAc,EAC7B,QAAQ,IAAI,WAAW,EACvB,MAAM,IAAI,SAAS,EACnB,YAAY,IAAI,eAAe,EAC/B,kBAAkB,IAAI,qBAAqB,EAC3C,WAAW,IAAI,cAAc,EAC7B,WAAW,IAAI,cAAc,EAC7B,WAAW,IAAI,cAAc,EAC7B,iBAAiB,GAGlB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAC5F,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEnD,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAuC7C,SAAS,MAAM,CACb,EACE,KAAK,EACL,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,UAAU,EACV,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,GAAG,KAAK,EACO,EACjB,GAAiC;IAEjC,MAAM,aAAa,GAAG,KAAK,EAAE,CAAC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AAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC;YACzC,CAAC;QACH,CAAC,qBACgB,CAAC,UAAU,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,YAE1E,KAAC,KAAK,IAAC,YAAY,EAAC,KAAK,GAAG,GACb,CAClB,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { useContext, type ForwardedRef } from 'react';\nimport { useId } from 'react-aria';\nimport {\n LabelContext as RACLabelContext,\n NumberField as RACNumberField,\n Provider as RACProvider,\n Slider as RACSlider,\n SliderOutput as RACSliderOutput,\n SliderStateContext as RACSliderStateContext,\n SliderThumb as RACSliderThumb,\n SliderTrack as RACSliderTrack,\n TextContext as RACTextContext,\n useSlottedContext,\n type NumberFieldProps as RACNumberFieldProps,\n type SliderProps as RACSliderProps,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useLocalizedMessages } from '../../i18n/localization-provider.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { FormFieldDescription, FormFieldLabel } from '../internal/form-field/form-field.js';\nimport { Input } from '../internal/input/input.js';\nimport type { CommonProps, LabellableProps } from '../types.js';\nimport { Text } from '../typography/text.js';\n\nexport interface SliderProps<T extends number | [number, number] = number>\n extends\n CommonProps,\n LabellableProps,\n Pick<RACSliderProps<T>, 'isDisabled' | 'minValue' | 'maxValue' | 'step' | 'formatOptions'> {\n /** A description for the field. Provides a hint such as specific requirements for what to choose. */\n description?: string;\n /** The current value (controlled). */\n value?: T;\n /** The default value (uncontrolled). */\n defaultValue?: T;\n /** Handler that is called when the value changes. */\n onChange?: (value: T) => void;\n /** Handler that is called when the slider stops moving. */\n onChangeEnd?: (value: T) => void;\n /**\n * The `<form>` element to associate the input with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).\n */\n form?: string;\n /**\n * The name(s) of the input element(s), used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name).\n */\n name?: T extends [number, number] ? [string, string] : string;\n /**\n * Whether to show input fields for slider values.\n * @default false\n */\n withInput?: boolean;\n /**\n * Whether to show static labels with minimum and maximum values.\n * @default false\n * */\n showLabels?: boolean;\n}\n\nfunction Slider<T extends number | [number, number] = number>(\n {\n label,\n description,\n UNSAFE_className,\n UNSAFE_style,\n form,\n name,\n withInput,\n showLabels,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n ...props\n }: SliderProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descriptionId = useId();\n const rangeStartLabelId = useId();\n const rangeEndLabelId = useId();\n const messages = useLocalizedMessages('slider');\n\n useProductionWarning(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn('Slider requires one of label / aria-label / aria-labelledby for accessibility');\n }\n }, [label, ariaLabel, ariaLabelledBy]);\n\n return (\n <RACProvider values={[[RACTextContext, { slots: { description: { id: descriptionId } } }]]}>\n <RACSlider\n {...props}\n ref={ref}\n className={clsx('cim-slider', UNSAFE_className)}\n style={UNSAFE_style}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n orientation=\"horizontal\"\n aria-describedby={[description && descriptionId, props['aria-describedby']].filter(Boolean).join(' ')}\n >\n {({ state, isDisabled }) => {\n const isRangeSlider = state.values.length === 2;\n\n return (\n <>\n <FormFieldLabel isRequired={false} isDisabled={isDisabled}>\n {label}\n </FormFieldLabel>\n\n {!withInput && label != null && (\n <RACSliderOutput className=\"cim-slider-output\">\n <Text as=\"span\" variant=\"medium\">\n {state.values.map((_, i) => state.getThumbValueLabel(i)).join(' – ')}\n </Text>\n </RACSliderOutput>\n )}\n\n <div className=\"cim-slider-track-container\">\n {showLabels && (\n <Text as=\"span\" variant=\"medium\" UNSAFE_className=\"cim-slider-label-min\">\n {state.getThumbMinValue(0)}\n </Text>\n )}\n\n <RACSliderTrack className=\"cim-slider-track\">\n {({ state: trackState, isDisabled: trackIsDisabled }) => (\n <>\n <div className=\"cim-slider-track-background\" data-disabled={trackIsDisabled || undefined} />\n\n <div\n className=\"cim-slider-fill\"\n style={\n (state.values.length === 1\n ? {\n '--cim-slider-fill-size': trackState.getThumbPercent(0) * 100 + '%',\n }\n : isRangeSlider\n ? {\n '--cim-slider-fill-start': trackState.getThumbPercent(0) * 100 + '%',\n '--cim-slider-fill-size':\n (trackState.getThumbPercent(1) - trackState.getThumbPercent(0)) * 100 + '%',\n }\n : {}) as React.CSSProperties\n }\n />\n\n {trackState.values.map((_, i) => (\n <RACSliderThumb\n key={i}\n index={i}\n className=\"cim-slider-thumb\"\n name={typeof name === 'string' ? name : name?.[i]}\n form={form}\n aria-labelledby={isRangeSlider ? (i === 0 ? rangeStartLabelId : rangeEndLabelId) : undefined}\n />\n ))}\n </>\n )}\n </RACSliderTrack>\n\n {showLabels && (\n <Text as=\"span\" variant=\"medium\" UNSAFE_className=\"cim-slider-label-max\">\n {state.getThumbMaxValue(state.values.length - 1)}\n </Text>\n )}\n\n {withInput && (\n <div className=\"cim-slider-inputs-container-wide\">\n {state.values.map((_, i) => (\n <SliderNumberField\n key={i}\n index={i}\n aria-labelledby={isRangeSlider ? (i === 0 ? rangeStartLabelId : rangeEndLabelId) : undefined}\n style={{ order: isRangeSlider ? (i === 0 ? -1 : 1) : undefined }}\n formatOptions={props.formatOptions}\n />\n ))}\n </div>\n )}\n </div>\n\n {withInput && (\n <div className=\"cim-slider-inputs-container-narrow\">\n {state.values.map((_, i) => (\n <SliderNumberField\n key={i}\n index={i}\n aria-labelledby={isRangeSlider ? (i === 0 ? rangeStartLabelId : rangeEndLabelId) : undefined}\n formatOptions={props.formatOptions}\n />\n ))}\n </div>\n )}\n\n <FormFieldDescription>{description}</FormFieldDescription>\n\n {isRangeSlider && (\n <>\n <span style={{ display: 'none' }} id={rangeStartLabelId}>\n {messages.format('rangeStart')}\n </span>\n <span style={{ display: 'none' }} id={rangeEndLabelId}>\n {messages.format('rangeEnd')}\n </span>\n </>\n )}\n </>\n );\n }}\n </RACSlider>\n </RACProvider>\n );\n}\n\n/**\n * Allows users to select one or more values within a range.\n *\n * See [slider usage guidelines](https://ui.cimpress.io/components/slider/).\n */\nconst _Slider = withStyleProps(forwardRef(Slider), 'Slider');\n\nexport { _Slider as Slider };\n\ninterface SliderNumberFieldProps extends RACNumberFieldProps {\n index: number;\n}\n\nfunction SliderNumberField({ index, 'aria-labelledby': ariaLabelledBy, ...props }: SliderNumberFieldProps) {\n const state = useContext(RACSliderStateContext)!;\n const labelProps = useSlottedContext(RACLabelContext)!;\n\n return (\n <RACNumberField\n {...props}\n className=\"cim-slider-input\"\n value={state.values[index]}\n onChange={(value) => {\n if (!Number.isNaN(value)) {\n state.setThumbValue(index, value ?? 0);\n }\n }}\n aria-labelledby={[labelProps.id, ariaLabelledBy].filter(Boolean).join(' ')}\n >\n <Input contentWidth=\"5ch\" />\n </RACNumberField>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"slider.js","sourceRoot":"","sources":["../../../../src/components/slider/slider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAqB,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACL,YAAY,IAAI,eAAe,EAC/B,WAAW,IAAI,cAAc,EAC7B,QAAQ,IAAI,WAAW,EACvB,MAAM,IAAI,SAAS,EACnB,UAAU,IAAI,aAAa,EAC3B,YAAY,IAAI,eAAe,EAC/B,kBAAkB,IAAI,qBAAqB,EAC3C,WAAW,IAAI,cAAc,EAC7B,WAAW,IAAI,cAA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AM,UAAU,GAAG,iBAAiB,CAAC,eAAe,CAAE,CAAC;IAEvD,OAAO,CACL,KAAC,cAAc,OACT,KAAK,EACT,SAAS,EAAC,kBAAkB,EAC5B,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAC1B,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;YAClB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzB,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC;YACzC,CAAC;QACH,CAAC,qBACgB,CAAC,UAAU,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,YAE1E,KAAC,KAAK,IAAC,YAAY,EAAC,KAAK,GAAG,GACb,CAClB,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { useContext, type ForwardedRef } from 'react';\nimport { useId } from 'react-aria';\nimport {\n LabelContext as RACLabelContext,\n NumberField as RACNumberField,\n Provider as RACProvider,\n Slider as RACSlider,\n SliderFill as RACSliderFill,\n SliderOutput as RACSliderOutput,\n SliderStateContext as RACSliderStateContext,\n SliderThumb as RACSliderThumb,\n SliderTrack as RACSliderTrack,\n TextContext as RACTextContext,\n useSlottedContext,\n type NumberFieldProps as RACNumberFieldProps,\n type SliderProps as RACSliderProps,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useLocalizedMessages } from '../../i18n/localization-provider.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { FormFieldDescription, FormFieldLabel } from '../internal/form-field/form-field.js';\nimport { Input } from '../internal/input/input.js';\nimport type { CommonProps, LabellableProps } from '../types.js';\nimport { Text } from '../typography/text.js';\n\nexport interface SliderProps<T extends number | [number, number] = number>\n extends\n CommonProps,\n LabellableProps,\n Pick<RACSliderProps<T>, 'isDisabled' | 'minValue' | 'maxValue' | 'step' | 'formatOptions'> {\n /** A description for the field. Provides a hint such as specific requirements for what to choose. */\n description?: string;\n /** The current value (controlled). */\n value?: T;\n /** The default value (uncontrolled). */\n defaultValue?: T;\n /** Handler that is called when the value changes. */\n onChange?: (value: T) => void;\n /** Handler that is called when the slider stops moving. */\n onChangeEnd?: (value: T) => void;\n /**\n * The `<form>` element to associate the input with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).\n */\n form?: string;\n /**\n * The name(s) of the input element(s), used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name).\n */\n name?: T extends [number, number] ? [string, string] : string;\n /**\n * Whether to show input fields for slider values.\n * @default false\n */\n withInput?: boolean;\n /**\n * Whether to show static labels with minimum and maximum values.\n * @default false\n * */\n showLabels?: boolean;\n}\n\nfunction Slider<T extends number | [number, number] = number>(\n {\n label,\n description,\n UNSAFE_className,\n UNSAFE_style,\n form,\n name,\n withInput,\n showLabels,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n ...props\n }: SliderProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descriptionId = useId();\n const rangeStartLabelId = useId();\n const rangeEndLabelId = useId();\n const messages = useLocalizedMessages('slider');\n\n useProductionWarning(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn('Slider requires one of label / aria-label / aria-labelledby for accessibility');\n }\n }, [label, ariaLabel, ariaLabelledBy]);\n\n return (\n <RACProvider values={[[RACTextContext, { slots: { description: { id: descriptionId } } }]]}>\n <RACSlider\n {...props}\n ref={ref}\n className={clsx('cim-slider', UNSAFE_className)}\n style={UNSAFE_style}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n orientation=\"horizontal\"\n aria-describedby={[description && descriptionId, props['aria-describedby']].filter(Boolean).join(' ')}\n >\n {({ state, isDisabled }) => {\n const isRangeSlider = state.values.length === 2;\n\n return (\n <>\n <FormFieldLabel isRequired={false} isDisabled={isDisabled}>\n {label}\n </FormFieldLabel>\n\n {!withInput && label != null && (\n <RACSliderOutput className=\"cim-slider-output\">\n <Text as=\"span\" variant=\"medium\">\n {state.values.map((_, i) => state.getThumbValueLabel(i)).join(' – ')}\n </Text>\n </RACSliderOutput>\n )}\n\n <div className=\"cim-slider-track-container\">\n {showLabels && (\n <Text as=\"span\" variant=\"medium\" UNSAFE_className=\"cim-slider-label-min\">\n {state.getThumbMinValue(0)}\n </Text>\n )}\n\n <RACSliderTrack className=\"cim-slider-track\">\n {({ state: trackState, isDisabled: trackIsDisabled }) => (\n <>\n <div className=\"cim-slider-track-background\" data-disabled={trackIsDisabled || undefined}>\n <RACSliderFill className=\"cim-slider-fill\" />\n </div>\n\n {trackState.values.map((_, i) => (\n <RACSliderThumb\n key={i}\n index={i}\n className=\"cim-slider-thumb\"\n name={typeof name === 'string' ? name : name?.[i]}\n form={form}\n aria-labelledby={isRangeSlider ? (i === 0 ? rangeStartLabelId : rangeEndLabelId) : undefined}\n />\n ))}\n </>\n )}\n </RACSliderTrack>\n\n {showLabels && (\n <Text as=\"span\" variant=\"medium\" UNSAFE_className=\"cim-slider-label-max\">\n {state.getThumbMaxValue(state.values.length - 1)}\n </Text>\n )}\n\n {withInput && (\n <div className=\"cim-slider-inputs-container-wide\">\n {state.values.map((_, i) => (\n <SliderNumberField\n key={i}\n index={i}\n aria-labelledby={isRangeSlider ? (i === 0 ? rangeStartLabelId : rangeEndLabelId) : undefined}\n style={{ order: isRangeSlider ? (i === 0 ? -1 : 1) : undefined }}\n formatOptions={props.formatOptions}\n />\n ))}\n </div>\n )}\n </div>\n\n {withInput && (\n <div className=\"cim-slider-inputs-container-narrow\">\n {state.values.map((_, i) => (\n <SliderNumberField\n key={i}\n index={i}\n aria-labelledby={isRangeSlider ? (i === 0 ? rangeStartLabelId : rangeEndLabelId) : undefined}\n formatOptions={props.formatOptions}\n />\n ))}\n </div>\n )}\n\n <FormFieldDescription>{description}</FormFieldDescription>\n\n {isRangeSlider && (\n <>\n <span style={{ display: 'none' }} id={rangeStartLabelId}>\n {messages.format('rangeStart')}\n </span>\n <span style={{ display: 'none' }} id={rangeEndLabelId}>\n {messages.format('rangeEnd')}\n </span>\n </>\n )}\n </>\n );\n }}\n </RACSlider>\n </RACProvider>\n );\n}\n\n/**\n * Allows users to select one or more values within a range.\n *\n * See [slider usage guidelines](https://ui.cimpress.io/components/slider/).\n */\nconst _Slider = withStyleProps(forwardRef(Slider), 'Slider');\n\nexport { _Slider as Slider };\n\ninterface SliderNumberFieldProps extends RACNumberFieldProps {\n index: number;\n}\n\nfunction SliderNumberField({ index, 'aria-labelledby': ariaLabelledBy, ...props }: SliderNumberFieldProps) {\n const state = useContext(RACSliderStateContext)!;\n const labelProps = useSlottedContext(RACLabelContext)!;\n\n return (\n <RACNumberField\n {...props}\n className=\"cim-slider-input\"\n value={state.values[index]}\n onChange={(value) => {\n if (!Number.isNaN(value)) {\n state.setThumbValue(index, value ?? 0);\n }\n }}\n aria-labelledby={[labelProps.id, ariaLabelledBy].filter(Boolean).join(' ')}\n >\n <Input contentWidth=\"5ch\" />\n </RACNumberField>\n );\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type MutableRefObject, type ReactNode } from 'react';
|
|
2
|
+
export interface TableRefs {
|
|
3
|
+
header: MutableRefObject<HTMLTableSectionElement | null>;
|
|
4
|
+
}
|
|
5
|
+
export declare function TableRefsProvider({ children, header, }: {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
header: MutableRefObject<HTMLTableSectionElement | null>;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function useTableRefs(): TableRefs;
|
|
10
|
+
//# sourceMappingURL=refs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../../../../src/components/table/contexts/refs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,gBAAgB,EAAE,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AAElG,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,gBAAgB,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAC;CAC1D;AAID,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,MAAM,GACP,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,gBAAgB,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAC;CAC1D,2CASA;AAGD,wBAAgB,YAAY,IAAI,SAAS,CAOxC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useMemo } from 'react';
|
|
3
|
+
const TableRefsContext = createContext(null);
|
|
4
|
+
export function TableRefsProvider({ children, header, }) {
|
|
5
|
+
const tableRefs = useMemo(() => ({
|
|
6
|
+
header,
|
|
7
|
+
}), [header]);
|
|
8
|
+
return _jsx(TableRefsContext.Provider, { value: tableRefs, children: children });
|
|
9
|
+
}
|
|
10
|
+
// eslint-disable-next-line react-refresh/only-export-components
|
|
11
|
+
export function useTableRefs() {
|
|
12
|
+
const tableRefs = useContext(TableRefsContext);
|
|
13
|
+
if (!tableRefs) {
|
|
14
|
+
throw new Error('Cannot use table refs outside of a table');
|
|
15
|
+
}
|
|
16
|
+
return tableRefs;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=refs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refs.js","sourceRoot":"","sources":["../../../../../src/components/table/contexts/refs.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAyC,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAMlG,MAAM,gBAAgB,GAAG,aAAa,CAAmB,IAAI,CAAC,CAAC;AAE/D,MAAM,UAAU,iBAAiB,CAAC,EAChC,QAAQ,EACR,MAAM,GAIP;IACC,MAAM,SAAS,GAAc,OAAO,CAClC,GAAG,EAAE,CAAC,CAAC;QACL,MAAM;KACP,CAAC,EACF,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO,KAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,SAAS,YAAG,QAAQ,GAA6B,CAAC;AAC7F,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,YAAY;IAC1B,MAAM,SAAS,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC/C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { createContext, type MutableRefObject, type ReactNode, useContext, useMemo } from 'react';\n\nexport interface TableRefs {\n header: MutableRefObject<HTMLTableSectionElement | null>;\n}\n\nconst TableRefsContext = createContext<TableRefs | null>(null);\n\nexport function TableRefsProvider({\n children,\n header,\n}: {\n children: ReactNode;\n header: MutableRefObject<HTMLTableSectionElement | null>;\n}) {\n const tableRefs: TableRefs = useMemo(\n () => ({\n header,\n }),\n [header],\n );\n\n return <TableRefsContext.Provider value={tableRefs}>{children}</TableRefsContext.Provider>;\n}\n\n// eslint-disable-next-line react-refresh/only-export-components\nexport function useTableRefs(): TableRefs {\n const tableRefs = useContext(TableRefsContext);\n if (!tableRefs) {\n throw new Error('Cannot use table refs outside of a table');\n }\n\n return tableRefs;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-body.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-body.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"table-body.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-body.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAKlE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM/C,MAAM,WAAW,cAAe,SAAQ,WAAW;IACjD,+CAA+C;IAC/C,QAAQ,EAAE,SAAS,CAAC;CACrB;AAgBD;;;;GAIG;AACH,QAAA,MAAM,UAAU,wHAAqC,CAAC;AAEtD,OAAO,EAAE,UAAU,IAAI,SAAS,EAAE,CAAC"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useRef } from 'react';
|
|
4
|
+
import { useId } from 'react-aria';
|
|
4
5
|
import { forwardRef } from '../../forward-ref.js';
|
|
5
6
|
import { useLocalizedMessages } from '../../i18n/localization-provider.js';
|
|
6
7
|
import { Spinner } from '../spinner/spinner.js';
|
|
7
|
-
import { useFullWidthCell } from './contexts/column-collection.js';
|
|
8
|
+
import { useColumnData, useFullWidthCell } from './contexts/column-collection.js';
|
|
8
9
|
import { useTableLoading } from './contexts/loading.js';
|
|
10
|
+
import { TableRowStateProvider, useTableRowState } from './contexts/row-state.js';
|
|
11
|
+
import { useTableCell } from './hooks/use-table-cell.js';
|
|
9
12
|
function TableBody({ children, UNSAFE_className, UNSAFE_style, ...props }, ref) {
|
|
10
13
|
const isLoading = useTableLoading();
|
|
11
14
|
return (_jsxs("tbody", { ...props, ref: ref, className: UNSAFE_className, style: UNSAFE_style, children: [isLoading && _jsx(TableLoader, {}), children] }));
|
|
@@ -18,9 +21,17 @@ function TableBody({ children, UNSAFE_className, UNSAFE_style, ...props }, ref)
|
|
|
18
21
|
const _TableBody = forwardRef(TableBody, 'TableBody');
|
|
19
22
|
export { _TableBody as TableBody };
|
|
20
23
|
function TableLoader() {
|
|
24
|
+
const rowKey = useId();
|
|
25
|
+
return (_jsx(TableRowStateProvider, { rowKey: rowKey, children: _jsx(TableLoaderInner, {}) }));
|
|
26
|
+
}
|
|
27
|
+
function TableLoaderInner() {
|
|
21
28
|
const loaderCellRef = useRef(null);
|
|
22
|
-
const {
|
|
29
|
+
const { rowKey } = useTableRowState();
|
|
30
|
+
const { colSpan, columnKey } = useFullWidthCell(loaderCellRef);
|
|
31
|
+
// `useTableCell` requires `TableRowStateProvider`
|
|
32
|
+
const { cellProps } = useTableCell(loaderCellRef, rowKey, columnKey);
|
|
33
|
+
const columnData = useColumnData(columnKey);
|
|
23
34
|
const messages = useLocalizedMessages('table');
|
|
24
|
-
return (_jsx("tr", { children: _jsx("td", { ref: loaderCellRef, className: "cim-table-loading-state", colSpan: colSpan, "data-alignment": "center", children: _jsx("div", { className: "cim-table-loading-state-overlay", children: _jsx(Spinner, { size: "medium", "aria-label": messages.format('loadingData'), UNSAFE_style: { height: 'min(70%, 48px)' } }) }) }) }, "__cim__internal__loading-state__"));
|
|
35
|
+
return (_jsx("tr", { children: _jsx("td", { ...cellProps, ref: loaderCellRef, className: "cim-table-loading-state", "aria-colindex": columnData?.number, colSpan: colSpan, "data-alignment": "center", children: _jsx("div", { className: "cim-table-loading-state-overlay", children: _jsx(Spinner, { size: "medium", "aria-label": messages.format('loadingData'), UNSAFE_style: { height: 'min(70%, 48px)' } }) }) }) }, "__cim__internal__loading-state__"));
|
|
25
36
|
}
|
|
26
37
|
//# sourceMappingURL=table-body.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-body.js","sourceRoot":"","sources":["../../../../src/components/table/table-body.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,MAAM,EAAqC,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE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;AACJ,CAAC;AAED,SAAS,gBAAgB;IACvB,MAAM,aAAa,GAAG,MAAM,CAAuB,IAAI,CAAC,CAAC;IACzD,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,EAAE,CAAC;IACtC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAC/D,kDAAkD;IAClD,MAAM,EAAE,SAAS,EAAE,GAAG,YAAY,CAAC,aAAa,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IACrE,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAE/C,OAAO,CACL,uBACE,gBACM,SAAS,EACb,GAAG,EAAE,aAAa,EAClB,SAAS,EAAC,yBAAyB,mBACpB,UAAU,EAAE,MAAM,EACjC,OAAO,EAAE,OAAO,oBACD,QAAQ,YAEvB,cAAK,SAAS,EAAC,iCAAiC,YAC9C,KAAC,OAAO,IACN,IAAI,EAAC,QAAQ,gBACD,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,EAC1C,YAAY,EAAE,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAC1C,GACE,GACH,IAhBC,kCAAkC,CAiBrC,CACN,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport { useRef, type ForwardedRef, type ReactNode } from 'react';\nimport { useId } from 'react-aria';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useLocalizedMessages } from '../../i18n/localization-provider.js';\nimport { Spinner } from '../spinner/spinner.js';\nimport type { CommonProps } from '../types.js';\nimport { useColumnData, useFullWidthCell } from './contexts/column-collection.js';\nimport { useTableLoading } from './contexts/loading.js';\nimport { TableRowStateProvider, useTableRowState } from './contexts/row-state.js';\nimport { useTableCell } from './hooks/use-table-cell.js';\n\nexport interface TableBodyProps extends CommonProps {\n /** The rows that belong to this table body. */\n children: ReactNode;\n}\n\nfunction TableBody(\n { children, UNSAFE_className, UNSAFE_style, ...props }: TableBodyProps,\n ref: ForwardedRef<HTMLTableSectionElement>,\n) {\n const isLoading = useTableLoading();\n\n return (\n <tbody {...props} ref={ref} className={UNSAFE_className} style={UNSAFE_style}>\n {isLoading && <TableLoader />}\n {children}\n </tbody>\n );\n}\n\n/**\n * Renders a body section within a table.\n *\n * See [table usage guidelines](https://ui.cimpress.io/components/table/) and [table building guide](https://ui.cimpress.io/dev-guides/tables/).\n */\nconst _TableBody = forwardRef(TableBody, 'TableBody');\n\nexport { _TableBody as TableBody };\n\nfunction TableLoader() {\n const rowKey = useId();\n\n return (\n <TableRowStateProvider rowKey={rowKey}>\n <TableLoaderInner />\n </TableRowStateProvider>\n );\n}\n\nfunction TableLoaderInner() {\n const loaderCellRef = useRef<HTMLTableCellElement>(null);\n const { rowKey } = useTableRowState();\n const { colSpan, columnKey } = useFullWidthCell(loaderCellRef);\n // `useTableCell` requires `TableRowStateProvider`\n const { cellProps } = useTableCell(loaderCellRef, rowKey, columnKey);\n const columnData = useColumnData(columnKey);\n const messages = useLocalizedMessages('table');\n\n return (\n <tr key=\"__cim__internal__loading-state__\">\n <td\n {...cellProps}\n ref={loaderCellRef}\n className=\"cim-table-loading-state\"\n aria-colindex={columnData?.number}\n colSpan={colSpan}\n data-alignment=\"center\"\n >\n <div className=\"cim-table-loading-state-overlay\">\n <Spinner\n size=\"medium\"\n aria-label={messages.format('loadingData')}\n UNSAFE_style={{ height: 'min(70%, 48px)' }}\n />\n </div>\n </td>\n </tr>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-container.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-container.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"table-container.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-container.tsx"],"names":[],"mappings":"AAIA,OAAO,EAA2D,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAIhG,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGlE,MAAM,WAAW,mBAAoB,SAAQ,WAAW,EAAE,iBAAiB;IACzE,qCAAqC;IACrC,QAAQ,EAAE,SAAS,CAAC;CACrB;AAuED;;;;GAIG;AACH,QAAA,MAAM,eAAe,qKAA+D,CAAC;AAErF,OAAO,EAAE,eAAe,IAAI,cAAc,EAAE,CAAC"}
|
|
@@ -1,11 +1,53 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useLayoutEffect, useObjectRef, useResizeObserver } from '@react-aria/utils';
|
|
3
4
|
import clsx from 'clsx';
|
|
5
|
+
import { useRef, useState } from 'react';
|
|
4
6
|
import { forwardRef } from '../../forward-ref.js';
|
|
5
7
|
import { withStyleProps } from '../../with-style-props.js';
|
|
6
8
|
import { FocusableContainer } from '../internal/focusable-container/focusable-container.js';
|
|
9
|
+
import { TableRefsProvider } from './contexts/refs.js';
|
|
7
10
|
function TableContainer({ children, UNSAFE_className, UNSAFE_style, ...props }, ref) {
|
|
8
|
-
|
|
11
|
+
const containerRef = useObjectRef(ref);
|
|
12
|
+
const headerRef = useRef(null);
|
|
13
|
+
const [headerHeight, setHeaderHeight] = useState(40);
|
|
14
|
+
const [hasClassicHorizontalScrollbar, setHasClassicHorizontalScrollbar] = useState(false);
|
|
15
|
+
const [hasClassicVerticalScrollbar, setHasClassicVerticalScrollbar] = useState(false);
|
|
16
|
+
useResizeObserver({
|
|
17
|
+
ref: containerRef,
|
|
18
|
+
onResize: () => {
|
|
19
|
+
const element = containerRef.current;
|
|
20
|
+
if (element) {
|
|
21
|
+
setHasClassicHorizontalScrollbar(element.offsetHeight - element.clientHeight > Number.EPSILON);
|
|
22
|
+
setHasClassicVerticalScrollbar(element.offsetWidth - element.clientWidth > Number.EPSILON);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
useLayoutEffect(() => {
|
|
27
|
+
const headerElement = headerRef.current;
|
|
28
|
+
const isSSR = typeof window === 'undefined';
|
|
29
|
+
let observer;
|
|
30
|
+
if (headerElement && !isSSR) {
|
|
31
|
+
observer = new window.ResizeObserver((entries) => {
|
|
32
|
+
if (entries[0]) {
|
|
33
|
+
const { target } = entries[0];
|
|
34
|
+
setHeaderHeight(target.clientHeight);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
observer.observe(headerElement);
|
|
38
|
+
}
|
|
39
|
+
return () => {
|
|
40
|
+
if (headerElement && observer) {
|
|
41
|
+
observer.unobserve(headerElement);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}, [headerRef]);
|
|
45
|
+
return (_jsx(TableRefsProvider, { header: headerRef, children: _jsx("div", { className: "cim-table-container-outer", children: _jsx(FocusableContainer, { ...props, ref: containerRef, className: clsx('cim-table-container', UNSAFE_className), style: {
|
|
46
|
+
...UNSAFE_style,
|
|
47
|
+
'--cim-table-header-height': `${headerHeight}px`,
|
|
48
|
+
'--cim-table-has-classic-v-scrollbar': hasClassicVerticalScrollbar ? 1 : 0,
|
|
49
|
+
'--cim-table-has-classic-h-scrollbar': hasClassicHorizontalScrollbar ? 1 : 0,
|
|
50
|
+
}, scrollDirection: "horizontal", children: children }) }) }));
|
|
9
51
|
}
|
|
10
52
|
/**
|
|
11
53
|
* Renders a scrollable container that allows a table to overflow in a responsive way.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-container.js","sourceRoot":"","sources":["../../../../src/components/table/table-container.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,IAAI,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"table-container.js","sourceRoot":"","sources":["../../../../src/components/table/table-container.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,IAAI,MAAM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,CAAC,cAAc,CAAC,EAAE,gBAAgB,CAAC,CAAC;AAErF,OAAO,EAAE,eAAe,IAAI,cAAc,EAAE,CAAC","sourcesContent":["'use client';\n\nimport { useLayoutEffect, useObjectRef, useResizeObserver } from '@react-aria/utils';\nimport clsx from 'clsx';\nimport { type CSSProperties, useRef, useState, type ForwardedRef, type ReactNode } from 'react';\nimport { forwardRef } from '../../forward-ref.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { FocusableContainer } from '../internal/focusable-container/focusable-container.js';\nimport type { AriaLabelingProps, CommonProps } from '../types.js';\nimport { TableRefsProvider } from './contexts/refs.js';\n\nexport interface TableContainerProps extends CommonProps, AriaLabelingProps {\n /** The contents of the container. */\n children: ReactNode;\n}\n\nfunction TableContainer(\n { children, UNSAFE_className, UNSAFE_style, ...props }: TableContainerProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const containerRef = useObjectRef(ref);\n const headerRef = useRef<HTMLTableSectionElement | null>(null);\n const [headerHeight, setHeaderHeight] = useState(40);\n const [hasClassicHorizontalScrollbar, setHasClassicHorizontalScrollbar] = useState(false);\n const [hasClassicVerticalScrollbar, setHasClassicVerticalScrollbar] = useState(false);\n\n useResizeObserver({\n ref: containerRef,\n onResize: () => {\n const element = containerRef.current;\n if (element) {\n setHasClassicHorizontalScrollbar(element.offsetHeight - element.clientHeight > Number.EPSILON);\n setHasClassicVerticalScrollbar(element.offsetWidth - element.clientWidth > Number.EPSILON);\n }\n },\n });\n\n useLayoutEffect(() => {\n const headerElement = headerRef.current;\n const isSSR = typeof window === 'undefined';\n\n let observer: ResizeObserver | undefined;\n\n if (headerElement && !isSSR) {\n observer = new window.ResizeObserver((entries) => {\n if (entries[0]) {\n const { target } = entries[0];\n setHeaderHeight(target.clientHeight);\n }\n });\n\n observer.observe(headerElement);\n }\n\n return () => {\n if (headerElement && observer) {\n observer.unobserve(headerElement);\n }\n };\n }, [headerRef]);\n\n return (\n <TableRefsProvider header={headerRef}>\n <div className=\"cim-table-container-outer\">\n <FocusableContainer\n {...props}\n ref={containerRef}\n className={clsx('cim-table-container', UNSAFE_className)}\n style={\n {\n ...UNSAFE_style,\n '--cim-table-header-height': `${headerHeight}px`,\n '--cim-table-has-classic-v-scrollbar': hasClassicVerticalScrollbar ? 1 : 0,\n '--cim-table-has-classic-h-scrollbar': hasClassicHorizontalScrollbar ? 1 : 0,\n } as CSSProperties\n }\n scrollDirection=\"horizontal\"\n >\n {children}\n </FocusableContainer>\n </div>\n </TableRefsProvider>\n );\n}\n\n/**\n * Renders a scrollable container that allows a table to overflow in a responsive way.\n *\n * See [table usage guidelines](https://ui.cimpress.io/components/table/) and [table building guide](https://ui.cimpress.io/dev-guides/tables/).\n */\nconst _TableContainer = withStyleProps(forwardRef(TableContainer), 'TableContainer');\n\nexport { _TableContainer as TableContainer };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-header.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-header.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"table-header.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-header.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA8B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,wDAAwD;IACxD,QAAQ,EAAE,SAAS,CAAC;CACrB;AAgBD;;;;GAIG;AACH,QAAA,MAAM,YAAY,0HAAyC,CAAC;AAE5D,OAAO,EAAE,YAAY,IAAI,WAAW,EAAE,CAAC"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { mergeRefs, useObjectRef } from 'react-aria';
|
|
3
5
|
import { forwardRef } from '../../forward-ref.js';
|
|
6
|
+
import { useTableRefs } from './contexts/refs.js';
|
|
4
7
|
function TableHeader({ children, UNSAFE_className, UNSAFE_style, ...props }, ref) {
|
|
5
|
-
|
|
8
|
+
const { header: headerRef } = useTableRefs();
|
|
9
|
+
const mergedRef = useObjectRef(useMemo(() => mergeRefs(ref, headerRef), [ref, headerRef]));
|
|
10
|
+
return (_jsx("thead", { ...props, ref: mergedRef, className: UNSAFE_className, style: UNSAFE_style, children: children }));
|
|
6
11
|
}
|
|
7
12
|
/**
|
|
8
13
|
* Renders a header section within a table.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-header.js","sourceRoot":"","sources":["../../../../src/components/table/table-header.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;
|
|
1
|
+
{"version":3,"file":"table-header.js","sourceRoot":"","sources":["../../../../src/components/table/table-header.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,OAAO,EAAqC,MAAM,OAAO,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAOlD,SAAS,WAAW,CAClB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,KAAK,EAAoB,EACxE,GAA0C;IAE1C,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,YAAY,EAAE,CAAC;IAC7C,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IAE3F,OAAO,CACL,mBAAW,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY,YAC/E,QAAQ,GACH,CACT,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,YAAY,GAAG,UAAU,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;AAE5D,OAAO,EAAE,YAAY,IAAI,WAAW,EAAE,CAAC","sourcesContent":["'use client';\n\nimport { useMemo, type ForwardedRef, type ReactNode } from 'react';\nimport { mergeRefs, useObjectRef } from 'react-aria';\nimport { forwardRef } from '../../forward-ref.js';\nimport type { CommonProps } from '../types.js';\nimport { useTableRefs } from './contexts/refs.js';\n\nexport interface TableHeaderProps extends CommonProps {\n /** The header rows that belong to this table header. */\n children: ReactNode;\n}\n\nfunction TableHeader(\n { children, UNSAFE_className, UNSAFE_style, ...props }: TableHeaderProps,\n ref: ForwardedRef<HTMLTableSectionElement>,\n) {\n const { header: headerRef } = useTableRefs();\n const mergedRef = useObjectRef(useMemo(() => mergeRefs(ref, headerRef), [ref, headerRef]));\n\n return (\n <thead {...props} ref={mergedRef} className={UNSAFE_className} style={UNSAFE_style}>\n {children}\n </thead>\n );\n}\n\n/**\n * Renders a header section within a table.\n *\n * See [table usage guidelines](https://ui.cimpress.io/components/table/) and [table building guide](https://ui.cimpress.io/dev-guides/tables/).\n */\nconst _TableHeader = forwardRef(TableHeader, 'TableHeader');\n\nexport { _TableHeader as TableHeader };\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IconProps } from '../components/types.js';
|
|
2
|
+
/** Renders an SVG icon. */
|
|
3
|
+
declare const SvgAppWindowPrevious: {
|
|
4
|
+
({ size, "aria-hidden": ariaHidden, tone, UNSAFE_className, UNSAFE_style, ...rest }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
displayName: string;
|
|
6
|
+
};
|
|
7
|
+
export default SvgAppWindowPrevious;
|
|
8
|
+
//# sourceMappingURL=app-window-previous.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-window-previous.d.ts","sourceRoot":"","sources":["../../../src/icons/app-window-previous.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGxD,2BAA2B;AAC3B,QAAA,MAAM,oBAAoB;yFAOvB,SAAS;;CAeX,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { fgTone } from '../utils/style/tone.js';
|
|
4
|
+
const displayName = 'IconAppWindowPrevious';
|
|
5
|
+
/** Renders an SVG icon. */
|
|
6
|
+
const SvgAppWindowPrevious = ({ size, 'aria-hidden': ariaHidden, tone, UNSAFE_className, UNSAFE_style, ...rest }) => {
|
|
7
|
+
const props = {
|
|
8
|
+
...rest,
|
|
9
|
+
'aria-hidden': ariaHidden ?? (rest['aria-label'] == null && rest['aria-labelledby'] == null),
|
|
10
|
+
className: clsx('cim-icon', tone && fgTone(tone), UNSAFE_className),
|
|
11
|
+
style: UNSAFE_style,
|
|
12
|
+
width: size != null ? size + 'px' : '1em',
|
|
13
|
+
height: size != null ? size + 'px' : '1em',
|
|
14
|
+
};
|
|
15
|
+
return (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 32 32", "data-icon": "true", fill: "currentColor", ...props, children: [_jsx("path", { d: "M26 14V7a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1v18a1 1 0 0 0 1 1h7a1 1 0 1 1 0 2H7a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3h18a3 3 0 0 1 3 3v7a1 1 0 1 1-2 0" }), _jsx("path", { d: "M29 28v-1.5a4.5 4.5 0 0 0-4.5-4.5h-4.086l2.293-2.293a1 1 0 1 0-1.414-1.414l-4 4a1 1 0 0 0 0 1.414l4 4a1 1 0 1 0 1.414-1.414L20.414 24H24.5a2.5 2.5 0 0 1 2.5 2.5V28a1 1 0 1 0 2 0m-2-18a1 1 0 1 1 0 2H5a1 1 0 1 1 0-2zM9 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0" })] }));
|
|
16
|
+
};
|
|
17
|
+
SvgAppWindowPrevious.displayName = displayName;
|
|
18
|
+
export default SvgAppWindowPrevious;
|
|
19
|
+
//# sourceMappingURL=app-window-previous.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-window-previous.js","sourceRoot":"","sources":["../../../src/icons/app-window-previous.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAC5C,2BAA2B;AAC3B,MAAM,oBAAoB,GAAG,CAAC,EAC5B,IAAI,EACJ,aAAa,EAAE,UAAU,EACzB,IAAI,EACJ,gBAAgB,EAChB,YAAY,EACZ,GAAG,IAAI,EACG,EAAE,EAAE;IACd,MAAM,KAAK,GAAG;QACZ,GAAG,IAAI;QACP,aAAa,EAAE,UAAU,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,IAAI,IAAI,IAAI,CAAC,iBAAiB,CAAC,IAAI,IAAI,CAAC;QAC5F,SAAS,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC;QACnE,KAAK,EAAE,YAAY;QACnB,KAAK,EAAE,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK;QACzC,MAAM,EAAE,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK;KAC3C,CAAC;IACF,OAAO,CACL,eAAK,KAAK,EAAC,4BAA4B,EAAC,OAAO,EAAC,WAAW,eAAW,MAAM,EAAC,IAAI,EAAC,cAAc,KAAK,KAAK,aACxG,eAAM,CAAC,EAAC,0IAA0I,GAAG,EACrJ,eAAM,CAAC,EAAC,wRAAwR,GAAG,IAC/R,CACP,CAAC;AACJ,CAAC,CAAC;AACF,oBAAoB,CAAC,WAAW,GAAG,WAAW,CAAC;AAC/C,eAAe,oBAAoB,CAAC","sourcesContent":["import clsx from 'clsx';\nimport type { IconProps } from '../components/types.js';\nimport { fgTone } from '../utils/style/tone.js';\nconst displayName = 'IconAppWindowPrevious';\n/** Renders an SVG icon. */\nconst SvgAppWindowPrevious = ({\n size,\n 'aria-hidden': ariaHidden,\n tone,\n UNSAFE_className,\n UNSAFE_style,\n ...rest\n}: IconProps) => {\n const props = {\n ...rest,\n 'aria-hidden': ariaHidden ?? (rest['aria-label'] == null && rest['aria-labelledby'] == null),\n className: clsx('cim-icon', tone && fgTone(tone), UNSAFE_className),\n style: UNSAFE_style,\n width: size != null ? size + 'px' : '1em',\n height: size != null ? size + 'px' : '1em',\n };\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\" data-icon=\"true\" fill=\"currentColor\" {...props}>\n <path d=\"M26 14V7a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1v18a1 1 0 0 0 1 1h7a1 1 0 1 1 0 2H7a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3h18a3 3 0 0 1 3 3v7a1 1 0 1 1-2 0\" />\n <path d=\"M29 28v-1.5a4.5 4.5 0 0 0-4.5-4.5h-4.086l2.293-2.293a1 1 0 1 0-1.414-1.414l-4 4a1 1 0 0 0 0 1.414l4 4a1 1 0 1 0 1.414-1.414L20.414 24H24.5a2.5 2.5 0 0 1 2.5 2.5V28a1 1 0 1 0 2 0m-2-18a1 1 0 1 1 0 2H5a1 1 0 1 1 0-2zM9 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0\" />\n </svg>\n );\n};\nSvgAppWindowPrevious.displayName = displayName;\nexport default SvgAppWindowPrevious;\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IconProps } from '../components/types.js';
|
|
2
|
+
/** Renders an SVG icon. */
|
|
3
|
+
declare const SvgIdentificationCard: {
|
|
4
|
+
({ size, "aria-hidden": ariaHidden, tone, UNSAFE_className, UNSAFE_style, ...rest }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
displayName: string;
|
|
6
|
+
};
|
|
7
|
+
export default SvgIdentificationCard;
|
|
8
|
+
//# sourceMappingURL=identification-card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identification-card.d.ts","sourceRoot":"","sources":["../../../src/icons/identification-card.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGxD,2BAA2B;AAC3B,QAAA,MAAM,qBAAqB;yFAOxB,SAAS;;CAiBX,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|