@salt-ds/lab 1.0.0-alpha.43 → 1.0.0-alpha.45

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.
Files changed (107) hide show
  1. package/css/salt-lab.css +46 -87
  2. package/dist-cjs/calendar/Calendar.js +7 -0
  3. package/dist-cjs/calendar/Calendar.js.map +1 -1
  4. package/dist-cjs/calendar/internal/CalendarCarousel.js +1 -1
  5. package/dist-cjs/calendar/internal/CalendarCarousel.js.map +1 -1
  6. package/dist-cjs/calendar/internal/CalendarDay.css.js +1 -1
  7. package/dist-cjs/calendar/internal/CalendarDay.js +5 -1
  8. package/dist-cjs/calendar/internal/CalendarDay.js.map +1 -1
  9. package/dist-cjs/calendar/internal/CalendarMonth.js.map +1 -1
  10. package/dist-cjs/calendar/internal/CalendarNavigation.css.js +1 -1
  11. package/dist-cjs/calendar/internal/CalendarNavigation.js +2 -6
  12. package/dist-cjs/calendar/internal/CalendarNavigation.js.map +1 -1
  13. package/dist-cjs/calendar/internal/useFocusManagement.js +3 -0
  14. package/dist-cjs/calendar/internal/useFocusManagement.js.map +1 -1
  15. package/dist-cjs/calendar/useCalendar.js +30 -2
  16. package/dist-cjs/calendar/useCalendar.js.map +1 -1
  17. package/dist-cjs/calendar/useSelection.js +5 -0
  18. package/dist-cjs/calendar/useSelection.js.map +1 -1
  19. package/dist-cjs/contact-details/ContactPrimaryInfo.js.map +1 -1
  20. package/dist-cjs/contact-details/ContactSecondaryInfo.js.map +1 -1
  21. package/dist-cjs/contact-details/ContactTertiaryInfo.js.map +1 -1
  22. package/dist-cjs/date-input/DateInput.css.js +1 -1
  23. package/dist-cjs/date-input/DateInput.js +196 -49
  24. package/dist-cjs/date-input/DateInput.js.map +1 -1
  25. package/dist-cjs/date-picker/DatePicker.js +164 -0
  26. package/dist-cjs/date-picker/DatePicker.js.map +1 -0
  27. package/dist-cjs/date-picker/DatePickerContext.js +36 -0
  28. package/dist-cjs/date-picker/DatePickerContext.js.map +1 -0
  29. package/dist-cjs/date-picker/DatePickerPanel.css.js +6 -0
  30. package/dist-cjs/date-picker/DatePickerPanel.css.js.map +1 -0
  31. package/dist-cjs/date-picker/DatePickerPanel.js +139 -0
  32. package/dist-cjs/date-picker/DatePickerPanel.js.map +1 -0
  33. package/dist-cjs/index.js +4 -0
  34. package/dist-cjs/index.js.map +1 -1
  35. package/dist-cjs/stepped-tracker/StepLabel/StepLabel.js.map +1 -1
  36. package/dist-cjs/stepped-tracker/TrackerStep/TrackerStep.css.js +1 -1
  37. package/dist-cjs/stepper-input/StepperInput.css.js +1 -1
  38. package/dist-cjs/stepper-input/StepperInput.js +25 -74
  39. package/dist-cjs/stepper-input/StepperInput.js.map +1 -1
  40. package/dist-cjs/stepper-input/useStepperInput.js +19 -63
  41. package/dist-cjs/stepper-input/useStepperInput.js.map +1 -1
  42. package/dist-es/calendar/Calendar.js +7 -0
  43. package/dist-es/calendar/Calendar.js.map +1 -1
  44. package/dist-es/calendar/internal/CalendarCarousel.js +1 -1
  45. package/dist-es/calendar/internal/CalendarCarousel.js.map +1 -1
  46. package/dist-es/calendar/internal/CalendarDay.css.js +1 -1
  47. package/dist-es/calendar/internal/CalendarDay.js +5 -1
  48. package/dist-es/calendar/internal/CalendarDay.js.map +1 -1
  49. package/dist-es/calendar/internal/CalendarMonth.js.map +1 -1
  50. package/dist-es/calendar/internal/CalendarNavigation.css.js +1 -1
  51. package/dist-es/calendar/internal/CalendarNavigation.js +3 -7
  52. package/dist-es/calendar/internal/CalendarNavigation.js.map +1 -1
  53. package/dist-es/calendar/internal/useFocusManagement.js +3 -0
  54. package/dist-es/calendar/internal/useFocusManagement.js.map +1 -1
  55. package/dist-es/calendar/useCalendar.js +32 -4
  56. package/dist-es/calendar/useCalendar.js.map +1 -1
  57. package/dist-es/calendar/useSelection.js +4 -1
  58. package/dist-es/calendar/useSelection.js.map +1 -1
  59. package/dist-es/contact-details/ContactPrimaryInfo.js.map +1 -1
  60. package/dist-es/contact-details/ContactSecondaryInfo.js.map +1 -1
  61. package/dist-es/contact-details/ContactTertiaryInfo.js.map +1 -1
  62. package/dist-es/date-input/DateInput.css.js +1 -1
  63. package/dist-es/date-input/DateInput.js +200 -53
  64. package/dist-es/date-input/DateInput.js.map +1 -1
  65. package/dist-es/date-picker/DatePicker.js +160 -0
  66. package/dist-es/date-picker/DatePicker.js.map +1 -0
  67. package/dist-es/date-picker/DatePickerContext.js +31 -0
  68. package/dist-es/date-picker/DatePickerContext.js.map +1 -0
  69. package/dist-es/date-picker/DatePickerPanel.css.js +4 -0
  70. package/dist-es/date-picker/DatePickerPanel.css.js.map +1 -0
  71. package/dist-es/date-picker/DatePickerPanel.js +135 -0
  72. package/dist-es/date-picker/DatePickerPanel.js.map +1 -0
  73. package/dist-es/index.js +2 -1
  74. package/dist-es/index.js.map +1 -1
  75. package/dist-es/stepped-tracker/StepLabel/StepLabel.js.map +1 -1
  76. package/dist-es/stepped-tracker/TrackerStep/TrackerStep.css.js +1 -1
  77. package/dist-es/stepper-input/StepperInput.css.js +1 -1
  78. package/dist-es/stepper-input/StepperInput.js +27 -76
  79. package/dist-es/stepper-input/StepperInput.js.map +1 -1
  80. package/dist-es/stepper-input/useStepperInput.js +19 -63
  81. package/dist-es/stepper-input/useStepperInput.js.map +1 -1
  82. package/dist-types/calendar/internal/CalendarMonth.d.ts +0 -1
  83. package/dist-types/calendar/useSelection.d.ts +3 -0
  84. package/dist-types/contact-details/ContactPrimaryInfo.d.ts +1 -1
  85. package/dist-types/contact-details/ContactSecondaryInfo.d.ts +1 -1
  86. package/dist-types/contact-details/ContactTertiaryInfo.d.ts +1 -1
  87. package/dist-types/contact-details/types.d.ts +1 -1
  88. package/dist-types/date-input/DateInput.d.ts +21 -7
  89. package/dist-types/date-picker/DatePicker.d.ts +55 -0
  90. package/dist-types/date-picker/DatePickerContext.d.ts +23 -0
  91. package/dist-types/date-picker/DatePickerPanel.d.ts +8 -0
  92. package/dist-types/date-picker/index.d.ts +1 -0
  93. package/dist-types/index.d.ts +1 -0
  94. package/dist-types/stepped-tracker/StepLabel/StepLabel.d.ts +4 -3
  95. package/dist-types/stepper-input/StepperInput.d.ts +43 -12
  96. package/dist-types/stepper-input/useStepperInput.d.ts +7 -288
  97. package/package.json +2 -2
  98. package/dist-cjs/stepper-input/internal/useActivationIndicatorPosition.js +0 -38
  99. package/dist-cjs/stepper-input/internal/useActivationIndicatorPosition.js.map +0 -1
  100. package/dist-cjs/stepper-input/internal/useDynamicAriaLabel.js +0 -76
  101. package/dist-cjs/stepper-input/internal/useDynamicAriaLabel.js.map +0 -1
  102. package/dist-es/stepper-input/internal/useActivationIndicatorPosition.js +0 -34
  103. package/dist-es/stepper-input/internal/useActivationIndicatorPosition.js.map +0 -1
  104. package/dist-es/stepper-input/internal/useDynamicAriaLabel.js +0 -72
  105. package/dist-es/stepper-input/internal/useDynamicAriaLabel.js.map +0 -1
  106. package/dist-types/stepper-input/internal/useActivationIndicatorPosition.d.ts +0 -2
  107. package/dist-types/stepper-input/internal/useDynamicAriaLabel.d.ts +0 -3
@@ -9,9 +9,6 @@ var core = require('@salt-ds/core');
9
9
  var styles = require('@salt-ds/styles');
10
10
  var window = require('@salt-ds/window');
11
11
  var icons = require('@salt-ds/icons');
12
- var InputLegacy = require('../input-legacy/InputLegacy.js');
13
- require('../input-legacy/StaticInputAdornment.js');
14
- var useActivationIndicatorPosition = require('./internal/useActivationIndicatorPosition.js');
15
12
  var useStepperInput = require('./useStepperInput.js');
16
13
  var StepperInput$1 = require('./StepperInput.css.js');
17
14
 
@@ -19,11 +16,13 @@ const withBaseName = core.makePrefixer("saltStepperInput");
19
16
  const StepperInput = React.forwardRef(
20
17
  function StepperInput2(props, ref) {
21
18
  const {
22
- ButtonProps: ButtonPropsProp,
23
- InputProps: InputPropsProp,
24
- textAlign = "left",
25
19
  className,
26
- showRefreshButton = false
20
+ hideButtons,
21
+ onBlur,
22
+ onChange,
23
+ onFocus,
24
+ readOnly,
25
+ ...rest
27
26
  } = props;
28
27
  const targetWindow = window.useWindow();
29
28
  styles.useComponentCssInjection({
@@ -31,90 +30,42 @@ const StepperInput = React.forwardRef(
31
30
  css: StepperInput$1,
32
31
  window: targetWindow
33
32
  });
34
- const adornmentRef = React.useRef(null);
35
33
  const inputRef = React.useRef(null);
36
- const {
37
- decrementButtonDown,
38
- getButtonIcon,
39
- getButtonProps,
40
- getInputProps,
41
- incrementButtonDown,
42
- isAtMax,
43
- isAtMin,
44
- refreshCurrentValue,
45
- stepperDirection,
46
- valuesHaveDiverged
47
- } = useStepperInput.useStepperInput(props, inputRef);
48
- useActivationIndicatorPosition.useActivationIndicatorPosition(
49
- adornmentRef,
50
- valuesHaveDiverged() || showRefreshButton
51
- );
52
- const endAdornment = /* @__PURE__ */ jsxRuntime.jsxs("div", {
53
- className: withBaseName("adornmentContainer"),
54
- ref: adornmentRef,
34
+ const { getButtonProps, getInputProps } = useStepperInput.useStepperInput(props, inputRef);
35
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", {
36
+ className: clsx.clsx(withBaseName(), className),
37
+ ref,
55
38
  children: [
56
- /* @__PURE__ */ jsxRuntime.jsx(core.Button, {
57
- "aria-label": "Refresh default value",
58
- className: clsx.clsx(withBaseName("secondaryButton"), {
59
- [withBaseName("hideSecondaryButton")]: !(showRefreshButton || valuesHaveDiverged())
60
- }),
61
- onClick: refreshCurrentValue,
62
- variant: "secondary",
63
- children: /* @__PURE__ */ jsxRuntime.jsx(icons.RefreshIcon, {
64
- "aria-label": "refresh"
65
- })
39
+ /* @__PURE__ */ jsxRuntime.jsx(core.Input, {
40
+ onBlur,
41
+ onFocus,
42
+ ref: inputRef,
43
+ readOnly,
44
+ ...getInputProps(rest)
66
45
  }),
67
- /* @__PURE__ */ jsxRuntime.jsxs("div", {
46
+ !hideButtons && !readOnly && /* @__PURE__ */ jsxRuntime.jsxs("div", {
68
47
  className: withBaseName("buttonContainer"),
69
48
  children: [
70
49
  /* @__PURE__ */ jsxRuntime.jsx(core.Button, {
71
- className: clsx.clsx(
72
- withBaseName("stepperButton"),
73
- withBaseName("increment"),
74
- {
75
- active: incrementButtonDown
76
- }
77
- ),
78
- disabled: isAtMax(),
79
- ...getButtonProps(stepperDirection.INCREMENT, ButtonPropsProp),
50
+ "aria-label": "increment value",
51
+ className: withBaseName("stepperButton"),
52
+ ...getButtonProps("increment"),
80
53
  children: /* @__PURE__ */ jsxRuntime.jsx(icons.TriangleUpIcon, {
81
- className: withBaseName("stepperButtonIcon"),
82
- "aria-label": getButtonIcon(stepperDirection.INCREMENT)
54
+ "aria-hidden": true
83
55
  })
84
56
  }),
85
57
  /* @__PURE__ */ jsxRuntime.jsx(core.Button, {
86
- className: clsx.clsx(
87
- withBaseName("stepperButton"),
88
- withBaseName("decrement"),
89
- {
90
- active: decrementButtonDown
91
- }
92
- ),
93
- disabled: isAtMin(),
94
- ...getButtonProps(stepperDirection.DECREMENT, ButtonPropsProp),
58
+ "aria-label": "decrement value",
59
+ className: withBaseName("stepperButton"),
60
+ ...getButtonProps("decrement"),
95
61
  children: /* @__PURE__ */ jsxRuntime.jsx(icons.TriangleDownIcon, {
96
- className: withBaseName("stepperButtonIcon"),
97
- "aria-label": getButtonIcon(stepperDirection.DECREMENT)
62
+ "aria-hidden": true
98
63
  })
99
64
  })
100
65
  ]
101
66
  })
102
67
  ]
103
68
  });
104
- return /* @__PURE__ */ jsxRuntime.jsx("div", {
105
- className: clsx.clsx(withBaseName(), className),
106
- onBlur: props.onBlur,
107
- onFocus: props.onFocus,
108
- ref,
109
- children: /* @__PURE__ */ jsxRuntime.jsx(InputLegacy.InputLegacy, {
110
- className: withBaseName("input"),
111
- endAdornment,
112
- highlightOnFocus: true,
113
- ref: inputRef,
114
- textAlign,
115
- ...getInputProps(InputPropsProp)
116
- })
117
- });
118
69
  }
119
70
  );
120
71
 
@@ -1 +1 @@
1
- {"version":3,"file":"StepperInput.js","sources":["../src/stepper-input/StepperInput.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport React, { forwardRef, ReactNode, useRef } from \"react\";\nimport { Button, ButtonProps, makePrefixer } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { RefreshIcon, TriangleDownIcon, TriangleUpIcon } from \"@salt-ds/icons\";\nimport {\n InputLegacy as Input,\n InputLegacyProps as InputProps,\n} from \"../input-legacy\";\nimport { useActivationIndicatorPosition } from \"./internal/useActivationIndicatorPosition\";\nimport { useStepperInput } from \"./useStepperInput\";\n\nimport stepperInputCss from \"./StepperInput.css\";\n\nconst withBaseName = makePrefixer(\"saltStepperInput\");\n\nexport interface StepperInputProps {\n ButtonProps?: Partial<ButtonProps>;\n InputProps?: Partial<InputProps>;\n block?: number;\n className?: string;\n decimalPlaces?: number;\n defaultValue?: number;\n liveValue?: number;\n max?: number;\n min?: number;\n onBlur?: (event: React.FocusEvent<HTMLDivElement>) => void;\n onFocus?: (event: React.FocusEvent<HTMLDivElement>) => void;\n onChange?: (changedValue: number | string) => void;\n showRefreshButton?: boolean;\n step?: number;\n textAlign?: \"center\" | \"left\" | \"right\";\n value?: number | string;\n}\n\nexport const StepperInput = forwardRef<HTMLDivElement, StepperInputProps>(\n function StepperInput(props, ref) {\n const {\n ButtonProps: ButtonPropsProp,\n InputProps: InputPropsProp,\n textAlign = \"left\",\n className,\n showRefreshButton = false,\n } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-stepper-input\",\n css: stepperInputCss,\n window: targetWindow,\n });\n\n const adornmentRef = useRef<HTMLDivElement | null>(null);\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const {\n decrementButtonDown,\n getButtonIcon,\n getButtonProps,\n getInputProps,\n incrementButtonDown,\n isAtMax,\n isAtMin,\n refreshCurrentValue,\n stepperDirection,\n valuesHaveDiverged,\n } = useStepperInput(props, inputRef);\n\n useActivationIndicatorPosition(\n adornmentRef,\n valuesHaveDiverged() || showRefreshButton\n );\n\n const endAdornment: ReactNode = (\n <div className={withBaseName(\"adornmentContainer\")} ref={adornmentRef}>\n <Button\n aria-label=\"Refresh default value\"\n className={clsx(withBaseName(\"secondaryButton\"), {\n // Refresh button is always rendered and has its visibility toggled to\n // avoid component width changing.\n [withBaseName(\"hideSecondaryButton\")]: !(\n showRefreshButton || valuesHaveDiverged()\n ),\n })}\n onClick={refreshCurrentValue}\n variant=\"secondary\"\n >\n <RefreshIcon aria-label=\"refresh\" />\n </Button>\n <div className={withBaseName(\"buttonContainer\")}>\n <Button\n className={clsx(\n withBaseName(\"stepperButton\"),\n withBaseName(\"increment\"),\n {\n active: incrementButtonDown,\n }\n )}\n disabled={isAtMax()}\n {...getButtonProps(stepperDirection.INCREMENT, ButtonPropsProp)}\n >\n <TriangleUpIcon\n className={withBaseName(\"stepperButtonIcon\")}\n aria-label={getButtonIcon(stepperDirection.INCREMENT)}\n />\n </Button>\n <Button\n className={clsx(\n withBaseName(\"stepperButton\"),\n withBaseName(\"decrement\"),\n {\n active: decrementButtonDown,\n }\n )}\n disabled={isAtMin()}\n {...getButtonProps(stepperDirection.DECREMENT, ButtonPropsProp)}\n >\n <TriangleDownIcon\n className={withBaseName(\"stepperButtonIcon\")}\n aria-label={getButtonIcon(stepperDirection.DECREMENT)}\n />\n </Button>\n </div>\n </div>\n );\n\n return (\n <div\n className={clsx(withBaseName(), className)}\n onBlur={props.onBlur}\n onFocus={props.onFocus}\n ref={ref}\n >\n <Input\n className={withBaseName(\"input\")}\n endAdornment={endAdornment}\n highlightOnFocus\n ref={inputRef}\n textAlign={textAlign}\n {...getInputProps(InputPropsProp)}\n />\n </div>\n );\n }\n);\n"],"names":["makePrefixer","forwardRef","StepperInput","useWindow","useComponentCssInjection","stepperInputCss","useRef","useStepperInput","useActivationIndicatorPosition","jsxs","jsx","Button","clsx","RefreshIcon","TriangleUpIcon","TriangleDownIcon","Input"],"mappings":";;;;;;;;;;;;;;;;;AAeA,MAAM,YAAA,GAAeA,kBAAa,kBAAkB,CAAA,CAAA;AAqB7C,MAA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W,aAAa,mBAAmB,CAAA;AAAA,gBAC3C,YAAA,EAAY,aAAc,CAAA,gBAAA,CAAiB,SAAS,CAAA;AAAA,eACtD,CAAA;AAAA,aACF,CAAA;AAAA,WAAA;AAAA,SACF,CAAA;AAAA,OAAA;AAAA,KACF,CAAA,CAAA;AAGF,IAAA,uBACGL,cAAA,CAAA,KAAA,EAAA;AAAA,MACC,SAAW,EAAAE,SAAA,CAAK,YAAa,EAAA,EAAG,SAAS,CAAA;AAAA,MACzC,QAAQ,KAAM,CAAA,MAAA;AAAA,MACd,SAAS,KAAM,CAAA,OAAA;AAAA,MACf,GAAA;AAAA,MAEA,QAAC,kBAAAF,cAAA,CAAAM,uBAAA,EAAA;AAAA,QACC,SAAA,EAAW,aAAa,OAAO,CAAA;AAAA,QAC/B,YAAA;AAAA,QACA,gBAAgB,EAAA,IAAA;AAAA,QAChB,GAAK,EAAA,QAAA;AAAA,QACL,SAAA;AAAA,QACC,GAAG,cAAc,cAAc,CAAA;AAAA,OAClC,CAAA;AAAA,KACF,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
1
+ {"version":3,"file":"StepperInput.js","sources":["../src/stepper-input/StepperInput.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport { FocusEventHandler, forwardRef, useRef } from \"react\";\nimport { Button, makePrefixer, Input, InputProps } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { TriangleDownIcon, TriangleUpIcon } from \"@salt-ds/icons\";\nimport { useStepperInput } from \"./useStepperInput\";\n\nimport stepperInputCss from \"./StepperInput.css\";\n\nconst withBaseName = makePrefixer(\"saltStepperInput\");\n\nexport interface StepperInputProps\n extends Omit<InputProps, \"onChange\" | \"emptyReadOnlyMarker\"> {\n /**\n * A multiplier applied to the `step` when the value is incremented or decremented using the PageDown/PageUp keys.\n */\n block?: number;\n /**\n * The number of decimal places to display.\n */\n decimalPlaces?: number;\n /**\n * Sets the initial default value of the component.\n */\n defaultValue?: number;\n /**\n * The maximum value that can be selected.\n */\n max?: number;\n /**\n * The minimum value that can be selected.\n */\n min?: number;\n /**\n * Whether to hide the stepper buttons. Defaults to `false`.\n */\n hideButtons?: boolean;\n /**\n * Callback when stepper input loses focus.\n */\n onBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Callback when stepper input value is changed.\n */\n onChange?: (changedValue: number | string) => void;\n /**\n * Callback when stepper input gains focus.\n */\n onFocus?: FocusEventHandler<HTMLInputElement>;\n /**\n * The amount to increment or decrement the value by when using the stepper buttons or Up Arrow and Down Arrow keys.\n */\n step?: number;\n /**\n * Determines the text alignment of the display value.\n */\n textAlign?: \"center\" | \"left\" | \"right\";\n /**\n * The value of the stepper input. The component will be controlled if this prop is provided.\n */\n value?: number | string;\n}\n\nexport const StepperInput = forwardRef<HTMLDivElement, StepperInputProps>(\n function StepperInput(props, ref) {\n const {\n className,\n hideButtons,\n onBlur,\n onChange,\n onFocus,\n readOnly,\n ...rest\n } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-stepper-input\",\n css: stepperInputCss,\n window: targetWindow,\n });\n\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const { getButtonProps, getInputProps } = useStepperInput(props, inputRef);\n\n return (\n <div className={clsx(withBaseName(), className)} ref={ref}>\n <Input\n onBlur={onBlur}\n onFocus={onFocus}\n ref={inputRef}\n readOnly={readOnly}\n {...getInputProps(rest)}\n />\n {!hideButtons && !readOnly && (\n <div className={withBaseName(\"buttonContainer\")}>\n <Button\n aria-label=\"increment value\"\n className={withBaseName(\"stepperButton\")}\n {...getButtonProps(\"increment\")}\n >\n <TriangleUpIcon aria-hidden />\n </Button>\n <Button\n aria-label=\"decrement value\"\n className={withBaseName(\"stepperButton\")}\n {...getButtonProps(\"decrement\")}\n >\n <TriangleDownIcon aria-hidden />\n </Button>\n </div>\n )}\n </div>\n );\n }\n);\n"],"names":["makePrefixer","forwardRef","StepperInput","useWindow","useCom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AA,4BAACE,cAAA,CAAAE,WAAA,EAAA;AAAA,cACC,YAAW,EAAA,iBAAA;AAAA,cACX,SAAA,EAAW,aAAa,eAAe,CAAA;AAAA,cACtC,GAAG,eAAe,WAAW,CAAA;AAAA,cAE9B,QAAC,kBAAAF,cAAA,CAAAG,oBAAA,EAAA;AAAA,gBAAe,aAAW,EAAA,IAAA;AAAA,eAAC,CAAA;AAAA,aAC9B,CAAA;AAAA,4BACCH,cAAA,CAAAE,WAAA,EAAA;AAAA,cACC,YAAW,EAAA,iBAAA;AAAA,cACX,SAAA,EAAW,aAAa,eAAe,CAAA;AAAA,cACtC,GAAG,eAAe,WAAW,CAAA;AAAA,cAE9B,QAAC,kBAAAF,cAAA,CAAAI,sBAAA,EAAA;AAAA,gBAAiB,aAAW,EAAA,IAAA;AAAA,eAAC,CAAA;AAAA,aAChC,CAAA;AAAA,WAAA;AAAA,SACF,CAAA;AAAA,OAAA;AAAA,KAEJ,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
@@ -3,13 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var core = require('@salt-ds/core');
6
- var useDynamicAriaLabel = require('./internal/useDynamicAriaLabel.js');
7
6
  var useSpinner = require('./internal/useSpinner.js');
8
7
 
9
- const stepperDirection = {
10
- INCREMENT: "increment",
11
- DECREMENT: "decrement"
12
- };
13
8
  const ACCEPT_INPUT = /^[-+]?[0-9]*\.?([0-9]+)?/g;
14
9
  const callAll = (...fns) => (...args) => fns.forEach((fn) => fn && fn(...args));
15
10
  const toFixedDecimalPlaces = (inputNumber, decimalPlaces) => inputNumber.toFixed(decimalPlaces);
@@ -23,27 +18,25 @@ const toFloat = (inputValue) => {
23
18
  return 0;
24
19
  return parseFloat(inputValue.toString());
25
20
  };
26
- const santizedInput = (numberString) => (numberString.match(ACCEPT_INPUT) || []).join("");
27
- const getButtonIcon = (type) => type === stepperDirection.INCREMENT ? "triangle-up" : "triangle-down";
21
+ const sanitizedInput = (numberString) => (numberString.match(ACCEPT_INPUT) || []).join("");
28
22
  const useStepperInput = (props, inputRef) => {
29
23
  const {
30
24
  block = 10,
31
25
  decimalPlaces = 0,
32
26
  defaultValue = 0,
33
- liveValue,
27
+ id: idProp,
34
28
  max = Number.MAX_SAFE_INTEGER,
35
29
  min = Number.MIN_SAFE_INTEGER,
36
30
  onChange,
37
31
  step = 1,
38
- value,
39
- InputProps: inputPropsProp = {}
32
+ value
40
33
  } = props;
41
34
  const [currentValue, setCurrentValue, isControlled] = core.useControlled({
42
35
  controlled: value,
43
36
  default: toFixedDecimalPlaces(defaultValue, decimalPlaces),
44
37
  name: "stepper-input"
45
38
  });
46
- const inputId = core.useId(inputPropsProp.id);
39
+ const inputId = core.useId(idProp);
47
40
  const isOutOfRange = () => {
48
41
  if (currentValue === void 0)
49
42
  return true;
@@ -59,18 +52,6 @@ const useStepperInput = (props, inputRef) => {
59
52
  return true;
60
53
  return toFloat(currentValue) <= min || min === 0 && currentValue === "";
61
54
  };
62
- const valuesHaveDiverged = () => {
63
- if (liveValue === void 0 || currentValue === void 0)
64
- return false;
65
- return toFloat(toFixedDecimalPlaces(liveValue, decimalPlaces)) !== toFloat(currentValue);
66
- };
67
- const { setHasAnnounced } = useDynamicAriaLabel.useDynamicAriaLabel(
68
- ", value out of date",
69
- liveValue !== void 0,
70
- inputRef,
71
- currentValue,
72
- valuesHaveDiverged
73
- );
74
55
  const decrement = () => {
75
56
  if (currentValue === void 0 || isAtMin())
76
57
  return;
@@ -104,6 +85,8 @@ const useStepperInput = (props, inputRef) => {
104
85
  setNextValue(nextValue);
105
86
  };
106
87
  const setNextValue = (modifiedValue) => {
88
+ if (props.readOnly)
89
+ return;
107
90
  let nextValue = modifiedValue;
108
91
  if (nextValue < min)
109
92
  nextValue = min;
@@ -137,16 +120,13 @@ const useStepperInput = (props, inputRef) => {
137
120
  onChange(roundedValue);
138
121
  }
139
122
  };
140
- const handleInputFocus = () => {
141
- setHasAnnounced(false);
142
- };
143
123
  const handleInputChange = (event) => {
144
- const changedValue = event.currentTarget.value;
124
+ const changedValue = event.target.value;
145
125
  if (!isControlled) {
146
- setCurrentValue(santizedInput(changedValue));
126
+ setCurrentValue(sanitizedInput(changedValue));
147
127
  }
148
128
  if (onChange) {
149
- onChange(santizedInput(changedValue));
129
+ onChange(sanitizedInput(changedValue));
150
130
  }
151
131
  };
152
132
  const handleInputKeyDown = (event) => {
@@ -159,40 +139,21 @@ const useStepperInput = (props, inputRef) => {
159
139
  event.key === "PageUp" ? incrementSpinnerBlock() : decrementSpinnerBlock();
160
140
  }
161
141
  };
162
- const handleButtonMouseDown = (event, type = stepperDirection.INCREMENT) => {
142
+ const handleButtonMouseDown = (event, direction) => {
163
143
  if (event.nativeEvent.button !== 0)
164
144
  return;
165
- type === stepperDirection.INCREMENT ? incrementSpinner() : decrementSpinner();
145
+ direction === "increment" ? incrementSpinner() : decrementSpinner();
166
146
  };
167
147
  const handleButtonMouseUp = () => {
168
148
  var _a;
169
149
  return (_a = inputRef.current) == null ? void 0 : _a.focus();
170
150
  };
171
- const refreshCurrentValue = () => {
172
- var _a;
173
- const refreshedcurrentValue = liveValue !== void 0 ? liveValue : defaultValue;
174
- if (refreshedcurrentValue === void 0)
175
- return;
176
- setCurrentValue(
177
- toFixedDecimalPlaces(toFloat(refreshedcurrentValue), decimalPlaces)
178
- );
179
- (_a = inputRef.current) == null ? void 0 : _a.focus();
180
- if (onChange) {
181
- onChange(
182
- toFixedDecimalPlaces(toFloat(refreshedcurrentValue), decimalPlaces)
183
- );
184
- }
185
- };
186
- const getButtonProps = (type = stepperDirection.INCREMENT, buttonPropsProp = {}) => ({
151
+ const getButtonProps = (direction) => ({
187
152
  "aria-hidden": true,
188
- "data-testid": `${type}-button`,
153
+ disabled: props.disabled || (direction === "increment" ? isAtMax() : isAtMin()),
189
154
  tabIndex: -1,
190
- ...buttonPropsProp,
191
- onMouseDown: callAll(
192
- (event) => handleButtonMouseDown(event, type),
193
- buttonPropsProp.onMouseDown
194
- ),
195
- onMouseUp: callAll(() => handleButtonMouseUp(), buttonPropsProp.onMouseUp)
155
+ onMouseDown: (event) => handleButtonMouseDown(event, direction),
156
+ onMouseUp: handleButtonMouseUp
196
157
  });
197
158
  const getInputProps = (inputProps = {}) => {
198
159
  if (currentValue === void 0)
@@ -212,22 +173,17 @@ const useStepperInput = (props, inputRef) => {
212
173
  },
213
174
  onBlur: callAll(inputProps.onBlur, handleInputBlur),
214
175
  onChange: callAll(inputProps.onChange, handleInputChange),
215
- onFocus: callAll(inputProps.onFocus, handleInputFocus),
216
- onKeyDown: callAll(inputProps.onKeyPress, handleInputKeyDown),
176
+ onFocus: inputProps.onFocus,
177
+ onKeyDown: callAll(inputProps.onKeyDown, handleInputKeyDown),
178
+ textAlign: inputProps.textAlign,
217
179
  value: String(currentValue)
218
180
  };
219
181
  };
220
182
  return {
221
183
  decrementButtonDown: arrowDownButtonDown || pgDnButtonDown,
222
- getButtonIcon,
223
184
  getButtonProps,
224
185
  getInputProps,
225
- incrementButtonDown: arrowUpButtonDown || pgUpButtonDown,
226
- isAtMax,
227
- isAtMin,
228
- refreshCurrentValue,
229
- stepperDirection,
230
- valuesHaveDiverged
186
+ incrementButtonDown: arrowUpButtonDown || pgUpButtonDown
231
187
  };
232
188
  };
233
189
 
@@ -1 +1 @@
1
- {"version":3,"file":"useStepperInput.js","sources":["../src/stepper-input/useStepperInput.ts"],"sourcesContent":["import { KeyboardEvent, MouseEvent, MutableRefObject } from \"react\";\nimport { ButtonProps, useControlled, useId } from \"@salt-ds/core\";\nimport { InputLegacyProps as InputProps } from \"../input-legacy\";\nimport { useDynamicAriaLabel } from \"./internal/useDynamicAriaLabel\";\nimport { useSpinner } from \"./internal/useSpinner\";\nimport { StepperInputProps } from \"./StepperInput\";\n\ntype Direction = \"decrement\" | \"increment\";\n\nconst stepperDirection = {\n INCREMENT: \"increment\" as Direction,\n DECREMENT: \"decrement\" as Direction,\n};\n\n// The input should only accept numbers, decimal points, and plus/minus symbols\nconst ACCEPT_INPUT = /^[-+]?[0-9]*\\.?([0-9]+)?/g;\n\nconst callAll =\n (...fns: any[]) =>\n (...args: any[]) =>\n fns.forEach((fn) => fn && fn(...args));\n\nconst toFixedDecimalPlaces = (inputNumber: number, decimalPlaces: number) =>\n inputNumber.toFixed(decimalPlaces);\n\nconst isAllowedNonNumeric = (inputCharacter: number | string) => {\n if (typeof inputCharacter === \"number\") return;\n return (\n (\"-+\".includes(inputCharacter) && inputCharacter.length === 1) ||\n inputCharacter === \"\"\n );\n};\n\nconst toFloat = (inputValue: number | string) => {\n // Plus, minus, and empty characters are treated as 0\n if (isAllowedNonNumeric(inputValue)) return 0;\n return parseFloat(inputValue.toString());\n};\n\nconst santizedInput = (numberString: string) =>\n (numberString.match(ACCEPT_INPUT) || []).join(\"\");\n\nconst getButtonIcon = (type: Direction) =>\n type === stepperDirection.INCREMENT ? \"triangle-up\" : \"triangle-down\";\n\nexport const useStepperInput = (\n props: StepperInputProps,\n inputRef: MutableRefObject<HTMLInputElement | null>\n) => {\n const {\n block = 10,\n decimalPlaces = 0,\n defaultValue = 0,\n liveValue,\n max = Number.MAX_SAFE_INTEGER,\n min = Number.MIN_SAFE_INTEGER,\n onChange,\n step = 1,\n value,\n InputProps: inputPropsProp = {},\n } = props;\n\n const [currentValue, setCurrentValue, isControlled] = useControlled({\n controlled: value,\n default: toFixedDecimalPlaces(defaultValue, decimalPlaces),\n name: \"stepper-input\",\n });\n const inputId = useId(inputPropsProp.id);\n\n const isOutOfRange = () => {\n if (currentValue === undefined) return true;\n return toFloat(currentValue) > max || toFloat(currentValue) < min;\n };\n\n const isAtMax = () => {\n if (currentValue === undefined) return true;\n return toFloat(currentValue) >= max || (max === 0 && currentValue === \"\");\n };\n\n const isAtMin = () => {\n if (currentValue === undefined) return true;\n return toFloat(currentValue) <= min || (min === 0 && currentValue === \"\");\n };\n\n const valuesHaveDiverged = () => {\n if (liveValue === undefined || currentValue === undefined) return false;\n return (\n toFloat(toFixedDecimalPlaces(liveValue, decimalPlaces)) !==\n toFloat(currentValue)\n );\n };\n\n const { setHasAnnounced } = useDynamicAriaLabel(\n \", value out of date\",\n liveValue !== undefined,\n inputRef,\n currentValue,\n valuesHaveDiverged\n );\n\n const decrement = () => {\n if (currentValue === undefined || isAtMin()) return;\n let nextValue = currentValue === \"\" ? -step : toFloat(currentValue) - step;\n\n // Set value to `max` if it's currently out of range\n if (max !== undefined && isOutOfRange()) nextValue = max;\n\n setNextValue(nextValue);\n };\n\n const decrementBlock = () => {\n if (currentValue === undefined || isAtMin()) return;\n let nextValue =\n currentValue === \"\"\n ? block * -step\n : toFloat(currentValue) - step * block;\n\n // Set value to `max` if it's currently out of range\n if (max !== undefined && isOutOfRange()) nextValue = max;\n\n setNextValue(nextValue);\n };\n\n const increment = () => {\n if (currentValue === undefined || isAtMax()) return;\n let nextValue = currentValue === \"\" ? step : toFloat(currentValue) + step;\n\n // Set value to `min` if it's currently out of range\n if (min !== undefined && isOutOfRange()) nextValue = min;\n\n setNextValue(nextValue);\n };\n\n const incrementBlock = () => {\n if (currentValue === undefined || isAtMax()) return;\n let nextValue =\n currentValue === \"\" ? block * step : toFloat(currentValue) + step * block;\n\n // Set value to `min` if it's currently out of range\n if (min !== undefined && isOutOfRange()) nextValue = min;\n\n setNextValue(nextValue);\n };\n\n const setNextValue = (modifiedValue: number) => {\n let nextValue = modifiedValue;\n if (nextValue < min) nextValue = min;\n if (nextValue > max) nextValue = max;\n\n const roundedValue = toFixedDecimalPlaces(nextValue, decimalPlaces);\n if (isNaN(toFloat(roundedValue))) return;\n\n if (!isControlled) {\n setCurrentValue(roundedValue);\n }\n\n if (onChange) {\n onChange(roundedValue);\n }\n };\n\n const { activate: decrementSpinnerBlock, buttonDown: pgDnButtonDown } =\n useSpinner(decrementBlock, isAtMin());\n\n const { activate: decrementSpinner, buttonDown: arrowDownButtonDown } =\n useSpinner(decrement, isAtMin());\n\n const { activate: incrementSpinnerBlock, buttonDown: pgUpButtonDown } =\n useSpinner(incrementBlock, isAtMax());\n\n const { activate: incrementSpinner, buttonDown: arrowUpButtonDown } =\n useSpinner(increment, isAtMax());\n\n const handleInputBlur = () => {\n if (currentValue === undefined) return;\n\n const roundedValue = toFixedDecimalPlaces(\n toFloat(currentValue),\n decimalPlaces\n );\n\n if (\n currentValue !== \"\" &&\n !isAllowedNonNumeric(currentValue) &&\n !isControlled\n ) {\n setCurrentValue(roundedValue);\n }\n\n if (onChange) {\n onChange(roundedValue);\n }\n };\n\n const handleInputFocus = () => {\n setHasAnnounced(false);\n };\n\n const handleInputChange = (event: KeyboardEvent) => {\n const changedValue = (event.currentTarget as HTMLInputElement).value;\n\n if (!isControlled) {\n setCurrentValue(santizedInput(changedValue));\n }\n\n if (onChange) {\n onChange(santizedInput(changedValue));\n }\n };\n\n const handleInputKeyDown = (event: KeyboardEvent) => {\n if ([\"ArrowUp\", \"ArrowDown\"].includes(event.key)) {\n event.preventDefault();\n event.key === \"ArrowUp\" ? incrementSpinner() : decrementSpinner();\n }\n if ([\"PageUp\", \"PageDown\"].includes(event.key)) {\n event.preventDefault();\n event.key === \"PageUp\"\n ? incrementSpinnerBlock()\n : decrementSpinnerBlock();\n }\n };\n\n const handleButtonMouseDown = (\n event: MouseEvent<HTMLButtonElement>,\n type: Direction = stepperDirection.INCREMENT\n ) => {\n if (event.nativeEvent.button !== 0) return;\n type === stepperDirection.INCREMENT\n ? incrementSpinner()\n : decrementSpinner();\n };\n\n const handleButtonMouseUp = () => inputRef.current?.focus();\n\n const refreshCurrentValue = () => {\n const refreshedcurrentValue =\n liveValue !== undefined ? liveValue : defaultValue;\n if (refreshedcurrentValue === undefined) return;\n\n setCurrentValue(\n toFixedDecimalPlaces(toFloat(refreshedcurrentValue), decimalPlaces)\n );\n\n inputRef.current?.focus();\n\n if (onChange) {\n onChange(\n toFixedDecimalPlaces(toFloat(refreshedcurrentValue), decimalPlaces)\n );\n }\n };\n\n const getButtonProps = (\n type: Direction = stepperDirection.INCREMENT,\n buttonPropsProp: ButtonProps = {}\n ) => ({\n \"aria-hidden\": true,\n \"data-testid\": `${type}-button`,\n tabIndex: -1,\n ...buttonPropsProp,\n onMouseDown: callAll(\n (event: MouseEvent<HTMLButtonElement>) =>\n handleButtonMouseDown(event, type),\n buttonPropsProp.onMouseDown\n ),\n onMouseUp: callAll(() => handleButtonMouseUp(), buttonPropsProp.onMouseUp),\n });\n\n const getInputProps = (\n inputProps: InputProps = {}\n ): InputProps | undefined => {\n if (currentValue === undefined) return undefined;\n return {\n ...inputProps,\n inputProps: {\n role: \"spinbutton\",\n \"aria-invalid\": isOutOfRange(),\n \"aria-valuemax\": toFloat(toFixedDecimalPlaces(max, decimalPlaces)),\n \"aria-valuemin\": toFloat(toFixedDecimalPlaces(min, decimalPlaces)),\n \"aria-valuenow\": toFloat(\n toFixedDecimalPlaces(toFloat(currentValue), decimalPlaces)\n ),\n id: inputId,\n ...inputProps.inputProps,\n },\n onBlur: callAll(inputProps.onBlur, handleInputBlur),\n onChange: callAll(inputProps.onChange, handleInputChange),\n onFocus: callAll(inputProps.onFocus, handleInputFocus),\n onKeyDown: callAll(inputProps.onKeyPress, handleInputKeyDown),\n value: String(currentValue),\n };\n };\n\n return {\n decrementButtonDown: arrowDownButtonDown || pgDnButtonDown,\n getButtonIcon,\n getButtonProps,\n getInputProps,\n incrementButtonDown: arrowUpButtonDown || pgUpButtonDown,\n isAtMax,\n isAtMin,\n refreshCurrentValue,\n stepperDirection,\n valuesHaveDiverged,\n };\n};\n"],"names":["useControlled","useId","useDynamicAriaLabel","useSpinner"],"mappings":";;;;;;;;AASA,MAAM,gBAAmB,GAAA;AAAA,EACvB,SAAW,EAAA,WAAA;AAAA,EACX,SAAW,EAAA,WAAA;AACb,CAAA,CAAA;AAGA,MAAM,YAAe,GAAA,2BAAA,CAAA;AAErB,MAAM,OACJ,GAAA,CAAA,GAAI,GACJ,KAAA,CAAA,GAAI,IACF,KAAA,GAAA,CAAI,OAAQ,CAAA,CAAC,EAAO,KAAA,EAAA,IAAM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;AAAA,QACJ,GAAG,UAAW,CAAA,UAAA;AAAA,OAChB;AAAA,MACA,MAAQ,EAAA,OAAA,CAAQ,UAAW,CAAA,MAAA,EAAQ,eAAe,CAAA;AAAA,MAClD,QAAU,EAAA,OAAA,CAAQ,UAAW,CAAA,QAAA,EAAU,iBAAiB,CAAA;AAAA,MACxD,OAAS,EAAA,OAAA,CAAQ,UAAW,CAAA,OAAA,EAAS,gBAAgB,CAAA;AAAA,MACrD,SAAW,EAAA,OAAA,CAAQ,UAAW,CAAA,UAAA,EAAY,kBAAkB,CAAA;AAAA,MAC5D,KAAA,EAAO,OAAO,YAAY,CAAA;AAAA,KAC5B,CAAA;AAAA,GACF,CAAA;AAEA,EAAO,OAAA;AAAA,IACL,qBAAqB,mBAAuB,IAAA,cAAA;AAAA,IAC5C,aAAA;AAAA,IACA,cAAA;AAAA,IACA,aAAA;AAAA,IACA,qBAAqB,iBAAqB,IAAA,cAAA;AAAA,IAC1C,OAAA;AAAA,IACA,OAAA;AAAA,IACA,mBAAA;AAAA,IACA,gBAAA;AAAA,IACA,kBAAA;AAAA,GACF,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"useStepperInput.js","sources":["../src/stepper-input/useStepperInput.ts"],"sourcesContent":["import {\n ChangeEvent,\n KeyboardEvent,\n MouseEvent,\n MutableRefObject,\n} from \"react\";\nimport { useControlled, useId, InputProps } from \"@salt-ds/core\";\nimport { useSpinner } from \"./internal/useSpinner\";\nimport { StepperInputProps } from \"./StepperInput\";\n\n// The input should only accept numbers, decimal points, and plus/minus symbols\nconst ACCEPT_INPUT = /^[-+]?[0-9]*\\.?([0-9]+)?/g;\n\nconst callAll =\n (...fns: any[]) =>\n (...args: any[]) =>\n fns.forEach((fn) => fn && fn(...args));\n\nconst toFixedDecimalPlaces = (inputNumber: number, decimalPlaces: number) =>\n inputNumber.toFixed(decimalPlaces);\n\nconst isAllowedNonNumeric = (inputCharacter: number | string) => {\n if (typeof inputCharacter === \"number\") return;\n return (\n (\"-+\".includes(inputCharacter) && inputCharacter.length === 1) ||\n inputCharacter === \"\"\n );\n};\n\nconst toFloat = (inputValue: number | string) => {\n // Plus, minus, and empty characters are treated as 0\n if (isAllowedNonNumeric(inputValue)) return 0;\n return parseFloat(inputValue.toString());\n};\n\nconst sanitizedInput = (numberString: string) =>\n (numberString.match(ACCEPT_INPUT) || []).join(\"\");\n\nexport const useStepperInput = (\n props: StepperInputProps,\n inputRef: MutableRefObject<HTMLInputElement | null>\n) => {\n const {\n block = 10,\n decimalPlaces = 0,\n defaultValue = 0,\n id: idProp,\n max = Number.MAX_SAFE_INTEGER,\n min = Number.MIN_SAFE_INTEGER,\n onChange,\n step = 1,\n value,\n } = props;\n\n const [currentValue, setCurrentValue, isControlled] = useControlled({\n controlled: value,\n default: toFixedDecimalPlaces(defaultValue, decimalPlaces),\n name: \"stepper-input\",\n });\n const inputId = useId(idProp);\n\n const isOutOfRange = () => {\n if (currentValue === undefined) return true;\n return toFloat(currentValue) > max || toFloat(currentValue) < min;\n };\n\n const isAtMax = () => {\n if (currentValue === undefined) return true;\n return toFloat(currentValue) >= max || (max === 0 && currentValue === \"\");\n };\n\n const isAtMin = () => {\n if (currentValue === undefined) return true;\n return toFloat(currentValue) <= min || (min === 0 && currentValue === \"\");\n };\n\n const decrement = () => {\n if (currentValue === undefined || isAtMin()) return;\n let nextValue = currentValue === \"\" ? -step : toFloat(currentValue) - step;\n\n // Set value to `max` if it's currently out of range\n if (max !== undefined && isOutOfRange()) nextValue = max;\n\n setNextValue(nextValue);\n };\n\n const decrementBlock = () => {\n if (currentValue === undefined || isAtMin()) return;\n let nextValue =\n currentValue === \"\"\n ? block * -step\n : toFloat(currentValue) - step * block;\n\n // Set value to `max` if it's currently out of range\n if (max !== undefined && isOutOfRange()) nextValue = max;\n\n setNextValue(nextValue);\n };\n\n const increment = () => {\n if (currentValue === undefined || isAtMax()) return;\n let nextValue = currentValue === \"\" ? step : toFloat(currentValue) + step;\n\n // Set value to `min` if it's currently out of range\n if (min !== undefined && isOutOfRange()) nextValue = min;\n\n setNextValue(nextValue);\n };\n\n const incrementBlock = () => {\n if (currentValue === undefined || isAtMax()) return;\n let nextValue =\n currentValue === \"\" ? block * step : toFloat(currentValue) + step * block;\n\n // Set value to `min` if it's currently out of range\n if (min !== undefined && isOutOfRange()) nextValue = min;\n\n setNextValue(nextValue);\n };\n\n const setNextValue = (modifiedValue: number) => {\n if (props.readOnly) return;\n let nextValue = modifiedValue;\n if (nextValue < min) nextValue = min;\n if (nextValue > max) nextValue = max;\n\n const roundedValue = toFixedDecimalPlaces(nextValue, decimalPlaces);\n if (isNaN(toFloat(roundedValue))) return;\n\n if (!isControlled) {\n setCurrentValue(roundedValue);\n }\n\n if (onChange) {\n onChange(roundedValue);\n }\n };\n\n const { activate: decrementSpinnerBlock, buttonDown: pgDnButtonDown } =\n useSpinner(decrementBlock, isAtMin());\n\n const { activate: decrementSpinner, buttonDown: arrowDownButtonDown } =\n useSpinner(decrement, isAtMin());\n\n const { activate: incrementSpinnerBlock, buttonDown: pgUpButtonDown } =\n useSpinner(incrementBlock, isAtMax());\n\n const { activate: incrementSpinner, buttonDown: arrowUpButtonDown } =\n useSpinner(increment, isAtMax());\n\n const handleInputBlur = () => {\n if (currentValue === undefined) return;\n\n const roundedValue = toFixedDecimalPlaces(\n toFloat(currentValue),\n decimalPlaces\n );\n\n if (\n currentValue !== \"\" &&\n !isAllowedNonNumeric(currentValue) &&\n !isControlled\n ) {\n setCurrentValue(roundedValue);\n }\n\n if (onChange) {\n onChange(roundedValue);\n }\n };\n\n const handleInputChange = (event: ChangeEvent<HTMLInputElement>) => {\n const changedValue = event.target.value;\n\n if (!isControlled) {\n setCurrentValue(sanitizedInput(changedValue));\n }\n\n if (onChange) {\n onChange(sanitizedInput(changedValue));\n }\n };\n\n const handleInputKeyDown = (event: KeyboardEvent) => {\n if ([\"ArrowUp\", \"ArrowDown\"].includes(event.key)) {\n event.preventDefault();\n event.key === \"ArrowUp\" ? incrementSpinner() : decrementSpinner();\n }\n if ([\"PageUp\", \"PageDown\"].includes(event.key)) {\n event.preventDefault();\n event.key === \"PageUp\"\n ? incrementSpinnerBlock()\n : decrementSpinnerBlock();\n }\n };\n\n const handleButtonMouseDown = (\n event: MouseEvent<HTMLButtonElement>,\n direction: string\n ) => {\n if (event.nativeEvent.button !== 0) return;\n direction === \"increment\" ? incrementSpinner() : decrementSpinner();\n };\n\n const handleButtonMouseUp = () => inputRef.current?.focus();\n\n const getButtonProps = (direction: string) => ({\n \"aria-hidden\": true,\n disabled:\n props.disabled || (direction === \"increment\" ? isAtMax() : isAtMin()),\n tabIndex: -1,\n onMouseDown: (event: MouseEvent<HTMLButtonElement>) =>\n handleButtonMouseDown(event, direction),\n onMouseUp: handleButtonMouseUp,\n });\n\n const getInputProps = (\n inputProps: InputProps = {}\n ): InputProps | undefined => {\n if (currentValue === undefined) return undefined;\n return {\n ...inputProps,\n inputProps: {\n role: \"spinbutton\",\n \"aria-invalid\": isOutOfRange(),\n \"aria-valuemax\": toFloat(toFixedDecimalPlaces(max, decimalPlaces)),\n \"aria-valuemin\": toFloat(toFixedDecimalPlaces(min, decimalPlaces)),\n \"aria-valuenow\": toFloat(\n toFixedDecimalPlaces(toFloat(currentValue), decimalPlaces)\n ),\n id: inputId,\n ...inputProps.inputProps,\n },\n onBlur: callAll(inputProps.onBlur, handleInputBlur),\n onChange: callAll(inputProps.onChange, handleInputChange),\n onFocus: inputProps.onFocus,\n onKeyDown: callAll(inputProps.onKeyDown, handleInputKeyDown),\n textAlign: inputProps.textAlign,\n value: String(currentValue),\n };\n };\n\n return {\n decrementButtonDown: arrowDownButtonDown || pgDnButtonDown,\n getButtonProps,\n getInputProps,\n incrementButtonDown: arrowUpButtonDown || pgUpButtonDown,\n };\n};\n"],"names":["useControlled","useId","useSpinner"],"mappings":";;;;;;;AAWA,MAAM,YAAe,GAAA,2BAAA,CAAA;AAErB,MAAM,OACJ,GAAA,CAAA,GAAI,GACJ,KAAA,CAAA,GAAI,IACF,K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,UAAW,CAAA,MAAA,EAAQ,eAAe,CAAA;AAAA,MAClD,QAAU,EAAA,OAAA,CAAQ,UAAW,CAAA,QAAA,EAAU,iBAAiB,CAAA;AAAA,MACxD,SAAS,UAAW,CAAA,OAAA;AAAA,MACpB,SAAW,EAAA,OAAA,CAAQ,UAAW,CAAA,SAAA,EAAW,kBAAkB,CAAA;AAAA,MAC3D,WAAW,UAAW,CAAA,SAAA;AAAA,MACtB,KAAA,EAAO,OAAO,YAAY,CAAA;AAAA,KAC5B,CAAA;AAAA,GACF,CAAA;AAEA,EAAO,OAAA;AAAA,IACL,qBAAqB,mBAAuB,IAAA,cAAA;AAAA,IAC5C,cAAA;AAAA,IACA,aAAA;AAAA,IACA,qBAAqB,iBAAqB,IAAA,cAAA;AAAA,GAC5C,CAAA;AACF;;;;"}
@@ -10,6 +10,8 @@ import { useCalendar } from './useCalendar.js';
10
10
  import { useWindow } from '@salt-ds/window';
11
11
  import { useComponentCssInjection } from '@salt-ds/styles';
12
12
  import css_248z from './Calendar.css.js';
13
+ import { DateFormatter, getLocalTimeZone } from '@internationalized/date';
14
+ import { getCurrentLocale } from './internal/utils.js';
13
15
 
14
16
  const withBaseName = makePrefixer("saltCalendar");
15
17
  const Calendar = forwardRef(
@@ -35,6 +37,10 @@ const Calendar = forwardRef(
35
37
  const handleBlur = useCallback(() => {
36
38
  setCalendarFocused(false);
37
39
  }, [setCalendarFocused]);
40
+ const calendarLabel = new DateFormatter(getCurrentLocale(), {
41
+ month: "long",
42
+ year: "numeric"
43
+ }).format(state.visibleMonth.toDate(getLocalTimeZone()));
38
44
  return /* @__PURE__ */ jsx(CalendarContext.Provider, {
39
45
  value: {
40
46
  state,
@@ -43,6 +49,7 @@ const Calendar = forwardRef(
43
49
  children: /* @__PURE__ */ jsxs("div", {
44
50
  className: clsx(withBaseName(), className),
45
51
  role: "application",
52
+ "aria-label": calendarLabel,
46
53
  ref,
47
54
  children: [
48
55
  /* @__PURE__ */ jsx(CalendarNavigation, {
@@ -1 +1 @@
1
- {"version":3,"file":"Calendar.js","sources":["../src/calendar/Calendar.tsx"],"sourcesContent":["import { forwardRef, useCallback } from \"react\";\nimport { clsx } from \"clsx\";\nimport { makePrefixer } from \"@salt-ds/core\";\nimport {\n CalendarNavigation,\n CalendarNavigationProps,\n} from \"./internal/CalendarNavigation\";\nimport { CalendarWeekHeader } from \"./internal/CalendarWeekHeader\";\nimport {\n CalendarCarousel,\n CalendarCarouselProps,\n} from \"./internal/CalendarCarousel\";\nimport { CalendarContext } from \"./internal/CalendarContext\";\nimport { useCalendar, useCalendarProps } from \"./useCalendar\";\n\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\n\nimport calendarCss from \"./Calendar.css\";\n\nexport type CalendarProps = useCalendarProps & {\n className?: string;\n renderDayContents?: CalendarCarouselProps[\"renderDayContents\"];\n hideYearDropdown?: CalendarNavigationProps[\"hideYearDropdown\"];\n TooltipProps?: CalendarCarouselProps[\"TooltipProps\"];\n hideOutOfRangeDates?: CalendarCarouselProps[\"hideOutOfRangeDates\"];\n};\n\nconst withBaseName = makePrefixer(\"saltCalendar\");\n\nexport const Calendar = forwardRef<HTMLDivElement, CalendarProps>(\n function Calendar(props, ref) {\n const {\n className,\n renderDayContents,\n hideYearDropdown,\n TooltipProps,\n ...rest\n } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-calendar\",\n css: calendarCss,\n window: targetWindow,\n });\n\n const { state, helpers } = useCalendar({ hideYearDropdown, ...rest });\n\n const { setCalendarFocused } = helpers;\n\n const handleFocus = useCallback(() => {\n setCalendarFocused(true);\n }, [setCalendarFocused]);\n\n const handleBlur = useCallback(() => {\n setCalendarFocused(false);\n }, [setCalendarFocused]);\n\n return (\n <CalendarContext.Provider\n value={{\n state,\n helpers,\n }}\n >\n <div\n className={clsx(withBaseName(), className)}\n role=\"application\"\n ref={ref}\n >\n <CalendarNavigation hideYearDropdown={hideYearDropdown} />\n <CalendarWeekHeader />\n <CalendarCarousel\n onFocus={handleFocus}\n onBlur={handleBlur}\n renderDayContents={renderDayContents}\n TooltipProps={TooltipProps}\n />\n </div>\n </CalendarContext.Provider>\n );\n }\n);\n"],"names":["Calendar","calendarCss"],"mappings":";;;;;;;;;;;;;AA4BA,MAAM,YAAA,GAAe,aAAa,cAAc,CAAA,CAAA;AAEzC,MAAM,QAAW,GAAA,UAAA;AAAA,EACtB,SAASA,SAAS,CAAA,KAAA,EAAO,GAAK,EAAA;AAC5B,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,iBAAA;AAAA,MACA,gBAAA;AAAA,MACA,YAAA;AAAA,MACG,GAAA,IAAA;AAAA,KACD,GAAA,KAAA,CAAA;AAEJ,IAAA,MAAM,eAAe,SAAU,EAAA,CAAA;AAC/B,IAAyB,wBAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,eAAA;AAAA,MACR,GAAK,EAAAC,QAAA;AAAA,MACL,MAAQ,EAAA,YAAA;AAAA,KACT,CAAA,CAAA;AAED,IAAM,MAAA,EAAE,OAAO,OAAQ,EAAA,GAAI,YAAY,EAAE,gBAAA,EAAkB,GAAG,IAAA,EAAM,CAAA,CAAA;AAEpE,IAAM,MAAA,EAAE,oBAAuB,GAAA,OAAA,CAAA;AAE/B,IAAM,MAAA,WAAA,GAAc,YAAY,MAAM;AACpC,MAAA,kBAAA,CAAmB,IAAI,CAAA,CAAA;AAAA,KACzB,EAAG,CAAC,kBAAkB,CAAC,CAAA,CAAA;AAEvB,IAAM,MAAA,UAAA,GAAa,YAAY,MAAM;AACnC,MAAA,kBAAA,CAAmB,KAAK,CAAA,CAAA;AAAA,KAC1B,EAAG,CAAC,kBAAkB,CAAC,CAAA,CAAA;AAEvB,IACE,uBAAA,GAAA,CAAC,gBAAgB,QAAhB,EAAA;AAAA,MACC,KAAO,EAAA;AAAA,QACL,KAAA;AAAA,QACA,OAAA;AAAA,OACF;AAAA,MAEA,QAAC,kBAAA,IAAA,CAAA,KAAA,EAAA;AAAA,QACC,SAAW,EAAA,IAAA,CAAK,YAAa,EAAA,EAAG,SAAS,CAAA;AAAA,QACzC,IAAK,EAAA,aAAA;AAAA,QACL,GAAA;AAAA,QAEA,QAAA,EAAA;AAAA,0BAAC,GAAA,CAAA,kBAAA,EAAA;AAAA,YAAmB,gBAAA;AAAA,WAAoC,CAAA;AAAA,8BACvD,kBAAmB,EAAA,EAAA,CAAA;AAAA,0BACnB,GAAA,CAAA,gBAAA,EAAA;AAAA,YACC,OAAS,EAAA,WAAA;AAAA,YACT,MAAQ,EAAA,UAAA;AAAA,YACR,iBAAA;AAAA,YACA,YAAA;AAAA,WACF,CAAA;AAAA,SAAA;AAAA,OACF,CAAA;AAAA,KACF,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
1
+ {"version":3,"file":"Calendar.js","sources":["../src/calendar/Calendar.tsx"],"sourcesContent":["import { forwardRef, useCallback } from \"react\";\nimport { clsx } from \"clsx\";\nimport { makePrefixer } from \"@salt-ds/core\";\nimport {\n CalendarNavigation,\n CalendarNavigationProps,\n} from \"./internal/CalendarNavigation\";\nimport { CalendarWeekHeader } from \"./internal/CalendarWeekHeader\";\nimport {\n CalendarCarousel,\n CalendarCarouselProps,\n} from \"./internal/CalendarCarousel\";\nimport { CalendarContext } from \"./internal/CalendarContext\";\nimport { useCalendar, useCalendarProps } from \"./useCalendar\";\n\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\n\nimport calendarCss from \"./Calendar.css\";\nimport { DateFormatter, getLocalTimeZone } from \"@internationalized/date\";\nimport { getCurrentLocale } from \"./internal/utils\";\n\nexport type CalendarProps = useCalendarProps & {\n className?: string;\n renderDayContents?: CalendarCarouselProps[\"renderDayContents\"];\n hideYearDropdown?: CalendarNavigationProps[\"hideYearDropdown\"];\n TooltipProps?: CalendarCarouselProps[\"TooltipProps\"];\n hideOutOfRangeDates?: CalendarCarouselProps[\"hideOutOfRangeDates\"];\n};\n\nconst withBaseName = makePrefixer(\"saltCalendar\");\n\nexport const Calendar = forwardRef<HTMLDivElement, CalendarProps>(\n function Calendar(props, ref) {\n const {\n className,\n renderDayContents,\n hideYearDropdown,\n TooltipProps,\n ...rest\n } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-calendar\",\n css: calendarCss,\n window: targetWindow,\n });\n\n const { state, helpers } = useCalendar({ hideYearDropdown, ...rest });\n\n const { setCalendarFocused } = helpers;\n\n const handleFocus = useCallback(() => {\n setCalendarFocused(true);\n }, [setCalendarFocused]);\n\n const handleBlur = useCallback(() => {\n setCalendarFocused(false);\n }, [setCalendarFocused]);\n\n const calendarLabel = new DateFormatter(getCurrentLocale(), {\n month: \"long\",\n year: \"numeric\",\n }).format(state.visibleMonth.toDate(getLocalTimeZone()));\n return (\n <CalendarContext.Provider\n value={{\n state,\n helpers,\n }}\n >\n <div\n className={clsx(withBaseName(), className)}\n role=\"application\"\n aria-label={calendarLabel}\n ref={ref}\n >\n <CalendarNavigation hideYearDropdown={hideYearDropdown} />\n <CalendarWeekHeader />\n <CalendarCarousel\n onFocus={handleFocus}\n onBlur={handleBlur}\n renderDayContents={renderDayContents}\n TooltipProps={TooltipProps}\n />\n </div>\n </CalendarContext.Provider>\n );\n }\n);\n"],"names":["Calendar","calendarCss"],"mappings":";;;;;;;;;;;;;;;AA8BA,MAAM,YAAA,GAAe,aAAa,cAAc,CAAA,CAAA;AAEzC,MAAM,QAAW,GAAA,UAAA;AAAA,EACtB,SAASA,SAAS,CAAA,KAAA,EAAO,GAAK,EAAA;AAC5B,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,iBAAA;AAAA,MACA,gBAAA;AAAA,MACA,YAAA;AAAA,MACG,GAAA,IAAA;AAAA,KACD,GAAA,KAAA,CAAA;AAEJ,IAAA,MAAM,eAAe,SAAU,EAAA,CAAA;AAC/B,IAAyB,wBAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,eAAA;AAAA,MACR,GAA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,EAAA,WAAA;AAAA,YACT,MAAQ,EAAA,UAAA;AAAA,YACR,iBAAA;AAAA,YACA,YAAA;AAAA,WACF,CAAA;AAAA,SAAA;AAAA,OACF,CAAA;AAAA,KACF,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
@@ -45,6 +45,7 @@ const CalendarCarousel = forwardRef(function CalendarCarousel2(props, ref) {
45
45
  }, [formatDate(visibleMonth)]);
46
46
  return /* @__PURE__ */ jsx("div", {
47
47
  className: withBaseName(),
48
+ tabIndex: -1,
48
49
  style: {
49
50
  overflowX: "hidden",
50
51
  position: "relative"
@@ -60,7 +61,6 @@ const CalendarCarousel = forwardRef(function CalendarCarousel2(props, ref) {
60
61
  },
61
62
  "aria-hidden": index !== 1 ? "true" : void 0,
62
63
  children: /* @__PURE__ */ jsx(CalendarMonth, {
63
- isVisible: index === 1,
64
64
  ...rest,
65
65
  date
66
66
  })
@@ -1 +1 @@
1
- {"version":3,"file":"CalendarCarousel.js","sources":["../src/calendar/internal/CalendarCarousel.tsx"],"sourcesContent":["import { forwardRef, useEffect, useRef, useState } from \"react\";\nimport { DateValue, isSameMonth } from \"@internationalized/date\";\nimport { CalendarMonth, CalendarMonthProps } from \"./CalendarMonth\";\nimport { makePrefixer, useIsomorphicLayoutEffect } from \"@salt-ds/core\";\nimport { useCalendarContext } from \"./CalendarContext\";\n\nimport calendarCarouselCss from \"./CalendarCarousel.css\";\nimport { formatDate, monthDiff } from \"./utils\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\n\nexport type CalendarCarouselProps = Omit<CalendarMonthProps, \"date\">;\n\nfunction getMonths(month: DateValue) {\n return [month.subtract({ months: 1 }), month, month.add({ months: 1 })];\n}\n\nconst withBaseName = makePrefixer(\"saltCalendarCarousel\");\n\nexport const CalendarCarousel = forwardRef<\n HTMLDivElement,\n CalendarCarouselProps\n>(function CalendarCarousel(props, ref) {\n const { ...rest } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-calendar-carousel\",\n css: calendarCarouselCss,\n window: targetWindow,\n });\n\n const {\n state: { visibleMonth },\n } = useCalendarContext();\n const containerRef = useRef<HTMLDivElement>(null);\n const diffIndex = (a: DateValue, b: DateValue) => monthDiff(a, b);\n\n const { current: baseIndex } = useRef(visibleMonth);\n\n useIsomorphicLayoutEffect(() => {\n if (containerRef.current) {\n containerRef.current.style.transform = `translate3d(${\n diffIndex(baseIndex, visibleMonth) * -101 // needs to be higher than 100% so the next month doesn't show on the edges\n }%, 0, 0)`;\n }\n });\n\n const [months, setMonths] = useState(() => getMonths(visibleMonth));\n\n useEffect(() => {\n setMonths((oldMonths) => {\n const newMonths = getMonths(visibleMonth).filter((month) => {\n return !oldMonths.find((oldMonth) => isSameMonth(oldMonth, month));\n });\n\n return oldMonths.concat(newMonths);\n });\n setMonths(getMonths(visibleMonth));\n return undefined;\n }, [formatDate(visibleMonth)]); // eslint-disable-line react-hooks/exhaustive-deps\n\n return (\n <div\n className={withBaseName()}\n style={{\n overflowX: \"hidden\",\n position: \"relative\",\n }}\n ref={ref}\n >\n <div className={withBaseName(\"track\")} ref={containerRef}>\n {months.map((date, index) => (\n <div\n key={formatDate(date)}\n className={withBaseName(\"slide\")}\n style={{\n transform: `translateX(${diffIndex(date, baseIndex) * -101}%)`,\n }}\n aria-hidden={index !== 1 ? \"true\" : undefined}\n >\n <CalendarMonth isVisible={index === 1} {...rest} date={date} />\n </div>\n ))}\n </div>\n </div>\n );\n});\n"],"names":["CalendarCarousel","calendarCarouselCss"],"mappings":";;;;;;;;;;;AAaA,SAAS,UAAU,KAAkB,EAAA;AACnC,EAAA,OAAO,CAAC,KAAA,CAAM,QAAS,CAAA,EAAE,QAAQ,CAAE,EAAC,CAAG,EAAA,KAAA,EAAO,MAAM,GAAI,CAAA,EAAE,MAAQ,EAAA,CAAA,EAAG,CAAC,CAAA,CAAA;AACxE,CAAA;AAEA,MAAM,YAAA,GAAe,aAAa,sBAAsB,CAAA,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sources":["../src/calendar/internal/CalendarCarousel.tsx"],"sourcesContent":["import { forwardRef, useEffect, useRef, useState } from \"react\";\nimport { DateValue, isSameMonth } from \"@internationalized/date\";\nimport { CalendarMonth, CalendarMonthProps } from \"./CalendarMonth\";\nimport { makePrefixer, useIsomorphicLayoutEffect } from \"@salt-ds/core\";\nimport { useCalendarContext } from \"./CalendarContext\";\n\nimport calendarCarouselCss from \"./CalendarCarousel.css\";\nimport { formatDate, monthDiff } from \"./utils\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\n\nexport type CalendarCarouselProps = Omit<CalendarMonthProps, \"date\">;\n\nfunction getMonths(month: DateValue) {\n return [month.subtract({ months: 1 }), month, month.add({ months: 1 })];\n}\n\nconst withBaseName = makePrefixer(\"saltCalendarCarousel\");\n\nexport const CalendarCarousel = forwardRef<\n HTMLDivElement,\n CalendarCarouselProps\n>(function CalendarCarousel(props, ref) {\n const { ...rest } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-calendar-carousel\",\n css: calendarCarouselCss,\n window: targetWindow,\n });\n\n const {\n state: { visibleMonth },\n } = useCalendarContext();\n const containerRef = useRef<HTMLDivElement>(null);\n const diffIndex = (a: DateValue, b: DateValue) => monthDiff(a, b);\n\n const { current: baseIndex } = useRef(visibleMonth);\n\n useIsomorphicLayoutEffect(() => {\n if (containerRef.current) {\n containerRef.current.style.transform = `translate3d(${\n diffIndex(baseIndex, visibleMonth) * -101 // needs to be higher than 100% so the next month doesn't show on the edges\n }%, 0, 0)`;\n }\n });\n\n const [months, setMonths] = useState(() => getMonths(visibleMonth));\n\n useEffect(() => {\n setMonths((oldMonths) => {\n const newMonths = getMonths(visibleMonth).filter((month) => {\n return !oldMonths.find((oldMonth) => isSameMonth(oldMonth, month));\n });\n\n return oldMonths.concat(newMonths);\n });\n setMonths(getMonths(visibleMonth));\n return undefined;\n }, [formatDate(visibleMonth)]); // eslint-disable-line react-hooks/exhaustive-deps\n\n return (\n <div\n className={withBaseName()}\n tabIndex={-1} // https://bugzilla.mozilla.org/show_bug.cgi?id=1069739\n style={{\n overflowX: \"hidden\",\n position: \"relative\",\n }}\n ref={ref}\n >\n <div className={withBaseName(\"track\")} ref={containerRef}>\n {months.map((date, index) => (\n <div\n key={formatDate(date)}\n className={withBaseName(\"slide\")}\n style={{\n transform: `translateX(${diffIndex(date, baseIndex) * -101}%)`,\n }}\n aria-hidden={index !== 1 ? \"true\" : undefined}\n >\n <CalendarMonth {...rest} date={date} />\n </div>\n ))}\n </div>\n </div>\n );\n});\n"],"names":["CalendarCarousel","calendarCarouselCss"],"mappings":";;;;;;;;;;;AAaA,SAAS,UAAU,KAAkB,EAAA;AACnC,EAAA,OAAO,CAAC,KAAA,CAAM,QAAS,CAAA,EAAE,QAAQ,CAAE,EAAC,CAAG,EAAA,KAAA,EAAO,MAAM,GAAI,CAAA,EAAE,MAAQ,EAAA,CAAA,EAAG,CAAC,CAAA,CAAA;AACxE,CAAA;AAEA,MAAM,YAAA,GAAe,aAAa,sBAAsB,CAAA,CAAA;AAEjD,MAAM,gBAAmB,GAAA,UAAA,CAG9B,SAASA,iBAAAA,CAAiB,OAAO,GAAK,EAAA;AACtC,EAAM,MAAA,EAAA,GAAK,MAAS,GAAA,KAAA,CAAA;AAEpB,EAAA,MAAM,eAAe,SAAU,EAAA,CAAA;AAC/B,EAAyB,wBAAA,CAAA;AAAA,IACvB,MAAQ,EAAA,wBAAA;AAAA,IACR,GAAK,EAAAC,QAAA;AAAA,IACL,MAAQ,EAAA,YAAA;AAAA,GACT,CAAA,CAAA;AAED,EAAM,MAAA;AAAA,IACJ,KAAA,EAAO,EAAE,YAAa,EAAA;AAAA,MACpB,kBAAmB,EAAA,CAAA;AACvB,EAAM,MAAA,YAAA,GAAe,OAAuB,IAAI,CAAA,CAAA;AAChD,EAAA,MAAM,YAAY,CAAC,CAAA,EAAc,CAAiB,KAAA,SAAA,CAAU,GAAG,CAAC,CAAA,CAAA;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aAAa,OAAO,CAAA;AAAA,MAAG,GAAK,EAAA,YAAA;AAAA,MACzC,QAAO,EAAA,MAAA,CAAA,GAAA,CAAI,CAAC,IAAA,EAAM,0BAChB,GAAA,CAAA,KAAA,EAAA;AAAA,QAEC,SAAA,EAAW,aAAa,OAAO,CAAA;AAAA,QAC/B,KAAO,EAAA;AAAA,UACL,SAAW,EAAA,CAAA,WAAA,EAAc,SAAU,CAAA,IAAA,EAAM,SAAS,CAAI,GAAA,CAAA,GAAA,CAAA,EAAA,CAAA;AAAA,SACxD;AAAA,QACA,aAAA,EAAa,KAAU,KAAA,CAAA,GAAI,MAAS,GAAA,KAAA,CAAA;AAAA,QAEpC,QAAC,kBAAA,GAAA,CAAA,aAAA,EAAA;AAAA,UAAe,GAAG,IAAA;AAAA,UAAM,IAAA;AAAA,SAAY,CAAA;AAAA,OAPhC,EAAA,UAAA,CAAW,IAAI,CAQtB,CACD,CAAA;AAAA,KACH,CAAA;AAAA,GACF,CAAA,CAAA;AAEJ,CAAC;;;;"}
@@ -1,4 +1,4 @@
1
- var css_248z = ".saltCalendarDay {\n font-family: var(--salt-text-fontFamily);\n font-weight: var(--salt-text-fontWeight);\n line-height: var(--salt-text-lineHeight);\n font-size: var(--salt-text-fontSize);\n width: var(--salt-size-base);\n height: var(--salt-size-base);\n color: var(--salt-content-primary-foreground);\n background: var(--salt-selectable-background);\n cursor: pointer;\n border: none;\n padding: 0;\n display: flex;\n justify-content: center;\n align-items: center;\n position: relative;\n overflow: hidden;\n}\n.saltCalendarDay-content {\n margin: 0 var(--salt-spacing-50);\n width: 100%;\n}\n\n.saltCalendarDay:focus-visible {\n outline: var(--salt-focused-outline);\n outline-offset: calc(0px - var(--salt-focused-outlineWidth));\n}\n\n.saltCalendarDay-outOfRange {\n color: var(--salt-content-secondary-foreground);\n}\n\n.saltCalendarDay:hover,\n.saltCalendarDay-hoveredOffset,\n.saltCalendarDay-hoveredOffset:hover {\n background: var(--salt-selectable-background-hover);\n}\n.saltCalendarDay-selectedStart {\n z-index: var(--salt-zIndex-default);\n}\n\n.saltCalendarDay-selected,\n.saltCalendarDay-selected:hover,\n.saltCalendarDay-selectedStart,\n.saltCalendarDay-selectedStart:hover,\n.saltCalendarDay-selectedEnd,\n.saltCalendarDay-selectedEnd:hover {\n background: var(--salt-selectable-background-selected);\n box-shadow: 0 0 0 var(--salt-size-border) var(--salt-selectable-borderColor-selected);\n}\n\n.saltCalendarDay-hoveredSpan,\n.saltCalendarDay-hoveredSpan:hover,\n.saltCalendarDay-selectedSpan,\n.saltCalendarDay-selectedSpan:hover {\n background: var(--salt-selectable-background-hover);\n box-shadow: calc(var(--salt-size-border) * -2) 0 0 0 var(--salt-selectable-background-hover),\n calc(var(--salt-size-border) * -1) 0 0 var(--salt-size-border) var(--salt-selectable-borderColor-selected), 0 calc(var(--salt-size-border) * -1) 0 var(--salt-selectable-borderColor-selected);\n}\n\n.saltCalendarDay-disabled,\n.saltCalendarDay-disabled:hover,\n.saltCalendarDay-unselectable,\n.saltCalendarDay-unselectable:hover {\n background: var(--salt-selectable-background-disabled);\n cursor: var(--salt-selectable-cursor-disabled);\n}\n\n.saltCalendarDay-highlighted:before {\n content: \"\";\n height: var(--salt-spacing-200); /* TODO: change for size-modifier when available */\n width: var(--salt-spacing-200);\n top: calc(var(--salt-spacing-100) * -1);\n right: calc(var(--salt-spacing-100) * -1);\n transform: rotate(45deg);\n background: var(--salt-selectable-borderColor-selected);\n position: absolute;\n}\n\n.saltCalendarDay-disabled {\n color: var(--salt-content-secondary-foreground-disabled);\n}\n.saltCalendarDay-unselectable:after {\n content: \"\";\n height: var(--salt-size-border);\n width: calc(100% - var(--salt-spacing-100));\n background: var(--salt-content-secondary-foreground);\n position: absolute;\n}\n\n.saltCalendarDay-today,\n.saltCalendarDay-today:hover {\n border-bottom: var(--salt-size-indicator) var(--salt-selectable-borderStyle) var(--salt-content-foreground-active);\n margin-bottom: calc(var(--salt-size-indicator) * -1);\n}\n\n.saltCalendarDay-hidden {\n visibility: hidden;\n}\n";
1
+ var css_248z = ".saltCalendarDay {\n font-family: var(--salt-text-fontFamily);\n font-weight: var(--salt-text-fontWeight);\n line-height: var(--salt-text-lineHeight);\n font-size: var(--salt-text-fontSize);\n width: var(--salt-size-base);\n height: var(--salt-size-base);\n color: var(--salt-content-primary-foreground);\n background: var(--salt-selectable-background);\n cursor: pointer;\n border: none;\n padding: 0;\n display: flex;\n justify-content: center;\n align-items: center;\n position: relative;\n overflow: hidden;\n}\n.saltCalendarDay-content {\n margin: 0 var(--salt-spacing-50);\n width: 100%;\n}\n\n.saltCalendarDay:focus-visible {\n outline: var(--salt-focused-outline);\n outline-offset: calc(0px - var(--salt-focused-outlineWidth));\n}\n\n.saltCalendarDay-outOfRange {\n color: var(--salt-content-secondary-foreground);\n}\n.saltCalendarDay-outOfRange:hover {\n color: var(--salt-content-primary-foreground);\n}\n.saltCalendarDay-outOfRange .saltCalendarDay-today {\n border-bottom: var(--salt-size-indicator) var(--salt-selectable-borderStyle) var(--salt-content-secondary-foreground);\n}\n\n.saltCalendarDay-outOfRange.saltCalendarDay-highlighted:before {\n background: var(--salt-content-secondary-foreground);\n}\n.saltCalendarDay:hover,\n.saltCalendarDay-hoveredOffset,\n.saltCalendarDay-hoveredOffset:hover {\n background: var(--salt-selectable-background-hover);\n}\n.saltCalendarDay-selectedStart {\n z-index: var(--salt-zIndex-default);\n}\n\n.saltCalendarDay-selected,\n.saltCalendarDay-selected:hover,\n.saltCalendarDay-selectedStart,\n.saltCalendarDay-selectedStart:hover,\n.saltCalendarDay-selectedEnd,\n.saltCalendarDay-selectedEnd:hover {\n background: var(--salt-selectable-background-selected);\n box-shadow: 0 0 0 var(--salt-size-border) var(--salt-selectable-borderColor-selected);\n}\n\n.saltCalendarDay-hoveredSpan,\n.saltCalendarDay-hoveredSpan:hover,\n.saltCalendarDay-selectedSpan,\n.saltCalendarDay-selectedSpan:hover {\n background: var(--salt-selectable-background-hover);\n box-shadow: calc(var(--salt-size-border) * -2) 0 0 0 var(--salt-selectable-background-hover),\n calc(var(--salt-size-border) * -1) 0 0 var(--salt-size-border) var(--salt-selectable-borderColor-selected), 0 calc(var(--salt-size-border) * -1) 0 var(--salt-selectable-borderColor-selected);\n}\n\n.saltCalendarDay-disabled,\n.saltCalendarDay-disabled:hover,\n.saltCalendarDay-unselectable,\n.saltCalendarDay-unselectable:hover {\n background: var(--salt-selectable-background-disabled);\n cursor: var(--salt-selectable-cursor-disabled);\n}\n\n.saltCalendarDay-highlighted:before,\n.saltCalendarDay-highlighted:hover:before {\n content: \"\";\n height: var(--salt-spacing-200); /* TODO: change for size-modifier when available */\n width: var(--salt-spacing-200);\n top: calc(var(--salt-spacing-100) * -1);\n right: calc(var(--salt-spacing-100) * -1);\n transform: rotate(45deg);\n background: var(--salt-selectable-borderColor-selected);\n position: absolute;\n}\n\n.saltCalendarDay-disabled {\n color: var(--salt-content-secondary-foreground-disabled);\n}\n.saltCalendarDay-unselectable:after {\n content: \"\";\n height: var(--salt-size-border);\n width: calc(100% - var(--salt-spacing-100));\n background: var(--salt-content-secondary-foreground);\n position: absolute;\n}\n\n.saltCalendarDay-today,\n.saltCalendarDay-today:hover,\n.saltCalendarDay-outOfRange .saltCalendarDay-today:hover {\n border-bottom: var(--salt-size-indicator) var(--salt-selectable-borderStyle) var(--salt-content-foreground-active);\n margin-bottom: calc(var(--salt-size-indicator) * -1);\n}\n\n.saltCalendarDay-hidden {\n visibility: hidden;\n}\n";
2
2
 
3
3
  export { css_248z as default };
4
4
  //# sourceMappingURL=CalendarDay.css.js.map
@@ -38,7 +38,11 @@ const CalendarDay = forwardRef(
38
38
  leaveDelay: 0,
39
39
  ...TooltipProps2,
40
40
  children: /* @__PURE__ */ jsx("button", {
41
- "aria-label": formatDate(day),
41
+ "aria-label": formatDate(day, {
42
+ day: "2-digit",
43
+ month: "long",
44
+ year: "numeric"
45
+ }),
42
46
  disabled,
43
47
  type: "button",
44
48
  ...dayProps,
@@ -1 +1 @@
1
- {"version":3,"file":"CalendarDay.js","sources":["../src/calendar/internal/CalendarDay.tsx"],"sourcesContent":["import { makePrefixer, Tooltip, TooltipProps, useForkRef } from \"@salt-ds/core\";\nimport { clsx } from \"clsx\";\nimport { ComponentPropsWithRef, forwardRef, ReactElement, useRef } from \"react\";\nimport { DateValue } from \"@internationalized/date\";\nimport { DayStatus, useCalendarDay } from \"../useCalendarDay\";\nimport calendarDayCss from \"./CalendarDay.css\";\nimport { formatDate } from \"./utils\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\n\nexport type DateFormatter = (day: Date) => string | undefined;\n\nexport interface CalendarDayProps\n extends Omit<ComponentPropsWithRef<\"button\">, \"children\"> {\n day: DateValue;\n formatDate?: DateFormatter;\n renderDayContents?: (date: DateValue, status: DayStatus) => ReactElement;\n status?: DayStatus;\n month: DateValue;\n TooltipProps?: Partial<TooltipProps>;\n}\n\nconst withBaseName = makePrefixer(\"saltCalendarDay\");\n\nexport const CalendarDay = forwardRef<HTMLButtonElement, CalendarDayProps>(\n function CalendarDay(props, ref) {\n const { className, day, renderDayContents, month, TooltipProps, ...rest } =\n props;\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-calendar-day\",\n css: calendarDayCss,\n window: targetWindow,\n });\n\n const dayRef = useRef<HTMLButtonElement>(null);\n const buttonRef = useForkRef(ref, dayRef);\n const { status, dayProps, unselectableReason, highlightedReason } =\n useCalendarDay(\n {\n date: day,\n month,\n },\n dayRef\n );\n const { outOfRange, today, unselectable, highlighted, hidden, disabled } =\n status;\n\n return (\n <Tooltip\n hideIcon\n status={unselectableReason ? \"error\" : \"info\"}\n content={\n unselectableReason || highlightedReason || \"Date is out of range\"\n }\n disabled={!unselectableReason && !highlightedReason}\n placement=\"top\"\n enterDelay={0} // --salt-duration-instant\n leaveDelay={0} // --salt-duration-instant\n {...TooltipProps}\n >\n <button\n aria-label={formatDate(day)}\n disabled={disabled}\n type=\"button\"\n {...dayProps}\n ref={buttonRef}\n {...rest}\n className={clsx(\n withBaseName(),\n {\n [withBaseName(\"hidden\")]: hidden,\n [withBaseName(\"outOfRange\")]: outOfRange,\n [withBaseName(\"disabled\")]: disabled,\n [withBaseName(\"unselectable\")]: !!unselectable,\n [withBaseName(\"highlighted\")]: !!highlighted,\n },\n dayProps.className,\n className\n )}\n >\n <span\n className={clsx(withBaseName(\"content\"), {\n [withBaseName(\"today\")]: today,\n })}\n >\n {renderDayContents\n ? renderDayContents(day, status)\n : formatDate(day, { day: \"numeric\" })}\n </span>\n </button>\n </Tooltip>\n );\n }\n);\n"],"names":["CalendarDay","TooltipProps","calendarDayCss"],"mappings":";;;;;;;;;;AAsBA,MAAM,YAAA,GAAe,aAAa,iBAAiB,CAAA,CAAA;AAE5C,MAAM,WAAc,GAAA,UAAA;AAAA,EACzB,SAASA,YAAY,CAAA,KAAA,EAAO,GAAK,EAAA;AAC/B,IAAM,MAAA,EAAE,WAAW,GAAK,EAAA,iBAAA,EAAmB,OAAO,YAAAC,EAAAA,aAAAA,EAAAA,GAAiB,MACjE,GAAA,KAAA,CAAA;AACF,IAAA,MAAM,eAAe,SAAU,EAAA,CAAA;AAC/B,IAAyB,wBAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,mBAAA;AAAA,MACR,GAAK,EAAAC,QAAA;AAAA,MACL,MAAQ,EAAA,YAAA;AAAA,KACT,CAAA,CAAA;AAED,IAAM,MAAA,MAAA,GAAS,OAA0B,IAAI,CAAA,CAAA;AAC7C,IAAM,MAAA,SAAA,GAAY,UAAW,CAAA,GAAA,EAAK,MAAM,CAAA,CAAA;AACxC,IAAA,MAAM,EAAE,MAAA,EAAQ,QAAU,EAAA,kBAAA,EAAoB,mBAC5C,GAAA,cAAA;AAAA,MACE;AAAA,QACE,IAAM,EAAA,GAAA;AAAA,QACN,KAAA;AAAA,OACF;AAAA,MACA,MAAA;AAAA,KACF,CAAA;AACF,IAAA,MAAM,EAAE,UAAY,EAAA,KAAA,EAAO,cAAc,WAAa,EAAA,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EA,QAAA,EAAA,iBAAA,GACG,iBAAkB,CAAA,GAAA,EAAK,MAAM,CAAA,GAC7B,WAAW,GAAK,EAAA,EAAE,GAAK,EAAA,SAAA,EAAW,CAAA;AAAA,SACxC,CAAA;AAAA,OACF,CAAA;AAAA,KACF,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
1
+ {"version":3,"file":"CalendarDay.js","sources":["../src/calendar/internal/CalendarDay.tsx"],"sourcesContent":["import { makePrefixer, Tooltip, TooltipProps, useForkRef } from \"@salt-ds/core\";\nimport { clsx } from \"clsx\";\nimport { ComponentPropsWithRef, forwardRef, ReactElement, useRef } from \"react\";\nimport { DateValue } from \"@internationalized/date\";\nimport { DayStatus, useCalendarDay } from \"../useCalendarDay\";\nimport calendarDayCss from \"./CalendarDay.css\";\nimport { formatDate } from \"./utils\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\n\nexport type DateFormatter = (day: Date) => string | undefined;\n\nexport interface CalendarDayProps\n extends Omit<ComponentPropsWithRef<\"button\">, \"children\"> {\n day: DateValue;\n formatDate?: DateFormatter;\n renderDayContents?: (date: DateValue, status: DayStatus) => ReactElement;\n status?: DayStatus;\n month: DateValue;\n TooltipProps?: Partial<TooltipProps>;\n}\n\nconst withBaseName = makePrefixer(\"saltCalendarDay\");\n\nexport const CalendarDay = forwardRef<HTMLButtonElement, CalendarDayProps>(\n function CalendarDay(props, ref) {\n const { className, day, renderDayContents, month, TooltipProps, ...rest } =\n props;\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-calendar-day\",\n css: calendarDayCss,\n window: targetWindow,\n });\n\n const dayRef = useRef<HTMLButtonElement>(null);\n const buttonRef = useForkRef(ref, dayRef);\n const { status, dayProps, unselectableReason, highlightedReason } =\n useCalendarDay(\n {\n date: day,\n month,\n },\n dayRef\n );\n const { outOfRange, today, unselectable, highlighted, hidden, disabled } =\n status;\n\n return (\n <Tooltip\n hideIcon\n status={unselectableReason ? \"error\" : \"info\"}\n content={\n unselectableReason || highlightedReason || \"Date is out of range\"\n }\n disabled={!unselectableReason && !highlightedReason}\n placement=\"top\"\n enterDelay={0} // --salt-duration-instant\n leaveDelay={0} // --salt-duration-instant\n {...TooltipProps}\n >\n <button\n aria-label={formatDate(day, {\n day: \"2-digit\",\n month: \"long\",\n year: \"numeric\",\n })}\n disabled={disabled}\n type=\"button\"\n {...dayProps}\n ref={buttonRef}\n {...rest}\n className={clsx(\n withBaseName(),\n {\n [withBaseName(\"hidden\")]: hidden,\n [withBaseName(\"outOfRange\")]: outOfRange,\n [withBaseName(\"disabled\")]: disabled,\n [withBaseName(\"unselectable\")]: !!unselectable,\n [withBaseName(\"highlighted\")]: !!highlighted,\n },\n dayProps.className,\n className\n )}\n >\n <span\n className={clsx(withBaseName(\"content\"), {\n [withBaseName(\"today\")]: today,\n })}\n >\n {renderDayContents\n ? renderDayContents(day, status)\n : formatDate(day, { day: \"numeric\" })}\n </span>\n </button>\n </Tooltip>\n );\n }\n);\n"],"names":["CalendarDay","TooltipProps","calendarDayCss"],"mappings":";;;;;;;;;;AAsBA,MAAM,YAAA,GAAe,aAAa,iBAAiB,CAAA,CAAA;AAE5C,MAAM,WAAc,GAAA,UAAA;AAAA,EACzB,SAASA,YAAY,CAAA,KAAA,EAAO,GAAK,EAAA;AAC/B,IAAM,MAAA,EAAE,WAAW,GAAK,EAAA,iBAAA,EAAmB,OAAO,YAAAC,EAAAA,aAAAA,EAAAA,GAAiB,MACjE,GAAA,KAAA,CAAA;AACF,IAAA,MAAM,eAAe,SAAU,EAAA,CAAA;AAC/B,IAAyB,wBAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,mBAAA;AAAA,MACR,GAAK,EAAAC,QAAA;AAAA,MACL,MAAQ,EAAA,YAAA;AAAA,KACT,CAAA,CAAA;AAED,IAAM,MAAA,MAAA,GAAS,OAA0B,IAAI,CAAA,CAAA;AAC7C,IAAM,MAAA,SAAA,GAAY,UAAW,CAAA,GAAA,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AAA,CAAa,cAAc,CAAA,GAAI,CAAC,CAAC,YAAA;AAAA,YAClC,CAAC,YAAA,CAAa,aAAa,CAAA,GAAI,CAAC,CAAC,WAAA;AAAA,WACnC;AAAA,UACA,QAAS,CAAA,SAAA;AAAA,UACT,SAAA;AAAA,SACF;AAAA,QAEA,QAAC,kBAAA,GAAA,CAAA,MAAA,EAAA;AAAA,UACC,SAAW,EAAA,IAAA,CAAK,YAAa,CAAA,SAAS,CAAG,EAAA;AAAA,YACvC,CAAC,YAAa,CAAA,OAAO,CAAI,GAAA,KAAA;AAAA,WAC1B,CAAA;AAAA,UAEA,QAAA,EAAA,iBAAA,GACG,iBAAkB,CAAA,GAAA,EAAK,MAAM,CAAA,GAC7B,WAAW,GAAK,EAAA,EAAE,GAAK,EAAA,SAAA,EAAW,CAAA;AAAA,SACxC,CAAA;AAAA,OACF,CAAA;AAAA,KACF,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"CalendarMonth.js","sources":["../src/calendar/internal/CalendarMonth.tsx"],"sourcesContent":["import {\n ComponentPropsWithRef,\n forwardRef,\n MouseEvent,\n SyntheticEvent,\n} from \"react\";\nimport { clsx } from \"clsx\";\nimport { makePrefixer } from \"@salt-ds/core\";\nimport { DateValue } from \"@internationalized/date\";\nimport { CalendarDay, CalendarDayProps } from \"./CalendarDay\";\nimport { formatDate, generateVisibleDays } from \"./utils\";\n\nimport calendarMonthCss from \"./CalendarMonth.css\";\nimport { useCalendarContext } from \"./CalendarContext\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\n\nexport interface CalendarMonthProps extends ComponentPropsWithRef<\"div\"> {\n date: DateValue;\n hideOutOfRangeDates?: boolean;\n renderDayContents?: CalendarDayProps[\"renderDayContents\"];\n isVisible?: boolean;\n TooltipProps?: CalendarDayProps[\"TooltipProps\"];\n}\n\nconst withBaseName = makePrefixer(\"saltCalendarMonth\");\n\nexport const CalendarMonth = forwardRef<HTMLDivElement, CalendarMonthProps>(\n function CalendarMonth(props, ref) {\n const {\n className,\n date,\n renderDayContents,\n onMouseLeave,\n TooltipProps,\n ...rest\n } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-calendar-month\",\n css: calendarMonthCss,\n window: targetWindow,\n });\n\n const days = generateVisibleDays(date);\n const {\n helpers: { setHoveredDate },\n } = useCalendarContext();\n\n const handleMouseLeave = (event: SyntheticEvent) => {\n setHoveredDate(event, null);\n onMouseLeave?.(event as MouseEvent<HTMLDivElement>);\n };\n\n return (\n <div\n className={clsx(withBaseName(), className)}\n ref={ref}\n onMouseLeave={handleMouseLeave}\n {...rest}\n >\n <div\n data-testid=\"CalendarDateGrid\"\n className={withBaseName(\"dateGrid\")}\n >\n {days.map((day) => {\n return (\n <CalendarDay\n key={formatDate(day.date)}\n day={day.date}\n renderDayContents={renderDayContents}\n month={date}\n TooltipProps={TooltipProps}\n />\n );\n })}\n </div>\n </div>\n );\n }\n);\n"],"names":["CalendarMonth","calendarMonthCss"],"mappings":";;;;;;;;;;;AAyBA,MAAM,YAAA,GAAe,aAAa,mBAAmB,CAAA,CAAA;AAE9C,MAAM,aAAgB,GAAA,UAAA;AAAA,EAC3B,SAASA,cAAc,CAAA,KAAA,EAAO,GAAK,EAAA;AACjC,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,IAAA;AAAA,MACA,iBAAA;AAAA,MACA,YAAA;AAAA,MACA,YAAA;AAAA,MACG,GAAA,IAAA;AAAA,KACD,GAAA,KAAA,CAAA;AAEJ,IAAA,MAAM,eAAe,SAAU,EAAA,CAAA;AAC/B,IAAyB,wBAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,qBAAA;AAAA,MACR,GAAK,EAAAC,QAAA;AAAA,MACL,MAAQ,EAAA,YAAA;AAAA,KACT,CAAA,CAAA;AAED,IAAM,MAAA,IAAA,GAAO,oBAAoB,IAAI,CAAA,CAAA;AACrC,IAAM,MAAA;AAAA,MACJ,OAAA,EAAS,EAAE,cAAe,EAAA;AAAA,QACxB,kBAAmB,EAAA,CAAA;AAEvB,IAAM,MAAA,gBAAA,GAAmB,CAAC,KAA0B,KAAA;AAClD,MAAA,cAAA,CAAe,OAAO,IAAI,CAAA,CAAA;AAC1B,MAAe,YAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,YAAA,CAAA,KAAA,CAAA,CAAA;AAAA,KACjB,CAAA;AAEA,IAAA,uBACG,GAAA,CAAA,KAAA,EAAA;AAAA,MACC,SAAW,EAAA,IAAA,CAAK,YAAa,EAAA,EAAG,SAAS,CAAA;AAAA,MACzC,GAAA;AAAA,MACA,YAAc,EAAA,gBAAA;AAAA,MACb,GAAG,IAAA;AAAA,MAEJ,QAAC,kBAAA,GAAA,CAAA,KAAA,EAAA;AAAA,QACC,aAAY,EAAA,kBAAA;AAAA,QACZ,SAAA,EAAW,aAAa,UAAU,CAAA;AAAA,QAEjC,QAAA,EAAA,IAAA,CAAK,GAAI,CAAA,CAAC,GAAQ,KAAA;AACjB,UAAA,uBACG,GAAA,CAAA,WAAA,EAAA;AAAA,YAEC,KAAK,GAAI,CAAA,IAAA;AAAA,YACT,iBAAA;AAAA,YACA,KAAO,EAAA,IAAA;AAAA,YACP,YAAA;AAAA,WAJK,EAAA,UAAA,CAAW,GAAI,CAAA,IAAI,CAK1B,CAAA,CAAA;AAAA,SAEH,CAAA;AAAA,OACH,CAAA;AAAA,KACF,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
1
+ {"version":3,"file":"CalendarMonth.js","sources":["../src/calendar/internal/CalendarMonth.tsx"],"sourcesContent":["import {\n ComponentPropsWithRef,\n forwardRef,\n MouseEvent,\n SyntheticEvent,\n} from \"react\";\nimport { clsx } from \"clsx\";\nimport { makePrefixer } from \"@salt-ds/core\";\nimport { DateValue } from \"@internationalized/date\";\nimport { CalendarDay, CalendarDayProps } from \"./CalendarDay\";\nimport { formatDate, generateVisibleDays } from \"./utils\";\n\nimport calendarMonthCss from \"./CalendarMonth.css\";\nimport { useCalendarContext } from \"./CalendarContext\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\n\nexport interface CalendarMonthProps extends ComponentPropsWithRef<\"div\"> {\n date: DateValue;\n hideOutOfRangeDates?: boolean;\n renderDayContents?: CalendarDayProps[\"renderDayContents\"];\n TooltipProps?: CalendarDayProps[\"TooltipProps\"];\n}\n\nconst withBaseName = makePrefixer(\"saltCalendarMonth\");\n\nexport const CalendarMonth = forwardRef<HTMLDivElement, CalendarMonthProps>(\n function CalendarMonth(props, ref) {\n const {\n className,\n date,\n renderDayContents,\n onMouseLeave,\n TooltipProps,\n ...rest\n } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-calendar-month\",\n css: calendarMonthCss,\n window: targetWindow,\n });\n\n const days = generateVisibleDays(date);\n const {\n helpers: { setHoveredDate },\n } = useCalendarContext();\n\n const handleMouseLeave = (event: SyntheticEvent) => {\n setHoveredDate(event, null);\n onMouseLeave?.(event as MouseEvent<HTMLDivElement>);\n };\n\n return (\n <div\n className={clsx(withBaseName(), className)}\n ref={ref}\n onMouseLeave={handleMouseLeave}\n {...rest}\n >\n <div\n data-testid=\"CalendarDateGrid\"\n className={withBaseName(\"dateGrid\")}\n >\n {days.map((day) => {\n return (\n <CalendarDay\n key={formatDate(day.date)}\n day={day.date}\n renderDayContents={renderDayContents}\n month={date}\n TooltipProps={TooltipProps}\n />\n );\n })}\n </div>\n </div>\n );\n }\n);\n"],"names":["CalendarMonth","calendarMonthCss"],"mappings":";;;;;;;;;;;AAwBA,MAAM,YAAA,GAAe,aAAa,mBAAmB,CAAA,CAAA;AAE9C,MAAM,aAAgB,GAAA,UAAA;AAAA,EAC3B,SAASA,cAAc,CAAA,KAAA,EAAO,GAAK,EAAA;AACjC,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,IAAA;AAAA,MACA,iBAAA;AAAA,MACA,YA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ACF,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
@@ -1,4 +1,4 @@
1
- var css_248z = ".saltCalendarNavigation {\n display: grid;\n grid-template-columns: min-content auto min-content;\n padding-bottom: var(--salt-spacing-100);\n grid-gap: 0;\n align-items: center;\n height: var(--salt-size-base);\n}\n\n.saltCalendarNavigation-hideYearDropdown {\n grid-template-columns: min-content auto min-content;\n grid-gap: var(--salt-spacing-300);\n}\n\n.saltCalendarNavigation-dropdowns {\n display: grid;\n grid-template-columns: 1fr 1fr;\n grid-gap: var(--salt-spacing-100);\n}\n";
1
+ var css_248z = ".saltCalendarNavigation {\n display: grid;\n grid-template-columns: min-content auto min-content;\n padding-bottom: var(--salt-spacing-100);\n grid-gap: 0;\n align-items: center;\n box-sizing: border-box;\n}\n\n.saltCalendarNavigation-hideYearDropdown {\n grid-template-columns: min-content auto min-content;\n grid-gap: var(--salt-spacing-300);\n}\n\n.saltCalendarNavigation-dropdowns {\n display: grid;\n grid-template-columns: 1fr 1fr;\n grid-gap: var(--salt-spacing-100);\n}\n";
2
2
 
3
3
  export { css_248z as default };
4
4
  //# sourceMappingURL=CalendarNavigation.css.js.map