@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
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
import classnames from 'classnames';
|
|
5
5
|
import { isInteger } from 'lodash';
|
|
6
6
|
import moment from 'moment';
|
|
7
|
+
import type { FocusEvent } from 'react';
|
|
8
|
+
import type { Moment } from 'moment';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* WordPress dependencies
|
|
@@ -22,25 +24,18 @@ import { __ } from '@wordpress/i18n';
|
|
|
22
24
|
import Button from '../button';
|
|
23
25
|
import ButtonGroup from '../button-group';
|
|
24
26
|
import TimeZone from './timezone';
|
|
27
|
+
import type { WordPressComponentProps } from '../ui/context';
|
|
28
|
+
import type { UpdateOnBlurAsIntegerFieldProps, TimePickerProps } from './types';
|
|
25
29
|
|
|
26
|
-
/**
|
|
27
|
-
* Module Constants
|
|
28
|
-
*/
|
|
29
30
|
const TIMEZONELESS_FORMAT = 'YYYY-MM-DDTHH:mm:ss';
|
|
30
31
|
|
|
31
|
-
function from12hTo24h( hours, isPm ) {
|
|
32
|
+
function from12hTo24h( hours: number, isPm: boolean ) {
|
|
32
33
|
return isPm ? ( ( hours % 12 ) + 12 ) % 24 : hours % 12;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* @param {Object} props Component props.
|
|
40
|
-
* @param {string} props.as Render the component as specific element tag, defaults to "input".
|
|
41
|
-
* @param {number|string} props.value The default value of the component which will be parsed to integer.
|
|
42
|
-
* @param {Function} props.onUpdate Call back when blurred and validated.
|
|
43
|
-
* @param {string} [props.className]
|
|
37
|
+
* A shared component to parse, validate, and handle remounting of the
|
|
38
|
+
* underlying form field element like <input> and <select>.
|
|
44
39
|
*/
|
|
45
40
|
function UpdateOnBlurAsIntegerField( {
|
|
46
41
|
as,
|
|
@@ -48,11 +43,11 @@ function UpdateOnBlurAsIntegerField( {
|
|
|
48
43
|
onUpdate,
|
|
49
44
|
className,
|
|
50
45
|
...props
|
|
51
|
-
} ) {
|
|
52
|
-
function handleBlur( event ) {
|
|
46
|
+
}: WordPressComponentProps< UpdateOnBlurAsIntegerFieldProps, 'input', true > ) {
|
|
47
|
+
function handleBlur( event: FocusEvent< HTMLInputElement > ) {
|
|
53
48
|
const { target } = event;
|
|
54
49
|
|
|
55
|
-
if ( value === target.value ) {
|
|
50
|
+
if ( String( value ) === target.value ) {
|
|
56
51
|
return;
|
|
57
52
|
}
|
|
58
53
|
|
|
@@ -65,10 +60,10 @@ function UpdateOnBlurAsIntegerField( {
|
|
|
65
60
|
( typeof props.min !== 'undefined' && parsedValue < props.min )
|
|
66
61
|
) {
|
|
67
62
|
// If validation failed, reset the value to the previous valid value.
|
|
68
|
-
target.value = value;
|
|
63
|
+
target.value = String( value );
|
|
69
64
|
} else {
|
|
70
65
|
// Otherwise, it's valid, call onUpdate.
|
|
71
|
-
onUpdate(
|
|
66
|
+
onUpdate( parsedValue );
|
|
72
67
|
}
|
|
73
68
|
}
|
|
74
69
|
|
|
@@ -86,19 +81,33 @@ function UpdateOnBlurAsIntegerField( {
|
|
|
86
81
|
}
|
|
87
82
|
|
|
88
83
|
/**
|
|
89
|
-
*
|
|
84
|
+
* TimePicker is a React component that renders a clock for time selection.
|
|
85
|
+
*
|
|
86
|
+
* ```jsx
|
|
87
|
+
* import { TimePicker } from '@wordpress/components';
|
|
88
|
+
* import { useState } from '@wordpress/element';
|
|
90
89
|
*
|
|
91
|
-
*
|
|
90
|
+
* const MyTimePicker = () => {
|
|
91
|
+
* const [ time, setTime ] = useState( new Date() );
|
|
92
92
|
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
93
|
+
* return (
|
|
94
|
+
* <TimePicker
|
|
95
|
+
* currentTime={ date }
|
|
96
|
+
* onChange={ ( newTime ) => setTime( newTime ) }
|
|
97
|
+
* is12Hour
|
|
98
|
+
* />
|
|
99
|
+
* );
|
|
100
|
+
* };
|
|
101
|
+
* ```
|
|
97
102
|
*/
|
|
98
|
-
export function TimePicker( {
|
|
103
|
+
export function TimePicker( {
|
|
104
|
+
is12Hour,
|
|
105
|
+
currentTime,
|
|
106
|
+
onChange,
|
|
107
|
+
}: TimePickerProps ) {
|
|
99
108
|
const [ date, setDate ] = useState( () =>
|
|
100
109
|
// Truncate the date at the minutes, see: #15495.
|
|
101
|
-
moment( currentTime ).startOf( 'minutes' )
|
|
110
|
+
currentTime ? moment( currentTime ).startOf( 'minutes' ) : moment()
|
|
102
111
|
);
|
|
103
112
|
|
|
104
113
|
// Reset the state when currentTime changed.
|
|
@@ -115,7 +124,7 @@ export function TimePicker( { is12Hour, currentTime, onChange } ) {
|
|
|
115
124
|
year: date.format( 'YYYY' ),
|
|
116
125
|
minutes: date.format( 'mm' ),
|
|
117
126
|
hours: date.format( is12Hour ? 'hh' : 'HH' ),
|
|
118
|
-
am: date.format( 'H' ) <= 11 ? 'AM' : 'PM',
|
|
127
|
+
am: Number( date.format( 'H' ) ) <= 11 ? 'AM' : 'PM',
|
|
119
128
|
} ),
|
|
120
129
|
[ date, is12Hour ]
|
|
121
130
|
);
|
|
@@ -124,28 +133,30 @@ export function TimePicker( { is12Hour, currentTime, onChange } ) {
|
|
|
124
133
|
* Function that sets the date state and calls the onChange with a new date.
|
|
125
134
|
* The date is truncated at the minutes.
|
|
126
135
|
*
|
|
127
|
-
* @param {
|
|
136
|
+
* @param {Moment} newDate The date object.
|
|
128
137
|
*/
|
|
129
|
-
function changeDate( newDate ) {
|
|
138
|
+
function changeDate( newDate: Moment ) {
|
|
130
139
|
setDate( newDate );
|
|
131
|
-
onChange( newDate.format( TIMEZONELESS_FORMAT ) );
|
|
140
|
+
onChange?.( newDate.format( TIMEZONELESS_FORMAT ) );
|
|
132
141
|
}
|
|
133
142
|
|
|
134
|
-
function update( name
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
143
|
+
function update( name: 'date' | 'month' | 'year' | 'hours' | 'minutes' ) {
|
|
144
|
+
return ( value: number ) => {
|
|
145
|
+
// If the 12-hour format is being used and the 'PM' period is selected, then
|
|
146
|
+
// the incoming value (which ranges 1-12) should be increased by 12 to match
|
|
147
|
+
// the expected 24-hour format.
|
|
148
|
+
let adjustedValue = value;
|
|
149
|
+
if ( name === 'hours' && is12Hour ) {
|
|
150
|
+
adjustedValue = from12hTo24h( value, am === 'PM' );
|
|
151
|
+
}
|
|
142
152
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
153
|
+
// Clone the date and call the specific setter function according to `name`.
|
|
154
|
+
const newDate = date.clone()[ name ]( adjustedValue );
|
|
155
|
+
changeDate( newDate );
|
|
156
|
+
};
|
|
146
157
|
}
|
|
147
158
|
|
|
148
|
-
function updateAmPm( value ) {
|
|
159
|
+
function updateAmPm( value: 'AM' | 'PM' ) {
|
|
149
160
|
return () => {
|
|
150
161
|
if ( am === value ) {
|
|
151
162
|
return;
|
|
@@ -173,7 +184,7 @@ export function TimePicker( { is12Hour, currentTime, onChange } ) {
|
|
|
173
184
|
step={ 1 }
|
|
174
185
|
min={ 1 }
|
|
175
186
|
max={ 31 }
|
|
176
|
-
onUpdate={ update }
|
|
187
|
+
onUpdate={ update( 'date' ) }
|
|
177
188
|
/>
|
|
178
189
|
</div>
|
|
179
190
|
);
|
|
@@ -187,7 +198,7 @@ export function TimePicker( { is12Hour, currentTime, onChange } ) {
|
|
|
187
198
|
name="month"
|
|
188
199
|
value={ month }
|
|
189
200
|
// The value starts from 0, so we have to -1 when setting month.
|
|
190
|
-
onUpdate={ (
|
|
201
|
+
onUpdate={ ( value ) => update( 'month' )( value - 1 ) }
|
|
191
202
|
>
|
|
192
203
|
<option value="01">{ __( 'January' ) }</option>
|
|
193
204
|
<option value="02">{ __( 'February' ) }</option>
|
|
@@ -236,7 +247,7 @@ export function TimePicker( { is12Hour, currentTime, onChange } ) {
|
|
|
236
247
|
min={ 0 }
|
|
237
248
|
max={ 9999 }
|
|
238
249
|
value={ year }
|
|
239
|
-
onUpdate={ update }
|
|
250
|
+
onUpdate={ update( 'year' ) }
|
|
240
251
|
/>
|
|
241
252
|
</div>
|
|
242
253
|
</div>
|
|
@@ -257,7 +268,7 @@ export function TimePicker( { is12Hour, currentTime, onChange } ) {
|
|
|
257
268
|
min={ is12Hour ? 1 : 0 }
|
|
258
269
|
max={ is12Hour ? 12 : 23 }
|
|
259
270
|
value={ hours }
|
|
260
|
-
onUpdate={ update }
|
|
271
|
+
onUpdate={ update( 'hours' ) }
|
|
261
272
|
/>
|
|
262
273
|
<span
|
|
263
274
|
className="components-datetime__time-separator"
|
|
@@ -274,7 +285,7 @@ export function TimePicker( { is12Hour, currentTime, onChange } ) {
|
|
|
274
285
|
min={ 0 }
|
|
275
286
|
max={ 59 }
|
|
276
287
|
value={ minutes }
|
|
277
|
-
onUpdate={ update }
|
|
288
|
+
onUpdate={ update( 'minutes' ) }
|
|
278
289
|
/>
|
|
279
290
|
</div>
|
|
280
291
|
{ is12Hour && (
|
|
@@ -10,7 +10,8 @@ import { __experimentalGetSettings as getDateSettings } from '@wordpress/date';
|
|
|
10
10
|
import Tooltip from '../tooltip';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Displays timezone information when user timezone is different from site
|
|
13
|
+
* Displays timezone information when user timezone is different from site
|
|
14
|
+
* timezone.
|
|
14
15
|
*/
|
|
15
16
|
const TimeZone = () => {
|
|
16
17
|
const { timezone } = getDateSettings();
|
|
@@ -24,9 +25,9 @@ const TimeZone = () => {
|
|
|
24
25
|
return null;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
const offsetSymbol = timezone.offset >= 0 ? '+' : '';
|
|
28
|
+
const offsetSymbol = Number( timezone.offset ) >= 0 ? '+' : '';
|
|
28
29
|
const zoneAbbr =
|
|
29
|
-
'' !== timezone.abbr && isNaN( timezone.abbr )
|
|
30
|
+
'' !== timezone.abbr && isNaN( Number( timezone.abbr ) )
|
|
30
31
|
? timezone.abbr
|
|
31
32
|
: `UTC${ offsetSymbol }${ timezone.offset }`;
|
|
32
33
|
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { Moment } from 'moment';
|
|
5
|
+
import type { ReactNode } from 'react';
|
|
6
|
+
|
|
7
|
+
export type UpdateOnBlurAsIntegerFieldProps = {
|
|
8
|
+
/**
|
|
9
|
+
* The value of the integer field.
|
|
10
|
+
*/
|
|
11
|
+
value: number | string;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Called when the field is changed.
|
|
15
|
+
*/
|
|
16
|
+
onUpdate: ( value: number ) => void;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Children to render inside the field.
|
|
20
|
+
*/
|
|
21
|
+
children?: ReactNode;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type TimePickerProps = {
|
|
25
|
+
/**
|
|
26
|
+
* The initial current time the time picker should render.
|
|
27
|
+
*/
|
|
28
|
+
currentTime?: Date | string | number | null;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Whether we use a 12-hour clock. With a 12-hour clock, an AM/PM widget is
|
|
32
|
+
* displayed and the time format is assumed to be `MM-DD-YYYY` (as opposed
|
|
33
|
+
* to the default format `DD-MM-YYYY`).
|
|
34
|
+
*/
|
|
35
|
+
is12Hour?: boolean;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The function called when a new time has been selected. It is passed the
|
|
39
|
+
* time as an argument.
|
|
40
|
+
*/
|
|
41
|
+
onChange?: ( time: string ) => void;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type DatePickerEvent = {
|
|
45
|
+
/**
|
|
46
|
+
* The date of the event.
|
|
47
|
+
*/
|
|
48
|
+
date: Date;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type DatePickerDayProps = {
|
|
52
|
+
/**
|
|
53
|
+
* The day to display.
|
|
54
|
+
*/
|
|
55
|
+
day: Moment;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* List of events to show on this day.
|
|
59
|
+
*
|
|
60
|
+
* @default []
|
|
61
|
+
*/
|
|
62
|
+
events?: DatePickerEvent[];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export type DatePickerProps = {
|
|
66
|
+
/**
|
|
67
|
+
* The current date and time at initialization. Optionally pass in a `null`
|
|
68
|
+
* value to specify no date is currently selected.
|
|
69
|
+
*/
|
|
70
|
+
currentDate?: Date | string | number | null;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The function called when a new date has been selected. It is passed the
|
|
74
|
+
* date as an argument.
|
|
75
|
+
*/
|
|
76
|
+
onChange?: ( date: string ) => void;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* A callback function which receives a Date object representing a day as an
|
|
80
|
+
* argument, and should return a Boolean to signify if the day is valid or
|
|
81
|
+
* not.
|
|
82
|
+
*/
|
|
83
|
+
isInvalidDate?: ( date: Date ) => boolean;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* A callback invoked when selecting the previous/next month in the date
|
|
87
|
+
* picker. The callback receives the new month date in the ISO format as an
|
|
88
|
+
* argument.
|
|
89
|
+
*/
|
|
90
|
+
onMonthPreviewed?: ( date: string ) => void;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* List of events to show in the date picker. Each event will appear as a
|
|
94
|
+
* dot on the day of the event.
|
|
95
|
+
*/
|
|
96
|
+
events?: DatePickerEvent[];
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export type DateTimePickerProps = Omit< DatePickerProps, 'onChange' > &
|
|
100
|
+
Omit< TimePickerProps, 'currentTime' | 'onChange' > & {
|
|
101
|
+
/**
|
|
102
|
+
* The function called when a new date or time has been selected. It is
|
|
103
|
+
* passed the date and time as an argument.
|
|
104
|
+
*/
|
|
105
|
+
onChange?: ( date: string | null ) => void;
|
|
106
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import moment from 'moment';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Create a Moment object from a date string. With no date supplied, default to
|
|
8
|
+
* a Moment object representing now. If a null value is passed, return a null
|
|
9
|
+
* value.
|
|
10
|
+
*
|
|
11
|
+
* @param [date] Date representing the currently selected
|
|
12
|
+
* date or null to signify no selection.
|
|
13
|
+
* @return Moment object for selected date or null.
|
|
14
|
+
*/
|
|
15
|
+
export const getMomentDate = ( date?: Date | string | number | null ) => {
|
|
16
|
+
if ( null === date ) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return date ? moment( date ) : moment();
|
|
20
|
+
};
|
package/src/disabled/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { useDisabled } from '@wordpress/compose';
|
|
10
10
|
import { createContext } from '@wordpress/element';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
Gesture,
|
|
6
|
+
GestureDetector,
|
|
7
|
+
LongPressGestureHandler,
|
|
8
|
+
} from 'react-native-gesture-handler';
|
|
9
|
+
import Animated, {
|
|
10
|
+
useSharedValue,
|
|
11
|
+
runOnJS,
|
|
12
|
+
useAnimatedReaction,
|
|
13
|
+
useAnimatedGestureHandler,
|
|
14
|
+
} from 'react-native-reanimated';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* WordPress dependencies
|
|
18
|
+
*/
|
|
19
|
+
import { createContext, useContext, useRef, useMemo } from '@wordpress/element';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Internal dependencies
|
|
23
|
+
*/
|
|
24
|
+
import styles from './style.scss';
|
|
25
|
+
|
|
26
|
+
const Context = createContext( {} );
|
|
27
|
+
const { Provider } = Context;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Draggable component.
|
|
31
|
+
*
|
|
32
|
+
* @param {Object} props Component props.
|
|
33
|
+
* @param {JSX.Element} props.children Children to be rendered.
|
|
34
|
+
* @param {Function} [props.onDragEnd] Callback when dragging ends.
|
|
35
|
+
* @param {Function} [props.onDragOver] Callback when dragging happens over an element.
|
|
36
|
+
* @param {Function} [props.onDragStart] Callback when dragging starts.
|
|
37
|
+
*
|
|
38
|
+
* @return {JSX.Element} The component to be rendered.
|
|
39
|
+
*/
|
|
40
|
+
const Draggable = ( { children, onDragEnd, onDragOver, onDragStart } ) => {
|
|
41
|
+
const isDragging = useSharedValue( false );
|
|
42
|
+
const isPanActive = useSharedValue( false );
|
|
43
|
+
const draggingId = useSharedValue( '' );
|
|
44
|
+
const panGestureRef = useRef();
|
|
45
|
+
const currentFirstTouchId = useSharedValue( null );
|
|
46
|
+
|
|
47
|
+
const initialPosition = {
|
|
48
|
+
x: useSharedValue( 0 ),
|
|
49
|
+
y: useSharedValue( 0 ),
|
|
50
|
+
};
|
|
51
|
+
const lastPosition = {
|
|
52
|
+
x: useSharedValue( 0 ),
|
|
53
|
+
y: useSharedValue( 0 ),
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
useAnimatedReaction(
|
|
57
|
+
() => isDragging.value,
|
|
58
|
+
( result, previous ) => {
|
|
59
|
+
if ( result === previous || previous === null ) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if ( result ) {
|
|
64
|
+
if ( onDragStart ) {
|
|
65
|
+
onDragStart( {
|
|
66
|
+
x: initialPosition.x.value,
|
|
67
|
+
y: initialPosition.y.value,
|
|
68
|
+
id: draggingId.value,
|
|
69
|
+
} );
|
|
70
|
+
}
|
|
71
|
+
} else if ( onDragEnd ) {
|
|
72
|
+
onDragEnd( {
|
|
73
|
+
x: lastPosition.x.value,
|
|
74
|
+
y: lastPosition.y.value,
|
|
75
|
+
id: draggingId.value,
|
|
76
|
+
} );
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
function getFirstTouchEvent( event ) {
|
|
82
|
+
'worklet';
|
|
83
|
+
|
|
84
|
+
return event.allTouches.find(
|
|
85
|
+
( touch ) => touch.id === currentFirstTouchId.value
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const panGesture = Gesture.Pan()
|
|
90
|
+
.manualActivation( true )
|
|
91
|
+
.onTouchesDown( ( event ) => {
|
|
92
|
+
if ( ! currentFirstTouchId.value ) {
|
|
93
|
+
const firstEvent = event.allTouches[ 0 ];
|
|
94
|
+
const { x = 0, y = 0 } = firstEvent;
|
|
95
|
+
|
|
96
|
+
currentFirstTouchId.value = firstEvent.id;
|
|
97
|
+
|
|
98
|
+
initialPosition.x.value = x;
|
|
99
|
+
initialPosition.y.value = y;
|
|
100
|
+
}
|
|
101
|
+
} )
|
|
102
|
+
.onTouchesMove( ( event, state ) => {
|
|
103
|
+
if ( ! isPanActive.value && isDragging.value ) {
|
|
104
|
+
isPanActive.value = true;
|
|
105
|
+
state.activate();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if ( isPanActive.value && isDragging.value ) {
|
|
109
|
+
const firstEvent = getFirstTouchEvent( event );
|
|
110
|
+
|
|
111
|
+
if ( ! firstEvent ) {
|
|
112
|
+
state.end();
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
lastPosition.x.value = firstEvent.x;
|
|
117
|
+
lastPosition.y.value = firstEvent.y;
|
|
118
|
+
|
|
119
|
+
if ( onDragOver ) {
|
|
120
|
+
onDragOver( firstEvent );
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
} )
|
|
124
|
+
.onTouchesCancelled( ( _event, state ) => {
|
|
125
|
+
state.end();
|
|
126
|
+
} )
|
|
127
|
+
.onEnd( () => {
|
|
128
|
+
currentFirstTouchId.value = null;
|
|
129
|
+
isPanActive.value = false;
|
|
130
|
+
isDragging.value = false;
|
|
131
|
+
} )
|
|
132
|
+
.withRef( panGestureRef )
|
|
133
|
+
.shouldCancelWhenOutside( false );
|
|
134
|
+
|
|
135
|
+
const providerValue = useMemo( () => {
|
|
136
|
+
return { panGestureRef, isDragging, isPanActive, draggingId };
|
|
137
|
+
}, [] );
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<GestureDetector gesture={ panGesture }>
|
|
141
|
+
<Animated.View style={ styles.draggable__container }>
|
|
142
|
+
<Provider value={ providerValue }>{ children }</Provider>
|
|
143
|
+
</Animated.View>
|
|
144
|
+
</GestureDetector>
|
|
145
|
+
);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Draggable trigger component.
|
|
150
|
+
*
|
|
151
|
+
* This component acts as the trigger for the dragging functionality.
|
|
152
|
+
*
|
|
153
|
+
* @param {Object} props Component props.
|
|
154
|
+
* @param {JSX.Element} props.children Children to be rendered.
|
|
155
|
+
* @param {*} props.id Identifier passed within the event callbacks.
|
|
156
|
+
* @param {boolean} [props.enabled] Enables the long-press gesture.
|
|
157
|
+
* @param {number} [props.maxDistance] Maximum distance, that defines how far the finger is allowed to travel during a long press gesture.
|
|
158
|
+
* @param {number} [props.minDuration] Minimum time, that a finger must remain pressed on the corresponding view.
|
|
159
|
+
* @param {Function} [props.onLongPress] Callback when long-press gesture is triggered over an element.
|
|
160
|
+
* @param {Function} [props.onLongPressEnd] Callback when long-press gesture ends.
|
|
161
|
+
*
|
|
162
|
+
* @return {JSX.Element} The component to be rendered.
|
|
163
|
+
*/
|
|
164
|
+
const DraggableTrigger = ( {
|
|
165
|
+
children,
|
|
166
|
+
enabled = true,
|
|
167
|
+
id,
|
|
168
|
+
maxDistance = 1000,
|
|
169
|
+
minDuration = 500,
|
|
170
|
+
onLongPress,
|
|
171
|
+
onLongPressEnd,
|
|
172
|
+
} ) => {
|
|
173
|
+
const { panGestureRef, isDragging, isPanActive, draggingId } = useContext(
|
|
174
|
+
Context
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
const gestureHandler = useAnimatedGestureHandler( {
|
|
178
|
+
onActive: () => {
|
|
179
|
+
if ( isDragging.value ) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
isDragging.value = true;
|
|
184
|
+
draggingId.value = id;
|
|
185
|
+
if ( onLongPress ) {
|
|
186
|
+
runOnJS( onLongPress )( id );
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
onEnd: () => {
|
|
190
|
+
if ( ! isPanActive.value ) {
|
|
191
|
+
isDragging.value = false;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if ( onLongPressEnd ) {
|
|
195
|
+
runOnJS( onLongPressEnd )( id );
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
} );
|
|
199
|
+
|
|
200
|
+
return (
|
|
201
|
+
<LongPressGestureHandler
|
|
202
|
+
enabled={ enabled }
|
|
203
|
+
minDurationMs={ minDuration }
|
|
204
|
+
maxDist={ maxDistance }
|
|
205
|
+
simultaneousHandlers={ panGestureRef }
|
|
206
|
+
shouldCancelWhenOutside={ false }
|
|
207
|
+
onGestureEvent={ gestureHandler }
|
|
208
|
+
>
|
|
209
|
+
{ children }
|
|
210
|
+
</LongPressGestureHandler>
|
|
211
|
+
);
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
export { DraggableTrigger };
|
|
215
|
+
export default Draggable;
|
package/src/dropdown/index.js
CHANGED
|
@@ -31,12 +31,12 @@ export default function Dropdown( props ) {
|
|
|
31
31
|
const {
|
|
32
32
|
renderContent,
|
|
33
33
|
renderToggle,
|
|
34
|
-
position = 'bottom right',
|
|
35
34
|
className,
|
|
36
35
|
contentClassName,
|
|
37
36
|
expandOnMobile,
|
|
38
37
|
headerTitle,
|
|
39
38
|
focusOnMount,
|
|
39
|
+
position,
|
|
40
40
|
popoverProps,
|
|
41
41
|
onClose,
|
|
42
42
|
onToggle,
|
|
@@ -82,6 +82,10 @@ export default function Dropdown( props ) {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
const args = { isOpen, onToggle: toggle, onClose: close };
|
|
85
|
+
const hasAnchorRef =
|
|
86
|
+
!! popoverProps?.anchorRef ||
|
|
87
|
+
!! popoverProps?.getAnchorRect ||
|
|
88
|
+
!! popoverProps?.anchorRect;
|
|
85
89
|
|
|
86
90
|
return (
|
|
87
91
|
<div
|
|
@@ -101,10 +105,11 @@ export default function Dropdown( props ) {
|
|
|
101
105
|
expandOnMobile={ expandOnMobile }
|
|
102
106
|
headerTitle={ headerTitle }
|
|
103
107
|
focusOnMount={ focusOnMount }
|
|
108
|
+
// This value is used to ensure that the dropdowns
|
|
109
|
+
// align with the editor header by default.
|
|
110
|
+
offset={ 13 }
|
|
111
|
+
anchorRef={ ! hasAnchorRef ? containerRef : undefined }
|
|
104
112
|
{ ...popoverProps }
|
|
105
|
-
anchorRef={
|
|
106
|
-
popoverProps?.anchorRef ?? containerRef.current
|
|
107
|
-
}
|
|
108
113
|
className={ classnames(
|
|
109
114
|
'components-dropdown__content',
|
|
110
115
|
popoverProps ? popoverProps.className : undefined,
|
package/src/dropdown/style.scss
CHANGED
|
@@ -105,7 +105,7 @@ function FocalPointPicker( props ) {
|
|
|
105
105
|
// coordinates to workaround a bug affecting Android's PanResponder.
|
|
106
106
|
// Specifically, dragging the handle outside the bounds of the image
|
|
107
107
|
// results in inaccurate locationX and locationY coordinates to be
|
|
108
|
-
// reported. https://
|
|
108
|
+
// reported. https://github.com/facebook/react-native/issues/15290#issuecomment-435494944
|
|
109
109
|
const x = pageX - locationPageOffsetX;
|
|
110
110
|
const y = pageY - locationPageOffsetY;
|
|
111
111
|
onChange( {
|
|
@@ -116,7 +116,7 @@ function FocalPointPicker( props ) {
|
|
|
116
116
|
} );
|
|
117
117
|
// Slider (child of RangeCell) is uncontrolled, so we must increment a
|
|
118
118
|
// key to re-mount and sync the pan gesture values to the sliders
|
|
119
|
-
// https://
|
|
119
|
+
// https://github.com/callstack/react-native-slider/tree/v3.0.3#value
|
|
120
120
|
setSliderKey( ( prevState ) => prevState + 1 );
|
|
121
121
|
},
|
|
122
122
|
} ),
|
|
@@ -193,7 +193,7 @@ function FocalPointPicker( props ) {
|
|
|
193
193
|
setVideoNaturalSize( { height, width } );
|
|
194
194
|
setDisplayPlaceholder( false );
|
|
195
195
|
// Avoid invisible, paused video on Android, presumably related to
|
|
196
|
-
// https://
|
|
196
|
+
// https://github.com/react-native-video/react-native-video/issues/1979
|
|
197
197
|
videoRef?.current.seek( 0 );
|
|
198
198
|
};
|
|
199
199
|
const onXCoordinateChange = ( x ) =>
|
|
@@ -14,10 +14,6 @@ import FormFileUpload from '../';
|
|
|
14
14
|
*/
|
|
15
15
|
const { File } = window;
|
|
16
16
|
|
|
17
|
-
const user = userEvent.setup( {
|
|
18
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
19
|
-
} );
|
|
20
|
-
|
|
21
17
|
// @testing-library/user-event considers changing <input type="file"> to a string as a change, but it do not occur on real browsers, so the comparisons will be against this result
|
|
22
18
|
const fakePath = expect.objectContaining( {
|
|
23
19
|
target: expect.objectContaining( {
|
|
@@ -45,6 +41,10 @@ describe( 'FormFileUpload', () => {
|
|
|
45
41
|
} );
|
|
46
42
|
|
|
47
43
|
it( 'should not fire a change event after selecting the same file', async () => {
|
|
44
|
+
const user = userEvent.setup( {
|
|
45
|
+
advanceTimers: jest.advanceTimersByTime,
|
|
46
|
+
} );
|
|
47
|
+
|
|
48
48
|
const onChange = jest.fn();
|
|
49
49
|
|
|
50
50
|
render(
|
|
@@ -68,6 +68,10 @@ describe( 'FormFileUpload', () => {
|
|
|
68
68
|
} );
|
|
69
69
|
|
|
70
70
|
it( 'should fire a change event after selecting the same file if the value was reset in between', async () => {
|
|
71
|
+
const user = userEvent.setup( {
|
|
72
|
+
advanceTimers: jest.advanceTimersByTime,
|
|
73
|
+
} );
|
|
74
|
+
|
|
71
75
|
const onChange = jest.fn();
|
|
72
76
|
|
|
73
77
|
render(
|