@coveord/plasma-mantine 56.2.2 → 56.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,7 +48,7 @@ var TableDateRangePicker = (0, _core.factory)(function(props, ref) {
48
48
  setOpened(false);
49
49
  };
50
50
  var formatDate = function(date) {
51
- return (0, _dayjs.default)(date).format('MMM DD, YYYY');
51
+ return (0, _dayjs.default)(date).format('MMM D, YYYY');
52
52
  };
53
53
  var formattedRange = "".concat(formatDate(store.state.dateRange[0]), " - ").concat(formatDate(store.state.dateRange[1]));
54
54
  var dateRangeInitialized = store.state.dateRange.every(function(date) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/components/table/table-date-range-picker/TableDateRangePicker.tsx"],"sourcesContent":["import {CalendarSize16Px} from '@coveord/plasma-react-icons';\nimport {BoxProps, CompoundStylesApiProps, Factory, factory, Grid, InputBase, Popover, useProps} from '@mantine/core';\nimport dayjs from 'dayjs';\n\nimport {type DatesRangeValue, type DateStringValue} from '@mantine/dates';\nimport {useState} from 'react';\nimport {\n DateRangePickerInlineCalendar,\n DateRangePickerInlineCalendarProps,\n DateRangePickerPreset,\n} from '../../date-range-picker/index.js';\nimport {TableComponentsOrder} from '../Table.js';\nimport {useTableContext} from '../TableContext.js';\n\nexport type TableDateRangePickerStylesNames = 'dateRangeRoot';\n\nexport interface TableDateRangePickerProps\n extends BoxProps,\n CompoundStylesApiProps<TableDateRangePickerFactory>,\n Pick<DateRangePickerInlineCalendarProps, 'startProps' | 'endProps' | 'rangeCalendarProps'> {\n /**\n * An object containing date presets.\n * If empty the preset dropdown won't be shown\n *\n * @example\n * {\n * january: {label: 'January', range: [new Date(2022, 0, 1), new Date(2022, 0, 31)]},\n * february: {label: 'February', range: [new Date(2022, 1, 1), new Date(2022, 1, 28)]}\n * }\n * @default {}\n */\n presets?: Record<string, DateRangePickerPreset>;\n}\n\nexport type TableDateRangePickerFactory = Factory<{\n props: TableDateRangePickerProps;\n ref: HTMLDivElement;\n stylesNames: TableDateRangePickerStylesNames;\n compound: true;\n}>;\n\nconst defaultProps: Partial<TableDateRangePickerProps> = {\n presets: {},\n};\n\nexport const TableDateRangePicker = factory<TableDateRangePickerFactory>((props, ref) => {\n const {store, getStyles} = useTableContext();\n const {presets, rangeCalendarProps, classNames, className, styles, style, vars, ...others} = useProps(\n 'PlasmaTableDateRangePicker',\n defaultProps,\n props,\n );\n const [opened, setOpened] = useState(false);\n\n const onApply = (dates: DatesRangeValue<DateStringValue | null>) => {\n store.setDateRange(dates);\n store.setPagination({pageIndex: 0, pageSize: store.state.pagination.pageSize});\n setOpened(false);\n };\n\n const onCancel = () => {\n setOpened(false);\n };\n\n const formatDate = (date: DateStringValue) => dayjs(date).format('MMM DD, YYYY');\n const formattedRange = `${formatDate(store.state.dateRange[0])} - ${formatDate(store.state.dateRange[1])}`;\n const dateRangeInitialized = store.state.dateRange.every(\n (date: DateStringValue) => typeof date === 'string' && date !== '',\n );\n\n const stylesApiProps = {classNames, styles};\n\n return (\n <Grid.Col\n span=\"content\"\n order={TableComponentsOrder.DateRangePicker}\n ref={ref}\n {...getStyles('dateRangeRoot', {className, style, ...stylesApiProps})}\n {...others}\n >\n <Popover opened={opened} onChange={setOpened}>\n <Popover.Target>\n <InputBase\n component=\"button\"\n leftSection={<CalendarSize16Px height={16} />}\n miw={220}\n onClick={() => setOpened(true)}\n >\n {dateRangeInitialized ? formattedRange : 'Select date range'}\n </InputBase>\n </Popover.Target>\n <Popover.Dropdown p={0}>\n <DateRangePickerInlineCalendar\n initialRange={store.state.dateRange}\n onApply={onApply}\n onCancel={onCancel}\n presets={presets}\n rangeCalendarProps={rangeCalendarProps}\n />\n </Popover.Dropdown>\n </Popover>\n </Grid.Col>\n );\n});\n"],"names":["TableDateRangePicker","defaultProps","presets","factory","props","ref","useTableContext","store","getStyles","useProps","rangeCalendarProps","classNames","className","styles","style","vars","others","useState","opened","setOpened","onApply","dates","setDateRange","setPagination","pageIndex","pageSize","state","pagination","onCancel","formatDate","date","dayjs","format","formattedRange","dateRange","dateRangeInitialized","every","stylesApiProps","Grid","Col","span","order","TableComponentsOrder","DateRangePicker","Popover","onChange","Target","InputBase","component","leftSection","CalendarSize16Px","height","miw","onClick","Dropdown","p","DateRangePickerInlineCalendar","initialRange"],"mappings":";;;;+BA6CaA;;;eAAAA;;;;;;;;;gCA7CkB;oBACsE;8DACnF;qBAGK;qBAKhB;qBAC4B;4BACL;AA6B9B,IAAMC,eAAmD;IACrDC,SAAS,CAAC;AACd;AAEO,IAAMF,uBAAuBG,IAAAA,aAAO,EAA8B,SAACC,OAAOC;IAC7E,IAA2BC,mBAAAA,IAAAA,6BAAe,KAAnCC,QAAoBD,iBAApBC,OAAOC,YAAaF,iBAAbE;IACd,IAA6FC,YAAAA,IAAAA,cAAQ,EACjG,8BACAR,cACAG,QAHGF,UAAsFO,UAAtFP,SAASQ,qBAA6ED,UAA7EC,oBAAoBC,aAAyDF,UAAzDE,YAAYC,YAA6CH,UAA7CG,WAAWC,SAAkCJ,UAAlCI,QAAQC,QAA0BL,UAA1BK,OAAOC,OAAmBN,UAAnBM,MAASC,sCAAUP;QAAtFP;QAASQ;QAAoBC;QAAYC;QAAWC;QAAQC;QAAOC;;IAK1E,IAA4BE,+BAAAA,IAAAA,eAAQ,EAAC,YAA9BC,SAAqBD,cAAbE,YAAaF;IAE5B,IAAMG,UAAU,SAACC;QACbd,MAAMe,YAAY,CAACD;QACnBd,MAAMgB,aAAa,CAAC;YAACC,WAAW;YAAGC,UAAUlB,MAAMmB,KAAK,CAACC,UAAU,CAACF,QAAQ;QAAA;QAC5EN,UAAU;IACd;IAEA,IAAMS,WAAW;QACbT,UAAU;IACd;IAEA,IAAMU,aAAa,SAACC;eAA0BC,IAAAA,cAAK,EAACD,MAAME,MAAM,CAAC;;IACjE,IAAMC,iBAAiB,AAAC,GAA4CJ,OAA1CA,WAAWtB,MAAMmB,KAAK,CAACQ,SAAS,CAAC,EAAE,GAAE,OAA0C,OAArCL,WAAWtB,MAAMmB,KAAK,CAACQ,SAAS,CAAC,EAAE;IACvG,IAAMC,uBAAuB5B,MAAMmB,KAAK,CAACQ,SAAS,CAACE,KAAK,CACpD,SAACN;eAA0B,OAAOA,SAAS,YAAYA,SAAS;;IAGpE,IAAMO,iBAAiB;QAAC1B,YAAAA;QAAYE,QAAAA;IAAM;IAE1C,qBACI,qBAACyB,UAAI,CAACC,GAAG;QACLC,MAAK;QACLC,OAAOC,2BAAoB,CAACC,eAAe;QAC3CtC,KAAKA;OACDG,UAAU,iBAAiB;QAACI,WAAAA;QAAWE,OAAAA;OAAUuB,kBACjDrB;kBAEJ,cAAA,sBAAC4B,aAAO;YAAC1B,QAAQA;YAAQ2B,UAAU1B;;8BAC/B,qBAACyB,aAAO,CAACE,MAAM;8BACX,cAAA,qBAACC,eAAS;wBACNC,WAAU;wBACVC,2BAAa,qBAACC,kCAAgB;4BAACC,QAAQ;;wBACvCC,KAAK;wBACLC,SAAS;mCAAMlC,UAAU;;kCAExBgB,uBAAuBF,iBAAiB;;;8BAGjD,qBAACW,aAAO,CAACU,QAAQ;oBAACC,GAAG;8BACjB,cAAA,qBAACC,oCAA6B;wBAC1BC,cAAclD,MAAMmB,KAAK,CAACQ,SAAS;wBACnCd,SAASA;wBACTQ,UAAUA;wBACV1B,SAASA;wBACTQ,oBAAoBA;;;;;;AAM5C"}
1
+ {"version":3,"sources":["../../../../../src/components/table/table-date-range-picker/TableDateRangePicker.tsx"],"sourcesContent":["import {CalendarSize16Px} from '@coveord/plasma-react-icons';\nimport {BoxProps, CompoundStylesApiProps, Factory, factory, Grid, InputBase, Popover, useProps} from '@mantine/core';\nimport dayjs from 'dayjs';\n\nimport {type DatesRangeValue, type DateStringValue} from '@mantine/dates';\nimport {useState} from 'react';\nimport {\n DateRangePickerInlineCalendar,\n DateRangePickerInlineCalendarProps,\n DateRangePickerPreset,\n} from '../../date-range-picker/index.js';\nimport {TableComponentsOrder} from '../Table.js';\nimport {useTableContext} from '../TableContext.js';\n\nexport type TableDateRangePickerStylesNames = 'dateRangeRoot';\n\nexport interface TableDateRangePickerProps\n extends BoxProps,\n CompoundStylesApiProps<TableDateRangePickerFactory>,\n Pick<DateRangePickerInlineCalendarProps, 'startProps' | 'endProps' | 'rangeCalendarProps'> {\n /**\n * An object containing date presets.\n * If empty the preset dropdown won't be shown\n *\n * @example\n * {\n * january: {label: 'January', range: [new Date(2022, 0, 1), new Date(2022, 0, 31)]},\n * february: {label: 'February', range: [new Date(2022, 1, 1), new Date(2022, 1, 28)]}\n * }\n * @default {}\n */\n presets?: Record<string, DateRangePickerPreset>;\n}\n\nexport type TableDateRangePickerFactory = Factory<{\n props: TableDateRangePickerProps;\n ref: HTMLDivElement;\n stylesNames: TableDateRangePickerStylesNames;\n compound: true;\n}>;\n\nconst defaultProps: Partial<TableDateRangePickerProps> = {\n presets: {},\n};\n\nexport const TableDateRangePicker = factory<TableDateRangePickerFactory>((props, ref) => {\n const {store, getStyles} = useTableContext();\n const {presets, rangeCalendarProps, classNames, className, styles, style, vars, ...others} = useProps(\n 'PlasmaTableDateRangePicker',\n defaultProps,\n props,\n );\n const [opened, setOpened] = useState(false);\n\n const onApply = (dates: DatesRangeValue<DateStringValue | null>) => {\n store.setDateRange(dates);\n store.setPagination({pageIndex: 0, pageSize: store.state.pagination.pageSize});\n setOpened(false);\n };\n\n const onCancel = () => {\n setOpened(false);\n };\n\n const formatDate = (date: DateStringValue) => dayjs(date).format('MMM D, YYYY');\n const formattedRange = `${formatDate(store.state.dateRange[0])} - ${formatDate(store.state.dateRange[1])}`;\n const dateRangeInitialized = store.state.dateRange.every(\n (date: DateStringValue) => typeof date === 'string' && date !== '',\n );\n\n const stylesApiProps = {classNames, styles};\n\n return (\n <Grid.Col\n span=\"content\"\n order={TableComponentsOrder.DateRangePicker}\n ref={ref}\n {...getStyles('dateRangeRoot', {className, style, ...stylesApiProps})}\n {...others}\n >\n <Popover opened={opened} onChange={setOpened}>\n <Popover.Target>\n <InputBase\n component=\"button\"\n leftSection={<CalendarSize16Px height={16} />}\n miw={220}\n onClick={() => setOpened(true)}\n >\n {dateRangeInitialized ? formattedRange : 'Select date range'}\n </InputBase>\n </Popover.Target>\n <Popover.Dropdown p={0}>\n <DateRangePickerInlineCalendar\n initialRange={store.state.dateRange}\n onApply={onApply}\n onCancel={onCancel}\n presets={presets}\n rangeCalendarProps={rangeCalendarProps}\n />\n </Popover.Dropdown>\n </Popover>\n </Grid.Col>\n );\n});\n"],"names":["TableDateRangePicker","defaultProps","presets","factory","props","ref","useTableContext","store","getStyles","useProps","rangeCalendarProps","classNames","className","styles","style","vars","others","useState","opened","setOpened","onApply","dates","setDateRange","setPagination","pageIndex","pageSize","state","pagination","onCancel","formatDate","date","dayjs","format","formattedRange","dateRange","dateRangeInitialized","every","stylesApiProps","Grid","Col","span","order","TableComponentsOrder","DateRangePicker","Popover","onChange","Target","InputBase","component","leftSection","CalendarSize16Px","height","miw","onClick","Dropdown","p","DateRangePickerInlineCalendar","initialRange"],"mappings":";;;;+BA6CaA;;;eAAAA;;;;;;;;;gCA7CkB;oBACsE;8DACnF;qBAGK;qBAKhB;qBAC4B;4BACL;AA6B9B,IAAMC,eAAmD;IACrDC,SAAS,CAAC;AACd;AAEO,IAAMF,uBAAuBG,IAAAA,aAAO,EAA8B,SAACC,OAAOC;IAC7E,IAA2BC,mBAAAA,IAAAA,6BAAe,KAAnCC,QAAoBD,iBAApBC,OAAOC,YAAaF,iBAAbE;IACd,IAA6FC,YAAAA,IAAAA,cAAQ,EACjG,8BACAR,cACAG,QAHGF,UAAsFO,UAAtFP,SAASQ,qBAA6ED,UAA7EC,oBAAoBC,aAAyDF,UAAzDE,YAAYC,YAA6CH,UAA7CG,WAAWC,SAAkCJ,UAAlCI,QAAQC,QAA0BL,UAA1BK,OAAOC,OAAmBN,UAAnBM,MAASC,sCAAUP;QAAtFP;QAASQ;QAAoBC;QAAYC;QAAWC;QAAQC;QAAOC;;IAK1E,IAA4BE,+BAAAA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TQ,UAAUA;wBACV1B,SAASA;wBACTQ,oBAAoBA;;;;;;AAM5C"}
@@ -24,7 +24,7 @@ export const TableDateRangePicker = factory((props, ref)=>{
24
24
  const onCancel = ()=>{
25
25
  setOpened(false);
26
26
  };
27
- const formatDate = (date)=>dayjs(date).format('MMM DD, YYYY');
27
+ const formatDate = (date)=>dayjs(date).format('MMM D, YYYY');
28
28
  const formattedRange = `${formatDate(store.state.dateRange[0])} - ${formatDate(store.state.dateRange[1])}`;
29
29
  const dateRangeInitialized = store.state.dateRange.every((date)=>typeof date === 'string' && date !== '');
30
30
  const stylesApiProps = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/components/table/table-date-range-picker/TableDateRangePicker.tsx"],"sourcesContent":["import {CalendarSize16Px} from '@coveord/plasma-react-icons';\nimport {BoxProps, CompoundStylesApiProps, Factory, factory, Grid, InputBase, Popover, useProps} from '@mantine/core';\nimport dayjs from 'dayjs';\n\nimport {type DatesRangeValue, type DateStringValue} from '@mantine/dates';\nimport {useState} from 'react';\nimport {\n DateRangePickerInlineCalendar,\n DateRangePickerInlineCalendarProps,\n DateRangePickerPreset,\n} from '../../date-range-picker/index.js';\nimport {TableComponentsOrder} from '../Table.js';\nimport {useTableContext} from '../TableContext.js';\n\nexport type TableDateRangePickerStylesNames = 'dateRangeRoot';\n\nexport interface TableDateRangePickerProps\n extends BoxProps,\n CompoundStylesApiProps<TableDateRangePickerFactory>,\n Pick<DateRangePickerInlineCalendarProps, 'startProps' | 'endProps' | 'rangeCalendarProps'> {\n /**\n * An object containing date presets.\n * If empty the preset dropdown won't be shown\n *\n * @example\n * {\n * january: {label: 'January', range: [new Date(2022, 0, 1), new Date(2022, 0, 31)]},\n * february: {label: 'February', range: [new Date(2022, 1, 1), new Date(2022, 1, 28)]}\n * }\n * @default {}\n */\n presets?: Record<string, DateRangePickerPreset>;\n}\n\nexport type TableDateRangePickerFactory = Factory<{\n props: TableDateRangePickerProps;\n ref: HTMLDivElement;\n stylesNames: TableDateRangePickerStylesNames;\n compound: true;\n}>;\n\nconst defaultProps: Partial<TableDateRangePickerProps> = {\n presets: {},\n};\n\nexport const TableDateRangePicker = factory<TableDateRangePickerFactory>((props, ref) => {\n const {store, getStyles} = useTableContext();\n const {presets, rangeCalendarProps, classNames, className, styles, style, vars, ...others} = useProps(\n 'PlasmaTableDateRangePicker',\n defaultProps,\n props,\n );\n const [opened, setOpened] = useState(false);\n\n const onApply = (dates: DatesRangeValue<DateStringValue | null>) => {\n store.setDateRange(dates);\n store.setPagination({pageIndex: 0, pageSize: store.state.pagination.pageSize});\n setOpened(false);\n };\n\n const onCancel = () => {\n setOpened(false);\n };\n\n const formatDate = (date: DateStringValue) => dayjs(date).format('MMM DD, YYYY');\n const formattedRange = `${formatDate(store.state.dateRange[0])} - ${formatDate(store.state.dateRange[1])}`;\n const dateRangeInitialized = store.state.dateRange.every(\n (date: DateStringValue) => typeof date === 'string' && date !== '',\n );\n\n const stylesApiProps = {classNames, styles};\n\n return (\n <Grid.Col\n span=\"content\"\n order={TableComponentsOrder.DateRangePicker}\n ref={ref}\n {...getStyles('dateRangeRoot', {className, style, ...stylesApiProps})}\n {...others}\n >\n <Popover opened={opened} onChange={setOpened}>\n <Popover.Target>\n <InputBase\n component=\"button\"\n leftSection={<CalendarSize16Px height={16} />}\n miw={220}\n onClick={() => setOpened(true)}\n >\n {dateRangeInitialized ? formattedRange : 'Select date range'}\n </InputBase>\n </Popover.Target>\n <Popover.Dropdown p={0}>\n <DateRangePickerInlineCalendar\n initialRange={store.state.dateRange}\n onApply={onApply}\n onCancel={onCancel}\n presets={presets}\n rangeCalendarProps={rangeCalendarProps}\n />\n </Popover.Dropdown>\n </Popover>\n </Grid.Col>\n );\n});\n"],"names":["CalendarSize16Px","factory","Grid","InputBase","Popover","useProps","dayjs","useState","DateRangePickerInlineCalendar","TableComponentsOrder","useTableContext","defaultProps","presets","TableDateRangePicker","props","ref","store","getStyles","rangeCalendarProps","classNames","className","styles","style","vars","others","opened","setOpened","onApply","dates","setDateRange","setPagination","pageIndex","pageSize","state","pagination","onCancel","formatDate","date","format","formattedRange","dateRange","dateRangeInitialized","every","stylesApiProps","Col","span","order","DateRangePicker","onChange","Target","component","leftSection","height","miw","onClick","Dropdown","p","initialRange"],"mappings":";AAAA,SAAQA,gBAAgB,QAAO,8BAA8B;AAC7D,SAAmDC,OAAO,EAAEC,IAAI,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAO,gBAAgB;AACrH,OAAOC,WAAW,QAAQ;AAG1B,SAAQC,QAAQ,QAAO,QAAQ;AAC/B,SACIC,6BAA6B,QAG1B,mCAAmC;AAC1C,SAAQC,oBAAoB,QAAO,cAAc;AACjD,SAAQC,eAAe,QAAO,qBAAqB;AA6BnD,MAAMC,eAAmD;IACrDC,SAAS,CAAC;AACd;AAEA,OAAO,MAAMC,uBAAuBZ,QAAqC,CAACa,OAAOC;IAC7E,MAAM,EAACC,KAAK,EAAEC,SAAS,EAAC,GAAGP;IAC3B,MAAM,EAACE,OAAO,EAAEM,kBAAkB,EAAEC,UAAU,EAAEC,SAAS,EAAEC,MAAM,EAAEC,KAAK,EAAEC,IAAI,EAAE,GAAGC,QAAO,GAAGnB,SACzF,8BACAM,cACAG;IAEJ,MAAM,CAACW,QAAQC,UAAU,GAAGnB,SAAS;IAErC,MAAMoB,UAAU,CAACC;QACbZ,MAAMa,YAAY,CAACD;QACnBZ,MAAMc,aAAa,CAAC;YAACC,WAAW;YAAGC,UAAUhB,MAAMiB,KAAK,CAACC,UAAU,CAACF,QAAQ;QAAA;QAC5EN,UAAU;IACd;IAEA,MAAMS,WAAW;QACbT,UAAU;IACd;IAEA,MAAMU,aAAa,CAACC,OAA0B/B,MAAM+B,MAAMC,MAAM,CAAC;IACjE,MAAMC,iBAAiB,GAAGH,WAAWpB,MAAMiB,KAAK,CAACO,SAAS,CAAC,EAAE,EAAE,GAAG,EAAEJ,WAAWpB,MAAMiB,KAAK,CAACO,SAAS,CAAC,EAAE,GAAG;IAC1G,MAAMC,uBAAuBzB,MAAMiB,KAAK,CAACO,SAAS,CAACE,KAAK,CACpD,CAACL,OAA0B,OAAOA,SAAS,YAAYA,SAAS;IAGpE,MAAMM,iBAAiB;QAACxB;QAAYE;IAAM;IAE1C,qBACI,KAACnB,KAAK0C,GAAG;QACLC,MAAK;QACLC,OAAOrC,qBAAqBsC,eAAe;QAC3ChC,KAAKA;QACJ,GAAGE,UAAU,iBAAiB;YAACG;YAAWE;YAAO,GAAGqB,cAAc;QAAA,EAAE;QACpE,GAAGnB,MAAM;kBAEV,cAAA,MAACpB;YAAQqB,QAAQA;YAAQuB,UAAUtB;;8BAC/B,KAACtB,QAAQ6C,MAAM;8BACX,cAAA,KAAC9C;wBACG+C,WAAU;wBACVC,2BAAa,KAACnD;4BAAiBoD,QAAQ;;wBACvCC,KAAK;wBACLC,SAAS,IAAM5B,UAAU;kCAExBe,uBAAuBF,iBAAiB;;;8BAGjD,KAACnC,QAAQmD,QAAQ;oBAACC,GAAG;8BACjB,cAAA,KAAChD;wBACGiD,cAAczC,MAAMiB,KAAK,CAACO,SAAS;wBACnCb,SAASA;wBACTQ,UAAUA;wBACVvB,SAASA;wBACTM,oBAAoBA;;;;;;AAM5C,GAAG"}
1
+ {"version":3,"sources":["../../../../../src/components/table/table-date-range-picker/TableDateRangePicker.tsx"],"sourcesContent":["import {CalendarSize16Px} from '@coveord/plasma-react-icons';\nimport {BoxProps, CompoundStylesApiProps, Factory, factory, Grid, InputBase, Popover, useProps} from '@mantine/core';\nimport dayjs from 'dayjs';\n\nimport {type DatesRangeValue, type DateStringValue} from '@mantine/dates';\nimport {useState} from 'react';\nimport {\n DateRangePickerInlineCalendar,\n DateRangePickerInlineCalendarProps,\n DateRangePickerPreset,\n} from '../../date-range-picker/index.js';\nimport {TableComponentsOrder} from '../Table.js';\nimport {useTableContext} from '../TableContext.js';\n\nexport type TableDateRangePickerStylesNames = 'dateRangeRoot';\n\nexport interface TableDateRangePickerProps\n extends BoxProps,\n CompoundStylesApiProps<TableDateRangePickerFactory>,\n Pick<DateRangePickerInlineCalendarProps, 'startProps' | 'endProps' | 'rangeCalendarProps'> {\n /**\n * An object containing date presets.\n * If empty the preset dropdown won't be shown\n *\n * @example\n * {\n * january: {label: 'January', range: [new Date(2022, 0, 1), new Date(2022, 0, 31)]},\n * february: {label: 'February', range: [new Date(2022, 1, 1), new Date(2022, 1, 28)]}\n * }\n * @default {}\n */\n presets?: Record<string, DateRangePickerPreset>;\n}\n\nexport type TableDateRangePickerFactory = Factory<{\n props: TableDateRangePickerProps;\n ref: HTMLDivElement;\n stylesNames: TableDateRangePickerStylesNames;\n compound: true;\n}>;\n\nconst defaultProps: Partial<TableDateRangePickerProps> = {\n presets: {},\n};\n\nexport const TableDateRangePicker = factory<TableDateRangePickerFactory>((props, ref) => {\n const {store, getStyles} = useTableContext();\n const {presets, rangeCalendarProps, classNames, className, styles, style, vars, ...others} = useProps(\n 'PlasmaTableDateRangePicker',\n defaultProps,\n props,\n );\n const [opened, setOpened] = useState(false);\n\n const onApply = (dates: DatesRangeValue<DateStringValue | null>) => {\n store.setDateRange(dates);\n store.setPagination({pageIndex: 0, pageSize: store.state.pagination.pageSize});\n setOpened(false);\n };\n\n const onCancel = () => {\n setOpened(false);\n };\n\n const formatDate = (date: DateStringValue) => dayjs(date).format('MMM D, YYYY');\n const formattedRange = `${formatDate(store.state.dateRange[0])} - ${formatDate(store.state.dateRange[1])}`;\n const dateRangeInitialized = store.state.dateRange.every(\n (date: DateStringValue) => typeof date === 'string' && date !== '',\n );\n\n const stylesApiProps = {classNames, styles};\n\n return (\n <Grid.Col\n span=\"content\"\n order={TableComponentsOrder.DateRangePicker}\n ref={ref}\n {...getStyles('dateRangeRoot', {className, style, ...stylesApiProps})}\n {...others}\n >\n <Popover opened={opened} onChange={setOpened}>\n <Popover.Target>\n <InputBase\n component=\"button\"\n leftSection={<CalendarSize16Px height={16} />}\n miw={220}\n onClick={() => setOpened(true)}\n >\n {dateRangeInitialized ? formattedRange : 'Select date range'}\n </InputBase>\n </Popover.Target>\n <Popover.Dropdown p={0}>\n <DateRangePickerInlineCalendar\n initialRange={store.state.dateRange}\n onApply={onApply}\n onCancel={onCancel}\n presets={presets}\n rangeCalendarProps={rangeCalendarProps}\n />\n </Popover.Dropdown>\n </Popover>\n </Grid.Col>\n );\n});\n"],"names":["CalendarSize16Px","factory","Grid","InputBase","Popover","useProps","dayjs","useState","DateRangePickerInlineCalendar","TableComponentsOrder","useTableContext","defaultProps","presets","TableDateRangePicker","props","ref","store","getStyles","rangeCalendarProps","classNames","className","styles","style","vars","others","opened","setOpened","onApply","dates","setDateRange","setPagination","pageIndex","pageSize","state","pagination","onCancel","formatDate","date","format","formattedRange","dateRange","dateRangeInitialized","every","stylesApiProps","Col","span","order","DateRangePicker","onChange","Target","component","leftSection","height","miw","onClick","Dropdown","p","initialRange"],"mappings":";AAAA,SAAQA,gBAAgB,QAAO,8BAA8B;AAC7D,SAAmDC,OAAO,EAAEC,IAAI,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAO,gBAAgB;AACrH,OAAOC,WAAW,QAAQ;AAG1B,SAAQC,QAAQ,QAAO,QAAQ;AAC/B,SACIC,6BAA6B,QAG1B,mCAAmC;AAC1C,SAAQC,oBAAoB,QAAO,cAAc;AACjD,SAAQC,eAAe,QAAO,qBAAqB;AA6BnD,MAAMC,eAAmD;IACrDC,SAAS,CAAC;AACd;AAEA,OAAO,MAAMC,uBAAuBZ,QAAqC,CAACa,OAAOC;IAC7E,MAAM,EAACC,KAAK,EAAEC,SAAS,EAAC,GAAGP;IAC3B,MAAM,EAACE,OAAO,EAAEM,kBAAkB,EAAEC,UAAU,EAAEC,SAAS,EAAEC,MAAM,EAAEC,KAAK,EAAEC,IAAI,EAAE,GAAGC,QAAO,GAAGnB,SACzF,8BACAM,cACAG;IAEJ,MAAM,CAACW,QAAQC,UAAU,GAAGnB,SAAS;IAErC,MAAMoB,UAAU,CAACC;QACbZ,MAAMa,YAA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version": "56.2.3",
4
4
  "description": "A Plasma flavoured Mantine theme",
5
5
  "keywords": [
6
6
  "plasma",
@@ -40,29 +40,29 @@
40
40
  "dayjs": "1.11.18",
41
41
  "fast-deep-equal": "3.1.3",
42
42
  "lodash.defaultsdeep": "4.6.1",
43
- "monaco-editor": "0.53.0",
44
- "@coveord/plasma-react-icons": "56.2.2",
45
- "@coveord/plasma-tokens": "56.2.2"
43
+ "monaco-editor": "0.54.0",
44
+ "@coveord/plasma-react-icons": "56.2.3",
45
+ "@coveord/plasma-tokens": "56.2.3"
46
46
  },
47
47
  "devDependencies": {
48
- "@mantine/carousel": "8.3.2",
49
- "@mantine/code-highlight": "8.3.2",
50
- "@mantine/core": "8.3.2",
51
- "@mantine/dates": "8.3.2",
52
- "@mantine/form": "8.3.2",
53
- "@mantine/hooks": "8.3.2",
54
- "@mantine/modals": "8.3.2",
55
- "@mantine/notifications": "8.3.2",
48
+ "@mantine/carousel": "8.3.3",
49
+ "@mantine/code-highlight": "8.3.3",
50
+ "@mantine/core": "8.3.3",
51
+ "@mantine/dates": "8.3.3",
52
+ "@mantine/form": "8.3.3",
53
+ "@mantine/hooks": "8.3.3",
54
+ "@mantine/modals": "8.3.3",
55
+ "@mantine/notifications": "8.3.3",
56
56
  "@swc/cli": "0.7.8",
57
57
  "@swc/core": "1.13.5",
58
58
  "@testing-library/dom": "10.4.1",
59
- "@testing-library/jest-dom": "6.8.0",
59
+ "@testing-library/jest-dom": "6.9.1",
60
60
  "@testing-library/react": "16.3.0",
61
61
  "@testing-library/user-event": "14.6.1",
62
62
  "@types/lodash.defaultsdeep": "4.6.9",
63
- "@types/react": "18.3.24",
63
+ "@types/react": "18.3.26",
64
64
  "@types/react-dom": "18.3.7",
65
- "@vitest/eslint-plugin": "1.0.1",
65
+ "@vitest/eslint-plugin": "1.3.16",
66
66
  "cross-env": "7.0.3",
67
67
  "embla-carousel": "8.6.0",
68
68
  "embla-carousel-react": "8.6.0",
@@ -72,12 +72,12 @@
72
72
  "postcss": "8.5.6",
73
73
  "postcss-preset-mantine": "^1.11.0",
74
74
  "postcss-simple-vars": "^7.0.1",
75
- "publint": "0.3.13",
75
+ "publint": "0.3.14",
76
76
  "react": "18.3.1",
77
77
  "react-dom": "18.3.1",
78
78
  "rimraf": "6.0.1",
79
79
  "tslib": "2.8.1",
80
- "typescript": "5.9.2",
80
+ "typescript": "5.9.3",
81
81
  "vitest": "3.2.4"
82
82
  },
83
83
  "peerDependencies": {
@@ -166,12 +166,14 @@ describe('Collection', () => {
166
166
  const removeOrange = await within(screen.queryByTestId('item-1')).findByRole('button', {name: /remove/i});
167
167
  await user.click(removeOrange);
168
168
 
169
- expect(onRemoveItemSpy).toHaveBeenCalledWith(1);
169
+ expect(onRemoveItemSpy).toHaveBeenCalledExactlyOnceWith(1);
170
+
171
+ onRemoveItemSpy.mockReset();
170
172
 
171
173
  const removeBanana = await within(screen.queryByTestId('item-0')).findByRole('button', {name: /remove/i});
172
174
  await user.click(removeBanana);
173
175
 
174
- expect(onRemoveItemSpy).toHaveBeenCalledWith(0);
176
+ expect(onRemoveItemSpy).toHaveBeenCalledExactlyOnceWith(0);
175
177
  });
176
178
 
177
179
  it('does not render the remove button when disabled', async () => {
@@ -278,7 +280,7 @@ describe('Collection', () => {
278
280
 
279
281
  const {rerender} = render(<Fixture />);
280
282
  expect(screen.getByRole('button', {name: /add/i})).toBeDisabled();
281
- expect(allowAdd).toHaveBeenCalledWith(['banana', 'orange']);
283
+ expect(allowAdd).toHaveBeenCalledExactlyOnceWith(['banana', 'orange']);
282
284
 
283
285
  allowAdd.mockImplementation(() => true);
284
286
  rerender(<Fixture />);
@@ -13,7 +13,7 @@ describe('DateRangePickerInlineCalendar', () => {
13
13
  await user.click(screen.getByRole('button', {name: 'Apply'}));
14
14
 
15
15
  expect(onApply).toHaveBeenCalledTimes(1);
16
- expect(onApply).toHaveBeenCalledWith([null, null]);
16
+ expect(onApply).toHaveBeenCalledExactlyOnceWith([null, null]);
17
17
  });
18
18
 
19
19
  it('calls onCancel when the user clicks on the cancel button', async () => {
@@ -54,7 +54,7 @@ describe('DateRangePickerInlineCalendar', () => {
54
54
  await user.click(screen.getByRole('option', {name: 'select me'}));
55
55
  await user.click(screen.getByRole('button', {name: 'Apply'}));
56
56
 
57
- expect(onApply).toHaveBeenCalledWith([new Date(1999, 11, 31), endOfDay(2000, 0, 1)]);
57
+ expect(onApply).toHaveBeenCalledExactlyOnceWith([new Date(1999, 11, 31), endOfDay(2000, 0, 1)]);
58
58
  });
59
59
 
60
60
  it('calls onApply with the selected dates when clicking in the calendar', async () => {
@@ -69,7 +69,7 @@ describe('DateRangePickerInlineCalendar', () => {
69
69
 
70
70
  await user.click(screen.getByRole('button', {name: 'Apply'}));
71
71
 
72
- expect(onApply).toHaveBeenCalledWith(['2022-01-08T00:00:00.000Z', '2022-01-14T23:59:59.999Z']);
72
+ expect(onApply).toHaveBeenCalledExactlyOnceWith(['2022-01-08T00:00:00.000Z', '2022-01-14T23:59:59.999Z']);
73
73
 
74
74
  vi.useRealTimers();
75
75
  });
@@ -82,7 +82,7 @@ describe('DateRangePickerInlineCalendar', () => {
82
82
  await user.click(screen.getAllByRole('button', {name: /8 january 2022/i})[0]);
83
83
  await user.click(screen.getByRole('button', {name: 'Apply'}));
84
84
 
85
- expect(onApply).toHaveBeenCalledWith(['2022-01-08T00:00:00.000Z', '2022-01-08T23:59:59.999Z']);
85
+ expect(onApply).toHaveBeenCalledExactlyOnceWith(['2022-01-08T00:00:00.000Z', '2022-01-08T23:59:59.999Z']);
86
86
 
87
87
  vi.useRealTimers();
88
88
  });
@@ -107,7 +107,7 @@ describe('DateRangePickerInlineCalendar', () => {
107
107
 
108
108
  await user.click(screen.getByRole('button', {name: 'Apply'}));
109
109
 
110
- expect(onApply).toHaveBeenCalledWith(['2022-01-08T00:00:00.000Z', '2022-01-14T23:59:59.999Z']);
110
+ expect(onApply).toHaveBeenCalledExactlyOnceWith(['2022-01-08T00:00:00.000Z', '2022-01-14T23:59:59.999Z']);
111
111
  vi.useRealTimers();
112
112
  });
113
113
  });
@@ -23,7 +23,7 @@ describe('DateRangePickerPresetSelect', () => {
23
23
  );
24
24
  await user.click(screen.getByRole('option', {name: 'select me'}));
25
25
 
26
- expect(onChange).toHaveBeenCalledWith([new Date(1999, 11, 31), new Date(2000, 0, 1)]);
26
+ expect(onChange).toHaveBeenCalledExactlyOnceWith([new Date(1999, 11, 31), new Date(2000, 0, 1)]);
27
27
  });
28
28
 
29
29
  it('autoselects the preset that match the value', () => {
@@ -27,7 +27,7 @@ describe('Table.DateRangePicker', () => {
27
27
  };
28
28
  render(<Fixture />);
29
29
 
30
- expect(screen.getByRole('button', {name: /jan 01, 2022 - jan 07, 2022/i})).toBeVisible();
30
+ expect(screen.getByRole('button', {name: /jan 1, 2022 - jan 7, 2022/i})).toBeVisible();
31
31
  });
32
32
 
33
33
  describe('when url sync is activated', () => {
@@ -51,7 +51,7 @@ describe('Table.DateRangePicker', () => {
51
51
  );
52
52
  };
53
53
  render(<Fixture />);
54
- await user.click(screen.getByRole('button', {name: /jan 01, 2022 - jan 07, 2022/i}));
54
+ await user.click(screen.getByRole('button', {name: /jan 1, 2022 - jan 7, 2022/i}));
55
55
  await screen.findByRole('dialog');
56
56
  await user.clear(screen.getByRole('textbox', {name: /start/i}));
57
57
  await user.type(screen.getByRole('textbox', {name: /start/i}), '2022-01-02');
@@ -77,7 +77,7 @@ describe('Table.DateRangePicker', () => {
77
77
  );
78
78
  };
79
79
  render(<Fixture />);
80
- expect(screen.getByRole('button', {name: /jan 02, 2022 - jan 08, 2022/i})).toBeVisible();
80
+ expect(screen.getByRole('button', {name: /jan 2, 2022 - jan 8, 2022/i})).toBeVisible();
81
81
  });
82
82
  });
83
83
  });
@@ -120,7 +120,7 @@ describe('Table.Pagination', () => {
120
120
  await user.click(screen.queryByRole('button', {name: '2'}));
121
121
 
122
122
  await waitFor(() => {
123
- expect(onChangePage).toHaveBeenCalledWith(1);
123
+ expect(onChangePage).toHaveBeenCalledExactlyOnceWith(1);
124
124
  });
125
125
  });
126
126
 
@@ -182,7 +182,7 @@ describe('Table.Pagination', () => {
182
182
  await user.click(screen.getByTestId('remove-page'));
183
183
 
184
184
  // The page is 2, but the index is 1
185
- expect(onChangePage).toHaveBeenCalledWith(1);
185
+ expect(onChangePage).toHaveBeenCalledExactlyOnceWith(1);
186
186
 
187
187
  buttons = screen.getAllByRole('button');
188
188
  expect(buttons).toHaveLength(5);
@@ -192,11 +192,13 @@ describe('Table.Pagination', () => {
192
192
  expect(buttons[3]).toHaveAccessibleName('2');
193
193
  expect(buttons[4]).toHaveAccessibleName('next page');
194
194
 
195
+ onChangePage.mockReset();
196
+
195
197
  // remove a page
196
198
  await user.click(screen.getByTestId('remove-page'));
197
199
 
198
200
  // The page is 1, but the index is 0
199
- expect(onChangePage).toHaveBeenCalledWith(0);
201
+ expect(onChangePage).toHaveBeenCalledExactlyOnceWith(0);
200
202
 
201
203
  buttons = screen.getAllByRole('button');
202
204
  expect(buttons).toHaveLength(4);
@@ -103,7 +103,7 @@ describe('Table.PerPage', () => {
103
103
  await user.click(screen.getByRole('radio', {name: /100/i}));
104
104
 
105
105
  await waitFor(() => {
106
- expect(onPerPageChange).toHaveBeenCalledWith(100);
106
+ expect(onPerPageChange).toHaveBeenCalledExactlyOnceWith(100);
107
107
  });
108
108
  });
109
109
 
@@ -231,7 +231,7 @@ describe('RowLayout', () => {
231
231
  render(<Fixture />);
232
232
  await user.dblClick(screen.getByRole('cell', {name: 'Mario'}));
233
233
  expect(doubleClickSpy).toHaveBeenCalledTimes(1);
234
- expect(doubleClickSpy).toHaveBeenCalledWith(
234
+ expect(doubleClickSpy).toHaveBeenCalledExactlyOnceWith(
235
235
  {id: '🆔-1', firstName: 'Mario'},
236
236
  0,
237
237
  expect.objectContaining({id: '🆔-1'}),
@@ -62,7 +62,7 @@ export const TableDateRangePicker = factory<TableDateRangePickerFactory>((props,
62
62
  setOpened(false);
63
63
  };
64
64
 
65
- const formatDate = (date: DateStringValue) => dayjs(date).format('MMM DD, YYYY');
65
+ const formatDate = (date: DateStringValue) => dayjs(date).format('MMM D, YYYY');
66
66
  const formattedRange = `${formatDate(store.state.dateRange[0])} - ${formatDate(store.state.dateRange[1])}`;
67
67
  const dateRangeInitialized = store.state.dateRange.every(
68
68
  (date: DateStringValue) => typeof date === 'string' && date !== '',
@@ -15,7 +15,7 @@ describe('useControlledList', () => {
15
15
  result.current[1].append('three');
16
16
 
17
17
  expect(onChange).toHaveBeenCalledTimes(1);
18
- expect(onChange).toHaveBeenCalledWith(['one', 'two', 'three']);
18
+ expect(onChange).toHaveBeenCalledExactlyOnceWith(['one', 'two', 'three']);
19
19
  });
20
20
  });
21
21
 
@@ -25,7 +25,7 @@ describe('useControlledList', () => {
25
25
  result.current[1].remove(1);
26
26
 
27
27
  expect(onChange).toHaveBeenCalledTimes(1);
28
- expect(onChange).toHaveBeenCalledWith(['good', 'good']);
28
+ expect(onChange).toHaveBeenCalledExactlyOnceWith(['good', 'good']);
29
29
  });
30
30
  });
31
31
 
@@ -35,7 +35,7 @@ describe('useControlledList', () => {
35
35
  result.current[1].reorder({from: 2, to: 0});
36
36
 
37
37
  expect(onChange).toHaveBeenCalledTimes(1);
38
- expect(onChange).toHaveBeenCalledWith(['a', 'b', 'c']);
38
+ expect(onChange).toHaveBeenCalledExactlyOnceWith(['a', 'b', 'c']);
39
39
  });
40
40
  });
41
41
  });