@wordpress/components 19.10.0 → 19.11.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 +24 -6
- package/build/border-box-control/border-box-control/component.js +22 -7
- package/build/border-box-control/border-box-control/component.js.map +1 -1
- package/build/border-box-control/border-box-control-linked-button/hook.js +3 -2
- package/build/border-box-control/border-box-control-linked-button/hook.js.map +1 -1
- package/build/border-box-control/border-box-control-split-controls/component.js +21 -8
- package/build/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build/border-box-control/border-box-control-visualizer/hook.js +3 -2
- package/build/border-box-control/border-box-control-visualizer/hook.js.map +1 -1
- package/build/border-box-control/styles.js +11 -15
- package/build/border-box-control/styles.js.map +1 -1
- package/build/border-control/border-control/component.js +5 -3
- package/build/border-control/border-control/component.js.map +1 -1
- package/build/border-control/border-control/hook.js +6 -3
- package/build/border-control/border-control/hook.js.map +1 -1
- package/build/border-control/border-control-dropdown/component.js +6 -2
- package/build/border-control/border-control-dropdown/component.js.map +1 -1
- package/build/border-control/border-control-dropdown/hook.js +5 -5
- package/build/border-control/border-control-dropdown/hook.js.map +1 -1
- package/build/border-control/styles.js +58 -29
- package/build/border-control/styles.js.map +1 -1
- package/build/button/index.native.js +16 -2
- package/build/button/index.native.js.map +1 -1
- package/build/button-group/index.js +24 -7
- package/build/button-group/index.js.map +1 -1
- package/build/{flyout → button-group}/types.js +0 -0
- package/build/button-group/types.js.map +1 -0
- package/build/checkbox-control/index.js +34 -7
- package/build/checkbox-control/index.js.map +1 -1
- package/build/checkbox-control/types.js +6 -0
- package/build/checkbox-control/types.js.map +1 -0
- package/build/color-palette/index.js +5 -12
- package/build/color-palette/index.js.map +1 -1
- package/build/date-time/date.js +43 -19
- package/build/date-time/date.js.map +1 -1
- package/build/date-time/index.js +28 -3
- package/build/date-time/index.js.map +1 -1
- package/build/date-time/time.js +42 -40
- package/build/date-time/time.js.map +1 -1
- package/build/date-time/timezone.js +4 -3
- package/build/date-time/timezone.js.map +1 -1
- package/build/date-time/types.js +6 -0
- package/build/date-time/types.js.map +1 -0
- package/build/date-time/utils.js +6 -4
- package/build/date-time/utils.js.map +1 -1
- package/build/disabled/index.js +1 -1
- package/build/disabled/index.js.map +1 -1
- package/build/draggable/index.native.js +223 -0
- package/build/draggable/index.native.js.map +1 -0
- package/build/dropdown/index.js +7 -5
- package/build/dropdown/index.js.map +1 -1
- package/build/focal-point-picker/index.native.js +3 -3
- package/build/focal-point-picker/index.native.js.map +1 -1
- package/build/index.js +0 -8
- package/build/index.js.map +1 -1
- package/build/index.native.js +16 -0
- package/build/index.native.js.map +1 -1
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -1
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build/mobile/bottom-sheet/index.native.js +1 -1
- package/build/mobile/bottom-sheet/index.native.js.map +1 -1
- package/build/mobile/bottom-sheet-select-control/index.native.js +3 -2
- package/build/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build/mobile/html-text-input/index.native.js +19 -8
- package/build/mobile/html-text-input/index.native.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/index.android.js +28 -5
- package/build/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/index.ios.js +47 -24
- package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
- package/build/palette-edit/index.js +38 -7
- package/build/palette-edit/index.js.map +1 -1
- package/build/popover/index.js +223 -277
- package/build/popover/index.js.map +1 -1
- package/build/resizable-box/resize-tooltip/utils.js +5 -8
- package/build/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build/sandbox/index.native.js +1 -1
- package/build/sandbox/index.native.js.map +1 -1
- package/build/select-control/styles/select-control-styles.js +14 -11
- package/build/select-control/styles/select-control-styles.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js +1 -3
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/tooltip/index.js +2 -2
- package/build/tooltip/index.js.map +1 -1
- package/build-module/border-box-control/border-box-control/component.js +22 -7
- package/build-module/border-box-control/border-box-control/component.js.map +1 -1
- package/build-module/border-box-control/border-box-control-linked-button/hook.js +3 -2
- package/build-module/border-box-control/border-box-control-linked-button/hook.js.map +1 -1
- package/build-module/border-box-control/border-box-control-split-controls/component.js +21 -8
- package/build-module/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build-module/border-box-control/border-box-control-visualizer/hook.js +3 -2
- package/build-module/border-box-control/border-box-control-visualizer/hook.js.map +1 -1
- package/build-module/border-box-control/styles.js +9 -15
- package/build-module/border-box-control/styles.js.map +1 -1
- package/build-module/border-control/border-control/component.js +5 -3
- package/build-module/border-control/border-control/component.js.map +1 -1
- package/build-module/border-control/border-control/hook.js +6 -3
- package/build-module/border-control/border-control/hook.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/component.js +6 -2
- package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/hook.js +5 -5
- package/build-module/border-control/border-control-dropdown/hook.js.map +1 -1
- package/build-module/border-control/styles.js +56 -29
- package/build-module/border-control/styles.js.map +1 -1
- package/build-module/button/index.native.js +16 -3
- package/build-module/button/index.native.js.map +1 -1
- package/build-module/button-group/index.js +27 -7
- package/build-module/button-group/index.js.map +1 -1
- package/build-module/{flyout → button-group}/types.js +0 -0
- package/build-module/{flyout → button-group}/types.js.map +0 -0
- package/build-module/checkbox-control/index.js +31 -7
- package/build-module/checkbox-control/index.js.map +1 -1
- package/build-module/checkbox-control/types.js +2 -0
- package/{build/flyout → build-module/checkbox-control}/types.js.map +0 -0
- package/build-module/color-palette/index.js +5 -11
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/date-time/date.js +44 -19
- package/build-module/date-time/date.js.map +1 -1
- package/build-module/date-time/index.js +28 -4
- package/build-module/date-time/index.js.map +1 -1
- package/build-module/date-time/time.js +43 -41
- package/build-module/date-time/time.js.map +1 -1
- package/build-module/date-time/timezone.js +4 -3
- package/build-module/date-time/timezone.js.map +1 -1
- package/build-module/date-time/types.js +2 -0
- package/build-module/date-time/types.js.map +1 -0
- package/build-module/date-time/utils.js +6 -4
- package/build-module/date-time/utils.js.map +1 -1
- package/build-module/disabled/index.js +1 -1
- package/build-module/disabled/index.js.map +1 -1
- package/build-module/draggable/index.native.js +206 -0
- package/build-module/draggable/index.native.js.map +1 -0
- package/build-module/dropdown/index.js +7 -5
- package/build-module/dropdown/index.js.map +1 -1
- package/build-module/focal-point-picker/index.native.js +3 -3
- package/build-module/focal-point-picker/index.native.js.map +1 -1
- package/build-module/index.js +0 -1
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +2 -1
- package/build-module/index.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/index.native.js +1 -1
- package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet-select-control/index.native.js +3 -2
- package/build-module/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build-module/mobile/html-text-input/index.native.js +20 -9
- package/build-module/mobile/html-text-input/index.native.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/index.android.js +21 -5
- package/build-module/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/index.ios.js +42 -25
- package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
- package/build-module/palette-edit/index.js +37 -7
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/popover/index.js +225 -279
- package/build-module/popover/index.js.map +1 -1
- package/build-module/resizable-box/resize-tooltip/utils.js +4 -5
- package/build-module/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build-module/sandbox/index.native.js +1 -1
- package/build-module/sandbox/index.native.js.map +1 -1
- package/build-module/select-control/styles/select-control-styles.js +14 -11
- package/build-module/select-control/styles/select-control-styles.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js +2 -3
- package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build-module/tooltip/index.js +2 -2
- package/build-module/tooltip/index.js.map +1 -1
- package/build-style/style-rtl.css +31 -170
- package/build-style/style.css +27 -170
- package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts +3 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/component.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +3 -1
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts.map +1 -1
- package/build-types/border-box-control/styles.d.ts +2 -2
- package/build-types/border-box-control/styles.d.ts.map +1 -1
- package/build-types/border-box-control/types.d.ts +40 -13
- package/build-types/border-box-control/types.d.ts.map +1 -1
- package/build-types/border-control/border-control/component.d.ts.map +1 -1
- package/build-types/border-control/border-control/hook.d.ts +2 -1
- package/build-types/border-control/border-control/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/hook.d.ts +1 -0
- package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
- package/build-types/border-control/styles.d.ts +2 -1
- package/build-types/border-control/styles.d.ts.map +1 -1
- package/build-types/border-control/types.d.ts +18 -6
- package/build-types/border-control/types.d.ts.map +1 -1
- package/build-types/button-group/index.d.ts +25 -0
- package/build-types/button-group/index.d.ts.map +1 -0
- package/build-types/button-group/stories/index.d.ts +12 -0
- package/build-types/button-group/stories/index.d.ts.map +1 -0
- package/build-types/button-group/types.d.ts +11 -0
- package/build-types/button-group/types.d.ts.map +1 -0
- package/build-types/checkbox-control/index.d.ts +26 -0
- package/build-types/checkbox-control/index.d.ts.map +1 -0
- package/build-types/checkbox-control/stories/index.d.ts +13 -0
- package/build-types/checkbox-control/stories/index.d.ts.map +1 -0
- package/build-types/checkbox-control/types.d.ts +35 -0
- package/build-types/checkbox-control/types.d.ts.map +1 -0
- package/build-types/color-palette/index.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +1 -1
- package/build-types/date-time/date.d.ts +24 -0
- package/build-types/date-time/date.d.ts.map +1 -0
- package/build-types/date-time/index.d.ts +35 -0
- package/build-types/date-time/index.d.ts.map +1 -0
- package/build-types/date-time/stories/date.d.ts +14 -0
- package/build-types/date-time/stories/date.d.ts.map +1 -0
- package/build-types/date-time/stories/index.d.ts +14 -0
- package/build-types/date-time/stories/index.d.ts.map +1 -0
- package/build-types/date-time/stories/time.d.ts +12 -0
- package/build-types/date-time/stories/time.d.ts.map +1 -0
- package/build-types/date-time/stories/utils.d.ts +3 -0
- package/build-types/date-time/stories/utils.d.ts.map +1 -0
- package/build-types/date-time/test/date.d.ts +2 -0
- package/build-types/date-time/test/date.d.ts.map +1 -0
- package/build-types/date-time/test/time.d.ts +2 -0
- package/build-types/date-time/test/time.d.ts.map +1 -0
- package/build-types/date-time/test/utils.d.ts +2 -0
- package/build-types/date-time/test/utils.d.ts.map +1 -0
- package/build-types/date-time/time.d.ts +25 -0
- package/build-types/date-time/time.d.ts.map +1 -0
- package/build-types/date-time/timezone.d.ts +8 -0
- package/build-types/date-time/timezone.d.ts.map +1 -0
- package/build-types/date-time/types.d.ts +91 -0
- package/build-types/date-time/types.d.ts.map +1 -0
- package/build-types/date-time/utils.d.ts +15 -0
- package/build-types/date-time/utils.d.ts.map +1 -0
- package/build-types/dropdown/index.d.ts.map +1 -1
- package/build-types/input-control/index.d.ts +1 -1
- package/build-types/input-control/stories/index.d.ts +5 -5
- package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
- package/build-types/popover/index.d.ts +5 -7
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/resizable-box/index.d.ts +1 -1
- package/build-types/resizable-box/resize-tooltip/index.d.ts +1 -1
- package/build-types/resizable-box/resize-tooltip/utils.d.ts.map +1 -1
- package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
- package/build-types/tooltip/index.d.ts.map +1 -1
- package/package.json +19 -19
- package/src/autocomplete/style.scss +1 -1
- package/src/border-box-control/border-box-control/README.md +10 -14
- package/src/border-box-control/border-box-control/component.tsx +21 -4
- package/src/border-box-control/border-box-control-linked-button/hook.ts +10 -6
- package/src/border-box-control/border-box-control-split-controls/component.tsx +24 -7
- package/src/border-box-control/border-box-control-visualizer/hook.ts +11 -6
- package/src/border-box-control/stories/index.js +1 -0
- package/src/border-box-control/styles.ts +15 -8
- package/src/border-box-control/types.ts +40 -14
- package/src/border-control/border-control/README.md +0 -7
- package/src/border-control/border-control/component.tsx +4 -2
- package/src/border-control/border-control/hook.ts +5 -2
- package/src/border-control/border-control-dropdown/component.tsx +18 -11
- package/src/border-control/border-control-dropdown/hook.ts +7 -5
- package/src/border-control/stories/index.js +1 -0
- package/src/border-control/styles.ts +82 -22
- package/src/border-control/types.ts +18 -6
- package/src/button/index.native.js +33 -18
- package/src/button-group/index.tsx +47 -0
- package/src/button-group/stories/index.tsx +41 -0
- package/src/button-group/types.ts +11 -0
- package/src/checkbox-control/README.md +10 -8
- package/src/checkbox-control/{index.js → index.tsx} +49 -14
- package/src/checkbox-control/stories/{index.js → index.tsx} +49 -27
- package/src/checkbox-control/types.ts +36 -0
- package/src/circular-option-picker/style.scss +1 -0
- package/src/color-palette/index.js +6 -13
- package/src/color-palette/style.scss +3 -18
- package/src/date-time/README.md +13 -10
- package/src/date-time/{date.js → date.tsx} +49 -20
- package/src/date-time/{index.js → index.tsx} +31 -5
- package/src/date-time/stories/date.tsx +73 -0
- package/src/date-time/stories/index.tsx +75 -0
- package/src/date-time/stories/time.tsx +51 -0
- package/src/date-time/stories/utils.ts +9 -0
- package/src/date-time/test/{date.js → date.tsx} +3 -2
- package/src/date-time/test/{time.js → time.tsx} +34 -19
- package/src/date-time/test/{utils.js → utils.ts} +1 -1
- package/src/date-time/{time.js → time.tsx} +57 -46
- package/src/date-time/{timezone.js → timezone.tsx} +4 -3
- package/src/date-time/types.ts +106 -0
- package/src/date-time/utils.ts +20 -0
- package/src/disabled/index.js +1 -1
- package/src/draggable/index.native.js +215 -0
- package/src/draggable/style.native.scss +3 -0
- package/src/dropdown/index.js +9 -4
- package/src/dropdown/style.scss +1 -1
- package/src/focal-point-picker/index.native.js +3 -3
- package/src/form-file-upload/test/index.js +8 -4
- package/src/index.js +0 -1
- package/src/index.native.js +1 -0
- package/src/item-group/stories/index.js +22 -18
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -1
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/test/navigation-container.native.js +1 -1
- package/src/mobile/bottom-sheet/index.native.js +1 -1
- package/src/mobile/bottom-sheet-select-control/index.native.js +7 -2
- package/src/mobile/html-text-input/index.native.js +45 -29
- package/src/mobile/html-text-input/style.android.scss +1 -15
- package/src/mobile/html-text-input/style.ios.scss +1 -15
- package/src/mobile/html-text-input/{style-common.native.scss → style.scss} +16 -0
- package/src/mobile/keyboard-aware-flat-list/index.android.js +15 -5
- package/src/mobile/keyboard-aware-flat-list/index.ios.js +75 -46
- package/src/navigator/stories/index.js +16 -10
- package/src/palette-edit/index.js +37 -9
- package/src/palette-edit/style.scss +0 -7
- package/src/palette-edit/test/index.js +63 -0
- package/src/panel/README.md +1 -1
- package/src/placeholder/test/index.js +7 -0
- package/src/popover/README.md +7 -9
- package/src/popover/index.js +242 -371
- package/src/popover/style.scss +20 -190
- package/src/popover/test/__snapshots__/index.js.snap +6 -18
- package/src/resizable-box/resize-tooltip/utils.ts +4 -5
- package/src/sandbox/index.native.js +1 -1
- package/src/select-control/styles/select-control-styles.ts +6 -3
- package/src/tab-panel/style.scss +1 -1
- package/src/toggle-group-control/test/__snapshots__/index.js.snap +4 -10
- package/src/toggle-group-control/toggle-group-control/component.tsx +7 -3
- package/src/tooltip/index.js +8 -2
- package/src/tooltip/style.scss +2 -4
- package/src/tooltip/test/index.native.js +1 -1
- package/src/unit-control/test/index.tsx +84 -4
- package/tsconfig.json +6 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/flyout/context.js +0 -23
- package/build/flyout/context.js.map +0 -1
- package/build/flyout/flyout/component.js +0 -106
- package/build/flyout/flyout/component.js.map +0 -1
- package/build/flyout/flyout/hook.js +0 -53
- package/build/flyout/flyout/hook.js.map +0 -1
- package/build/flyout/flyout/index.js +0 -24
- package/build/flyout/flyout/index.js.map +0 -1
- package/build/flyout/flyout-content/component.js +0 -65
- package/build/flyout/flyout-content/component.js.map +0 -1
- package/build/flyout/flyout-content/index.js +0 -16
- package/build/flyout/flyout-content/index.js.map +0 -1
- package/build/flyout/index.js +0 -16
- package/build/flyout/index.js.map +0 -1
- package/build/flyout/styles.js +0 -46
- package/build/flyout/styles.js.map +0 -1
- package/build/flyout/utils.js +0 -36
- package/build/flyout/utils.js.map +0 -1
- package/build/mobile/html-text-input/container.android.js +0 -41
- package/build/mobile/html-text-input/container.android.js.map +0 -1
- package/build/mobile/html-text-input/container.ios.js +0 -60
- package/build/mobile/html-text-input/container.ios.js.map +0 -1
- package/build/popover/utils.js +0 -322
- package/build/popover/utils.js.map +0 -1
- package/build-module/flyout/context.js +0 -11
- package/build-module/flyout/context.js.map +0 -1
- package/build-module/flyout/flyout/component.js +0 -89
- package/build-module/flyout/flyout/component.js.map +0 -1
- package/build-module/flyout/flyout/hook.js +0 -44
- package/build-module/flyout/flyout/hook.js.map +0 -1
- package/build-module/flyout/flyout/index.js +0 -3
- package/build-module/flyout/flyout/index.js.map +0 -1
- package/build-module/flyout/flyout-content/component.js +0 -51
- package/build-module/flyout/flyout-content/component.js.map +0 -1
- package/build-module/flyout/flyout-content/index.js +0 -2
- package/build-module/flyout/flyout-content/index.js.map +0 -1
- package/build-module/flyout/index.js +0 -2
- package/build-module/flyout/index.js.map +0 -1
- package/build-module/flyout/styles.js +0 -27
- package/build-module/flyout/styles.js.map +0 -1
- package/build-module/flyout/utils.js +0 -25
- package/build-module/flyout/utils.js.map +0 -1
- package/build-module/mobile/html-text-input/container.android.js +0 -29
- package/build-module/mobile/html-text-input/container.android.js.map +0 -1
- package/build-module/mobile/html-text-input/container.ios.js +0 -48
- package/build-module/mobile/html-text-input/container.ios.js.map +0 -1
- package/build-module/popover/utils.js +0 -308
- package/build-module/popover/utils.js.map +0 -1
- package/build-types/flyout/context.d.ts +0 -6
- package/build-types/flyout/context.d.ts.map +0 -1
- package/build-types/flyout/flyout/component.d.ts +0 -21
- package/build-types/flyout/flyout/component.d.ts.map +0 -1
- package/build-types/flyout/flyout/hook.d.ts +0 -270
- package/build-types/flyout/flyout/hook.d.ts.map +0 -1
- package/build-types/flyout/flyout/index.d.ts +0 -3
- package/build-types/flyout/flyout/index.d.ts.map +0 -1
- package/build-types/flyout/flyout-content/component.d.ts +0 -3
- package/build-types/flyout/flyout-content/component.d.ts.map +0 -1
- package/build-types/flyout/flyout-content/index.d.ts +0 -2
- package/build-types/flyout/flyout-content/index.d.ts.map +0 -1
- package/build-types/flyout/index.d.ts +0 -2
- package/build-types/flyout/index.d.ts.map +0 -1
- package/build-types/flyout/styles.d.ts +0 -22
- package/build-types/flyout/styles.d.ts.map +0 -1
- package/build-types/flyout/types.d.ts +0 -80
- package/build-types/flyout/types.d.ts.map +0 -1
- package/build-types/flyout/utils.d.ts +0 -8
- package/build-types/flyout/utils.d.ts.map +0 -1
- package/build-types/popover/utils.d.ts +0 -70
- package/build-types/popover/utils.d.ts.map +0 -1
- package/src/button-group/index.js +0 -17
- package/src/button-group/stories/index.js +0 -21
- package/src/date-time/stories/date.js +0 -17
- package/src/date-time/stories/index.js +0 -91
- package/src/date-time/stories/time.js +0 -32
- package/src/date-time/utils.js +0 -18
- package/src/flyout/context.js +0 -10
- package/src/flyout/flyout/README.md +0 -98
- package/src/flyout/flyout/component.js +0 -111
- package/src/flyout/flyout/hook.js +0 -45
- package/src/flyout/flyout/index.js +0 -2
- package/src/flyout/flyout-content/component.js +0 -53
- package/src/flyout/flyout-content/index.js +0 -1
- package/src/flyout/index.js +0 -1
- package/src/flyout/stories/index.js +0 -24
- package/src/flyout/styles.ts +0 -41
- package/src/flyout/test/__snapshots__/index.js.snap +0 -186
- package/src/flyout/test/index.js +0 -103
- package/src/flyout/types.ts +0 -84
- package/src/flyout/utils.js +0 -23
- package/src/mobile/html-text-input/container.android.js +0 -23
- package/src/mobile/html-text-input/container.ios.js +0 -50
- package/src/popover/test/utils.js +0 -304
- package/src/popover/utils.js +0 -396
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/date-time/date.js"],"names":["moment","classnames","DayPickerSingleDateController","useEffect","useRef","isRTL","_n","sprintf","getMomentDate","TIMEZONELESS_FORMAT","ARIAL_LABEL_TIME_FORMAT","DatePickerDay","day","events","ref","current","parentNode","dayAriaLabel","format","length","setAttribute","dayWithEventsDescription","DatePicker","currentDate","onChange","isInvalidDate","onMonthPreviewed","nodeRef","onMonthPreviewedHandler","newMonthDate","toISOString","keepFocusInside","ownerDocument","activeElement","contains","focusRegion","querySelector","focus","onChangeMoment","newDate","momentDate","momentTime","hours","minutes","seconds","set","getEventsPerDay","filter","eventDay","isSame","date","toDate"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,MAAP,MAAmB,QAAnB;AACA,OAAOC,UAAP,MAAuB,YAAvB,C,CAEA;AACA;;AACA,OAAOC,6BAAP,MAA0C,0DAA1C;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,KAAT,EAAgBC,EAAhB,EAAoBC,OAApB,QAAmC,iBAAnC;AAEA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EAAGA,uBArBpB;AAsBC,IAAA,iBAAiB,EAAKhB,GAAF,IACnB,cAAC,aAAD;AACC,MAAA,GAAG,EAAGA,GADP;AAEC,MAAA,MAAM,EAAGkC,eAAe,CAAElC,GAAF;AAFzB;AAvBF,IADD,CADD;AAiCA;;AAED,eAAeU,UAAf","sourcesContent":["/**\n * External dependencies\n */\nimport moment from 'moment';\nimport classnames from 'classnames';\n\n// react-dates doesn't tree-shake correctly, so we import from the individual\n// component here, to avoid including too much of the library\nimport DayPickerSingleDateController from 'react-dates/lib/components/DayPickerSingleDateController';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { isRTL, _n, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getMomentDate } from './utils';\n\n/**\n * Module Constants\n */\nconst TIMEZONELESS_FORMAT = 'YYYY-MM-DDTHH:mm:ss';\nconst ARIAL_LABEL_TIME_FORMAT = 'dddd, LL';\n\nfunction DatePickerDay( { day, events = [] } ) {\n\tconst ref = useRef();\n\n\t/*\n\t * a11y hack to make the `There is/are n events` string\n\t * available speaking for readers,\n\t * re-defining the aria-label attribute.\n\t * This attribute is handled by the react-dates component.\n\t */\n\tuseEffect( () => {\n\t\t// Bail when no parent node.\n\t\tif ( ! ref?.current?.parentNode ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { parentNode } = ref.current;\n\t\tconst dayAriaLabel = moment( day ).format( ARIAL_LABEL_TIME_FORMAT );\n\n\t\tif ( ! events.length ) {\n\t\t\t// Set aria-label without event description.\n\t\t\tparentNode.setAttribute( 'aria-label', dayAriaLabel );\n\t\t\treturn;\n\t\t}\n\n\t\tconst dayWithEventsDescription = sprintf(\n\t\t\t// translators: 1: Calendar day format, 2: Calendar event number.\n\t\t\t_n(\n\t\t\t\t'%1$s. There is %2$d event.',\n\t\t\t\t'%1$s. There are %2$d events.',\n\t\t\t\tevents.length\n\t\t\t),\n\t\t\tdayAriaLabel,\n\t\t\tevents.length\n\t\t);\n\n\t\tparentNode.setAttribute( 'aria-label', dayWithEventsDescription );\n\t}, [ events.length ] );\n\n\treturn (\n\t\t<div\n\t\t\tref={ ref }\n\t\t\tclassName={ classnames( 'components-datetime__date__day', {\n\t\t\t\t'has-events': events?.length,\n\t\t\t} ) }\n\t\t>\n\t\t\t{ day.format( 'D' ) }\n\t\t</div>\n\t);\n}\n\nfunction DatePicker( {\n\tcurrentDate,\n\tonChange,\n\tevents,\n\tisInvalidDate,\n\tonMonthPreviewed,\n} ) {\n\tconst nodeRef = useRef();\n\tconst onMonthPreviewedHandler = ( newMonthDate ) => {\n\t\tonMonthPreviewed?.( newMonthDate.toISOString() );\n\t\tkeepFocusInside();\n\t};\n\n\t/*\n\t * Todo: We should remove this function ASAP.\n\t * It is kept because focus is lost when we click on the previous and next month buttons.\n\t * This focus loss closes the date picker popover.\n\t * Ideally we should add an upstream commit on react-dates to fix this issue.\n\t */\n\tconst keepFocusInside = () => {\n\t\tif ( ! nodeRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { ownerDocument } = nodeRef.current;\n\t\tconst { activeElement } = ownerDocument;\n\n\t\t// If focus was lost.\n\t\tif (\n\t\t\t! activeElement ||\n\t\t\t! nodeRef.current.contains( ownerDocument.activeElement )\n\t\t) {\n\t\t\t// Retrieve the focus region div.\n\t\t\tconst focusRegion = nodeRef.current.querySelector(\n\t\t\t\t'.DayPicker_focusRegion'\n\t\t\t);\n\t\t\tif ( ! focusRegion ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Keep the focus on focus region.\n\t\t\tfocusRegion.focus();\n\t\t}\n\t};\n\n\tconst onChangeMoment = ( newDate ) => {\n\t\t// If currentDate is null, use now as momentTime to designate hours, minutes, seconds.\n\t\tconst momentDate = currentDate ? moment( currentDate ) : moment();\n\t\tconst momentTime = {\n\t\t\thours: momentDate.hours(),\n\t\t\tminutes: momentDate.minutes(),\n\t\t\tseconds: 0,\n\t\t};\n\n\t\tonChange( newDate.set( momentTime ).format( TIMEZONELESS_FORMAT ) );\n\n\t\t// Keep focus on the date picker.\n\t\tkeepFocusInside();\n\t};\n\n\tconst getEventsPerDay = ( day ) => {\n\t\tif ( ! events?.length ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn events.filter( ( eventDay ) =>\n\t\t\tday.isSame( eventDay.date, 'day' )\n\t\t);\n\t};\n\n\tconst momentDate = getMomentDate( currentDate );\n\n\treturn (\n\t\t<div className=\"components-datetime__date\" ref={ nodeRef }>\n\t\t\t<DayPickerSingleDateController\n\t\t\t\tdate={ momentDate }\n\t\t\t\tdaySize={ 30 }\n\t\t\t\tfocused\n\t\t\t\thideKeyboardShortcutsPanel\n\t\t\t\t// This is a hack to force the calendar to update on month or year change\n\t\t\t\t// https://github.com/airbnb/react-dates/issues/240#issuecomment-361776665\n\t\t\t\tkey={ `datepicker-controller-${\n\t\t\t\t\tmomentDate ? momentDate.format( 'MM-YYYY' ) : 'null'\n\t\t\t\t}` }\n\t\t\t\tnoBorder\n\t\t\t\tnumberOfMonths={ 1 }\n\t\t\t\tonDateChange={ onChangeMoment }\n\t\t\t\ttransitionDuration={ 0 }\n\t\t\t\tweekDayFormat=\"ddd\"\n\t\t\t\tdayAriaLabelFormat={ ARIAL_LABEL_TIME_FORMAT }\n\t\t\t\tisRTL={ isRTL() }\n\t\t\t\tisOutsideRange={ ( date ) => {\n\t\t\t\t\treturn isInvalidDate && isInvalidDate( date.toDate() );\n\t\t\t\t} }\n\t\t\t\tonPrevMonthClick={ onMonthPreviewedHandler }\n\t\t\t\tonNextMonthClick={ onMonthPreviewedHandler }\n\t\t\t\trenderDayContents={ ( day ) => (\n\t\t\t\t\t<DatePickerDay\n\t\t\t\t\t\tday={ day }\n\t\t\t\t\t\tevents={ getEventsPerDay( day ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport default DatePicker;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/date-time/date.tsx"],"names":["moment","classnames","noop","UntypedDayPickerSingleDateController","TypedDayPickerSingleDateController","useEffect","useRef","isRTL","_n","sprintf","getMomentDate","TIMEZONELESS_FORMAT","ARIAL_LABEL_TIME_FORMAT","DatePickerDay","day","events","ref","current","parentNode","Element","dayAriaLabel","format","length","setAttribute","dayWithEventsDescription","DatePicker","currentDate","onChange","isInvalidDate","onMonthPreviewed","nodeRef","onMonthPreviewedHandler","newMonthDate","toISOString","keepFocusInside","ownerDocument","activeElement","contains","focusRegion","querySelector","HTMLElement","focus","onChangeMoment","newDate","momentDate","momentTime","hours","minutes","seconds","set","getEventsPerDay","filter","eventDay","isSame","date","toDate"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,MAAP,MAAmB,QAAnB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA,SAASC,IAAT,QAAqB,QAArB,C,CAEA;AACA;AACA;AACA;AACA;;AACA,OAAOC,oCAAP,MAAiD,0DAAjD;AAEA,MAAMC,kCAAkC,GAAGD,oCAA3C;AAEA;AACA;AACA;;AACA,SAASE,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,KAAT,EAAgBC,EAAhB,EAAoBC,OAApB,QAAmC,iBAAnC;AAEA;AACA;AACA;;AACA,SAASC,aAAT,QAA8B,SAA9B;AAGA,MAAMC,mBAAmB,GAAG,qBAA5B;AACA,MAAMC,uBAAuB,GAAG,UAAhC;;AAEA,SAASC,aAAT,OAAmE;AAAA,MAA3C;AAAEC,IAAAA,GAAF;AAAOC,IAAAA,MAAM,GAAG;AAAhB,GAA2C;AAClE,QAAMC,GAAG,GAAGV,MAAM,CAAoB,IAApB,CAAlB;AAEA;AACD;AACA;AACA;AACA;AACA;;AACCD,EAAAA,SAAS,CAAE,MAAM;AAAA;;AAChB;AACA,QAAK,EAAI,CAAAW,GAAG,SAAH,IAAAA,GAAG,WAAH,4BAAAA,GAAG,CAAEC,OAAL,8DAAcC,UAAd,aAAoCC,OAAxC,CAAL,EAA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;AA5BjB,IADD,CADD;AAkCA;AAED,eAAeuB,UAAf","sourcesContent":["/**\n * External dependencies\n */\nimport moment from 'moment';\nimport classnames from 'classnames';\nimport type { Moment } from 'moment';\nimport { noop } from 'lodash';\n\n// `react-dates` doesn't tree-shake correctly, so we import from the individual\n// component here.\n// @ts-expect-error TypeScript won't find any type declarations at\n// `react-dates/lib/components/DayPickerSingleDateController` as they're located\n// at `react-dates`.\nimport UntypedDayPickerSingleDateController from 'react-dates/lib/components/DayPickerSingleDateController';\nimport type { DayPickerSingleDateController } from 'react-dates';\nconst TypedDayPickerSingleDateController = UntypedDayPickerSingleDateController as DayPickerSingleDateController;\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { isRTL, _n, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getMomentDate } from './utils';\nimport type { DatePickerDayProps, DatePickerProps } from './types';\n\nconst TIMEZONELESS_FORMAT = 'YYYY-MM-DDTHH:mm:ss';\nconst ARIAL_LABEL_TIME_FORMAT = 'dddd, LL';\n\nfunction DatePickerDay( { day, events = [] }: DatePickerDayProps ) {\n\tconst ref = useRef< HTMLDivElement >( null );\n\n\t/*\n\t * a11y hack to make the `There is/are n events` string\n\t * available speaking for readers,\n\t * re-defining the aria-label attribute.\n\t * This attribute is handled by the react-dates component.\n\t */\n\tuseEffect( () => {\n\t\t// Bail when no parent node.\n\t\tif ( ! ( ref?.current?.parentNode instanceof Element ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { parentNode } = ref.current;\n\t\tconst dayAriaLabel = moment( day ).format( ARIAL_LABEL_TIME_FORMAT );\n\n\t\tif ( ! events.length ) {\n\t\t\t// Set aria-label without event description.\n\t\t\tparentNode.setAttribute( 'aria-label', dayAriaLabel );\n\t\t\treturn;\n\t\t}\n\n\t\tconst dayWithEventsDescription = sprintf(\n\t\t\t// translators: 1: Calendar day format, 2: Calendar event number.\n\t\t\t_n(\n\t\t\t\t'%1$s. There is %2$d event.',\n\t\t\t\t'%1$s. There are %2$d events.',\n\t\t\t\tevents.length\n\t\t\t),\n\t\t\tdayAriaLabel,\n\t\t\tevents.length\n\t\t);\n\n\t\tparentNode.setAttribute( 'aria-label', dayWithEventsDescription );\n\t}, [ events.length ] );\n\n\treturn (\n\t\t<div\n\t\t\tref={ ref }\n\t\t\tclassName={ classnames( 'components-datetime__date__day', {\n\t\t\t\t'has-events': events?.length,\n\t\t\t} ) }\n\t\t>\n\t\t\t{ day.format( 'D' ) }\n\t\t</div>\n\t);\n}\n\n/**\n * DatePicker is a React component that renders a calendar for date selection.\n *\n * ```jsx\n * import { DatePicker } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyDatePicker = () => {\n * const [ date, setDate ] = useState( new Date() );\n *\n * return (\n * <DatePicker\n * currentDate={ date }\n * onChange={ ( newDate ) => setDate( newDate ) }\n * />\n * );\n * };\n * ```\n */\nexport function DatePicker( {\n\tcurrentDate,\n\tonChange,\n\tevents,\n\tisInvalidDate,\n\tonMonthPreviewed,\n}: DatePickerProps ) {\n\tconst nodeRef = useRef< HTMLDivElement >( null );\n\tconst onMonthPreviewedHandler = ( newMonthDate: Moment ) => {\n\t\tonMonthPreviewed?.( newMonthDate.toISOString() );\n\t\tkeepFocusInside();\n\t};\n\n\t/*\n\t * Todo: We should remove this function ASAP.\n\t * It is kept because focus is lost when we click on the previous and next month buttons.\n\t * This focus loss closes the date picker popover.\n\t * Ideally we should add an upstream commit on react-dates to fix this issue.\n\t */\n\tconst keepFocusInside = () => {\n\t\tif ( ! nodeRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { ownerDocument } = nodeRef.current;\n\t\tconst { activeElement } = ownerDocument;\n\n\t\t// If focus was lost.\n\t\tif (\n\t\t\t! activeElement ||\n\t\t\t! nodeRef.current.contains( ownerDocument.activeElement )\n\t\t) {\n\t\t\t// Retrieve the focus region div.\n\t\t\tconst focusRegion = nodeRef.current.querySelector(\n\t\t\t\t'.DayPicker_focusRegion'\n\t\t\t);\n\t\t\tif ( ! ( focusRegion instanceof HTMLElement ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Keep the focus on focus region.\n\t\t\tfocusRegion.focus();\n\t\t}\n\t};\n\n\tconst onChangeMoment = ( newDate: Moment | null ) => {\n\t\tif ( ! newDate ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If currentDate is null, use now as momentTime to designate hours, minutes, seconds.\n\t\tconst momentDate = currentDate ? moment( currentDate ) : moment();\n\t\tconst momentTime = {\n\t\t\thours: momentDate.hours(),\n\t\t\tminutes: momentDate.minutes(),\n\t\t\tseconds: 0,\n\t\t};\n\n\t\tonChange?.( newDate.set( momentTime ).format( TIMEZONELESS_FORMAT ) );\n\n\t\t// Keep focus on the date picker.\n\t\tkeepFocusInside();\n\t};\n\n\tconst getEventsPerDay = ( day: Moment ) => {\n\t\tif ( ! events?.length ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn events.filter( ( eventDay ) =>\n\t\t\tday.isSame( eventDay.date, 'day' )\n\t\t);\n\t};\n\n\tconst momentDate = getMomentDate( currentDate );\n\n\treturn (\n\t\t<div className=\"components-datetime__date\" ref={ nodeRef }>\n\t\t\t<TypedDayPickerSingleDateController\n\t\t\t\tdate={ momentDate }\n\t\t\t\tdaySize={ 30 }\n\t\t\t\tfocused\n\t\t\t\thideKeyboardShortcutsPanel\n\t\t\t\t// This is a hack to force the calendar to update on month or year change\n\t\t\t\t// https://github.com/airbnb/react-dates/issues/240#issuecomment-361776665\n\t\t\t\tkey={ `datepicker-controller-${\n\t\t\t\t\tmomentDate ? momentDate.format( 'MM-YYYY' ) : 'null'\n\t\t\t\t}` }\n\t\t\t\tnoBorder\n\t\t\t\tnumberOfMonths={ 1 }\n\t\t\t\tonDateChange={ onChangeMoment }\n\t\t\t\ttransitionDuration={ 0 }\n\t\t\t\tweekDayFormat=\"ddd\"\n\t\t\t\tdayAriaLabelFormat={ ARIAL_LABEL_TIME_FORMAT }\n\t\t\t\tisRTL={ isRTL() }\n\t\t\t\tisOutsideRange={ ( date ) => {\n\t\t\t\t\treturn !! isInvalidDate && isInvalidDate( date.toDate() );\n\t\t\t\t} }\n\t\t\t\tonPrevMonthClick={ onMonthPreviewedHandler }\n\t\t\t\tonNextMonthClick={ onMonthPreviewedHandler }\n\t\t\t\trenderDayContents={ ( day ) => (\n\t\t\t\t\t<DatePickerDay\n\t\t\t\t\t\tday={ day }\n\t\t\t\t\t\tevents={ getEventsPerDay( day ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\tonFocusChange={ noop }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport default DatePicker;\n"]}
|
|
@@ -7,10 +7,10 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
7
7
|
// See: https://github.com/airbnb/react-dates#initialize
|
|
8
8
|
import 'react-dates/initialize';
|
|
9
9
|
import { noop } from 'lodash';
|
|
10
|
+
|
|
10
11
|
/**
|
|
11
12
|
* WordPress dependencies
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
14
|
import { useState, forwardRef } from '@wordpress/element';
|
|
15
15
|
import { __, _x } from '@wordpress/i18n';
|
|
16
16
|
/**
|
|
@@ -22,7 +22,7 @@ import { default as DatePicker } from './date';
|
|
|
22
22
|
import { default as TimePicker } from './time';
|
|
23
23
|
export { DatePicker, TimePicker };
|
|
24
24
|
|
|
25
|
-
function
|
|
25
|
+
function UnforwardedDateTimePicker(_ref, ref) {
|
|
26
26
|
let {
|
|
27
27
|
currentDate,
|
|
28
28
|
is12Hour,
|
|
@@ -77,13 +77,37 @@ function DateTimePicker(_ref, ref) {
|
|
|
77
77
|
}, !calendarHelpIsVisible && currentDate && createElement(Button, {
|
|
78
78
|
className: "components-datetime__date-reset-button",
|
|
79
79
|
variant: "link",
|
|
80
|
-
onClick: () => onChange(null)
|
|
80
|
+
onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange(null)
|
|
81
81
|
}, __('Reset')), createElement(Button, {
|
|
82
82
|
className: "components-datetime__date-help-toggle",
|
|
83
83
|
variant: "link",
|
|
84
84
|
onClick: onClickDescriptionToggle
|
|
85
85
|
}, calendarHelpIsVisible ? __('Close') : __('Calendar Help'))));
|
|
86
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* DateTimePicker is a React component that renders a calendar and clock for
|
|
89
|
+
* date and time selection. The calendar and clock components can be accessed
|
|
90
|
+
* individually using the `DatePicker` and `TimePicker` components respectively.
|
|
91
|
+
*
|
|
92
|
+
* ```jsx
|
|
93
|
+
* import { DateTimePicker } from '@wordpress/components';
|
|
94
|
+
* import { useState } from '@wordpress/element';
|
|
95
|
+
*
|
|
96
|
+
* const MyDateTimePicker = () => {
|
|
97
|
+
* const [ date, setDate ] = useState( new Date() );
|
|
98
|
+
*
|
|
99
|
+
* return (
|
|
100
|
+
* <DateTimePicker
|
|
101
|
+
* currentDate={ date }
|
|
102
|
+
* onChange={ ( newDate ) => setDate( newDate ) }
|
|
103
|
+
* is12Hour
|
|
104
|
+
* />
|
|
105
|
+
* );
|
|
106
|
+
* };
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
|
|
87
110
|
|
|
88
|
-
export
|
|
111
|
+
export const DateTimePicker = forwardRef(UnforwardedDateTimePicker);
|
|
112
|
+
export default DateTimePicker;
|
|
89
113
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/date-time/index.
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/date-time/index.tsx"],"names":["noop","useState","forwardRef","__","_x","Button","default","DatePicker","TimePicker","UnforwardedDateTimePicker","ref","currentDate","is12Hour","isInvalidDate","onMonthPreviewed","onChange","events","calendarHelpIsVisible","setCalendarHelpIsVisible","onClickDescriptionToggle","DateTimePicker"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,wBAAP;AACA,SAASA,IAAT,QAAqB,QAArB;;AAGA;AACA;AACA;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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAMiB,cAAc,GAAGlB,UAAU,CAAEO,yBAAF,CAAjC;AAEP,eAAeW,cAAf","sourcesContent":["/**\n * External dependencies\n */\n// Needed to initialise the default datepicker styles.\n// See: https://github.com/airbnb/react-dates#initialize\nimport 'react-dates/initialize';\nimport { noop } from 'lodash';\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useState, forwardRef } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { default as DatePicker } from './date';\nimport { default as TimePicker } from './time';\nimport type { DateTimePickerProps } from './types';\n\nexport { DatePicker, TimePicker };\n\nfunction UnforwardedDateTimePicker(\n\t{\n\t\tcurrentDate,\n\t\tis12Hour,\n\t\tisInvalidDate,\n\t\tonMonthPreviewed = noop,\n\t\tonChange,\n\t\tevents,\n\t}: DateTimePickerProps,\n\tref: ForwardedRef< any >\n) {\n\tconst [ calendarHelpIsVisible, setCalendarHelpIsVisible ] = useState(\n\t\tfalse\n\t);\n\n\tfunction onClickDescriptionToggle() {\n\t\tsetCalendarHelpIsVisible( ! calendarHelpIsVisible );\n\t}\n\n\treturn (\n\t\t<div ref={ ref } className=\"components-datetime\">\n\t\t\t{ ! calendarHelpIsVisible && (\n\t\t\t\t<>\n\t\t\t\t\t<TimePicker\n\t\t\t\t\t\tcurrentTime={ currentDate }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tis12Hour={ is12Hour }\n\t\t\t\t\t/>\n\t\t\t\t\t<DatePicker\n\t\t\t\t\t\tcurrentDate={ currentDate }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tisInvalidDate={ isInvalidDate }\n\t\t\t\t\t\tevents={ events }\n\t\t\t\t\t\tonMonthPreviewed={ onMonthPreviewed }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ calendarHelpIsVisible && (\n\t\t\t\t<>\n\t\t\t\t\t<div className=\"components-datetime__calendar-help\">\n\t\t\t\t\t\t<h4>{ __( 'Click to Select' ) }</h4>\n\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Click the right or left arrows to select other months in the past or the future.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t{ __( 'Click the desired day to select it.' ) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t<h4>{ __( 'Navigating with a keyboard' ) }</h4>\n\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<abbr\n\t\t\t\t\t\t\t\t\taria-label={ _x(\n\t\t\t\t\t\t\t\t\t\t'Enter',\n\t\t\t\t\t\t\t\t\t\t'keyboard button'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t↵\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t' ' /* JSX removes whitespace, but a space is required for screen readers. */\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t\t{ __( 'Select the date in focus.' ) }\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<abbr\n\t\t\t\t\t\t\t\t\taria-label={ __( 'Left and Right Arrows' ) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t←/→\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t' ' /* JSX removes whitespace, but a space is required for screen readers. */\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Move backward (left) or forward (right) by one day.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<abbr aria-label={ __( 'Up and Down Arrows' ) }>\n\t\t\t\t\t\t\t\t\t↑/↓\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t' ' /* JSX removes whitespace, but a space is required for screen readers. */\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Move backward (up) or forward (down) by one week.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<abbr\n\t\t\t\t\t\t\t\t\taria-label={ __( 'Page Up and Page Down' ) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'PgUp/PgDn' ) }\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t' ' /* JSX removes whitespace, but a space is required for screen readers. */\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Move backward (PgUp) or forward (PgDn) by one month.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<abbr aria-label={ __( 'Home and End' ) }>\n\t\t\t\t\t\t\t\t\t{ /* Translators: Home/End reffer to the 'Home' and 'End' buttons on the keyboard.*/ }\n\t\t\t\t\t\t\t\t\t{ __( 'Home/End' ) }\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t' ' /* JSX removes whitespace, but a space is required for screen readers. */\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Go to the first (Home) or last (End) day of a week.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t</div>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<div className=\"components-datetime__buttons\">\n\t\t\t\t{ ! calendarHelpIsVisible && currentDate && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"components-datetime__date-reset-button\"\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => onChange?.( null ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"components-datetime__date-help-toggle\"\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\tonClick={ onClickDescriptionToggle }\n\t\t\t\t>\n\t\t\t\t\t{ calendarHelpIsVisible\n\t\t\t\t\t\t? __( 'Close' )\n\t\t\t\t\t\t: __( 'Calendar Help' ) }\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\n/**\n * DateTimePicker is a React component that renders a calendar and clock for\n * date and time selection. The calendar and clock components can be accessed\n * individually using the `DatePicker` and `TimePicker` components respectively.\n *\n * ```jsx\n * import { DateTimePicker } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyDateTimePicker = () => {\n * const [ date, setDate ] = useState( new Date() );\n *\n * return (\n * <DateTimePicker\n * currentDate={ date }\n * onChange={ ( newDate ) => setDate( newDate ) }\n * is12Hour\n * />\n * );\n * };\n * ```\n */\nexport const DateTimePicker = forwardRef( UnforwardedDateTimePicker );\n\nexport default DateTimePicker;\n"]}
|
|
@@ -6,10 +6,10 @@ import { Fragment } from "@wordpress/element";
|
|
|
6
6
|
import classnames from 'classnames';
|
|
7
7
|
import { isInteger } from 'lodash';
|
|
8
8
|
import moment from 'moment';
|
|
9
|
+
|
|
9
10
|
/**
|
|
10
11
|
* WordPress dependencies
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
13
|
import { createElement, useState, useMemo, useEffect } from '@wordpress/element';
|
|
14
14
|
import { __ } from '@wordpress/i18n';
|
|
15
15
|
/**
|
|
@@ -19,24 +19,14 @@ import { __ } from '@wordpress/i18n';
|
|
|
19
19
|
import Button from '../button';
|
|
20
20
|
import ButtonGroup from '../button-group';
|
|
21
21
|
import TimeZone from './timezone';
|
|
22
|
-
/**
|
|
23
|
-
* Module Constants
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
22
|
const TIMEZONELESS_FORMAT = 'YYYY-MM-DDTHH:mm:ss';
|
|
27
23
|
|
|
28
24
|
function from12hTo24h(hours, isPm) {
|
|
29
25
|
return isPm ? (hours % 12 + 12) % 24 : hours % 12;
|
|
30
26
|
}
|
|
31
27
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* @param {Object} props Component props.
|
|
36
|
-
* @param {string} props.as Render the component as specific element tag, defaults to "input".
|
|
37
|
-
* @param {number|string} props.value The default value of the component which will be parsed to integer.
|
|
38
|
-
* @param {Function} props.onUpdate Call back when blurred and validated.
|
|
39
|
-
* @param {string} [props.className]
|
|
28
|
+
* A shared component to parse, validate, and handle remounting of the
|
|
29
|
+
* underlying form field element like <input> and <select>.
|
|
40
30
|
*/
|
|
41
31
|
|
|
42
32
|
|
|
@@ -54,7 +44,7 @@ function UpdateOnBlurAsIntegerField(_ref) {
|
|
|
54
44
|
target
|
|
55
45
|
} = event;
|
|
56
46
|
|
|
57
|
-
if (value === target.value) {
|
|
47
|
+
if (String(value) === target.value) {
|
|
58
48
|
return;
|
|
59
49
|
}
|
|
60
50
|
|
|
@@ -62,10 +52,10 @@ function UpdateOnBlurAsIntegerField(_ref) {
|
|
|
62
52
|
|
|
63
53
|
if (!isInteger(parsedValue) || typeof props.max !== 'undefined' && parsedValue > props.max || typeof props.min !== 'undefined' && parsedValue < props.min) {
|
|
64
54
|
// If validation failed, reset the value to the previous valid value.
|
|
65
|
-
target.value = value;
|
|
55
|
+
target.value = String(value);
|
|
66
56
|
} else {
|
|
67
57
|
// Otherwise, it's valid, call onUpdate.
|
|
68
|
-
onUpdate(
|
|
58
|
+
onUpdate(parsedValue);
|
|
69
59
|
}
|
|
70
60
|
}
|
|
71
61
|
|
|
@@ -79,14 +69,24 @@ function UpdateOnBlurAsIntegerField(_ref) {
|
|
|
79
69
|
});
|
|
80
70
|
}
|
|
81
71
|
/**
|
|
82
|
-
*
|
|
72
|
+
* TimePicker is a React component that renders a clock for time selection.
|
|
73
|
+
*
|
|
74
|
+
* ```jsx
|
|
75
|
+
* import { TimePicker } from '@wordpress/components';
|
|
76
|
+
* import { useState } from '@wordpress/element';
|
|
83
77
|
*
|
|
84
|
-
*
|
|
78
|
+
* const MyTimePicker = () => {
|
|
79
|
+
* const [ time, setTime ] = useState( new Date() );
|
|
85
80
|
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
81
|
+
* return (
|
|
82
|
+
* <TimePicker
|
|
83
|
+
* currentTime={ date }
|
|
84
|
+
* onChange={ ( newTime ) => setTime( newTime ) }
|
|
85
|
+
* is12Hour
|
|
86
|
+
* />
|
|
87
|
+
* );
|
|
88
|
+
* };
|
|
89
|
+
* ```
|
|
90
90
|
*/
|
|
91
91
|
|
|
92
92
|
|
|
@@ -97,7 +97,7 @@ export function TimePicker(_ref2) {
|
|
|
97
97
|
onChange
|
|
98
98
|
} = _ref2;
|
|
99
99
|
const [date, setDate] = useState(() => // Truncate the date at the minutes, see: #15495.
|
|
100
|
-
moment(currentTime).startOf('minutes')); // Reset the state when currentTime changed.
|
|
100
|
+
currentTime ? moment(currentTime).startOf('minutes') : moment()); // Reset the state when currentTime changed.
|
|
101
101
|
|
|
102
102
|
useEffect(() => {
|
|
103
103
|
setDate(currentTime ? moment(currentTime).startOf('minutes') : moment());
|
|
@@ -115,33 +115,35 @@ export function TimePicker(_ref2) {
|
|
|
115
115
|
year: date.format('YYYY'),
|
|
116
116
|
minutes: date.format('mm'),
|
|
117
117
|
hours: date.format(is12Hour ? 'hh' : 'HH'),
|
|
118
|
-
am: date.format('H') <= 11 ? 'AM' : 'PM'
|
|
118
|
+
am: Number(date.format('H')) <= 11 ? 'AM' : 'PM'
|
|
119
119
|
}), [date, is12Hour]);
|
|
120
120
|
/**
|
|
121
121
|
* Function that sets the date state and calls the onChange with a new date.
|
|
122
122
|
* The date is truncated at the minutes.
|
|
123
123
|
*
|
|
124
|
-
* @param {
|
|
124
|
+
* @param {Moment} newDate The date object.
|
|
125
125
|
*/
|
|
126
126
|
|
|
127
127
|
function changeDate(newDate) {
|
|
128
128
|
setDate(newDate);
|
|
129
|
-
onChange(newDate.format(TIMEZONELESS_FORMAT));
|
|
129
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newDate.format(TIMEZONELESS_FORMAT));
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
function update(name
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
132
|
+
function update(name) {
|
|
133
|
+
return value => {
|
|
134
|
+
// If the 12-hour format is being used and the 'PM' period is selected, then
|
|
135
|
+
// the incoming value (which ranges 1-12) should be increased by 12 to match
|
|
136
|
+
// the expected 24-hour format.
|
|
137
|
+
let adjustedValue = value;
|
|
137
138
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
if (name === 'hours' && is12Hour) {
|
|
140
|
+
adjustedValue = from12hTo24h(value, am === 'PM');
|
|
141
|
+
} // Clone the date and call the specific setter function according to `name`.
|
|
141
142
|
|
|
142
143
|
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
const newDate = date.clone()[name](adjustedValue);
|
|
145
|
+
changeDate(newDate);
|
|
146
|
+
};
|
|
145
147
|
}
|
|
146
148
|
|
|
147
149
|
function updateAmPm(value) {
|
|
@@ -168,7 +170,7 @@ export function TimePicker(_ref2) {
|
|
|
168
170
|
step: 1,
|
|
169
171
|
min: 1,
|
|
170
172
|
max: 31,
|
|
171
|
-
onUpdate: update
|
|
173
|
+
onUpdate: update('date')
|
|
172
174
|
}));
|
|
173
175
|
const monthFormat = createElement("div", {
|
|
174
176
|
className: "components-datetime__time-field components-datetime__time-field-month"
|
|
@@ -179,7 +181,7 @@ export function TimePicker(_ref2) {
|
|
|
179
181
|
name: "month",
|
|
180
182
|
value: month // The value starts from 0, so we have to -1 when setting month.
|
|
181
183
|
,
|
|
182
|
-
onUpdate:
|
|
184
|
+
onUpdate: value => update('month')(value - 1)
|
|
183
185
|
}, createElement("option", {
|
|
184
186
|
value: "01"
|
|
185
187
|
}, __('January')), createElement("option", {
|
|
@@ -223,7 +225,7 @@ export function TimePicker(_ref2) {
|
|
|
223
225
|
min: 0,
|
|
224
226
|
max: 9999,
|
|
225
227
|
value: year,
|
|
226
|
-
onUpdate: update
|
|
228
|
+
onUpdate: update('year')
|
|
227
229
|
})))), createElement("fieldset", null, createElement("legend", {
|
|
228
230
|
className: "components-datetime__time-legend invisible"
|
|
229
231
|
}, __('Time')), createElement("div", {
|
|
@@ -239,7 +241,7 @@ export function TimePicker(_ref2) {
|
|
|
239
241
|
min: is12Hour ? 1 : 0,
|
|
240
242
|
max: is12Hour ? 12 : 23,
|
|
241
243
|
value: hours,
|
|
242
|
-
onUpdate: update
|
|
244
|
+
onUpdate: update('hours')
|
|
243
245
|
}), createElement("span", {
|
|
244
246
|
className: "components-datetime__time-separator",
|
|
245
247
|
"aria-hidden": "true"
|
|
@@ -252,7 +254,7 @@ export function TimePicker(_ref2) {
|
|
|
252
254
|
min: 0,
|
|
253
255
|
max: 59,
|
|
254
256
|
value: minutes,
|
|
255
|
-
onUpdate: update
|
|
257
|
+
onUpdate: update('minutes')
|
|
256
258
|
})), is12Hour && createElement(ButtonGroup, {
|
|
257
259
|
className: "components-datetime__time-field components-datetime__time-field-am-pm"
|
|
258
260
|
}, createElement(Button, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/date-time/time.js"],"names":["classnames","isInteger","moment","createElement","useState","useMemo","useEffect","__","Button","ButtonGroup","TimeZone","TIMEZONELESS_FORMAT","from12hTo24h","hours","isPm","UpdateOnBlurAsIntegerField","as","value","onUpdate","className","props","handleBlur","event","target","parsedValue","parseInt","max","min","name","key","defaultValue","onBlur","TimePicker","is12Hour","currentTime","onChange","date","setDate","startOf","day","month","year","minutes","am","format","changeDate","newDate","update","adjustedValue","clone","updateAmPm","parsedHours","dayFormat","monthFormat","dayMonthFormat"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,SAAT,QAA0B,QAA1B;AACA,OAAOC,MAAP,MAAmB,QAAnB;AAEA;AACA;AACA;;AACA,SACCC,aADD,EAECC,QAFD,EAGCC,OAHD,EAICC,SAJD,QAKO,oBALP;AAMA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AACA,OAAOC,QAAP,MAAqB,YAArB;AAEA;AACA;AACA;;AACA,MAAMC,mBAAmB,GAAG,qBAA5B;;AAEA,SAASC,YAAT,CAAuBC,KAAvB,EAA8BC,IAA9B,EAAqC;AACpC,SAAOA,IAAI,GAAG,CAAID,KAAK,GAAG,EAAV,GAAiB,EAAnB,IAA0B,EAA7B,GAAkCA,KAAK,GAAG,EAArD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASE,0BAAT,OAMI;AAAA,MANiC;AACpCC,IAAAA,EADoC;AAEpCC,IAAAA,KAFoC;AAGpCC,IAAAA,QAHoC;AAIpCC,IAAAA,SAJoC;AAKpC,OAAGC;AALiC,GAMjC;;AACH,WAASC,UAAT,CAAqBC,KAArB,EAA6B;AAC5B,UAAM;AAAEC,MAAAA;AAAF,QAAaD,KAAnB;;AAEA,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OART;AASC,IAAA,QAAQ,EAAGK;AATZ,IAlBD,CADD,EA+BGd,QAAQ,IACT,cAAC,WAAD;AAAa,IAAA,SAAS,EAAC;AAAvB,KACC,cAAC,MAAD;AACC,IAAA,OAAO,EACNU,EAAE,KAAK,IAAP,GAAc,SAAd,GAA0B,WAF5B;AAIC,IAAA,OAAO,EAAGO,UAAU,CAAE,IAAF,CAJrB;AAKC,IAAA,SAAS,EAAC;AALX,KAOG3C,EAAE,CAAE,IAAF,CAPL,CADD,EAUC,cAAC,MAAD;AACC,IAAA,OAAO,EACNoC,EAAE,KAAK,IAAP,GAAc,SAAd,GAA0B,WAF5B;AAIC,IAAA,OAAO,EAAGO,UAAU,CAAE,IAAF,CAJrB;AAKC,IAAA,SAAS,EAAC;AALX,KAOG3C,EAAE,CAAE,IAAF,CAPL,CAVD,CAhCF,EAsDC,cAAC,QAAD,OAtDD,CAJD,CAxBD,CADD;AAwFA;AAED,eAAeyB,UAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { isInteger } from 'lodash';\nimport moment from 'moment';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreateElement,\n\tuseState,\n\tuseMemo,\n\tuseEffect,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport ButtonGroup from '../button-group';\nimport TimeZone from './timezone';\n\n/**\n * Module Constants\n */\nconst TIMEZONELESS_FORMAT = 'YYYY-MM-DDTHH:mm:ss';\n\nfunction from12hTo24h( hours, isPm ) {\n\treturn isPm ? ( ( hours % 12 ) + 12 ) % 24 : hours % 12;\n}\n\n/**\n * <UpdateOnBlurAsIntegerField>\n * A shared component to parse, validate, and handle remounting of the underlying form field element like <input> and <select>.\n *\n * @param {Object} props Component props.\n * @param {string} props.as Render the component as specific element tag, defaults to \"input\".\n * @param {number|string} props.value The default value of the component which will be parsed to integer.\n * @param {Function} props.onUpdate Call back when blurred and validated.\n * @param {string} [props.className]\n */\nfunction UpdateOnBlurAsIntegerField( {\n\tas,\n\tvalue,\n\tonUpdate,\n\tclassName,\n\t...props\n} ) {\n\tfunction handleBlur( event ) {\n\t\tconst { target } = event;\n\n\t\tif ( value === target.value ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst parsedValue = parseInt( target.value, 10 );\n\n\t\t// Run basic number validation on the input.\n\t\tif (\n\t\t\t! isInteger( parsedValue ) ||\n\t\t\t( typeof props.max !== 'undefined' && parsedValue > props.max ) ||\n\t\t\t( typeof props.min !== 'undefined' && parsedValue < props.min )\n\t\t) {\n\t\t\t// If validation failed, reset the value to the previous valid value.\n\t\t\ttarget.value = value;\n\t\t} else {\n\t\t\t// Otherwise, it's valid, call onUpdate.\n\t\t\tonUpdate( target.name, parsedValue );\n\t\t}\n\t}\n\n\treturn createElement( as || 'input', {\n\t\t// Re-mount the input value to accept the latest value as the defaultValue.\n\t\tkey: value,\n\t\tdefaultValue: value,\n\t\tonBlur: handleBlur,\n\t\tclassName: classnames(\n\t\t\t'components-datetime__time-field-integer-field',\n\t\t\tclassName\n\t\t),\n\t\t...props,\n\t} );\n}\n\n/**\n * <TimePicker>\n *\n * @typedef {Date|string|number} WPValidDateTimeFormat\n *\n * @param {Object} props Component props.\n * @param {boolean} props.is12Hour Should the time picker showed in 12 hour format or 24 hour format.\n * @param {WPValidDateTimeFormat} props.currentTime The initial current time the time picker should render.\n * @param {Function} props.onChange Callback function when the date changed.\n */\nexport function TimePicker( { is12Hour, currentTime, onChange } ) {\n\tconst [ date, setDate ] = useState( () =>\n\t\t// Truncate the date at the minutes, see: #15495.\n\t\tmoment( currentTime ).startOf( 'minutes' )\n\t);\n\n\t// Reset the state when currentTime changed.\n\tuseEffect( () => {\n\t\tsetDate(\n\t\t\tcurrentTime ? moment( currentTime ).startOf( 'minutes' ) : moment()\n\t\t);\n\t}, [ currentTime ] );\n\n\tconst { day, month, year, minutes, hours, am } = useMemo(\n\t\t() => ( {\n\t\t\tday: date.format( 'DD' ),\n\t\t\tmonth: date.format( 'MM' ),\n\t\t\tyear: date.format( 'YYYY' ),\n\t\t\tminutes: date.format( 'mm' ),\n\t\t\thours: date.format( is12Hour ? 'hh' : 'HH' ),\n\t\t\tam: date.format( 'H' ) <= 11 ? 'AM' : 'PM',\n\t\t} ),\n\t\t[ date, is12Hour ]\n\t);\n\n\t/**\n\t * Function that sets the date state and calls the onChange with a new date.\n\t * The date is truncated at the minutes.\n\t *\n\t * @param {Object} newDate The date object.\n\t */\n\tfunction changeDate( newDate ) {\n\t\tsetDate( newDate );\n\t\tonChange( newDate.format( TIMEZONELESS_FORMAT ) );\n\t}\n\n\tfunction update( name, value ) {\n\t\t// If the 12-hour format is being used and the 'PM' period is selected, then\n\t\t// the incoming value (which ranges 1-12) should be increased by 12 to match\n\t\t// the expected 24-hour format.\n\t\tlet adjustedValue = value;\n\t\tif ( name === 'hours' && is12Hour ) {\n\t\t\tadjustedValue = from12hTo24h( value, am === 'PM' );\n\t\t}\n\n\t\t// Clone the date and call the specific setter function according to `name`.\n\t\tconst newDate = date.clone()[ name ]( adjustedValue );\n\t\tchangeDate( newDate );\n\t}\n\n\tfunction updateAmPm( value ) {\n\t\treturn () => {\n\t\t\tif ( am === value ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst parsedHours = parseInt( hours, 10 );\n\n\t\t\tconst newDate = date\n\t\t\t\t.clone()\n\t\t\t\t.hours( from12hTo24h( parsedHours, value === 'PM' ) );\n\n\t\t\tchangeDate( newDate );\n\t\t};\n\t}\n\n\tconst dayFormat = (\n\t\t<div className=\"components-datetime__time-field components-datetime__time-field-day\">\n\t\t\t<UpdateOnBlurAsIntegerField\n\t\t\t\taria-label={ __( 'Day' ) }\n\t\t\t\tclassName=\"components-datetime__time-field-day-input\"\n\t\t\t\ttype=\"number\"\n\t\t\t\t// The correct function to call in moment.js is \"date\" not \"day\".\n\t\t\t\tname=\"date\"\n\t\t\t\tvalue={ day }\n\t\t\t\tstep={ 1 }\n\t\t\t\tmin={ 1 }\n\t\t\t\tmax={ 31 }\n\t\t\t\tonUpdate={ update }\n\t\t\t/>\n\t\t</div>\n\t);\n\n\tconst monthFormat = (\n\t\t<div className=\"components-datetime__time-field components-datetime__time-field-month\">\n\t\t\t<UpdateOnBlurAsIntegerField\n\t\t\t\tas=\"select\"\n\t\t\t\taria-label={ __( 'Month' ) }\n\t\t\t\tclassName=\"components-datetime__time-field-month-select\"\n\t\t\t\tname=\"month\"\n\t\t\t\tvalue={ month }\n\t\t\t\t// The value starts from 0, so we have to -1 when setting month.\n\t\t\t\tonUpdate={ ( key, value ) => update( key, value - 1 ) }\n\t\t\t>\n\t\t\t\t<option value=\"01\">{ __( 'January' ) }</option>\n\t\t\t\t<option value=\"02\">{ __( 'February' ) }</option>\n\t\t\t\t<option value=\"03\">{ __( 'March' ) }</option>\n\t\t\t\t<option value=\"04\">{ __( 'April' ) }</option>\n\t\t\t\t<option value=\"05\">{ __( 'May' ) }</option>\n\t\t\t\t<option value=\"06\">{ __( 'June' ) }</option>\n\t\t\t\t<option value=\"07\">{ __( 'July' ) }</option>\n\t\t\t\t<option value=\"08\">{ __( 'August' ) }</option>\n\t\t\t\t<option value=\"09\">{ __( 'September' ) }</option>\n\t\t\t\t<option value=\"10\">{ __( 'October' ) }</option>\n\t\t\t\t<option value=\"11\">{ __( 'November' ) }</option>\n\t\t\t\t<option value=\"12\">{ __( 'December' ) }</option>\n\t\t\t</UpdateOnBlurAsIntegerField>\n\t\t</div>\n\t);\n\n\tconst dayMonthFormat = is12Hour ? (\n\t\t<>\n\t\t\t{ monthFormat }\n\t\t\t{ dayFormat }\n\t\t</>\n\t) : (\n\t\t<>\n\t\t\t{ dayFormat }\n\t\t\t{ monthFormat }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<div className={ classnames( 'components-datetime__time' ) }>\n\t\t\t<fieldset>\n\t\t\t\t<legend className=\"components-datetime__time-legend invisible\">\n\t\t\t\t\t{ __( 'Date' ) }\n\t\t\t\t</legend>\n\t\t\t\t<div className=\"components-datetime__time-wrapper\">\n\t\t\t\t\t{ dayMonthFormat }\n\n\t\t\t\t\t<div className=\"components-datetime__time-field components-datetime__time-field-year\">\n\t\t\t\t\t\t<UpdateOnBlurAsIntegerField\n\t\t\t\t\t\t\taria-label={ __( 'Year' ) }\n\t\t\t\t\t\t\tclassName=\"components-datetime__time-field-year-input\"\n\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\tname=\"year\"\n\t\t\t\t\t\t\tstep={ 1 }\n\t\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\t\tmax={ 9999 }\n\t\t\t\t\t\t\tvalue={ year }\n\t\t\t\t\t\t\tonUpdate={ update }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</fieldset>\n\n\t\t\t<fieldset>\n\t\t\t\t<legend className=\"components-datetime__time-legend invisible\">\n\t\t\t\t\t{ __( 'Time' ) }\n\t\t\t\t</legend>\n\t\t\t\t<div className=\"components-datetime__time-wrapper\">\n\t\t\t\t\t<div className=\"components-datetime__time-field components-datetime__time-field-time\">\n\t\t\t\t\t\t<UpdateOnBlurAsIntegerField\n\t\t\t\t\t\t\taria-label={ __( 'Hours' ) }\n\t\t\t\t\t\t\tclassName=\"components-datetime__time-field-hours-input\"\n\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\tname=\"hours\"\n\t\t\t\t\t\t\tstep={ 1 }\n\t\t\t\t\t\t\tmin={ is12Hour ? 1 : 0 }\n\t\t\t\t\t\t\tmax={ is12Hour ? 12 : 23 }\n\t\t\t\t\t\t\tvalue={ hours }\n\t\t\t\t\t\t\tonUpdate={ update }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"components-datetime__time-separator\"\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t:\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<UpdateOnBlurAsIntegerField\n\t\t\t\t\t\t\taria-label={ __( 'Minutes' ) }\n\t\t\t\t\t\t\tclassName=\"components-datetime__time-field-minutes-input\"\n\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\tname=\"minutes\"\n\t\t\t\t\t\t\tstep={ 1 }\n\t\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\t\tmax={ 59 }\n\t\t\t\t\t\t\tvalue={ minutes }\n\t\t\t\t\t\t\tonUpdate={ update }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t{ is12Hour && (\n\t\t\t\t\t\t<ButtonGroup className=\"components-datetime__time-field components-datetime__time-field-am-pm\">\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tam === 'AM' ? 'primary' : 'secondary'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonClick={ updateAmPm( 'AM' ) }\n\t\t\t\t\t\t\t\tclassName=\"components-datetime__time-am-button\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'AM' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tam === 'PM' ? 'primary' : 'secondary'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonClick={ updateAmPm( 'PM' ) }\n\t\t\t\t\t\t\t\tclassName=\"components-datetime__time-pm-button\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'PM' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</ButtonGroup>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<TimeZone />\n\t\t\t\t</div>\n\t\t\t</fieldset>\n\t\t</div>\n\t);\n}\n\nexport default TimePicker;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/date-time/time.tsx"],"names":["classnames","isInteger","moment","createElement","useState","useMemo","useEffect","__","Button","ButtonGroup","TimeZone","TIMEZONELESS_FORMAT","from12hTo24h","hours","isPm","UpdateOnBlurAsIntegerField","as","value","onUpdate","className","props","handleBlur","event","target","String","parsedValue","parseInt","max","min","key","defaultValue","onBlur","TimePicker","is12Hour","currentTime","onChange","date","setDate","startOf","day","month","year","minutes","am","format","Number","changeDate","newDate","update","name","adjustedValue","clone","updateAmPm","parsedHours","dayFormat","monthFormat","dayMonthFormat"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,SAAT,QAA0B,QAA1B;AACA,OAAOC,MAAP,MAAmB,QAAnB;;AAIA;AACA;AACA;AACA,SACCC,aADD,EAECC,QAFD,EAGCC,OAHD,EAICC,SAJD,QAKO,oBALP;AAMA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AACA,OAAOC,QAAP,MAAqB,YAArB;AAIA,MAAMC,mBAAmB,GAAG,qBAA5B;;AAEA,SAASC,YAAT,CAAuBC,KAAvB,EAAsCC,IAAtC,EAAsD;AACrD,SAAOA,IAAI,GAAG,CAAID,KAAK,GAAG,EAAV,GAAiB,EAAnB,IAA0B,EAA7B,GAAkCA,KAAK,GAAG,EAArD;AACA;AAED;AACA;AACA;AACA;;;AACA,SAASE,0BAAT,OAM+E;AAAA,MAN1C;AACpCC,IAAAA,EADoC;AAEpCC,IAAAA,KAFoC;AAGpCC,IAAAA,QAHoC;AAIpCC,IAAAA,SAJoC;AAKpC,OAAGC;AALiC,GAM0C;;AAC9E,WAASC,UAAT,CAAqBC,KAArB,EAA6D;AAC5D,UAAM;AAAEC,MAAAA;AAAF,QAAaD,KAAnB;;AAEA,QAAKE,MAAM,CAAEP,KAAF,CAAN,KAAoBM,MAAM,CAACN,KAAhC,EAAwC;AACvC;AACA;;AAED,UAAMQ,WAAW,GAAGC,QAAQ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IAAA,IAAI,EAAG,CALR;AAMC,IAAA,GAAG,EAAG,CANP;AAOC,IAAA,GAAG,EAAG,EAPP;AAQC,IAAA,KAAK,EAAGmC,OART;AASC,IAAA,QAAQ,EAAGM,MAAM,CAAE,SAAF;AATlB,IAlBD,CADD,EA+BGf,QAAQ,IACT,cAAC,WAAD;AAAa,IAAA,SAAS,EAAC;AAAvB,KACC,cAAC,MAAD;AACC,IAAA,OAAO,EACNU,EAAE,KAAK,IAAP,GAAc,SAAd,GAA0B,WAF5B;AAIC,IAAA,OAAO,EAAGS,UAAU,CAAE,IAAF,CAJrB;AAKC,IAAA,SAAS,EAAC;AALX,KAOG7C,EAAE,CAAE,IAAF,CAPL,CADD,EAUC,cAAC,MAAD;AACC,IAAA,OAAO,EACNoC,EAAE,KAAK,IAAP,GAAc,SAAd,GAA0B,WAF5B;AAIC,IAAA,OAAO,EAAGS,UAAU,CAAE,IAAF,CAJrB;AAKC,IAAA,SAAS,EAAC;AALX,KAOG7C,EAAE,CAAE,IAAF,CAPL,CAVD,CAhCF,EAsDC,cAAC,QAAD,OAtDD,CAJD,CAxBD,CADD;AAwFA;AAED,eAAeyB,UAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { isInteger } from 'lodash';\nimport moment from 'moment';\nimport type { FocusEvent } from 'react';\nimport type { Moment } from 'moment';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreateElement,\n\tuseState,\n\tuseMemo,\n\tuseEffect,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport ButtonGroup from '../button-group';\nimport TimeZone from './timezone';\nimport type { WordPressComponentProps } from '../ui/context';\nimport type { UpdateOnBlurAsIntegerFieldProps, TimePickerProps } from './types';\n\nconst TIMEZONELESS_FORMAT = 'YYYY-MM-DDTHH:mm:ss';\n\nfunction from12hTo24h( hours: number, isPm: boolean ) {\n\treturn isPm ? ( ( hours % 12 ) + 12 ) % 24 : hours % 12;\n}\n\n/**\n * A shared component to parse, validate, and handle remounting of the\n * underlying form field element like <input> and <select>.\n */\nfunction UpdateOnBlurAsIntegerField( {\n\tas,\n\tvalue,\n\tonUpdate,\n\tclassName,\n\t...props\n}: WordPressComponentProps< UpdateOnBlurAsIntegerFieldProps, 'input', true > ) {\n\tfunction handleBlur( event: FocusEvent< HTMLInputElement > ) {\n\t\tconst { target } = event;\n\n\t\tif ( String( value ) === target.value ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst parsedValue = parseInt( target.value, 10 );\n\n\t\t// Run basic number validation on the input.\n\t\tif (\n\t\t\t! isInteger( parsedValue ) ||\n\t\t\t( typeof props.max !== 'undefined' && parsedValue > props.max ) ||\n\t\t\t( typeof props.min !== 'undefined' && parsedValue < props.min )\n\t\t) {\n\t\t\t// If validation failed, reset the value to the previous valid value.\n\t\t\ttarget.value = String( value );\n\t\t} else {\n\t\t\t// Otherwise, it's valid, call onUpdate.\n\t\t\tonUpdate( parsedValue );\n\t\t}\n\t}\n\n\treturn createElement( as || 'input', {\n\t\t// Re-mount the input value to accept the latest value as the defaultValue.\n\t\tkey: value,\n\t\tdefaultValue: value,\n\t\tonBlur: handleBlur,\n\t\tclassName: classnames(\n\t\t\t'components-datetime__time-field-integer-field',\n\t\t\tclassName\n\t\t),\n\t\t...props,\n\t} );\n}\n\n/**\n * TimePicker is a React component that renders a clock for time selection.\n *\n * ```jsx\n * import { TimePicker } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyTimePicker = () => {\n * const [ time, setTime ] = useState( new Date() );\n *\n * return (\n * <TimePicker\n * currentTime={ date }\n * onChange={ ( newTime ) => setTime( newTime ) }\n * is12Hour\n * />\n * );\n * };\n * ```\n */\nexport function TimePicker( {\n\tis12Hour,\n\tcurrentTime,\n\tonChange,\n}: TimePickerProps ) {\n\tconst [ date, setDate ] = useState( () =>\n\t\t// Truncate the date at the minutes, see: #15495.\n\t\tcurrentTime ? moment( currentTime ).startOf( 'minutes' ) : moment()\n\t);\n\n\t// Reset the state when currentTime changed.\n\tuseEffect( () => {\n\t\tsetDate(\n\t\t\tcurrentTime ? moment( currentTime ).startOf( 'minutes' ) : moment()\n\t\t);\n\t}, [ currentTime ] );\n\n\tconst { day, month, year, minutes, hours, am } = useMemo(\n\t\t() => ( {\n\t\t\tday: date.format( 'DD' ),\n\t\t\tmonth: date.format( 'MM' ),\n\t\t\tyear: date.format( 'YYYY' ),\n\t\t\tminutes: date.format( 'mm' ),\n\t\t\thours: date.format( is12Hour ? 'hh' : 'HH' ),\n\t\t\tam: Number( date.format( 'H' ) ) <= 11 ? 'AM' : 'PM',\n\t\t} ),\n\t\t[ date, is12Hour ]\n\t);\n\n\t/**\n\t * Function that sets the date state and calls the onChange with a new date.\n\t * The date is truncated at the minutes.\n\t *\n\t * @param {Moment} newDate The date object.\n\t */\n\tfunction changeDate( newDate: Moment ) {\n\t\tsetDate( newDate );\n\t\tonChange?.( newDate.format( TIMEZONELESS_FORMAT ) );\n\t}\n\n\tfunction update( name: 'date' | 'month' | 'year' | 'hours' | 'minutes' ) {\n\t\treturn ( value: number ) => {\n\t\t\t// If the 12-hour format is being used and the 'PM' period is selected, then\n\t\t\t// the incoming value (which ranges 1-12) should be increased by 12 to match\n\t\t\t// the expected 24-hour format.\n\t\t\tlet adjustedValue = value;\n\t\t\tif ( name === 'hours' && is12Hour ) {\n\t\t\t\tadjustedValue = from12hTo24h( value, am === 'PM' );\n\t\t\t}\n\n\t\t\t// Clone the date and call the specific setter function according to `name`.\n\t\t\tconst newDate = date.clone()[ name ]( adjustedValue );\n\t\t\tchangeDate( newDate );\n\t\t};\n\t}\n\n\tfunction updateAmPm( value: 'AM' | 'PM' ) {\n\t\treturn () => {\n\t\t\tif ( am === value ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst parsedHours = parseInt( hours, 10 );\n\n\t\t\tconst newDate = date\n\t\t\t\t.clone()\n\t\t\t\t.hours( from12hTo24h( parsedHours, value === 'PM' ) );\n\n\t\t\tchangeDate( newDate );\n\t\t};\n\t}\n\n\tconst dayFormat = (\n\t\t<div className=\"components-datetime__time-field components-datetime__time-field-day\">\n\t\t\t<UpdateOnBlurAsIntegerField\n\t\t\t\taria-label={ __( 'Day' ) }\n\t\t\t\tclassName=\"components-datetime__time-field-day-input\"\n\t\t\t\ttype=\"number\"\n\t\t\t\t// The correct function to call in moment.js is \"date\" not \"day\".\n\t\t\t\tname=\"date\"\n\t\t\t\tvalue={ day }\n\t\t\t\tstep={ 1 }\n\t\t\t\tmin={ 1 }\n\t\t\t\tmax={ 31 }\n\t\t\t\tonUpdate={ update( 'date' ) }\n\t\t\t/>\n\t\t</div>\n\t);\n\n\tconst monthFormat = (\n\t\t<div className=\"components-datetime__time-field components-datetime__time-field-month\">\n\t\t\t<UpdateOnBlurAsIntegerField\n\t\t\t\tas=\"select\"\n\t\t\t\taria-label={ __( 'Month' ) }\n\t\t\t\tclassName=\"components-datetime__time-field-month-select\"\n\t\t\t\tname=\"month\"\n\t\t\t\tvalue={ month }\n\t\t\t\t// The value starts from 0, so we have to -1 when setting month.\n\t\t\t\tonUpdate={ ( value ) => update( 'month' )( value - 1 ) }\n\t\t\t>\n\t\t\t\t<option value=\"01\">{ __( 'January' ) }</option>\n\t\t\t\t<option value=\"02\">{ __( 'February' ) }</option>\n\t\t\t\t<option value=\"03\">{ __( 'March' ) }</option>\n\t\t\t\t<option value=\"04\">{ __( 'April' ) }</option>\n\t\t\t\t<option value=\"05\">{ __( 'May' ) }</option>\n\t\t\t\t<option value=\"06\">{ __( 'June' ) }</option>\n\t\t\t\t<option value=\"07\">{ __( 'July' ) }</option>\n\t\t\t\t<option value=\"08\">{ __( 'August' ) }</option>\n\t\t\t\t<option value=\"09\">{ __( 'September' ) }</option>\n\t\t\t\t<option value=\"10\">{ __( 'October' ) }</option>\n\t\t\t\t<option value=\"11\">{ __( 'November' ) }</option>\n\t\t\t\t<option value=\"12\">{ __( 'December' ) }</option>\n\t\t\t</UpdateOnBlurAsIntegerField>\n\t\t</div>\n\t);\n\n\tconst dayMonthFormat = is12Hour ? (\n\t\t<>\n\t\t\t{ monthFormat }\n\t\t\t{ dayFormat }\n\t\t</>\n\t) : (\n\t\t<>\n\t\t\t{ dayFormat }\n\t\t\t{ monthFormat }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<div className={ classnames( 'components-datetime__time' ) }>\n\t\t\t<fieldset>\n\t\t\t\t<legend className=\"components-datetime__time-legend invisible\">\n\t\t\t\t\t{ __( 'Date' ) }\n\t\t\t\t</legend>\n\t\t\t\t<div className=\"components-datetime__time-wrapper\">\n\t\t\t\t\t{ dayMonthFormat }\n\n\t\t\t\t\t<div className=\"components-datetime__time-field components-datetime__time-field-year\">\n\t\t\t\t\t\t<UpdateOnBlurAsIntegerField\n\t\t\t\t\t\t\taria-label={ __( 'Year' ) }\n\t\t\t\t\t\t\tclassName=\"components-datetime__time-field-year-input\"\n\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\tname=\"year\"\n\t\t\t\t\t\t\tstep={ 1 }\n\t\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\t\tmax={ 9999 }\n\t\t\t\t\t\t\tvalue={ year }\n\t\t\t\t\t\t\tonUpdate={ update( 'year' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</fieldset>\n\n\t\t\t<fieldset>\n\t\t\t\t<legend className=\"components-datetime__time-legend invisible\">\n\t\t\t\t\t{ __( 'Time' ) }\n\t\t\t\t</legend>\n\t\t\t\t<div className=\"components-datetime__time-wrapper\">\n\t\t\t\t\t<div className=\"components-datetime__time-field components-datetime__time-field-time\">\n\t\t\t\t\t\t<UpdateOnBlurAsIntegerField\n\t\t\t\t\t\t\taria-label={ __( 'Hours' ) }\n\t\t\t\t\t\t\tclassName=\"components-datetime__time-field-hours-input\"\n\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\tname=\"hours\"\n\t\t\t\t\t\t\tstep={ 1 }\n\t\t\t\t\t\t\tmin={ is12Hour ? 1 : 0 }\n\t\t\t\t\t\t\tmax={ is12Hour ? 12 : 23 }\n\t\t\t\t\t\t\tvalue={ hours }\n\t\t\t\t\t\t\tonUpdate={ update( 'hours' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"components-datetime__time-separator\"\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t:\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<UpdateOnBlurAsIntegerField\n\t\t\t\t\t\t\taria-label={ __( 'Minutes' ) }\n\t\t\t\t\t\t\tclassName=\"components-datetime__time-field-minutes-input\"\n\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\tname=\"minutes\"\n\t\t\t\t\t\t\tstep={ 1 }\n\t\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\t\tmax={ 59 }\n\t\t\t\t\t\t\tvalue={ minutes }\n\t\t\t\t\t\t\tonUpdate={ update( 'minutes' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t{ is12Hour && (\n\t\t\t\t\t\t<ButtonGroup className=\"components-datetime__time-field components-datetime__time-field-am-pm\">\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tam === 'AM' ? 'primary' : 'secondary'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonClick={ updateAmPm( 'AM' ) }\n\t\t\t\t\t\t\t\tclassName=\"components-datetime__time-am-button\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'AM' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tam === 'PM' ? 'primary' : 'secondary'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonClick={ updateAmPm( 'PM' ) }\n\t\t\t\t\t\t\t\tclassName=\"components-datetime__time-pm-button\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'PM' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</ButtonGroup>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<TimeZone />\n\t\t\t\t</div>\n\t\t\t</fieldset>\n\t\t</div>\n\t);\n}\n\nexport default TimePicker;\n"]}
|
|
@@ -11,7 +11,8 @@ import { __experimentalGetSettings as getDateSettings } from '@wordpress/date';
|
|
|
11
11
|
|
|
12
12
|
import Tooltip from '../tooltip';
|
|
13
13
|
/**
|
|
14
|
-
* Displays timezone information when user timezone is different from site
|
|
14
|
+
* Displays timezone information when user timezone is different from site
|
|
15
|
+
* timezone.
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
const TimeZone = () => {
|
|
@@ -26,8 +27,8 @@ const TimeZone = () => {
|
|
|
26
27
|
return null;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
const offsetSymbol = timezone.offset >= 0 ? '+' : '';
|
|
30
|
-
const zoneAbbr = '' !== timezone.abbr && isNaN(timezone.abbr) ? timezone.abbr : `UTC${offsetSymbol}${timezone.offset}`;
|
|
30
|
+
const offsetSymbol = Number(timezone.offset) >= 0 ? '+' : '';
|
|
31
|
+
const zoneAbbr = '' !== timezone.abbr && isNaN(Number(timezone.abbr)) ? timezone.abbr : `UTC${offsetSymbol}${timezone.offset}`;
|
|
31
32
|
const timezoneDetail = 'UTC' === timezone.string ? __('Coordinated Universal Time') : `(${zoneAbbr}) ${timezone.string.replace('_', ' ')}`;
|
|
32
33
|
return createElement(Tooltip, {
|
|
33
34
|
position: "top center",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/date-time/timezone.
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/date-time/timezone.tsx"],"names":["__","__experimentalGetSettings","getDateSettings","Tooltip","TimeZone","timezone","userTimezoneOffset","Date","getTimezoneOffset","Number","offset","offsetSymbol","zoneAbbr","abbr","isNaN","timezoneDetail","string","replace"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,yBAAyB,IAAIC,eAAtC,QAA6D,iBAA7D;AAEA;AACA;AACA;;AACA,OAAOC,OAAP,MAAoB,YAApB;AAEA;AACA;AACA;AACA;;AACA,MAAMC,QAAQ,GAAG,MAAM;AACtB,QAAM;AAAEC,IAAAA;AAAF,MAAeH,eAAe,EAApC,CADsB,CAGtB;;AACA,QAAMI,kBAAkB,GAAG,CAAC,CAAD,IAAO,IAAIC,IAAJ,GAAWC,iBAAX,KAAiC,EAAxC,CAA3B,CAJsB,CAMtB;AACA;;AACA,MAAKC,MAAM,CAAEJ,QAAQ,CAACK,MAAX,CAAN,KAA8BJ,kBAAnC,EAAwD;AACvD,WAAO,IAAP;AACA;;AAED,QAAMK,YAAY,GAAGF,MAAM,CAAEJ,QAAQ,CAACK,MAAX,CAAN,IAA6B,CAA7B,GAAiC,GAAjC,GAAuC,EAA5D;AACA,QAAME,QAAQ,GACb,OAAOP,QAAQ,CAACQ,IAAhB,IAAwBC,KAAK,CAAEL,MAAM,CAAEJ,QAAQ,CAACQ,IAAX,CAAR,CAA7B,GACGR,QAAQ,CAACQ,IADZ,GAEI,MAAMF,YAAc,GAAGN,QAAQ,CAACK,MAAQ,EAH7C;AAKA,QAAMK,cAAc,GACnB,UAAUV,QAAQ,CAACW,MAAnB,GACGhB,EAAE,CAAE,4BAAF,CADL,GAEI,IAAIY,QAAU,KAAKP,QAAQ,CAACW,MAAT,CAAgBC,OAAhB,CAAyB,GAAzB,EAA8B,GAA9B,CAAqC,EAH7D;AAKA,SACC,cAAC,OAAD;AAAS,IAAA,QAAQ,EAAC,YAAlB;AAA+B,IAAA,IAAI,EAAGF;AAAtC,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KAAiDH,QAAjD,CADD,CADD;AAKA,CA5BD;;AA8BA,eAAeR,QAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalGetSettings as getDateSettings } from '@wordpress/date';\n\n/**\n * Internal dependencies\n */\nimport Tooltip from '../tooltip';\n\n/**\n * Displays timezone information when user timezone is different from site\n * timezone.\n */\nconst TimeZone = () => {\n\tconst { timezone } = getDateSettings();\n\n\t// Convert timezone offset to hours.\n\tconst userTimezoneOffset = -1 * ( new Date().getTimezoneOffset() / 60 );\n\n\t// System timezone and user timezone match, nothing needed.\n\t// Compare as numbers because it comes over as string.\n\tif ( Number( timezone.offset ) === userTimezoneOffset ) {\n\t\treturn null;\n\t}\n\n\tconst offsetSymbol = Number( timezone.offset ) >= 0 ? '+' : '';\n\tconst zoneAbbr =\n\t\t'' !== timezone.abbr && isNaN( Number( timezone.abbr ) )\n\t\t\t? timezone.abbr\n\t\t\t: `UTC${ offsetSymbol }${ timezone.offset }`;\n\n\tconst timezoneDetail =\n\t\t'UTC' === timezone.string\n\t\t\t? __( 'Coordinated Universal Time' )\n\t\t\t: `(${ zoneAbbr }) ${ timezone.string.replace( '_', ' ' ) }`;\n\n\treturn (\n\t\t<Tooltip position=\"top center\" text={ timezoneDetail }>\n\t\t\t<div className=\"components-datetime__timezone\">{ zoneAbbr }</div>\n\t\t</Tooltip>\n\t);\n};\n\nexport default TimeZone;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import moment from 'moment';
|
|
5
5
|
/**
|
|
6
|
-
* Create a Moment object from a date string. With no date supplied, default to
|
|
7
|
-
* object representing now. If a null value is passed, return a null
|
|
6
|
+
* Create a Moment object from a date string. With no date supplied, default to
|
|
7
|
+
* a Moment object representing now. If a null value is passed, return a null
|
|
8
|
+
* value.
|
|
8
9
|
*
|
|
9
|
-
* @param
|
|
10
|
-
*
|
|
10
|
+
* @param [date] Date representing the currently selected
|
|
11
|
+
* date or null to signify no selection.
|
|
12
|
+
* @return Moment object for selected date or null.
|
|
11
13
|
*/
|
|
12
14
|
|
|
13
15
|
export const getMomentDate = date => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/date-time/utils.
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/date-time/utils.ts"],"names":["moment","getMomentDate","date"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,MAAP,MAAmB,QAAnB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GAAKC,IAAF,IAA4C;AACxE,MAAK,SAASA,IAAd,EAAqB;AACpB,WAAO,IAAP;AACA;;AACD,SAAOA,IAAI,GAAGF,MAAM,CAAEE,IAAF,CAAT,GAAoBF,MAAM,EAArC;AACA,CALM","sourcesContent":["/**\n * External dependencies\n */\nimport moment from 'moment';\n\n/**\n * Create a Moment object from a date string. With no date supplied, default to\n * a Moment object representing now. If a null value is passed, return a null\n * value.\n *\n * @param [date] Date representing the currently selected\n * date or null to signify no selection.\n * @return Moment object for selected date or null.\n */\nexport const getMomentDate = ( date?: Date | string | number | null ) => {\n\tif ( null === date ) {\n\t\treturn null;\n\t}\n\treturn date ? moment( date ) : moment();\n};\n"]}
|
|
@@ -9,7 +9,7 @@ import classnames from 'classnames';
|
|
|
9
9
|
* WordPress dependencies
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { useDisabled } from '@wordpress/compose';
|
|
13
13
|
import { createContext } from '@wordpress/element';
|
|
14
14
|
/**
|
|
15
15
|
* Internal dependencies
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/disabled/index.js"],"names":["classnames","
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/disabled/index.js"],"names":["classnames","useDisabled","createContext","StyledWrapper","Context","Consumer","Provider","Disabled","className","children","isDisabled","props","ref"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,oBAA5B;AACA,SAASC,aAAT,QAA8B,oBAA9B;AAEA;AACA;AACA;;AACA,SAASC,aAAT,QAA8B,0BAA9B;AAEA,MAAMC,OAAO,GAAGF,aAAa,CAAE,KAAF,CAA7B;AACA,MAAM;AAAEG,EAAAA,QAAF;AAAYC,EAAAA;AAAZ,IAAyBF,OAA/B;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AACA,SAASG,QAAT,OAA0E;AAAA,MAAvD;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,QAAb;AAAuBC,IAAAA,UAAU,GAAG,IAApC;AAA0C,OAAGC;AAA7C,GAAuD;;AACzE;AACA,QAAMC,GAAG,GAAGX,WAAW,EAAvB;;AAEA,MAAK,CAAES,UAAP,EAAoB;AACnB,WAAO,cAAC,QAAD;AAAU,MAAA,KAAK,EAAG;AAAlB,OAA4BD,QAA5B,CAAP;AACA;;AAED,SACC,cAAC,QAAD;AAAU,IAAA,KAAK,EAAG;AAAlB,KACC,cAAC,aAAD;AACC,IAAA,GAAG,EAAGG,GADP;AAEC,IAAA,SAAS,EAAGZ,UAAU,CAAEQ,SAAF,EAAa,qBAAb;AAFvB,KAGMG,KAHN,GAKGF,QALH,CADD,CADD;AAWA;;AAEDF,QAAQ,CAACH,OAAT,GAAmBA,OAAnB;AACAG,QAAQ,CAACF,QAAT,GAAoBA,QAApB;AAEA,eAAeE,QAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useDisabled } from '@wordpress/compose';\nimport { createContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { StyledWrapper } from './styles/disabled-styles';\n\nconst Context = createContext( false );\nconst { Consumer, Provider } = Context;\n\n/**\n * @typedef OwnProps\n * @property {string} [className] Classname for the disabled element.\n * @property {import('react').ReactNode} children Children to disable.\n * @property {boolean} [isDisabled=true] Whether to disable the children.\n */\n\n/**\n * @param {OwnProps & import('react').HTMLAttributes<HTMLDivElement>} props\n * @return {JSX.Element} Element wrapping the children to disable them when isDisabled is true.\n */\nfunction Disabled( { className, children, isDisabled = true, ...props } ) {\n\t/** @type {import('react').RefCallback<HTMLDivElement>} */\n\tconst ref = useDisabled();\n\n\tif ( ! isDisabled ) {\n\t\treturn <Provider value={ false }>{ children }</Provider>;\n\t}\n\n\treturn (\n\t\t<Provider value={ true }>\n\t\t\t<StyledWrapper\n\t\t\t\tref={ ref }\n\t\t\t\tclassName={ classnames( className, 'components-disabled' ) }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</StyledWrapper>\n\t\t</Provider>\n\t);\n}\n\nDisabled.Context = Context;\nDisabled.Consumer = Consumer;\n\nexport default Disabled;\n"]}
|