@wordpress/components 29.13.1-next.719a03cbe.0 → 30.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -3
- package/build/autocomplete/index.js +4 -0
- package/build/autocomplete/index.js.map +1 -1
- package/build/calendar/date-calendar/index.js +13 -4
- package/build/calendar/date-calendar/index.js.map +1 -1
- package/build/calendar/date-range-calendar/index.js +8 -4
- package/build/calendar/date-range-calendar/index.js.map +1 -1
- package/build/calendar/types.js.map +1 -1
- package/build/color-picker/styles.js +7 -7
- package/build/color-picker/styles.js.map +1 -1
- package/build/icon/index.js +2 -0
- package/build/icon/index.js.map +1 -1
- package/build/index.js +0 -19
- package/build/index.js.map +1 -1
- package/build/palette-edit/index.js +1 -1
- package/build/palette-edit/index.js.map +1 -1
- package/build/private-apis.js +9 -1
- package/build/private-apis.js.map +1 -1
- package/build/range-control/index.js +1 -1
- package/build/range-control/index.js.map +1 -1
- package/build/range-control/styles/range-control-styles.js +35 -35
- package/build/range-control/styles/range-control-styles.js.map +1 -1
- package/build/range-control/tooltip.js +15 -15
- package/build/range-control/tooltip.js.map +1 -1
- package/build/range-control/types.js.map +1 -1
- package/build/select-control/index.js +1 -1
- package/build/select-control/index.js.map +1 -1
- package/build/textarea-control/index.js +7 -1
- package/build/textarea-control/index.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/as-button-group.js.map +1 -1
- package/build/utils/hooks/use-controlled-value.js +8 -4
- package/build/utils/hooks/use-controlled-value.js.map +1 -1
- package/build/validated-form-controls/components/checkbox-control.js +52 -0
- package/build/validated-form-controls/components/checkbox-control.js.map +1 -0
- package/build/validated-form-controls/components/combobox-control.js +64 -0
- package/build/validated-form-controls/components/combobox-control.js.map +1 -0
- package/build/validated-form-controls/components/custom-select-control.js +71 -0
- package/build/validated-form-controls/components/custom-select-control.js.map +1 -0
- package/build/validated-form-controls/components/index.js +138 -0
- package/build/validated-form-controls/components/index.js.map +1 -0
- package/build/validated-form-controls/components/input-control.js +50 -0
- package/build/validated-form-controls/components/input-control.js.map +1 -0
- package/build/validated-form-controls/components/number-control.js +53 -0
- package/build/validated-form-controls/components/number-control.js.map +1 -0
- package/build/validated-form-controls/components/radio-control.js +51 -0
- package/build/validated-form-controls/components/radio-control.js.map +1 -0
- package/build/validated-form-controls/components/range-control.js +51 -0
- package/build/validated-form-controls/components/range-control.js.map +1 -0
- package/build/validated-form-controls/components/select-control.js +53 -0
- package/build/validated-form-controls/components/select-control.js.map +1 -0
- package/build/validated-form-controls/components/text-control.js +51 -0
- package/build/validated-form-controls/components/text-control.js.map +1 -0
- package/build/validated-form-controls/components/textarea-control.js +50 -0
- package/build/validated-form-controls/components/textarea-control.js.map +1 -0
- package/build/validated-form-controls/components/toggle-control.js +60 -0
- package/build/validated-form-controls/components/toggle-control.js.map +1 -0
- package/build/validated-form-controls/components/toggle-group-control.js +69 -0
- package/build/validated-form-controls/components/toggle-group-control.js.map +1 -0
- package/build/validated-form-controls/components/types.js +6 -0
- package/build/validated-form-controls/components/types.js.map +1 -0
- package/build/validated-form-controls/control-with-error.js +137 -0
- package/build/validated-form-controls/control-with-error.js.map +1 -0
- package/build/validated-form-controls/index.js +28 -0
- package/build/validated-form-controls/index.js.map +1 -0
- package/build-module/autocomplete/index.js +4 -0
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/calendar/date-calendar/index.js +11 -3
- package/build-module/calendar/date-calendar/index.js.map +1 -1
- package/build-module/calendar/date-range-calendar/index.js +8 -4
- package/build-module/calendar/date-range-calendar/index.js.map +1 -1
- package/build-module/calendar/types.js.map +1 -1
- package/build-module/color-picker/styles.js +7 -7
- package/build-module/color-picker/styles.js.map +1 -1
- package/build-module/icon/index.js +2 -0
- package/build-module/icon/index.js.map +1 -1
- package/build-module/index.js +0 -1
- package/build-module/index.js.map +1 -1
- package/build-module/palette-edit/index.js +2 -2
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/private-apis.js +9 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/range-control/index.js +1 -1
- package/build-module/range-control/index.js.map +1 -1
- package/build-module/range-control/styles/range-control-styles.js +35 -35
- package/build-module/range-control/styles/range-control-styles.js.map +1 -1
- package/build-module/range-control/tooltip.js +15 -15
- package/build-module/range-control/tooltip.js.map +1 -1
- package/build-module/range-control/types.js.map +1 -1
- package/build-module/select-control/index.js +1 -1
- package/build-module/select-control/index.js.map +1 -1
- package/build-module/textarea-control/index.js +7 -1
- package/build-module/textarea-control/index.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/as-button-group.js.map +1 -1
- package/build-module/utils/hooks/use-controlled-value.js +9 -5
- package/build-module/utils/hooks/use-controlled-value.js.map +1 -1
- package/build-module/validated-form-controls/components/checkbox-control.js +44 -0
- package/build-module/validated-form-controls/components/checkbox-control.js.map +1 -0
- package/build-module/validated-form-controls/components/combobox-control.js +56 -0
- package/build-module/validated-form-controls/components/combobox-control.js.map +1 -0
- package/build-module/validated-form-controls/components/custom-select-control.js +63 -0
- package/build-module/validated-form-controls/components/custom-select-control.js.map +1 -0
- package/build-module/validated-form-controls/components/index.js +13 -0
- package/build-module/validated-form-controls/components/index.js.map +1 -0
- package/build-module/validated-form-controls/components/input-control.js +42 -0
- package/build-module/validated-form-controls/components/input-control.js.map +1 -0
- package/build-module/validated-form-controls/components/number-control.js +45 -0
- package/build-module/validated-form-controls/components/number-control.js.map +1 -0
- package/build-module/validated-form-controls/components/radio-control.js +43 -0
- package/build-module/validated-form-controls/components/radio-control.js.map +1 -0
- package/build-module/validated-form-controls/components/range-control.js +43 -0
- package/build-module/validated-form-controls/components/range-control.js.map +1 -0
- package/build-module/validated-form-controls/components/select-control.js +45 -0
- package/build-module/validated-form-controls/components/select-control.js.map +1 -0
- package/build-module/validated-form-controls/components/text-control.js +43 -0
- package/build-module/validated-form-controls/components/text-control.js.map +1 -0
- package/build-module/validated-form-controls/components/textarea-control.js +42 -0
- package/build-module/validated-form-controls/components/textarea-control.js.map +1 -0
- package/build-module/validated-form-controls/components/toggle-control.js +52 -0
- package/build-module/validated-form-controls/components/toggle-control.js.map +1 -0
- package/build-module/validated-form-controls/components/toggle-group-control.js +62 -0
- package/build-module/validated-form-controls/components/toggle-group-control.js.map +1 -0
- package/build-module/validated-form-controls/components/types.js +2 -0
- package/build-module/validated-form-controls/components/types.js.map +1 -0
- package/build-module/validated-form-controls/control-with-error.js +129 -0
- package/build-module/validated-form-controls/control-with-error.js.map +1 -0
- package/build-module/validated-form-controls/index.js +3 -0
- package/build-module/validated-form-controls/index.js.map +1 -0
- package/build-style/style-rtl.css +81 -71
- package/build-style/style.css +81 -71
- package/build-types/autocomplete/index.d.ts.map +1 -1
- package/build-types/box-control/utils.d.ts +7 -7
- package/build-types/calendar/date-calendar/index.d.ts.map +1 -1
- package/build-types/calendar/date-range-calendar/index.d.ts.map +1 -1
- package/build-types/calendar/types.d.ts +2 -2
- package/build-types/calendar/types.d.ts.map +1 -1
- package/build-types/calendar/utils/use-localization-props.d.ts +3 -3
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/constants.d.ts +2 -2
- package/build-types/dimension-control/sizes.d.ts +5 -5
- package/build-types/font-size-picker/constants.d.ts +2 -2
- package/build-types/font-size-picker/constants.d.ts.map +1 -1
- package/build-types/icon/index.d.ts.map +1 -1
- package/build-types/index.d.ts +0 -1
- package/build-types/index.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/range-control/types.d.ts +2 -2
- package/build-types/range-control/types.d.ts.map +1 -1
- package/build-types/select-control/stories/index.story.d.ts.map +1 -1
- package/build-types/text-control/stories/index.story.d.ts.map +1 -1
- package/build-types/textarea-control/index.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts.map +1 -1
- package/build-types/utils/hooks/use-controlled-value.d.ts +2 -2
- package/build-types/utils/hooks/use-controlled-value.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/checkbox-control.d.ts +9 -0
- package/build-types/validated-form-controls/components/checkbox-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/combobox-control.d.ts +21 -0
- package/build-types/validated-form-controls/components/combobox-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/custom-select-control.d.ts +4 -0
- package/build-types/validated-form-controls/components/custom-select-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/index.d.ts +13 -0
- package/build-types/validated-form-controls/components/index.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/input-control.d.ts +4 -0
- package/build-types/validated-form-controls/components/input-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/number-control.d.ts +17 -0
- package/build-types/validated-form-controls/components/number-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/radio-control.d.ts +11 -0
- package/build-types/validated-form-controls/components/radio-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/range-control.d.ts +36 -0
- package/build-types/validated-form-controls/components/range-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/select-control.d.ts +9 -0
- package/build-types/validated-form-controls/components/select-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/stories/checkbox-control.story.d.ts +12 -0
- package/build-types/validated-form-controls/components/stories/checkbox-control.story.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/stories/combobox-control.story.d.ts +12 -0
- package/build-types/validated-form-controls/components/stories/combobox-control.story.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/stories/custom-select-control.story.d.ts +12 -0
- package/build-types/validated-form-controls/components/stories/custom-select-control.story.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/stories/input-control.story.d.ts +18 -0
- package/build-types/validated-form-controls/components/stories/input-control.story.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/stories/number-control.story.d.ts +12 -0
- package/build-types/validated-form-controls/components/stories/number-control.story.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/stories/overview.story.d.ts +19 -0
- package/build-types/validated-form-controls/components/stories/overview.story.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/stories/radio-control.story.d.ts +12 -0
- package/build-types/validated-form-controls/components/stories/radio-control.story.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/stories/range-control.story.d.ts +9 -0
- package/build-types/validated-form-controls/components/stories/range-control.story.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/stories/select-control.story.d.ts +12 -0
- package/build-types/validated-form-controls/components/stories/select-control.story.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/stories/story-utils.d.ts +9 -0
- package/build-types/validated-form-controls/components/stories/story-utils.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/stories/text-control.story.d.ts +9 -0
- package/build-types/validated-form-controls/components/stories/text-control.story.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/stories/textarea-control.story.d.ts +9 -0
- package/build-types/validated-form-controls/components/stories/textarea-control.story.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/stories/toggle-control.story.d.ts +9 -0
- package/build-types/validated-form-controls/components/stories/toggle-control.story.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/stories/toggle-group-control.story.d.ts +9 -0
- package/build-types/validated-form-controls/components/stories/toggle-group-control.story.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/text-control.d.ts +8 -0
- package/build-types/validated-form-controls/components/text-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/textarea-control.d.ts +7 -0
- package/build-types/validated-form-controls/components/textarea-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/toggle-control.d.ts +7 -0
- package/build-types/validated-form-controls/components/toggle-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/toggle-group-control.d.ts +15 -0
- package/build-types/validated-form-controls/components/toggle-group-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/types.d.ts +27 -0
- package/build-types/validated-form-controls/components/types.d.ts.map +1 -0
- package/build-types/validated-form-controls/control-with-error.d.ts +36 -0
- package/build-types/validated-form-controls/control-with-error.d.ts.map +1 -0
- package/build-types/validated-form-controls/index.d.ts +3 -0
- package/build-types/validated-form-controls/index.d.ts.map +1 -0
- package/package.json +19 -19
- package/src/autocomplete/index.tsx +4 -0
- package/src/calendar/date-calendar/README.md +57 -46
- package/src/calendar/date-calendar/index.tsx +22 -8
- package/src/calendar/date-range-calendar/README.md +63 -52
- package/src/calendar/date-range-calendar/index.tsx +23 -11
- package/src/calendar/types.ts +2 -2
- package/src/color-picker/styles.ts +10 -0
- package/src/dimension-control/test/__snapshots__/index.test.js.snap +8 -8
- package/src/icon/index.tsx +2 -0
- package/src/index.ts +0 -1
- package/src/modal/style.scss +2 -2
- package/src/palette-edit/index.tsx +3 -3
- package/src/private-apis.ts +13 -0
- package/src/range-control/index.tsx +1 -1
- package/src/range-control/styles/range-control-styles.ts +3 -3
- package/src/range-control/tooltip.tsx +13 -13
- package/src/range-control/types.ts +2 -2
- package/src/select-control/index.tsx +1 -1
- package/src/style.scss +2 -2
- package/src/text-control/stories/index.story.tsx +1 -0
- package/src/text-control/style.scss +6 -1
- package/src/textarea-control/index.tsx +8 -1
- package/src/toggle-group-control/toggle-group-control/as-button-group.tsx +3 -1
- package/src/utils/hooks/use-controlled-value.ts +16 -8
- package/src/utils/theme-variables.scss +3 -0
- package/src/validated-form-controls/components/checkbox-control.tsx +64 -0
- package/src/validated-form-controls/components/combobox-control.tsx +77 -0
- package/src/validated-form-controls/components/custom-select-control.tsx +86 -0
- package/src/validated-form-controls/components/index.ts +12 -0
- package/src/validated-form-controls/components/input-control.tsx +59 -0
- package/src/validated-form-controls/components/number-control.tsx +61 -0
- package/src/validated-form-controls/components/radio-control.tsx +60 -0
- package/src/validated-form-controls/components/range-control.tsx +60 -0
- package/src/validated-form-controls/components/select-control.tsx +75 -0
- package/src/validated-form-controls/components/stories/checkbox-control.story.tsx +57 -0
- package/src/validated-form-controls/components/stories/combobox-control.story.tsx +64 -0
- package/src/validated-form-controls/components/stories/custom-select-control.story.tsx +64 -0
- package/src/validated-form-controls/components/stories/input-control.story.tsx +132 -0
- package/src/validated-form-controls/components/stories/number-control.story.tsx +62 -0
- package/src/validated-form-controls/components/stories/overview.mdx +52 -0
- package/src/validated-form-controls/components/stories/overview.story.tsx +100 -0
- package/src/validated-form-controls/components/stories/radio-control.story.tsx +64 -0
- package/src/validated-form-controls/components/stories/range-control.story.tsx +60 -0
- package/src/validated-form-controls/components/stories/select-control.story.tsx +60 -0
- package/src/validated-form-controls/components/stories/story-utils.tsx +46 -0
- package/src/validated-form-controls/components/stories/text-control.story.tsx +55 -0
- package/src/validated-form-controls/components/stories/textarea-control.story.tsx +52 -0
- package/src/validated-form-controls/components/stories/toggle-control.story.tsx +55 -0
- package/src/validated-form-controls/components/stories/toggle-group-control.story.tsx +66 -0
- package/src/validated-form-controls/components/text-control.tsx +60 -0
- package/src/validated-form-controls/components/textarea-control.tsx +59 -0
- package/src/validated-form-controls/components/toggle-control.tsx +69 -0
- package/src/validated-form-controls/components/toggle-group-control.tsx +82 -0
- package/src/validated-form-controls/components/types.ts +28 -0
- package/src/validated-form-controls/control-with-error.tsx +198 -0
- package/src/validated-form-controls/index.ts +2 -0
- package/src/validated-form-controls/style.scss +75 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/calendar/utils/use-controlled-value.js +0 -58
- package/build/calendar/utils/use-controlled-value.js.map +0 -1
- package/build-module/calendar/utils/use-controlled-value.js +0 -51
- package/build-module/calendar/utils/use-controlled-value.js.map +0 -1
- package/build-types/calendar/utils/use-controlled-value.d.ts +0 -27
- package/build-types/calendar/utils/use-controlled-value.d.ts.map +0 -1
- package/src/calendar/utils/use-controlled-value.ts +0 -61
- package/src/dimension-control/style.scss +0 -22
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
5
|
+
/**
|
|
6
|
+
* Internal dependencies
|
|
7
|
+
*/
|
|
8
|
+
import { ValidatedSelectControl } from '../select-control';
|
|
9
|
+
declare const meta: Meta<typeof ValidatedSelectControl>;
|
|
10
|
+
export default meta;
|
|
11
|
+
export declare const Default: StoryObj<typeof ValidatedSelectControl>;
|
|
12
|
+
//# sourceMappingURL=select-control.story.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-control.story.d.ts","sourceRoot":"","sources":["../../../../src/validated-form-controls/components/stories/select-control.story.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;GAEG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAG3D,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,sBAAsB,CAS9C,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAE,OAAO,sBAAsB,CAe5D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"story-utils.d.ts","sourceRoot":"","sources":["../../../../src/validated-form-controls/components/stories/story-utils.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAO7C,eAAO,MAAM,aAAa,EAAE,IAAI,CAAE,YAAY,CA+B7C,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
5
|
+
import { ValidatedTextControl } from '../text-control';
|
|
6
|
+
declare const meta: Meta<typeof ValidatedTextControl>;
|
|
7
|
+
export default meta;
|
|
8
|
+
export declare const Default: StoryObj<typeof ValidatedTextControl>;
|
|
9
|
+
//# sourceMappingURL=text-control.story.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-control.story.d.ts","sourceRoot":"","sources":["../../../../src/validated-form-controls/components/stories/text-control.story.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAMvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,oBAAoB,CAS5C,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAE,OAAO,oBAAoB,CAe1D,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
5
|
+
import { ValidatedTextareaControl } from '../textarea-control';
|
|
6
|
+
declare const meta: Meta<typeof ValidatedTextareaControl>;
|
|
7
|
+
export default meta;
|
|
8
|
+
export declare const Default: StoryObj<typeof ValidatedTextareaControl>;
|
|
9
|
+
//# sourceMappingURL=textarea-control.story.d.ts.map
|
package/build-types/validated-form-controls/components/stories/textarea-control.story.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textarea-control.story.d.ts","sourceRoot":"","sources":["../../../../src/validated-form-controls/components/stories/textarea-control.story.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAKvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,wBAAwB,CAOhD,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAE,OAAO,wBAAwB,CAe9D,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
5
|
+
import { ValidatedToggleControl } from '../toggle-control';
|
|
6
|
+
declare const meta: Meta<typeof ValidatedToggleControl>;
|
|
7
|
+
export default meta;
|
|
8
|
+
export declare const Default: StoryObj<typeof ValidatedToggleControl>;
|
|
9
|
+
//# sourceMappingURL=toggle-control.story.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggle-control.story.d.ts","sourceRoot":"","sources":["../../../../src/validated-form-controls/components/stories/toggle-control.story.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAMvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,sBAAsB,CAS9C,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAE,OAAO,sBAAsB,CAe5D,CAAC"}
|
package/build-types/validated-form-controls/components/stories/toggle-group-control.story.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
5
|
+
import { ValidatedToggleGroupControl } from '../toggle-group-control';
|
|
6
|
+
declare const meta: Meta<typeof ValidatedToggleGroupControl>;
|
|
7
|
+
export default meta;
|
|
8
|
+
export declare const Default: StoryObj<typeof ValidatedToggleGroupControl>;
|
|
9
|
+
//# sourceMappingURL=toggle-group-control.story.d.ts.map
|
package/build-types/validated-form-controls/components/stories/toggle-group-control.story.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggle-group-control.story.d.ts","sourceRoot":"","sources":["../../../../src/validated-form-controls/components/stories/toggle-group-control.story.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAMvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAGtE,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,2BAA2B,CASnD,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAE,OAAO,2BAA2B,CAoBjE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ValidatedControlProps } from './types';
|
|
2
|
+
export declare const ValidatedTextControl: import("react").ForwardRefExoticComponent<Omit<Omit<Pick<import("../../base-control/types").BaseControlProps, "help" | "label" | "className" | "hideLabelFromVision" | "__nextHasNoMarginBottom"> & {
|
|
3
|
+
onChange: (value: string) => void;
|
|
4
|
+
value: string | number;
|
|
5
|
+
type?: "date" | "datetime-local" | "email" | "number" | "password" | "tel" | "text" | "time" | "search" | "url";
|
|
6
|
+
__next40pxDefaultSize?: boolean;
|
|
7
|
+
} & Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "help" | "label" | "className" | "type" | "children" | "onChange" | "value" | "as" | "__next40pxDefaultSize" | "hideLabelFromVision" | "__nextHasNoMarginBottom"> & import("react").RefAttributes<HTMLInputElement>, "__next40pxDefaultSize" | "__nextHasNoMarginBottom"> & ValidatedControlProps<string | number>, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
8
|
+
//# sourceMappingURL=text-control.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-control.d.ts","sourceRoot":"","sources":["../../../src/validated-form-controls/components/text-control.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AA+CrD,eAAO,MAAM,oBAAoB;;;;;+eAEhC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ValidatedControlProps } from './types';
|
|
2
|
+
export declare const ValidatedTextareaControl: import("react").ForwardRefExoticComponent<Omit<Omit<Pick<import("../../base-control/types").BaseControlProps, "help" | "label" | "hideLabelFromVision" | "__nextHasNoMarginBottom"> & {
|
|
3
|
+
onChange: (value: string) => void;
|
|
4
|
+
value: string;
|
|
5
|
+
rows?: import("react").TextareaHTMLAttributes<HTMLTextAreaElement>["rows"];
|
|
6
|
+
} & Omit<Omit<import("react").DetailedHTMLProps<import("react").TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref">, "help" | "label" | "children" | "onChange" | "value" | "rows" | "as" | "hideLabelFromVision" | "__nextHasNoMarginBottom"> & import("react").RefAttributes<HTMLTextAreaElement>, "__nextHasNoMarginBottom"> & ValidatedControlProps<string>, "ref"> & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
7
|
+
//# sourceMappingURL=textarea-control.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textarea-control.d.ts","sourceRoot":"","sources":["../../../src/validated-form-controls/components/textarea-control.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AA8CrD,eAAO,MAAM,wBAAwB;;;;mbAEpC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ValidatedControlProps } from './types';
|
|
2
|
+
export declare const ValidatedToggleControl: import("react").ForwardRefExoticComponent<Omit<Omit<Pick<import("../../form-toggle/types").FormToggleProps, "disabled" | "checked"> & Pick<import("../../base-control/types").BaseControlProps, "className" | "__nextHasNoMarginBottom"> & {
|
|
3
|
+
help?: import("react").ReactNode | ((checked: boolean) => import("react").ReactNode);
|
|
4
|
+
label: import("react").ReactNode;
|
|
5
|
+
onChange: (value: boolean) => void;
|
|
6
|
+
} & Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "help" | "disabled" | "label" | "className" | "children" | "onChange" | "checked" | "as" | "__nextHasNoMarginBottom"> & import("react").RefAttributes<HTMLInputElement>, "__nextHasNoMarginBottom"> & ValidatedControlProps<boolean | undefined>, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
7
|
+
//# sourceMappingURL=toggle-control.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggle-control.d.ts","sourceRoot":"","sources":["../../../src/validated-form-controls/components/toggle-control.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAwDrD,eAAO,MAAM,sBAAsB;;;;6aAElC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ValidatedControlProps } from './types';
|
|
2
|
+
export declare const ValidatedToggleGroupControl: import("react").ForwardRefExoticComponent<Omit<Omit<Pick<import("../../base-control/types").BaseControlProps, "help" | "__nextHasNoMarginBottom"> & {
|
|
3
|
+
label: string;
|
|
4
|
+
hideLabelFromVision?: boolean;
|
|
5
|
+
isAdaptiveWidth?: boolean;
|
|
6
|
+
isBlock?: boolean;
|
|
7
|
+
isDeselectable?: boolean;
|
|
8
|
+
onChange?: (value: string | number | undefined) => void;
|
|
9
|
+
value?: string | number;
|
|
10
|
+
children: import("react").ReactNode;
|
|
11
|
+
size?: "default" | "__unstable-large";
|
|
12
|
+
__next40pxDefaultSize?: boolean;
|
|
13
|
+
__shouldNotWarnDeprecated36pxSize?: boolean;
|
|
14
|
+
} & import("react").RefAttributes<any> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "size" | "help" | "label" | "children" | "onChange" | "value" | "as" | keyof import("react").RefAttributes<any> | "isBlock" | "__next40pxDefaultSize" | "__shouldNotWarnDeprecated36pxSize" | "hideLabelFromVision" | "__nextHasNoMarginBottom" | "isAdaptiveWidth" | "isDeselectable">, "__next40pxDefaultSize" | "__nextHasNoMarginBottom"> & ValidatedControlProps<string | number | undefined>, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
15
|
+
//# sourceMappingURL=toggle-group-control.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggle-group-control.d.ts","sourceRoot":"","sources":["../../../src/validated-form-controls/components/toggle-group-control.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAsErD,eAAO,MAAM,2BAA2B;;;;;;;;;;;;2lBAEvC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type ValidatedControlProps<V> = {
|
|
2
|
+
/**
|
|
3
|
+
* Whether the control is required.
|
|
4
|
+
* @default false
|
|
5
|
+
*/
|
|
6
|
+
required?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Label the control as "optional" when _not_ `required`, instead of the inverse.
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
markWhenOptional?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* A function that returns a custom validity message when applicable. This error message will be applied to the
|
|
14
|
+
* underlying element using the native [`setCustomValidity()` method](https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/setCustomValidity).
|
|
15
|
+
* This means the custom validator will be run _in addition_ to any other HTML attribute-based validation, and
|
|
16
|
+
* will be prioritized over any existing validity messages dictated by the HTML attributes.
|
|
17
|
+
* An empty string or `undefined` return value will clear any existing custom validity message.
|
|
18
|
+
*
|
|
19
|
+
* Make sure you don't programatically pass a value (such as an initial value) to the control component
|
|
20
|
+
* that fails this validator, because the validator will only run for user-initiated changes.
|
|
21
|
+
*
|
|
22
|
+
* Always prefer using standard HTML attributes like `required` and `min`/`max` over custom validators
|
|
23
|
+
* when possible, as they are simpler and have localized error messages built in.
|
|
24
|
+
*/
|
|
25
|
+
customValidator?: (currentValue: V) => string | void;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/validated-form-controls/components/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,CAAE,CAAC,IAAK;IACxC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;;;;;;;OAYG;IAGH,eAAe,CAAC,EAAE,CAAE,YAAY,EAAE,CAAC,KAAM,MAAM,GAAG,IAAI,CAAC;CACvD,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML elements that support the Constraint Validation API.
|
|
3
|
+
*
|
|
4
|
+
* Here, we exclude HTMLButtonElement because although it does technically support the API,
|
|
5
|
+
* normal buttons are actually exempted from any validation.
|
|
6
|
+
* @see https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Forms/Form_validation
|
|
7
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/willValidate
|
|
8
|
+
*/
|
|
9
|
+
type ValidityTarget = HTMLFieldSetElement | HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
|
|
10
|
+
export declare const ControlWithError: import("react").ForwardRefExoticComponent<{
|
|
11
|
+
/**
|
|
12
|
+
* Whether the control is required.
|
|
13
|
+
*/
|
|
14
|
+
required?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Label the control as "optional" when _not_ `required`, instead of the inverse.
|
|
17
|
+
*/
|
|
18
|
+
markWhenOptional?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* A function that returns a custom validity message when applicable.
|
|
21
|
+
*
|
|
22
|
+
* This message will be applied to the element returned by `getValidityTarget`.
|
|
23
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/setCustomValidity
|
|
24
|
+
*/
|
|
25
|
+
customValidator?: () => string | void;
|
|
26
|
+
/**
|
|
27
|
+
* A function that returns the actual element on which the validity data should be applied.
|
|
28
|
+
*/
|
|
29
|
+
getValidityTarget: () => ValidityTarget | null | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* The control component to apply validation to.
|
|
32
|
+
*/
|
|
33
|
+
children: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
34
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=control-with-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-with-error.d.ts","sourceRoot":"","sources":["../../src/validated-form-controls/control-with-error.tsx"],"names":[],"mappings":"AA6CA;;;;;;;GAOG;AACH,KAAK,cAAc,GAChB,mBAAmB,GACnB,gBAAgB,GAChB,iBAAiB,GACjB,mBAAmB,CAAC;AA4IvB,eAAO,MAAM,gBAAgB;IAlI3B;;OAEG;eACQ,OAAO;IAClB;;OAEG;uBACgB,OAAO;IAC1B;;;;;OAKG;sBACe,MAAM,MAAM,GAAG,IAAI;IACrC;;OAEG;uBACgB,MAAM,cAAc,GAAG,IAAI,GAAG,SAAS;IAC1D;;OAEG;;kDA6GoE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validated-form-controls/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "30.1.0",
|
|
4
4
|
"description": "UI components for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -44,23 +44,23 @@
|
|
|
44
44
|
"@types/gradient-parser": "0.1.3",
|
|
45
45
|
"@types/highlight-words-core": "1.2.1",
|
|
46
46
|
"@use-gesture/react": "^10.3.1",
|
|
47
|
-
"@wordpress/a11y": "^4.
|
|
48
|
-
"@wordpress/compose": "^7.
|
|
49
|
-
"@wordpress/date": "^5.
|
|
50
|
-
"@wordpress/deprecated": "^4.
|
|
51
|
-
"@wordpress/dom": "^4.
|
|
52
|
-
"@wordpress/element": "^6.
|
|
53
|
-
"@wordpress/escape-html": "^3.
|
|
54
|
-
"@wordpress/hooks": "^4.
|
|
55
|
-
"@wordpress/html-entities": "^4.
|
|
56
|
-
"@wordpress/i18n": "^6.
|
|
57
|
-
"@wordpress/icons": "^10.
|
|
58
|
-
"@wordpress/is-shallow-equal": "^5.
|
|
59
|
-
"@wordpress/keycodes": "^4.
|
|
60
|
-
"@wordpress/primitives": "^4.
|
|
61
|
-
"@wordpress/private-apis": "^1.
|
|
62
|
-
"@wordpress/rich-text": "^7.
|
|
63
|
-
"@wordpress/warning": "^3.
|
|
47
|
+
"@wordpress/a11y": "^4.28.0",
|
|
48
|
+
"@wordpress/compose": "^7.28.0",
|
|
49
|
+
"@wordpress/date": "^5.28.0",
|
|
50
|
+
"@wordpress/deprecated": "^4.28.0",
|
|
51
|
+
"@wordpress/dom": "^4.28.0",
|
|
52
|
+
"@wordpress/element": "^6.28.0",
|
|
53
|
+
"@wordpress/escape-html": "^3.28.0",
|
|
54
|
+
"@wordpress/hooks": "^4.28.0",
|
|
55
|
+
"@wordpress/html-entities": "^4.28.0",
|
|
56
|
+
"@wordpress/i18n": "^6.1.0",
|
|
57
|
+
"@wordpress/icons": "^10.28.0",
|
|
58
|
+
"@wordpress/is-shallow-equal": "^5.28.0",
|
|
59
|
+
"@wordpress/keycodes": "^4.28.0",
|
|
60
|
+
"@wordpress/primitives": "^4.28.0",
|
|
61
|
+
"@wordpress/private-apis": "^1.28.0",
|
|
62
|
+
"@wordpress/rich-text": "^7.28.0",
|
|
63
|
+
"@wordpress/warning": "^3.28.0",
|
|
64
64
|
"change-case": "^4.1.2",
|
|
65
65
|
"clsx": "^2.1.1",
|
|
66
66
|
"colord": "^2.7.0",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"publishConfig": {
|
|
87
87
|
"access": "public"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "28cc2098f5ee28f89096b638533796538f495f72"
|
|
90
90
|
}
|
|
@@ -126,6 +126,10 @@ export function useAutocomplete( {
|
|
|
126
126
|
// Reset autocomplete state after insertion rather than before
|
|
127
127
|
// so insertion events don't cause the completion menu to redisplay.
|
|
128
128
|
reset();
|
|
129
|
+
|
|
130
|
+
// Make sure that the content remains focused after making a selection
|
|
131
|
+
// and that the text cursor position is not lost.
|
|
132
|
+
contentRef.current?.focus();
|
|
129
133
|
}
|
|
130
134
|
|
|
131
135
|
function reset() {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# `DateCalendar`
|
|
2
2
|
|
|
3
|
+
🔒 This component is locked as a [private API](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-private-apis/). We do not yet recommend using this outside of the Gutenberg project.
|
|
4
|
+
|
|
3
5
|
`DateCalendar` is a React component that provides a customizable calendar interface for **single date** selection.
|
|
4
6
|
|
|
5
7
|
The component is built with accessibility in mind and follows ARIA best practices for calendar widgets. It provides keyboard navigation, screen reader support, and customizable labels for internationalization.
|
|
@@ -7,7 +9,7 @@ The component is built with accessibility in mind and follows ARIA best practice
|
|
|
7
9
|
## Usage example
|
|
8
10
|
|
|
9
11
|
```tsx
|
|
10
|
-
import { DateCalendar } from '@
|
|
12
|
+
import { DateCalendar } from '@wordpress/components';
|
|
11
13
|
|
|
12
14
|
function MyComponent() {
|
|
13
15
|
const [ selected, setSelected ] = useState< Date >( new Date() );
|
|
@@ -22,95 +24,95 @@ These props are shared between both single date and date range calendar modes.
|
|
|
22
24
|
|
|
23
25
|
### `required`
|
|
24
26
|
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
27
|
+
- Type: `boolean`
|
|
28
|
+
- Required: No
|
|
29
|
+
- Default: `false`
|
|
28
30
|
|
|
29
31
|
Whether the selection is required. When `true`, there always needs to be a date selected.
|
|
30
32
|
|
|
31
33
|
### `selected`
|
|
32
34
|
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
+
- Type: `Date | undefined | null`
|
|
36
|
+
- Required: No
|
|
35
37
|
|
|
36
38
|
The selected date.
|
|
37
39
|
|
|
38
40
|
### `onSelect`
|
|
39
41
|
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
+
- Type: `(selected: Date | undefined, triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => void`
|
|
43
|
+
- Required: No
|
|
42
44
|
|
|
43
45
|
Event handler when a day is selected.
|
|
44
46
|
|
|
45
47
|
### `defaultSelected`
|
|
46
48
|
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
+
- Type: `Date`
|
|
50
|
+
- Required: No
|
|
49
51
|
|
|
50
52
|
The default selected date (for uncontrolled usage).
|
|
51
53
|
|
|
52
54
|
### `defaultMonth`
|
|
53
55
|
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
56
|
+
- Type: `Date`
|
|
57
|
+
- Required: No
|
|
58
|
+
- Default: Current month
|
|
57
59
|
|
|
58
60
|
The initial month to show in the calendar view (uncontrolled).
|
|
59
61
|
|
|
60
62
|
### `month`
|
|
61
63
|
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
+
- Type: `Date`
|
|
65
|
+
- Required: No
|
|
64
66
|
|
|
65
67
|
The month displayed in the calendar view (controlled). Use together with `onMonthChange` to change the month programmatically.
|
|
66
68
|
|
|
67
69
|
### `numberOfMonths`
|
|
68
70
|
|
|
69
|
-
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
71
|
+
- Type: `number`
|
|
72
|
+
- Required: No
|
|
73
|
+
- Default: `1`
|
|
72
74
|
|
|
73
75
|
The number of months displayed at once.
|
|
74
76
|
|
|
75
77
|
### `startMonth`
|
|
76
78
|
|
|
77
|
-
-
|
|
78
|
-
-
|
|
79
|
+
- Type: `Date`
|
|
80
|
+
- Required: No
|
|
79
81
|
|
|
80
82
|
The earliest month to start the month navigation.
|
|
81
83
|
|
|
82
84
|
### `endMonth`
|
|
83
85
|
|
|
84
|
-
-
|
|
85
|
-
-
|
|
86
|
+
- Type: `Date`
|
|
87
|
+
- Required: No
|
|
86
88
|
|
|
87
89
|
The latest month to end the month navigation.
|
|
88
90
|
|
|
89
91
|
### `autoFocus`
|
|
90
92
|
|
|
91
|
-
-
|
|
92
|
-
-
|
|
93
|
+
- Type: `boolean`
|
|
94
|
+
- Required: No
|
|
93
95
|
|
|
94
96
|
Focus the first selected day (if set) or today's date (if not disabled). Use this prop when you need to focus the calendar after a user action (e.g. opening the dialog with the calendar).
|
|
95
97
|
|
|
96
98
|
### `disabled`
|
|
97
99
|
|
|
98
|
-
-
|
|
99
|
-
-
|
|
100
|
+
- Type: `Matcher | Matcher[] | undefined`
|
|
101
|
+
- Required: No
|
|
100
102
|
|
|
101
103
|
Specify which days are disabled. Using `true` will disable all dates. See the [Matcher Types](#matcher-types) section for more details.
|
|
102
104
|
|
|
103
105
|
### `disableNavigation`
|
|
104
106
|
|
|
105
|
-
-
|
|
106
|
-
-
|
|
107
|
+
- Type: `boolean`
|
|
108
|
+
- Required: No
|
|
107
109
|
|
|
108
110
|
Disable the navigation buttons.
|
|
109
111
|
|
|
110
112
|
### `labels`
|
|
111
113
|
|
|
112
|
-
-
|
|
113
|
-
-
|
|
114
|
+
- Type: `object`
|
|
115
|
+
- Required: No
|
|
114
116
|
|
|
115
117
|
Use custom labels for internationalization. All labels are optional and have sensible defaults:
|
|
116
118
|
|
|
@@ -130,9 +132,9 @@ Use custom labels for internationalization. All labels are optional and have sen
|
|
|
130
132
|
|
|
131
133
|
### `locale`
|
|
132
134
|
|
|
133
|
-
-
|
|
134
|
-
-
|
|
135
|
-
-
|
|
135
|
+
- Type: `Locale`
|
|
136
|
+
- Required: No
|
|
137
|
+
- Default: `enUS` from `@date-fns/locale`
|
|
136
138
|
|
|
137
139
|
The locale object used to localize dates. Pass a locale from `@date-fns/locale` to localize the calendar.
|
|
138
140
|
|
|
@@ -140,45 +142,51 @@ The locale object used to localize dates. Pass a locale from `@date-fns/locale`
|
|
|
140
142
|
|
|
141
143
|
### `weekStartsOn`
|
|
142
144
|
|
|
143
|
-
-
|
|
144
|
-
-
|
|
145
|
-
-
|
|
145
|
+
- Type: `0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined`
|
|
146
|
+
- Required: No
|
|
147
|
+
- Default: Based on the `locale` prop
|
|
146
148
|
|
|
147
149
|
The index of the first day of the week (0 - Sunday). Overrides the locale's setting.
|
|
148
150
|
|
|
149
151
|
### `onMonthChange`
|
|
150
152
|
|
|
151
|
-
-
|
|
152
|
-
-
|
|
153
|
+
- Type: `(month: Date) => void`
|
|
154
|
+
- Required: No
|
|
153
155
|
|
|
154
156
|
Event fired when the user navigates between months.
|
|
155
157
|
|
|
156
158
|
### `timeZone`
|
|
157
159
|
|
|
158
|
-
-
|
|
159
|
-
-
|
|
160
|
+
- Type: `string`
|
|
161
|
+
- Required: No
|
|
160
162
|
|
|
161
163
|
The time zone (IANA or UTC offset) to use in the calendar. See [Wikipedia](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) for possible values.
|
|
162
164
|
|
|
163
165
|
When working with time zones, use the `TZDate` object exported by this package instead of the native `Date` object.
|
|
164
166
|
|
|
165
167
|
```tsx
|
|
166
|
-
import { DateCalendar, TZDate } from '@
|
|
168
|
+
import { DateCalendar, TZDate } from '@wordpress/components';
|
|
167
169
|
|
|
168
170
|
export function WithTimeZone() {
|
|
169
171
|
const timeZone = 'America/New_York';
|
|
170
172
|
const [ selected, setSelected ] = useState< Date | undefined >(
|
|
171
173
|
new TZDate( 2024, 12, 10, timeZone ) // Use `TZDate` instead of `Date`
|
|
172
174
|
);
|
|
173
|
-
return
|
|
175
|
+
return (
|
|
176
|
+
<DateCalendar
|
|
177
|
+
timeZone={ timeZone }
|
|
178
|
+
selected={ selected }
|
|
179
|
+
onSelect={ setSelected }
|
|
180
|
+
/>
|
|
181
|
+
);
|
|
174
182
|
}
|
|
175
183
|
```
|
|
176
184
|
|
|
177
185
|
### `role`
|
|
178
186
|
|
|
179
|
-
-
|
|
180
|
-
-
|
|
181
|
-
-
|
|
187
|
+
- Type: `'application' | 'dialog' | undefined`
|
|
188
|
+
- Required: No
|
|
189
|
+
- Default: `'application'`
|
|
182
190
|
|
|
183
191
|
The role attribute to add to the container element.
|
|
184
192
|
|
|
@@ -201,7 +209,10 @@ const dateMatcher: Matcher = new Date(); // Will match today's date
|
|
|
201
209
|
### Array Matcher
|
|
202
210
|
|
|
203
211
|
```typescript
|
|
204
|
-
const arrayMatcher: Matcher = [
|
|
212
|
+
const arrayMatcher: Matcher = [
|
|
213
|
+
new Date( 2019, 1, 2 ),
|
|
214
|
+
new Date( 2019, 1, 4 ),
|
|
215
|
+
]; // Will match the days in the array
|
|
205
216
|
```
|
|
206
217
|
|
|
207
218
|
### Date After Matcher
|
|
@@ -3,14 +3,18 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { DayPicker } from 'react-day-picker';
|
|
5
5
|
import { enUS } from 'react-day-picker/locale';
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useCallback } from '@wordpress/element';
|
|
6
10
|
/**
|
|
7
11
|
* Internal dependencies
|
|
8
12
|
*/
|
|
9
13
|
import { COMMON_PROPS } from '../utils/constants';
|
|
10
14
|
import { clampNumberOfMonths } from '../utils/misc';
|
|
11
|
-
import { useControlledValue } from '
|
|
15
|
+
import { useControlledValue } from '../../utils/hooks';
|
|
12
16
|
import { useLocalizationProps } from '../utils/use-localization-props';
|
|
13
|
-
import type { DateCalendarProps } from '../types';
|
|
17
|
+
import type { DateCalendarProps, OnSelectHandler } from '../types';
|
|
14
18
|
|
|
15
19
|
/**
|
|
16
20
|
* `DateCalendar` is a React component that provides a customizable calendar
|
|
@@ -35,11 +39,21 @@ export const DateCalendar = ( {
|
|
|
35
39
|
mode: 'single',
|
|
36
40
|
} );
|
|
37
41
|
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
const onChange: OnSelectHandler< typeof selectedProp > = useCallback(
|
|
43
|
+
( selected, triggerDate, modifiers, e ) => {
|
|
44
|
+
// Convert internal `null` to `undefined` for the public event handler.
|
|
45
|
+
onSelect?.( selected ?? undefined, triggerDate, modifiers, e );
|
|
46
|
+
},
|
|
47
|
+
[ onSelect ]
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const [ selected, setSelected ] = useControlledValue< typeof selectedProp >(
|
|
51
|
+
{
|
|
52
|
+
defaultValue: defaultSelected,
|
|
53
|
+
value: selectedProp,
|
|
54
|
+
onChange,
|
|
55
|
+
}
|
|
56
|
+
);
|
|
43
57
|
|
|
44
58
|
return (
|
|
45
59
|
<DayPicker
|
|
@@ -48,7 +62,7 @@ export const DateCalendar = ( {
|
|
|
48
62
|
{ ...props }
|
|
49
63
|
mode="single"
|
|
50
64
|
numberOfMonths={ clampNumberOfMonths( numberOfMonths ) }
|
|
51
|
-
selected={ selected }
|
|
65
|
+
selected={ selected ?? undefined }
|
|
52
66
|
onSelect={ setSelected }
|
|
53
67
|
/>
|
|
54
68
|
);
|