@wordpress/components 23.6.0 → 23.8.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 +43 -4
- package/build/angle-picker-control/angle-circle.js +1 -4
- package/build/angle-picker-control/angle-circle.js.map +1 -1
- package/build/angle-picker-control/index.js +10 -22
- package/build/angle-picker-control/index.js.map +1 -1
- package/build/angle-picker-control/styles/angle-picker-control-styles.js +24 -15
- package/build/angle-picker-control/styles/angle-picker-control-styles.js.map +1 -1
- package/build/animate/index.js +27 -19
- package/build/animate/index.js.map +1 -1
- package/build/animate/types.js.map +1 -0
- package/build/box-control/axial-input-controls.js.map +1 -1
- package/build/color-picker/color-input.js +0 -4
- package/build/color-picker/color-input.js.map +1 -1
- package/build/color-picker/component.js +5 -4
- package/build/color-picker/component.js.map +1 -1
- package/build/color-picker/hex-input.js.map +1 -1
- package/build/color-picker/hsl-input.js.map +1 -1
- package/build/color-picker/input-with-slider.js.map +1 -1
- package/build/color-picker/legacy-adapter.js.map +1 -1
- package/build/color-picker/picker.js.map +1 -1
- package/build/color-picker/rgb-input.js.map +1 -1
- package/build/color-picker/use-deprecated-props.js.map +1 -1
- package/build/custom-gradient-picker/constants.js +1 -1
- package/build/custom-gradient-picker/constants.js.map +1 -1
- package/build/custom-gradient-picker/gradient-bar/constants.js.map +1 -1
- package/build/custom-gradient-picker/gradient-bar/control-points.js +9 -5
- package/build/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
- package/build/custom-gradient-picker/gradient-bar/index.js +14 -9
- package/build/custom-gradient-picker/gradient-bar/index.js.map +1 -1
- package/build/custom-gradient-picker/gradient-bar/utils.js +34 -54
- package/build/custom-gradient-picker/gradient-bar/utils.js.map +1 -1
- package/build/custom-gradient-picker/index.js +45 -16
- package/build/custom-gradient-picker/index.js.map +1 -1
- package/build/custom-gradient-picker/serializer.js +10 -4
- package/build/custom-gradient-picker/serializer.js.map +1 -1
- package/build/custom-gradient-picker/styles/custom-gradient-picker-styles.js +6 -6
- package/build/custom-gradient-picker/styles/custom-gradient-picker-styles.js.map +1 -1
- package/build/custom-gradient-picker/types.js +6 -0
- package/build/custom-gradient-picker/types.js.map +1 -0
- package/build/custom-gradient-picker/utils.js +17 -12
- package/build/custom-gradient-picker/utils.js.map +1 -1
- package/build/drop-zone/index.js +8 -8
- package/build/drop-zone/index.js.map +1 -1
- package/build/{color-list-picker → duotone-picker/color-list-picker}/index.js +5 -5
- package/build/duotone-picker/color-list-picker/index.js.map +1 -0
- package/build/duotone-picker/color-list-picker/types.js +6 -0
- package/build/duotone-picker/color-list-picker/types.js.map +1 -0
- package/build/duotone-picker/custom-duotone-bar.js.map +1 -1
- package/build/duotone-picker/duotone-picker.js +39 -2
- package/build/duotone-picker/duotone-picker.js.map +1 -1
- package/build/duotone-picker/duotone-swatch.js.map +1 -1
- package/build/duotone-picker/index.js.map +1 -1
- package/build/duotone-picker/types.js +6 -0
- package/build/duotone-picker/types.js.map +1 -0
- package/build/duotone-picker/utils.js +13 -11
- package/build/duotone-picker/utils.js.map +1 -1
- package/build/form-token-field/index.js +9 -3
- package/build/form-token-field/index.js.map +1 -1
- package/build/gradient-picker/index.js +61 -9
- package/build/gradient-picker/index.js.map +1 -1
- package/build/gradient-picker/types.js +6 -0
- package/build/gradient-picker/types.js.map +1 -0
- package/build/index.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/index.android.js +0 -4
- package/build/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/index.ios.js +100 -55
- package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/use-keyboard-offset.native.js +82 -0
- package/build/mobile/keyboard-aware-flat-list/use-keyboard-offset.native.js.map +1 -0
- package/build/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js +85 -0
- package/build/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +1 -0
- package/build/mobile/keyboard-aware-flat-list/use-text-input-caret-position.native.js +44 -0
- package/build/mobile/keyboard-aware-flat-list/use-text-input-caret-position.native.js.map +1 -0
- package/build/mobile/keyboard-aware-flat-list/use-text-input-offset.native.js +53 -0
- package/build/mobile/keyboard-aware-flat-list/use-text-input-offset.native.js.map +1 -0
- package/build/navigator/navigator-provider/component.js +4 -2
- package/build/navigator/navigator-provider/component.js.map +1 -1
- package/build/navigator/navigator-screen/component.js +4 -3
- package/build/navigator/navigator-screen/component.js.map +1 -1
- package/build/palette-edit/index.js +1 -2
- package/build/palette-edit/index.js.map +1 -1
- package/build/private-apis.js.map +1 -1
- package/build/query-controls/author-select.js +2 -1
- package/build/query-controls/author-select.js.map +1 -1
- package/build/query-controls/category-select.js +3 -1
- package/build/query-controls/category-select.js.map +1 -1
- package/build/query-controls/index.js +7 -1
- package/build/query-controls/index.js.map +1 -1
- package/build/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build/sandbox/index.native.js +129 -93
- package/build/sandbox/index.native.js.map +1 -1
- package/build/tab-panel/index.js +1 -1
- package/build/tab-panel/index.js.map +1 -1
- package/build/tools-panel/tools-panel/hook.js +45 -6
- package/build/tools-panel/tools-panel/hook.js.map +1 -1
- package/build/utils/input/input-control.js +1 -1
- package/build/utils/input/input-control.js.map +1 -1
- package/build-module/angle-picker-control/angle-circle.js +1 -4
- package/build-module/angle-picker-control/angle-circle.js.map +1 -1
- package/build-module/angle-picker-control/index.js +12 -21
- package/build-module/angle-picker-control/index.js.map +1 -1
- package/build-module/angle-picker-control/styles/angle-picker-control-styles.js +20 -13
- package/build-module/angle-picker-control/styles/angle-picker-control-styles.js.map +1 -1
- package/build-module/animate/index.js +25 -17
- package/build-module/animate/index.js.map +1 -1
- package/build-module/box-control/axial-input-controls.js.map +1 -1
- package/build-module/color-picker/color-input.js +0 -4
- package/build-module/color-picker/color-input.js.map +1 -1
- package/build-module/color-picker/component.js +3 -3
- package/build-module/color-picker/component.js.map +1 -1
- package/build-module/color-picker/hex-input.js.map +1 -1
- package/build-module/color-picker/hsl-input.js.map +1 -1
- package/build-module/color-picker/input-with-slider.js.map +1 -1
- package/build-module/color-picker/legacy-adapter.js.map +1 -1
- package/build-module/color-picker/picker.js +4 -0
- package/build-module/color-picker/picker.js.map +1 -1
- package/build-module/color-picker/rgb-input.js.map +1 -1
- package/build-module/color-picker/use-deprecated-props.js.map +1 -1
- package/build-module/custom-gradient-picker/constants.js +1 -1
- package/build-module/custom-gradient-picker/constants.js.map +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/constants.js.map +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/control-points.js +9 -4
- package/build-module/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/index.js +14 -8
- package/build-module/custom-gradient-picker/gradient-bar/index.js.map +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/utils.js +34 -54
- package/build-module/custom-gradient-picker/gradient-bar/utils.js.map +1 -1
- package/build-module/custom-gradient-picker/index.js +44 -17
- package/build-module/custom-gradient-picker/index.js.map +1 -1
- package/build-module/custom-gradient-picker/serializer.js +10 -4
- package/build-module/custom-gradient-picker/serializer.js.map +1 -1
- package/build-module/custom-gradient-picker/styles/custom-gradient-picker-styles.js +6 -6
- package/build-module/custom-gradient-picker/styles/custom-gradient-picker-styles.js.map +1 -1
- package/build-module/custom-gradient-picker/types.js +2 -0
- package/build-module/custom-gradient-picker/utils.js +17 -12
- package/build-module/custom-gradient-picker/utils.js.map +1 -1
- package/build-module/drop-zone/index.js +8 -8
- package/build-module/drop-zone/index.js.map +1 -1
- package/build-module/{color-list-picker → duotone-picker/color-list-picker}/index.js +5 -5
- package/build-module/duotone-picker/color-list-picker/index.js.map +1 -0
- package/build-module/duotone-picker/color-list-picker/types.js +2 -0
- package/build-module/duotone-picker/color-list-picker/types.js.map +1 -0
- package/build-module/duotone-picker/custom-duotone-bar.js.map +1 -1
- package/build-module/duotone-picker/duotone-picker.js +38 -2
- package/build-module/duotone-picker/duotone-picker.js.map +1 -1
- package/build-module/duotone-picker/duotone-swatch.js.map +1 -1
- package/build-module/duotone-picker/index.js.map +1 -1
- package/build-module/duotone-picker/types.js +2 -0
- package/build-module/duotone-picker/types.js.map +1 -0
- package/build-module/duotone-picker/utils.js +17 -11
- package/build-module/duotone-picker/utils.js.map +1 -1
- package/build-module/form-token-field/index.js +9 -4
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/gradient-picker/index.js +61 -10
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/gradient-picker/types.js +2 -0
- package/build-module/gradient-picker/types.js.map +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/index.android.js +0 -4
- 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 +97 -54
- package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/use-keyboard-offset.native.js +73 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-keyboard-offset.native.js.map +1 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js +76 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +1 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-text-input-caret-position.native.js +33 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-text-input-caret-position.native.js.map +1 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-text-input-offset.native.js +40 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-text-input-offset.native.js.map +1 -0
- package/build-module/navigator/navigator-provider/component.js +4 -2
- package/build-module/navigator/navigator-provider/component.js.map +1 -1
- package/build-module/navigator/navigator-screen/component.js +4 -3
- package/build-module/navigator/navigator-screen/component.js.map +1 -1
- package/build-module/palette-edit/index.js +1 -2
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/query-controls/author-select.js +2 -1
- package/build-module/query-controls/author-select.js.map +1 -1
- package/build-module/query-controls/category-select.js +3 -1
- package/build-module/query-controls/category-select.js.map +1 -1
- package/build-module/query-controls/index.js +7 -2
- package/build-module/query-controls/index.js.map +1 -1
- package/build-module/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build-module/sandbox/index.native.js +121 -87
- package/build-module/sandbox/index.native.js.map +1 -1
- package/build-module/tab-panel/index.js +2 -2
- package/build-module/tab-panel/index.js.map +1 -1
- package/build-module/tools-panel/tools-panel/hook.js +45 -6
- package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
- package/build-module/utils/input/input-control.js +1 -1
- package/build-module/utils/input/input-control.js.map +1 -1
- package/build-style/style-rtl.css +41 -29
- package/build-style/style.css +43 -29
- package/build-types/angle-picker-control/angle-circle.d.ts.map +1 -1
- package/build-types/angle-picker-control/index.d.ts.map +1 -1
- package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts +6 -1
- package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts.map +1 -1
- package/build-types/animate/index.d.ts +27 -22
- package/build-types/animate/index.d.ts.map +1 -1
- package/build-types/animate/stories/index.d.ts +18 -0
- package/build-types/animate/stories/index.d.ts.map +1 -0
- package/build-types/animate/types.d.ts +30 -0
- package/build-types/animate/types.d.ts.map +1 -0
- package/build-types/border-box-control/border-box-control/hook.d.ts +2 -2
- package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +2 -2
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +2 -2
- package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +2 -2
- package/build-types/border-control/border-control/hook.d.ts +2 -2
- package/build-types/border-control/border-control-dropdown/hook.d.ts +2 -2
- package/build-types/border-control/border-control-style-picker/hook.d.ts +2 -2
- package/build-types/box-control/styles/box-control-styles.d.ts +5 -5
- package/build-types/button/deprecated.d.ts +2 -2
- package/build-types/card/card/hook.d.ts +2 -2
- package/build-types/card/card-body/hook.d.ts +2 -2
- package/build-types/card/card-divider/hook.d.ts +2 -2
- package/build-types/card/card-footer/hook.d.ts +2 -2
- package/build-types/card/card-header/hook.d.ts +2 -2
- package/build-types/card/card-media/hook.d.ts +2 -2
- package/build-types/color-palette/styles.d.ts +1 -1
- package/build-types/color-picker/color-input.d.ts +1 -11
- package/build-types/color-picker/color-input.d.ts.map +1 -1
- package/build-types/color-picker/component.d.ts +8 -9
- package/build-types/color-picker/component.d.ts.map +1 -1
- package/build-types/color-picker/hex-input.d.ts +1 -10
- package/build-types/color-picker/hex-input.d.ts.map +1 -1
- package/build-types/color-picker/hsl-input.d.ts +1 -10
- package/build-types/color-picker/hsl-input.d.ts.map +1 -1
- package/build-types/color-picker/input-with-slider.d.ts +1 -9
- package/build-types/color-picker/input-with-slider.d.ts.map +1 -1
- package/build-types/color-picker/legacy-adapter.d.ts +1 -3
- package/build-types/color-picker/legacy-adapter.d.ts.map +1 -1
- package/build-types/color-picker/picker.d.ts +4 -7
- package/build-types/color-picker/picker.d.ts.map +1 -1
- package/build-types/color-picker/rgb-input.d.ts +1 -10
- package/build-types/color-picker/rgb-input.d.ts.map +1 -1
- package/build-types/color-picker/stories/index.d.ts +19 -0
- package/build-types/color-picker/stories/index.d.ts.map +1 -0
- package/build-types/color-picker/styles.d.ts +5 -5
- package/build-types/color-picker/test/index.d.ts +2 -0
- package/build-types/color-picker/test/index.d.ts.map +1 -0
- package/build-types/color-picker/types.d.ts +105 -1
- package/build-types/color-picker/types.d.ts.map +1 -1
- package/build-types/color-picker/use-deprecated-props.d.ts +1 -44
- package/build-types/color-picker/use-deprecated-props.d.ts.map +1 -1
- package/build-types/combobox-control/styles.d.ts +1 -1
- package/build-types/custom-gradient-picker/constants.d.ts +8 -8
- package/build-types/custom-gradient-picker/constants.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/gradient-bar/constants.d.ts +7 -7
- package/build-types/custom-gradient-picker/gradient-bar/constants.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/gradient-bar/control-points.d.ts +5 -22
- package/build-types/custom-gradient-picker/gradient-bar/control-points.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/gradient-bar/index.d.ts +3 -9
- package/build-types/custom-gradient-picker/gradient-bar/index.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/gradient-bar/test/utils.d.ts +2 -0
- package/build-types/custom-gradient-picker/gradient-bar/test/utils.d.ts.map +1 -0
- package/build-types/custom-gradient-picker/gradient-bar/utils.d.ts +44 -92
- package/build-types/custom-gradient-picker/gradient-bar/utils.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/index.d.ts +27 -6
- package/build-types/custom-gradient-picker/index.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/serializer.d.ts +9 -16
- package/build-types/custom-gradient-picker/serializer.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/stories/index.d.ts +12 -0
- package/build-types/custom-gradient-picker/stories/index.d.ts.map +1 -0
- package/build-types/custom-gradient-picker/styles/custom-gradient-picker-styles.d.ts +3 -2
- package/build-types/custom-gradient-picker/styles/custom-gradient-picker-styles.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/test/serializer.d.ts +2 -0
- package/build-types/custom-gradient-picker/test/serializer.d.ts.map +1 -0
- package/build-types/custom-gradient-picker/types.d.ts +118 -0
- package/build-types/custom-gradient-picker/types.d.ts.map +1 -0
- package/build-types/custom-gradient-picker/utils.d.ts +12 -4
- package/build-types/custom-gradient-picker/utils.d.ts.map +1 -1
- package/build-types/date-time/date/styles.d.ts +2 -2
- package/build-types/date-time/date-time/styles.d.ts +1 -1
- package/build-types/date-time/time/styles.d.ts +8 -8
- package/build-types/drop-zone/index.d.ts.map +1 -1
- package/build-types/duotone-picker/color-list-picker/index.d.ts.map +1 -0
- package/build-types/{color-list-picker → duotone-picker/color-list-picker}/types.d.ts +2 -2
- package/build-types/duotone-picker/color-list-picker/types.d.ts.map +1 -0
- package/build-types/duotone-picker/custom-duotone-bar.d.ts +6 -0
- package/build-types/duotone-picker/custom-duotone-bar.d.ts.map +1 -0
- package/build-types/duotone-picker/duotone-picker.d.ts +38 -0
- package/build-types/duotone-picker/duotone-picker.d.ts.map +1 -0
- package/build-types/duotone-picker/duotone-swatch.d.ts +5 -0
- package/build-types/duotone-picker/duotone-swatch.d.ts.map +1 -0
- package/build-types/duotone-picker/index.d.ts +3 -0
- package/build-types/duotone-picker/index.d.ts.map +1 -0
- package/build-types/duotone-picker/stories/duotone-picker.d.ts +12 -0
- package/build-types/duotone-picker/stories/duotone-picker.d.ts.map +1 -0
- package/build-types/duotone-picker/stories/duotone-swatch.d.ts +14 -0
- package/build-types/duotone-picker/stories/duotone-swatch.d.ts.map +1 -0
- package/build-types/duotone-picker/types.d.ts +60 -0
- package/build-types/duotone-picker/types.d.ts.map +1 -0
- package/build-types/duotone-picker/utils.d.ts +52 -0
- package/build-types/duotone-picker/utils.d.ts.map +1 -0
- package/build-types/elevation/hook.d.ts +2 -2
- package/build-types/external-link/styles/external-link-styles.d.ts +1 -1
- package/build-types/flex/flex/hook.d.ts +2 -2
- package/build-types/flex/flex-block/hook.d.ts +2 -2
- package/build-types/flex/flex-item/hook.d.ts +2 -2
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +2 -2
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/styles.d.ts +1 -1
- package/build-types/form-token-field/types.d.ts +6 -0
- package/build-types/form-token-field/types.d.ts.map +1 -1
- package/build-types/gradient-picker/index.d.ts +49 -11
- package/build-types/gradient-picker/index.d.ts.map +1 -1
- package/build-types/gradient-picker/stories/index.d.ts +14 -0
- package/build-types/gradient-picker/stories/index.d.ts.map +1 -0
- package/build-types/gradient-picker/types.d.ts +87 -0
- package/build-types/gradient-picker/types.d.ts.map +1 -0
- package/build-types/grid/hook.d.ts +2 -2
- package/build-types/h-stack/hook.d.ts +2 -2
- package/build-types/heading/hook.d.ts +2 -2
- package/build-types/index.d.ts +128 -0
- package/build-types/index.d.ts.map +1 -0
- package/build-types/input-control/styles/input-control-styles.d.ts +2 -2
- package/build-types/item-group/item/hook.d.ts +2 -2
- package/build-types/item-group/item-group/hook.d.ts +2 -2
- package/build-types/navigation/styles/navigation-styles.d.ts +2 -2
- package/build-types/navigator/navigator-back-button/hook.d.ts +2 -2
- package/build-types/navigator/navigator-button/hook.d.ts +2 -2
- package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-screen/component.d.ts +1 -1
- package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
- package/build-types/navigator/stories/index.d.ts +1 -0
- package/build-types/navigator/stories/index.d.ts.map +1 -1
- package/build-types/navigator/types.d.ts +2 -2
- package/build-types/navigator/types.d.ts.map +1 -1
- package/build-types/number-control/index.d.ts +2 -2
- package/build-types/number-control/stories/index.d.ts +2 -2
- package/build-types/palette-edit/index.d.ts.map +1 -1
- package/build-types/palette-edit/styles.d.ts +3 -3
- package/build-types/popover/index.d.ts +1 -1
- package/build-types/popover/stories/e2e/index.d.ts +1 -1
- package/build-types/private-apis.d.ts +2 -3
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/query-controls/author-select.d.ts.map +1 -1
- package/build-types/query-controls/category-select.d.ts.map +1 -1
- package/build-types/query-controls/index.d.ts.map +1 -1
- package/build-types/range-control/index.d.ts +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts +2 -2
- 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 +1 -1
- package/build-types/resizable-box/resize-tooltip/utils.d.ts.map +1 -1
- package/build-types/resizable-box/stories/index.d.ts +2 -2
- package/build-types/scrollable/hook.d.ts +2 -2
- package/build-types/search-control/index.d.ts +1 -1
- package/build-types/search-control/stories/index.d.ts +2 -2
- package/build-types/spacer/hook.d.ts +2 -2
- package/build-types/spinner/index.d.ts +1 -1
- package/build-types/surface/hook.d.ts +2 -2
- package/build-types/tab-panel/index.d.ts.map +1 -1
- package/build-types/text/hook.d.ts +2 -2
- package/build-types/text-control/index.d.ts +1 -1
- package/build-types/toolbar/toolbar-button/index.d.ts +2 -2
- package/build-types/tools-panel/tools-panel/hook.d.ts +2 -2
- package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/hook.d.ts +2 -2
- package/build-types/tools-panel/tools-panel-item/hook.d.ts +2 -2
- package/build-types/tools-panel/types.d.ts +1 -0
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/build-types/truncate/hook.d.ts +2 -2
- package/build-types/ui/control-group/hook.d.ts +2 -2
- package/build-types/ui/control-label/hook.d.ts +2 -2
- package/build-types/ui/form-group/form-group.d.ts +2 -2
- package/build-types/ui/form-group/use-form-group.d.ts +2 -2
- package/build-types/unit-control/index.d.ts +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts +2 -2
- package/build-types/utils/input/input-control.d.ts.map +1 -1
- package/build-types/v-stack/hook.d.ts +2 -2
- package/package.json +20 -19
- package/src/angle-picker-control/angle-circle.tsx +0 -1
- package/src/angle-picker-control/index.tsx +14 -27
- package/src/angle-picker-control/styles/angle-picker-control-styles.tsx +16 -9
- package/src/animate/index.tsx +75 -0
- package/src/animate/stories/index.tsx +102 -0
- package/src/animate/types.ts +32 -0
- package/src/border-box-control/stories/index.tsx +1 -1
- package/src/box-control/axial-input-controls.tsx +1 -1
- package/src/circular-option-picker/style.scss +10 -0
- package/src/color-indicator/style.scss +1 -0
- package/src/color-picker/README.md +2 -2
- package/src/color-picker/color-input.tsx +1 -12
- package/src/color-picker/component.tsx +9 -18
- package/src/color-picker/hex-input.tsx +2 -7
- package/src/color-picker/hsl-input.tsx +2 -7
- package/src/color-picker/input-with-slider.tsx +1 -9
- package/src/color-picker/legacy-adapter.tsx +1 -2
- package/src/color-picker/picker.tsx +5 -6
- package/src/color-picker/rgb-input.tsx +2 -7
- package/src/color-picker/stories/index.tsx +51 -0
- package/src/color-picker/test/{index.js → index.tsx} +36 -18
- package/src/color-picker/types.ts +128 -1
- package/src/color-picker/use-deprecated-props.ts +2 -53
- package/src/combobox-control/stories/index.tsx +1 -1
- package/src/custom-gradient-picker/{constants.js → constants.ts} +2 -2
- package/src/custom-gradient-picker/gradient-bar/{control-points.js → control-points.tsx} +171 -134
- package/src/custom-gradient-picker/gradient-bar/{index.js → index.tsx} +32 -10
- package/src/custom-gradient-picker/gradient-bar/test/{utils.js → utils.ts} +58 -31
- package/src/custom-gradient-picker/gradient-bar/utils.ts +193 -0
- package/src/custom-gradient-picker/{index.js → index.tsx} +63 -22
- package/src/custom-gradient-picker/serializer.ts +78 -0
- package/src/custom-gradient-picker/stories/index.tsx +45 -0
- package/src/custom-gradient-picker/style.scss +25 -4
- package/src/custom-gradient-picker/test/{serializer.js → serializer.ts} +39 -33
- package/src/custom-gradient-picker/types.ts +119 -0
- package/src/custom-gradient-picker/{utils.js → utils.ts} +37 -22
- package/src/custom-select-control/test/index.js +6 -4
- package/src/drop-zone/index.tsx +12 -8
- package/src/drop-zone/style.scss +1 -1
- package/src/{color-list-picker → duotone-picker/color-list-picker}/index.tsx +7 -6
- package/src/{color-list-picker → duotone-picker/color-list-picker}/types.ts +2 -2
- package/src/duotone-picker/{custom-duotone-bar.js → custom-duotone-bar.tsx} +7 -1
- package/src/duotone-picker/{duotone-picker.js → duotone-picker.tsx} +39 -2
- package/src/duotone-picker/{duotone-swatch.js → duotone-swatch.tsx} +2 -1
- package/src/duotone-picker/stories/{duotone-picker.js → duotone-picker.tsx} +15 -8
- package/src/duotone-picker/stories/{duotone-swatch.js → duotone-swatch.tsx} +9 -3
- package/src/duotone-picker/types.ts +61 -0
- package/src/duotone-picker/{utils.js → utils.ts} +29 -14
- package/src/flex/flex-item/README.md +1 -1
- package/src/form-token-field/README.md +1 -0
- package/src/form-token-field/index.tsx +10 -3
- package/src/form-token-field/style.scss +0 -7
- package/src/form-token-field/test/index.tsx +1 -0
- package/src/form-token-field/types.ts +6 -0
- package/src/gradient-picker/README.md +16 -23
- package/src/gradient-picker/{index.js → index.tsx} +70 -16
- package/src/gradient-picker/stories/{index.js → index.tsx} +19 -8
- package/src/gradient-picker/types.ts +89 -0
- package/src/item-group/test/index.js +5 -3
- package/src/mobile/keyboard-aware-flat-list/index.android.js +0 -4
- package/src/mobile/keyboard-aware-flat-list/index.ios.js +118 -67
- package/src/mobile/keyboard-aware-flat-list/test/use-keyboard-offset.native.js +203 -0
- package/src/mobile/keyboard-aware-flat-list/test/use-scroll-to-text-input.native.js +140 -0
- package/src/mobile/keyboard-aware-flat-list/test/use-text-input-caret-position.native.js +82 -0
- package/src/mobile/keyboard-aware-flat-list/test/use-text-input-offset.native.js +147 -0
- package/src/mobile/keyboard-aware-flat-list/use-keyboard-offset.native.js +87 -0
- package/src/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js +105 -0
- package/src/mobile/keyboard-aware-flat-list/use-text-input-caret-position.native.js +36 -0
- package/src/mobile/keyboard-aware-flat-list/use-text-input-offset.native.js +54 -0
- package/src/navigator/navigator-provider/component.tsx +2 -0
- package/src/navigator/navigator-screen/component.tsx +5 -2
- package/src/navigator/stories/index.tsx +68 -0
- package/src/navigator/test/index.tsx +52 -0
- package/src/navigator/types.ts +2 -1
- package/src/palette-edit/index.tsx +4 -5
- package/src/query-controls/author-select.tsx +1 -0
- package/src/query-controls/category-select.tsx +1 -0
- package/src/query-controls/index.tsx +4 -2
- package/src/resizable-box/resize-tooltip/utils.ts +1 -1
- package/src/sandbox/index.native.js +139 -112
- package/src/slot-fill/test/slot.js +8 -6
- package/src/style.scss +1 -1
- package/src/tab-panel/index.tsx +7 -2
- package/src/tools-panel/test/index.tsx +86 -0
- package/src/tools-panel/tools-panel/hook.ts +44 -4
- package/src/tools-panel/types.ts +1 -0
- package/src/tooltip/test/index.js +251 -301
- package/src/utils/input/input-control.js +1 -0
- package/tsconfig.json +1 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/build/color-list-picker/index.js.map +0 -1
- package/build-module/color-list-picker/index.js.map +0 -1
- package/build-types/color-list-picker/index.d.ts.map +0 -1
- package/build-types/color-list-picker/types.d.ts.map +0 -1
- package/src/animate/index.js +0 -60
- package/src/animate/stories/index.js +0 -53
- package/src/color-picker/stories/index.js +0 -41
- package/src/custom-gradient-picker/gradient-bar/utils.js +0 -189
- package/src/custom-gradient-picker/serializer.js +0 -48
- package/src/custom-gradient-picker/stories/index.js +0 -33
- /package/build/{color-list-picker → animate}/types.js +0 -0
- /package/build-module/{color-list-picker → animate}/types.js +0 -0
- /package/build-module/{color-list-picker → animate}/types.js.map +0 -0
- /package/{build/color-list-picker → build-module/custom-gradient-picker}/types.js.map +0 -0
- /package/build-types/{color-list-picker → duotone-picker/color-list-picker}/index.d.ts +0 -0
- /package/src/custom-gradient-picker/gradient-bar/{constants.js → constants.ts} +0 -0
- /package/src/custom-gradient-picker/styles/{custom-gradient-picker-styles.js → custom-gradient-picker-styles.tsx} +0 -0
- /package/src/{color-list-picker → duotone-picker/color-list-picker}/style.scss +0 -0
- /package/src/duotone-picker/{index.js → index.ts} +0 -0
- /package/src/{index.js → index.ts} +0 -0
- /package/src/{private-apis.js → private-apis.ts} +0 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { HeadingSize } from '../heading/types';
|
|
5
|
+
|
|
6
|
+
export type GradientObject = {
|
|
7
|
+
gradient: string;
|
|
8
|
+
name: string;
|
|
9
|
+
slug: string;
|
|
10
|
+
};
|
|
11
|
+
export type OriginObject = { name: string; gradients: GradientObject[] };
|
|
12
|
+
export type GradientsProp = GradientObject[] | OriginObject[];
|
|
13
|
+
|
|
14
|
+
type GradientPickerBaseProps = {
|
|
15
|
+
/**
|
|
16
|
+
* The class name added to the wrapper.
|
|
17
|
+
*/
|
|
18
|
+
className?: string;
|
|
19
|
+
/**
|
|
20
|
+
* The function called when a new gradient has been defined. It is passed to
|
|
21
|
+
* the `currentGradient` as an argument.
|
|
22
|
+
*/
|
|
23
|
+
onChange: ( currentGradient: string | undefined ) => void;
|
|
24
|
+
/**
|
|
25
|
+
* The current value of the gradient. Pass a css gradient string (See default value for example).
|
|
26
|
+
* Optionally pass in a `null` value to specify no gradient is currently selected.
|
|
27
|
+
*
|
|
28
|
+
* @default 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)'
|
|
29
|
+
*/
|
|
30
|
+
value?: GradientObject[ 'gradient' ] | null;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the palette should have a clearing button or not.
|
|
33
|
+
*
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
clearable?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The heading level. Only applies in cases where gradients are provided
|
|
39
|
+
* from multiple origins (ie. when the array passed as the `gradients` prop
|
|
40
|
+
* contains two or more items).
|
|
41
|
+
*
|
|
42
|
+
* @default 2
|
|
43
|
+
*/
|
|
44
|
+
headingLevel?: HeadingSize;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type GradientPickerComponentProps = GradientPickerBaseProps & {
|
|
48
|
+
/**
|
|
49
|
+
* An array of objects as predefined gradients displayed above the gradient
|
|
50
|
+
* selector. Alternatively, if there are multiple sets (or 'origins') of
|
|
51
|
+
* gradients, you can pass an array of objects each with a `name` and a
|
|
52
|
+
* `gradients` array which will in turn contain the predefined gradient objects.
|
|
53
|
+
*
|
|
54
|
+
* @default []
|
|
55
|
+
*/
|
|
56
|
+
gradients?: GradientsProp;
|
|
57
|
+
/**
|
|
58
|
+
* Start opting in to the new margin-free styles that will become the default
|
|
59
|
+
* in a future version, currently scheduled to be WordPress 6.4. (The prop
|
|
60
|
+
* can be safely removed once this happens.)
|
|
61
|
+
*
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
64
|
+
__nextHasNoMargin?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* If true, the gradient picker will not be displayed and only defined
|
|
67
|
+
* gradients from `gradients` will be shown.
|
|
68
|
+
*
|
|
69
|
+
* @default false
|
|
70
|
+
*/
|
|
71
|
+
disableCustomGradients?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Whether this is rendered in the sidebar.
|
|
74
|
+
*
|
|
75
|
+
* @default false
|
|
76
|
+
*/
|
|
77
|
+
__experimentalIsRenderedInSidebar?: boolean;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export type PickerProps< TOriginType extends GradientObject | OriginObject > =
|
|
81
|
+
GradientPickerBaseProps & {
|
|
82
|
+
clearGradient: () => void;
|
|
83
|
+
onChange: (
|
|
84
|
+
currentGradient: string | undefined,
|
|
85
|
+
index: number
|
|
86
|
+
) => void;
|
|
87
|
+
actions?: React.ReactNode;
|
|
88
|
+
gradients: TOriginType[];
|
|
89
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
import userEvent from '@testing-library/user-event';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
@@ -72,7 +73,8 @@ describe( 'ItemGroup', () => {
|
|
|
72
73
|
} );
|
|
73
74
|
|
|
74
75
|
describe( 'Item', () => {
|
|
75
|
-
it( 'should render as a `button` if the `onClick` handler is specified', () => {
|
|
76
|
+
it( 'should render as a `button` if the `onClick` handler is specified', async () => {
|
|
77
|
+
const user = userEvent.setup();
|
|
76
78
|
const spy = jest.fn();
|
|
77
79
|
render( <Item onClick={ spy }>Code is poetry</Item> );
|
|
78
80
|
|
|
@@ -80,7 +82,7 @@ describe( 'ItemGroup', () => {
|
|
|
80
82
|
|
|
81
83
|
expect( button ).toBeInTheDocument();
|
|
82
84
|
|
|
83
|
-
|
|
85
|
+
await user.click( button );
|
|
84
86
|
|
|
85
87
|
expect( spy ).toHaveBeenCalled();
|
|
86
88
|
} );
|
|
@@ -24,8 +24,4 @@ export const KeyboardAwareFlatList = ( { innerRef, onScroll, ...props } ) => {
|
|
|
24
24
|
);
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
KeyboardAwareFlatList.handleCaretVerticalPositionChange = () => {
|
|
28
|
-
// no need to handle on Android, it is system managed
|
|
29
|
-
};
|
|
30
|
-
|
|
31
27
|
export default KeyboardAwareFlatList;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
import { FlatList } from 'react-native';
|
|
6
|
-
import fastDeepEqual from 'fast-deep-equal/es6';
|
|
4
|
+
|
|
5
|
+
import { ScrollView, FlatList, useWindowDimensions } from 'react-native';
|
|
7
6
|
import Animated, {
|
|
8
7
|
useAnimatedScrollHandler,
|
|
9
8
|
useSharedValue,
|
|
@@ -12,36 +11,123 @@ import Animated, {
|
|
|
12
11
|
/**
|
|
13
12
|
* WordPress dependencies
|
|
14
13
|
*/
|
|
15
|
-
import {
|
|
14
|
+
import { useCallback, useEffect, useRef } from '@wordpress/element';
|
|
15
|
+
import { useThrottle } from '@wordpress/compose';
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Internal dependencies
|
|
19
|
+
*/
|
|
20
|
+
import useTextInputOffset from './use-text-input-offset';
|
|
21
|
+
import useKeyboardOffset from './use-keyboard-offset';
|
|
22
|
+
import useScrollToTextInput from './use-scroll-to-text-input';
|
|
23
|
+
import useTextInputCaretPosition from './use-text-input-caret-position';
|
|
21
24
|
|
|
25
|
+
const AnimatedScrollView = Animated.createAnimatedComponent( ScrollView );
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* React component that provides a FlatList that is aware of the keyboard state and can scroll
|
|
29
|
+
* to the currently focused TextInput.
|
|
30
|
+
*
|
|
31
|
+
* @param {Object} props Component props.
|
|
32
|
+
* @param {number} props.extraScrollHeight Extra scroll height for the content.
|
|
33
|
+
* @param {Function} props.innerRef Function to pass the ScrollView ref to the parent component.
|
|
34
|
+
* @param {Function} props.onScroll Function to be called when the list is scrolled.
|
|
35
|
+
* @param {boolean} props.scrollEnabled Whether the list can be scrolled.
|
|
36
|
+
* @param {Object} props.scrollViewStyle Additional style for the ScrollView component.
|
|
37
|
+
* @param {boolean} props.shouldPreventAutomaticScroll Whether to prevent scrolling when there's a Keyboard offset set.
|
|
38
|
+
* @param {Object} props... Other props to pass to the FlatList component.
|
|
39
|
+
* @return {WPComponent} KeyboardAwareFlatList component.
|
|
40
|
+
*/
|
|
22
41
|
export const KeyboardAwareFlatList = ( {
|
|
23
42
|
extraScrollHeight,
|
|
24
|
-
shouldPreventAutomaticScroll,
|
|
25
43
|
innerRef,
|
|
26
|
-
autoScroll,
|
|
27
|
-
scrollViewStyle,
|
|
28
|
-
inputAccessoryViewHeight,
|
|
29
44
|
onScroll,
|
|
30
|
-
|
|
45
|
+
scrollEnabled,
|
|
46
|
+
scrollViewStyle,
|
|
47
|
+
shouldPreventAutomaticScroll,
|
|
48
|
+
...props
|
|
31
49
|
} ) => {
|
|
32
50
|
const scrollViewRef = useRef();
|
|
33
|
-
const
|
|
51
|
+
const scrollViewMeasurements = useRef();
|
|
52
|
+
const scrollViewYOffset = useSharedValue( -1 );
|
|
53
|
+
|
|
54
|
+
const { height: windowHeight, width: windowWidth } = useWindowDimensions();
|
|
55
|
+
const isLandscape = windowWidth >= windowHeight;
|
|
56
|
+
|
|
57
|
+
const [ keyboardOffset ] = useKeyboardOffset(
|
|
58
|
+
scrollEnabled,
|
|
59
|
+
shouldPreventAutomaticScroll
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const [ currentCaretData ] = useTextInputCaretPosition( scrollEnabled );
|
|
63
|
+
|
|
64
|
+
const [ getTextInputOffset ] = useTextInputOffset(
|
|
65
|
+
scrollEnabled,
|
|
66
|
+
scrollViewRef
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const [ scrollToTextInputOffset ] = useScrollToTextInput(
|
|
70
|
+
extraScrollHeight,
|
|
71
|
+
keyboardOffset,
|
|
72
|
+
scrollEnabled,
|
|
73
|
+
scrollViewMeasurements,
|
|
74
|
+
scrollViewRef,
|
|
75
|
+
scrollViewYOffset
|
|
76
|
+
);
|
|
34
77
|
|
|
35
|
-
const
|
|
78
|
+
const onScrollToTextInput = useThrottle(
|
|
79
|
+
useCallback(
|
|
80
|
+
async ( caret ) => {
|
|
81
|
+
const textInputOffset = await getTextInputOffset( caret );
|
|
82
|
+
const hasTextInputOffset = textInputOffset !== null;
|
|
83
|
+
|
|
84
|
+
if ( hasTextInputOffset ) {
|
|
85
|
+
scrollToTextInputOffset( caret, textInputOffset );
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
[ getTextInputOffset, scrollToTextInputOffset ]
|
|
89
|
+
),
|
|
90
|
+
200,
|
|
91
|
+
{ leading: false }
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
useEffect( () => {
|
|
95
|
+
onScrollToTextInput( currentCaretData );
|
|
96
|
+
}, [ currentCaretData, onScrollToTextInput ] );
|
|
97
|
+
|
|
98
|
+
// When the orientation changes, the ScrollView measurements
|
|
99
|
+
// need to be re-calculated.
|
|
100
|
+
useEffect( () => {
|
|
101
|
+
scrollViewMeasurements.current = null;
|
|
102
|
+
}, [ isLandscape ] );
|
|
36
103
|
|
|
37
104
|
const scrollHandler = useAnimatedScrollHandler( {
|
|
38
105
|
onScroll: ( event ) => {
|
|
39
106
|
const { contentOffset } = event;
|
|
40
|
-
|
|
107
|
+
scrollViewYOffset.value = contentOffset.y;
|
|
41
108
|
onScroll( event );
|
|
42
109
|
},
|
|
43
110
|
} );
|
|
44
111
|
|
|
112
|
+
const measureScrollView = useCallback( () => {
|
|
113
|
+
if ( scrollViewRef.current ) {
|
|
114
|
+
const scrollRef = scrollViewRef.current.getNativeScrollRef();
|
|
115
|
+
|
|
116
|
+
scrollRef.measureInWindow( ( _x, y, width, height ) => {
|
|
117
|
+
scrollViewMeasurements.current = { y, width, height };
|
|
118
|
+
} );
|
|
119
|
+
}
|
|
120
|
+
}, [] );
|
|
121
|
+
|
|
122
|
+
const onContentSizeChange = useCallback( () => {
|
|
123
|
+
onScrollToTextInput( currentCaretData );
|
|
124
|
+
|
|
125
|
+
// Sets the first values when the content size changes.
|
|
126
|
+
if ( ! scrollViewMeasurements.current ) {
|
|
127
|
+
measureScrollView();
|
|
128
|
+
}
|
|
129
|
+
}, [ measureScrollView, onScrollToTextInput, currentCaretData ] );
|
|
130
|
+
|
|
45
131
|
const getRef = useCallback(
|
|
46
132
|
( ref ) => {
|
|
47
133
|
scrollViewRef.current = ref;
|
|
@@ -49,63 +135,28 @@ export const KeyboardAwareFlatList = ( {
|
|
|
49
135
|
},
|
|
50
136
|
[ innerRef ]
|
|
51
137
|
);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
! keyboardWillShowIndicator.current &&
|
|
59
|
-
latestContentOffsetY.value !== -1 &&
|
|
60
|
-
! shouldPreventAutomaticScroll()
|
|
61
|
-
) {
|
|
62
|
-
// Reset the content position if keyboard is still closed.
|
|
63
|
-
scrollViewRef.current?.scrollToPosition(
|
|
64
|
-
0,
|
|
65
|
-
latestContentOffsetY.value,
|
|
66
|
-
true
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
}, 50 );
|
|
70
|
-
}, [ latestContentOffsetY, shouldPreventAutomaticScroll ] );
|
|
71
|
-
const onKeyboardWillShow = useCallback( () => {
|
|
72
|
-
keyboardWillShowIndicator.current = true;
|
|
73
|
-
}, [] );
|
|
138
|
+
|
|
139
|
+
// Adds content insets when the keyboard is opened to have
|
|
140
|
+
// extra padding at the bottom.
|
|
141
|
+
const contentInset = { bottom: keyboardOffset };
|
|
142
|
+
|
|
143
|
+
const style = [ { flex: 1 }, scrollViewStyle ];
|
|
74
144
|
|
|
75
145
|
return (
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
enableResetScrollToCoords={ false }
|
|
146
|
+
<AnimatedScrollView
|
|
147
|
+
automaticallyAdjustContentInsets={ false }
|
|
148
|
+
contentInset={ contentInset }
|
|
80
149
|
keyboardShouldPersistTaps="handled"
|
|
81
|
-
|
|
82
|
-
extraHeight={ 0 }
|
|
83
|
-
inputAccessoryViewHeight={ inputAccessoryViewHeight }
|
|
84
|
-
enableAutomaticScroll={
|
|
85
|
-
autoScroll === undefined ? false : autoScroll
|
|
86
|
-
}
|
|
87
|
-
ref={ getRef }
|
|
88
|
-
onKeyboardWillHide={ onKeyboardWillHide }
|
|
89
|
-
onKeyboardDidHide={ onKeyboardDidHide }
|
|
90
|
-
onKeyboardWillShow={ onKeyboardWillShow }
|
|
91
|
-
scrollEnabled={ listProps.scrollEnabled }
|
|
150
|
+
onContentSizeChange={ onContentSizeChange }
|
|
92
151
|
onScroll={ scrollHandler }
|
|
152
|
+
ref={ getRef }
|
|
153
|
+
scrollEnabled={ scrollEnabled }
|
|
154
|
+
scrollEventThrottle={ 16 }
|
|
155
|
+
style={ style }
|
|
93
156
|
>
|
|
94
|
-
<
|
|
95
|
-
</
|
|
157
|
+
<FlatList { ...props } />
|
|
158
|
+
</AnimatedScrollView>
|
|
96
159
|
);
|
|
97
160
|
};
|
|
98
161
|
|
|
99
|
-
KeyboardAwareFlatList.handleCaretVerticalPositionChange = (
|
|
100
|
-
scrollView,
|
|
101
|
-
targetId,
|
|
102
|
-
caretY,
|
|
103
|
-
previousCaretY
|
|
104
|
-
) => {
|
|
105
|
-
if ( previousCaretY ) {
|
|
106
|
-
// If this is not the first tap.
|
|
107
|
-
scrollView.refreshScrollForField( targetId );
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
162
|
export default KeyboardAwareFlatList;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { act, renderHook } from '@testing-library/react-native';
|
|
5
|
+
import { Keyboard } from 'react-native';
|
|
6
|
+
import RCTDeviceEventEmitter from 'react-native/Libraries/EventEmitter/RCTDeviceEventEmitter';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import useKeyboardOffset from '../use-keyboard-offset';
|
|
12
|
+
|
|
13
|
+
jest.useFakeTimers();
|
|
14
|
+
|
|
15
|
+
describe( 'useKeyboardOffset', () => {
|
|
16
|
+
beforeEach( () => {
|
|
17
|
+
Keyboard.removeAllListeners( 'keyboardDidShow' );
|
|
18
|
+
Keyboard.removeAllListeners( 'keyboardDidHide' );
|
|
19
|
+
Keyboard.removeAllListeners( 'keyboardWillShow' );
|
|
20
|
+
} );
|
|
21
|
+
|
|
22
|
+
it( 'returns the initial state', () => {
|
|
23
|
+
// Arrange
|
|
24
|
+
const { result } = renderHook( () => useKeyboardOffset( true ) );
|
|
25
|
+
const [ keyboardOffset ] = result.current;
|
|
26
|
+
|
|
27
|
+
// Assert
|
|
28
|
+
expect( keyboardOffset ).toBe( 0 );
|
|
29
|
+
} );
|
|
30
|
+
|
|
31
|
+
it( 'updates keyboard visibility and offset when the keyboard is shown', () => {
|
|
32
|
+
// Arrange
|
|
33
|
+
const { result } = renderHook( () => useKeyboardOffset( true ) );
|
|
34
|
+
|
|
35
|
+
// Act
|
|
36
|
+
act( () => {
|
|
37
|
+
RCTDeviceEventEmitter.emit( 'keyboardDidShow', {
|
|
38
|
+
endCoordinates: { height: 250 },
|
|
39
|
+
} );
|
|
40
|
+
} );
|
|
41
|
+
|
|
42
|
+
// Assert
|
|
43
|
+
const [ keyboardOffset ] = result.current;
|
|
44
|
+
expect( keyboardOffset ).toBe( 250 );
|
|
45
|
+
} );
|
|
46
|
+
|
|
47
|
+
it( 'updates keyboard visibility and offset when the keyboard is hidden', () => {
|
|
48
|
+
// Arrange
|
|
49
|
+
const shouldPreventAutomaticScroll = jest.fn().mockReturnValue( false );
|
|
50
|
+
const { result } = renderHook( () =>
|
|
51
|
+
useKeyboardOffset( true, shouldPreventAutomaticScroll )
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
// Act
|
|
55
|
+
act( () => {
|
|
56
|
+
RCTDeviceEventEmitter.emit( 'keyboardDidShow', {
|
|
57
|
+
endCoordinates: { height: 250 },
|
|
58
|
+
} );
|
|
59
|
+
} );
|
|
60
|
+
|
|
61
|
+
act( () => {
|
|
62
|
+
RCTDeviceEventEmitter.emit( 'keyboardDidHide' );
|
|
63
|
+
jest.runAllTimers();
|
|
64
|
+
} );
|
|
65
|
+
|
|
66
|
+
// Assert
|
|
67
|
+
const [ keyboardOffset ] = result.current;
|
|
68
|
+
expect( keyboardOffset ).toBe( 0 );
|
|
69
|
+
} );
|
|
70
|
+
|
|
71
|
+
it( 'removes all keyboard listeners when scrollEnabled changes to false', () => {
|
|
72
|
+
// Arrange
|
|
73
|
+
const { result, rerender } = renderHook(
|
|
74
|
+
( { scrollEnabled } ) => useKeyboardOffset( scrollEnabled ),
|
|
75
|
+
{
|
|
76
|
+
initialProps: { scrollEnabled: true },
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
const [ keyboardOffset ] = result.current;
|
|
80
|
+
|
|
81
|
+
// Act
|
|
82
|
+
rerender( { scrollEnabled: false } );
|
|
83
|
+
|
|
84
|
+
// Assert
|
|
85
|
+
expect( keyboardOffset ).toBe( 0 );
|
|
86
|
+
expect( RCTDeviceEventEmitter.listenerCount( 'keyboardDidHide' ) ).toBe(
|
|
87
|
+
0
|
|
88
|
+
);
|
|
89
|
+
expect( RCTDeviceEventEmitter.listenerCount( 'keyboardDidShow' ) ).toBe(
|
|
90
|
+
0
|
|
91
|
+
);
|
|
92
|
+
} );
|
|
93
|
+
|
|
94
|
+
it( 'adds all keyboard listeners when scrollEnabled changes to true', () => {
|
|
95
|
+
// Arrange
|
|
96
|
+
const { result, rerender } = renderHook(
|
|
97
|
+
( { scrollEnabled } ) => useKeyboardOffset( scrollEnabled ),
|
|
98
|
+
{
|
|
99
|
+
initialProps: { scrollEnabled: false },
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
// Act
|
|
103
|
+
act( () => {
|
|
104
|
+
rerender( { scrollEnabled: true } );
|
|
105
|
+
} );
|
|
106
|
+
|
|
107
|
+
act( () => {
|
|
108
|
+
RCTDeviceEventEmitter.emit( 'keyboardDidShow', {
|
|
109
|
+
endCoordinates: { height: 250 },
|
|
110
|
+
} );
|
|
111
|
+
} );
|
|
112
|
+
|
|
113
|
+
const [ keyboardOffset ] = result.current;
|
|
114
|
+
|
|
115
|
+
// Assert
|
|
116
|
+
expect( keyboardOffset ).toBe( 250 );
|
|
117
|
+
expect( RCTDeviceEventEmitter.listenerCount( 'keyboardDidShow' ) ).toBe(
|
|
118
|
+
1
|
|
119
|
+
);
|
|
120
|
+
expect( RCTDeviceEventEmitter.listenerCount( 'keyboardDidHide' ) ).toBe(
|
|
121
|
+
1
|
|
122
|
+
);
|
|
123
|
+
} );
|
|
124
|
+
|
|
125
|
+
it( 'does not set keyboard offset to 0 when keyboard is hidden and shouldPreventAutomaticScroll is true', () => {
|
|
126
|
+
// Arrange
|
|
127
|
+
const shouldPreventAutomaticScroll = jest.fn().mockReturnValue( true );
|
|
128
|
+
const { result } = renderHook( () =>
|
|
129
|
+
useKeyboardOffset( true, shouldPreventAutomaticScroll )
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
// Act
|
|
133
|
+
act( () => {
|
|
134
|
+
RCTDeviceEventEmitter.emit( 'keyboardDidShow', {
|
|
135
|
+
endCoordinates: { height: 250 },
|
|
136
|
+
} );
|
|
137
|
+
} );
|
|
138
|
+
act( () => {
|
|
139
|
+
RCTDeviceEventEmitter.emit( 'keyboardDidHide' );
|
|
140
|
+
jest.runAllTimers();
|
|
141
|
+
} );
|
|
142
|
+
|
|
143
|
+
// Assert
|
|
144
|
+
expect( result.current[ 0 ] ).toBe( 250 );
|
|
145
|
+
} );
|
|
146
|
+
|
|
147
|
+
it( 'handles updates to shouldPreventAutomaticScroll', () => {
|
|
148
|
+
// Arrange
|
|
149
|
+
const preventScrollTrue = jest.fn( () => true );
|
|
150
|
+
const preventScrollFalse = jest.fn( () => false );
|
|
151
|
+
|
|
152
|
+
// Act
|
|
153
|
+
const { result, rerender } = renderHook(
|
|
154
|
+
( { shouldPreventAutomaticScroll } ) =>
|
|
155
|
+
useKeyboardOffset( true, shouldPreventAutomaticScroll ),
|
|
156
|
+
{
|
|
157
|
+
initialProps: {
|
|
158
|
+
shouldPreventAutomaticScroll: preventScrollFalse,
|
|
159
|
+
},
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
// Assert
|
|
164
|
+
expect( result.current[ 0 ] ).toBe( 0 );
|
|
165
|
+
|
|
166
|
+
// Act
|
|
167
|
+
act( () => {
|
|
168
|
+
RCTDeviceEventEmitter.emit( 'keyboardDidShow', {
|
|
169
|
+
endCoordinates: { height: 150 },
|
|
170
|
+
} );
|
|
171
|
+
} );
|
|
172
|
+
|
|
173
|
+
// Assert
|
|
174
|
+
expect( result.current[ 0 ] ).toBe( 150 );
|
|
175
|
+
|
|
176
|
+
// Act
|
|
177
|
+
act( () => {
|
|
178
|
+
rerender( { shouldPreventAutomaticScroll: preventScrollTrue } );
|
|
179
|
+
} );
|
|
180
|
+
|
|
181
|
+
act( () => {
|
|
182
|
+
RCTDeviceEventEmitter.emit( 'keyboardDidHide' );
|
|
183
|
+
jest.runAllTimers();
|
|
184
|
+
} );
|
|
185
|
+
|
|
186
|
+
// Assert
|
|
187
|
+
expect( result.current[ 0 ] ).toBe( 150 );
|
|
188
|
+
|
|
189
|
+
// Act
|
|
190
|
+
act( () => {
|
|
191
|
+
rerender( { shouldPreventAutomaticScroll: preventScrollFalse } );
|
|
192
|
+
} );
|
|
193
|
+
|
|
194
|
+
act( () => {
|
|
195
|
+
RCTDeviceEventEmitter.emit( 'keyboardDidShow', {
|
|
196
|
+
endCoordinates: { height: 250 },
|
|
197
|
+
} );
|
|
198
|
+
} );
|
|
199
|
+
|
|
200
|
+
// Assert
|
|
201
|
+
expect( result.current[ 0 ] ).toBe( 250 );
|
|
202
|
+
} );
|
|
203
|
+
} );
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { renderHook } from '@testing-library/react-native';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import useScrollToTextInput from '../use-scroll-to-text-input';
|
|
11
|
+
|
|
12
|
+
describe( 'useScrollToTextInput', () => {
|
|
13
|
+
it( 'scrolls up to the current TextInput offset', () => {
|
|
14
|
+
// Arrange
|
|
15
|
+
const currentCaretData = { caretHeight: 10 };
|
|
16
|
+
const extraScrollHeight = 50;
|
|
17
|
+
const keyboardOffset = 100;
|
|
18
|
+
const scrollEnabled = true;
|
|
19
|
+
const scrollViewRef = { current: { scrollTo: jest.fn() } };
|
|
20
|
+
const scrollViewMeasurements = { current: { height: 600 } };
|
|
21
|
+
const scrollViewYOffset = { value: 150 };
|
|
22
|
+
const textInputOffset = 50;
|
|
23
|
+
|
|
24
|
+
const { result } = renderHook( () =>
|
|
25
|
+
useScrollToTextInput(
|
|
26
|
+
extraScrollHeight,
|
|
27
|
+
keyboardOffset,
|
|
28
|
+
scrollEnabled,
|
|
29
|
+
scrollViewMeasurements,
|
|
30
|
+
scrollViewRef,
|
|
31
|
+
scrollViewYOffset
|
|
32
|
+
)
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
// Act
|
|
36
|
+
result.current[ 0 ]( currentCaretData, textInputOffset );
|
|
37
|
+
|
|
38
|
+
// Assert
|
|
39
|
+
expect( scrollViewRef.current.scrollTo ).toHaveBeenCalledWith( {
|
|
40
|
+
y: textInputOffset,
|
|
41
|
+
animated: true,
|
|
42
|
+
} );
|
|
43
|
+
} );
|
|
44
|
+
|
|
45
|
+
it( 'scrolls down to the current TextInput offset', () => {
|
|
46
|
+
// Arrange
|
|
47
|
+
const currentCaretData = { caretHeight: 10 };
|
|
48
|
+
const extraScrollHeight = 50;
|
|
49
|
+
const keyboardOffset = 100;
|
|
50
|
+
const scrollEnabled = true;
|
|
51
|
+
const scrollViewRef = { current: { scrollTo: jest.fn() } };
|
|
52
|
+
const scrollViewMeasurements = { current: { height: 600 } };
|
|
53
|
+
const scrollViewYOffset = { value: 250 };
|
|
54
|
+
const textInputOffset = 750;
|
|
55
|
+
|
|
56
|
+
const { result } = renderHook( () =>
|
|
57
|
+
useScrollToTextInput(
|
|
58
|
+
extraScrollHeight,
|
|
59
|
+
keyboardOffset,
|
|
60
|
+
scrollEnabled,
|
|
61
|
+
scrollViewMeasurements,
|
|
62
|
+
scrollViewRef,
|
|
63
|
+
scrollViewYOffset
|
|
64
|
+
)
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
// Act
|
|
68
|
+
result.current[ 0 ]( currentCaretData, textInputOffset );
|
|
69
|
+
|
|
70
|
+
// Assert
|
|
71
|
+
const expectedYOffset =
|
|
72
|
+
textInputOffset -
|
|
73
|
+
( scrollViewMeasurements.current.height -
|
|
74
|
+
( keyboardOffset +
|
|
75
|
+
extraScrollHeight +
|
|
76
|
+
currentCaretData.caretHeight ) );
|
|
77
|
+
expect( scrollViewRef.current.scrollTo ).toHaveBeenCalledWith( {
|
|
78
|
+
y: expectedYOffset,
|
|
79
|
+
animated: true,
|
|
80
|
+
} );
|
|
81
|
+
} );
|
|
82
|
+
|
|
83
|
+
it( 'does not scroll when the ScrollView ref is not available', () => {
|
|
84
|
+
// Arrange
|
|
85
|
+
const currentCaretData = { caretHeight: 10 };
|
|
86
|
+
const extraScrollHeight = 50;
|
|
87
|
+
const keyboardOffset = 100;
|
|
88
|
+
const scrollEnabled = true;
|
|
89
|
+
const scrollViewRef = { current: null };
|
|
90
|
+
const scrollViewMeasurements = { current: { height: 600 } };
|
|
91
|
+
const scrollViewYOffset = { value: 0 };
|
|
92
|
+
const textInputOffset = 50;
|
|
93
|
+
|
|
94
|
+
const { result } = renderHook( () =>
|
|
95
|
+
useScrollToTextInput(
|
|
96
|
+
extraScrollHeight,
|
|
97
|
+
keyboardOffset,
|
|
98
|
+
scrollEnabled,
|
|
99
|
+
scrollViewMeasurements,
|
|
100
|
+
scrollViewRef,
|
|
101
|
+
scrollViewYOffset
|
|
102
|
+
)
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
// Act
|
|
106
|
+
result.current[ 0 ]( currentCaretData, textInputOffset );
|
|
107
|
+
|
|
108
|
+
// Assert
|
|
109
|
+
expect( scrollViewRef.current ).toBeNull();
|
|
110
|
+
} );
|
|
111
|
+
|
|
112
|
+
it( 'does not scroll when the scroll is not enabled', () => {
|
|
113
|
+
// Arrange
|
|
114
|
+
const currentCaretData = { caretHeight: 10 };
|
|
115
|
+
const extraScrollHeight = 50;
|
|
116
|
+
const keyboardOffset = 100;
|
|
117
|
+
const scrollEnabled = false;
|
|
118
|
+
const scrollViewRef = { current: { scrollTo: jest.fn() } };
|
|
119
|
+
const scrollViewMeasurements = { current: { height: 600 } };
|
|
120
|
+
const scrollViewYOffset = { value: 0 };
|
|
121
|
+
const textInputOffset = 50;
|
|
122
|
+
|
|
123
|
+
const { result } = renderHook( () =>
|
|
124
|
+
useScrollToTextInput(
|
|
125
|
+
extraScrollHeight,
|
|
126
|
+
keyboardOffset,
|
|
127
|
+
scrollEnabled,
|
|
128
|
+
scrollViewMeasurements,
|
|
129
|
+
scrollViewRef,
|
|
130
|
+
scrollViewYOffset
|
|
131
|
+
)
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
// Act
|
|
135
|
+
result.current[ 0 ]( currentCaretData, textInputOffset );
|
|
136
|
+
|
|
137
|
+
// Assert
|
|
138
|
+
expect( scrollViewRef.current.scrollTo ).not.toHaveBeenCalled();
|
|
139
|
+
} );
|
|
140
|
+
} );
|