@wordpress/components 20.0.1-next.d6164808d3.0 → 20.0.2-next.957ca95e4c.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 +29 -1
- package/CONTRIBUTING.md +12 -12
- package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js +12 -12
- package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
- package/build/autocomplete/get-default-use-items.js +7 -1
- package/build/autocomplete/get-default-use-items.js.map +1 -1
- package/build/autocomplete/index.js +3 -1
- package/build/autocomplete/index.js.map +1 -1
- package/build/card/card/component.js +6 -11
- package/build/card/card/component.js.map +1 -1
- package/build/card/card/hook.js +0 -10
- package/build/card/card/hook.js.map +1 -1
- package/build/card/card/index.js.map +1 -1
- package/build/card/card-body/component.js +7 -8
- package/build/card/card-body/component.js.map +1 -1
- package/build/card/card-body/hook.js +0 -4
- package/build/card/card-body/hook.js.map +1 -1
- package/build/card/card-body/index.js.map +1 -1
- package/build/card/card-divider/component.js +7 -8
- package/build/card/card-divider/component.js.map +1 -1
- package/build/card/card-divider/hook.js +0 -4
- package/build/card/card-divider/hook.js.map +1 -1
- package/build/card/card-divider/index.js.map +1 -1
- package/build/card/card-footer/component.js +7 -8
- package/build/card/card-footer/component.js.map +1 -1
- package/build/card/card-footer/hook.js +0 -4
- package/build/card/card-footer/hook.js.map +1 -1
- package/build/card/card-footer/index.js.map +1 -1
- package/build/card/card-header/component.js +7 -8
- package/build/card/card-header/component.js.map +1 -1
- package/build/card/card-header/hook.js +0 -4
- package/build/card/card-header/hook.js.map +1 -1
- package/build/card/card-header/index.js.map +1 -1
- package/build/card/card-media/component.js +7 -7
- package/build/card/card-media/component.js.map +1 -1
- package/build/card/card-media/hook.js +0 -4
- package/build/card/card-media/hook.js.map +1 -1
- package/build/card/card-media/index.js.map +1 -1
- package/build/card/context.js.map +1 -1
- package/build/card/index.js.map +1 -1
- package/build/card/styles.js +17 -17
- package/build/card/styles.js.map +1 -1
- package/build/clipboard-button/index.js +16 -1
- package/build/clipboard-button/index.js.map +1 -1
- package/build/color-palette/index.js +6 -2
- package/build/color-palette/index.js.map +1 -1
- package/build/custom-gradient-picker/index.js +11 -0
- package/build/custom-gradient-picker/index.js.map +1 -1
- package/build/date-time/date/index.js +25 -6
- package/build/date-time/date/index.js.map +1 -1
- package/build/date-time/date/styles.js +22 -12
- package/build/date-time/date/styles.js.map +1 -1
- package/build/date-time/date-time/index.js +1 -3
- package/build/date-time/date-time/index.js.map +1 -1
- package/build/date-time/date-time/styles.js +19 -5
- package/build/date-time/date-time/styles.js.map +1 -1
- package/build/date-time/time/styles.js +12 -12
- package/build/date-time/time/styles.js.map +1 -1
- package/build/drop-zone/index.js +2 -4
- package/build/drop-zone/index.js.map +1 -1
- package/build/dropdown-menu/index.js +1 -3
- package/build/dropdown-menu/index.js.map +1 -1
- package/build/dropdown-menu/index.native.js +0 -17
- package/build/dropdown-menu/index.native.js.map +1 -1
- package/build/focal-point-picker/controls.js +4 -4
- package/build/focal-point-picker/controls.js.map +1 -1
- package/build/focal-point-picker/focal-point.js +4 -6
- package/build/focal-point-picker/focal-point.js.map +1 -1
- package/build/focal-point-picker/grid.js +6 -35
- package/build/focal-point-picker/grid.js.map +1 -1
- package/build/focal-point-picker/index.js +160 -330
- package/build/focal-point-picker/index.js.map +1 -1
- package/build/focal-point-picker/media.js +4 -34
- package/build/focal-point-picker/media.js.map +1 -1
- package/build/focal-point-picker/styles/focal-point-picker-style.js +14 -14
- package/build/focal-point-picker/styles/focal-point-picker-style.js.map +1 -1
- package/build/focal-point-picker/utils.js +2 -6
- package/build/focal-point-picker/utils.js.map +1 -1
- package/build/focusable-iframe/index.js +6 -0
- package/build/focusable-iframe/index.js.map +1 -1
- package/build/form-token-field/index.js +18 -15
- package/build/form-token-field/index.js.map +1 -1
- package/build/gradient-picker/index.js +12 -1
- package/build/gradient-picker/index.js.map +1 -1
- package/build/guide/index.js +8 -6
- package/build/guide/index.js.map +1 -1
- package/build/higher-order/with-constrained-tabbing/index.js +1 -1
- package/build/higher-order/with-constrained-tabbing/index.js.map +1 -1
- package/build/higher-order/with-spoken-messages/index.js +2 -0
- package/build/higher-order/with-spoken-messages/index.js.map +1 -1
- package/build/isolated-event-container/index.js +4 -0
- package/build/isolated-event-container/index.js.map +1 -1
- package/build/mobile/global-styles-context/utils.native.js +1 -1
- package/build/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build/navigable-container/menu.js +3 -9
- package/build/navigable-container/menu.js.map +1 -1
- package/build/navigation/menu/menu-title-search.js +1 -3
- package/build/navigation/menu/menu-title-search.js.map +1 -1
- package/build/palette-edit/index.js +6 -2
- package/build/palette-edit/index.js.map +1 -1
- package/build/popover/index.js +15 -35
- package/build/popover/index.js.map +1 -1
- package/build/text-highlight/index.js +4 -4
- package/build/text-highlight/index.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/styles.js +23 -8
- package/build/toggle-group-control/toggle-group-control/styles.js.map +1 -1
- package/build/tooltip/index.js +1 -7
- package/build/tooltip/index.js.map +1 -1
- package/build/tree-grid/index.js +4 -10
- package/build/tree-grid/index.js.map +1 -1
- package/build/utils/strings.js +13 -0
- package/build/utils/strings.js.map +1 -1
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js +12 -12
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
- package/build-module/autocomplete/get-default-use-items.js +6 -1
- package/build-module/autocomplete/get-default-use-items.js.map +1 -1
- package/build-module/autocomplete/index.js +2 -1
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/card/card/component.js +5 -10
- package/build-module/card/card/component.js.map +1 -1
- package/build-module/card/card/hook.js +0 -9
- package/build-module/card/card/hook.js.map +1 -1
- package/build-module/card/card/index.js.map +1 -1
- package/build-module/card/card-body/component.js +7 -8
- package/build-module/card/card-body/component.js.map +1 -1
- package/build-module/card/card-body/hook.js +0 -4
- package/build-module/card/card-body/hook.js.map +1 -1
- package/build-module/card/card-body/index.js.map +1 -1
- package/build-module/card/card-divider/component.js +7 -8
- package/build-module/card/card-divider/component.js.map +1 -1
- package/build-module/card/card-divider/hook.js +0 -4
- package/build-module/card/card-divider/hook.js.map +1 -1
- package/build-module/card/card-divider/index.js.map +1 -1
- package/build-module/card/card-footer/component.js +7 -8
- package/build-module/card/card-footer/component.js.map +1 -1
- package/build-module/card/card-footer/hook.js +0 -4
- package/build-module/card/card-footer/hook.js.map +1 -1
- package/build-module/card/card-footer/index.js.map +1 -1
- package/build-module/card/card-header/component.js +7 -8
- package/build-module/card/card-header/component.js.map +1 -1
- package/build-module/card/card-header/hook.js +0 -4
- package/build-module/card/card-header/hook.js.map +1 -1
- package/build-module/card/card-header/index.js.map +1 -1
- package/build-module/card/card-media/component.js +7 -7
- package/build-module/card/card-media/component.js.map +1 -1
- package/build-module/card/card-media/hook.js +0 -4
- package/build-module/card/card-media/hook.js.map +1 -1
- package/build-module/card/card-media/index.js.map +1 -1
- package/build-module/card/context.js.map +1 -1
- package/build-module/card/index.js.map +1 -1
- package/build-module/card/styles.js +17 -17
- package/build-module/card/styles.js.map +1 -1
- package/build-module/clipboard-button/index.js +17 -1
- package/build-module/clipboard-button/index.js.map +1 -1
- package/build-module/color-palette/index.js +5 -2
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/custom-gradient-picker/index.js +10 -0
- package/build-module/custom-gradient-picker/index.js.map +1 -1
- package/build-module/date-time/date/index.js +27 -8
- package/build-module/date-time/date/index.js.map +1 -1
- package/build-module/date-time/date/styles.js +21 -5
- package/build-module/date-time/date/styles.js.map +1 -1
- package/build-module/date-time/date-time/index.js +2 -3
- package/build-module/date-time/date-time/index.js.map +1 -1
- package/build-module/date-time/date-time/styles.js +20 -1
- package/build-module/date-time/date-time/styles.js.map +1 -1
- package/build-module/date-time/time/styles.js +12 -12
- package/build-module/date-time/time/styles.js.map +1 -1
- package/build-module/drop-zone/index.js +2 -3
- package/build-module/drop-zone/index.js.map +1 -1
- package/build-module/dropdown-menu/index.js +1 -2
- package/build-module/dropdown-menu/index.js.map +1 -1
- package/build-module/dropdown-menu/index.native.js +0 -16
- package/build-module/dropdown-menu/index.native.js.map +1 -1
- package/build-module/focal-point-picker/controls.js +4 -4
- package/build-module/focal-point-picker/controls.js.map +1 -1
- package/build-module/focal-point-picker/focal-point.js +4 -6
- package/build-module/focal-point-picker/focal-point.js.map +1 -1
- package/build-module/focal-point-picker/grid.js +6 -34
- package/build-module/focal-point-picker/grid.js.map +1 -1
- package/build-module/focal-point-picker/index.js +158 -325
- package/build-module/focal-point-picker/index.js.map +1 -1
- package/build-module/focal-point-picker/media.js +4 -36
- package/build-module/focal-point-picker/media.js.map +1 -1
- package/build-module/focal-point-picker/styles/focal-point-picker-style.js +13 -14
- package/build-module/focal-point-picker/styles/focal-point-picker-style.js.map +1 -1
- package/build-module/focal-point-picker/utils.js +2 -6
- package/build-module/focal-point-picker/utils.js.map +1 -1
- package/build-module/focusable-iframe/index.js +6 -0
- package/build-module/focusable-iframe/index.js.map +1 -1
- package/build-module/form-token-field/index.js +18 -14
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/gradient-picker/index.js +11 -1
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/guide/index.js +8 -5
- package/build-module/guide/index.js.map +1 -1
- package/build-module/higher-order/with-constrained-tabbing/index.js +1 -1
- package/build-module/higher-order/with-constrained-tabbing/index.js.map +1 -1
- package/build-module/higher-order/with-spoken-messages/index.js +2 -0
- package/build-module/higher-order/with-spoken-messages/index.js.map +1 -1
- package/build-module/isolated-event-container/index.js +3 -0
- package/build-module/isolated-event-container/index.js.map +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js +2 -2
- package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build-module/navigable-container/menu.js +3 -8
- package/build-module/navigable-container/menu.js.map +1 -1
- package/build-module/navigation/menu/menu-title-search.js +1 -2
- package/build-module/navigation/menu/menu-title-search.js.map +1 -1
- package/build-module/palette-edit/index.js +6 -2
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/popover/index.js +15 -35
- package/build-module/popover/index.js.map +1 -1
- package/build-module/text-highlight/index.js +2 -5
- package/build-module/text-highlight/index.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js +2 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/styles.js +20 -6
- package/build-module/toggle-group-control/toggle-group-control/styles.js.map +1 -1
- package/build-module/tooltip/index.js +1 -6
- package/build-module/tooltip/index.js.map +1 -1
- package/build-module/tree-grid/index.js +4 -9
- package/build-module/tree-grid/index.js.map +1 -1
- package/build-module/utils/strings.js +11 -0
- package/build-module/utils/strings.js.map +1 -1
- package/build-style/style-rtl.css +2 -21
- package/build-style/style.css +2 -21
- package/build-types/animation/index.d.ts +2 -0
- package/build-types/animation/index.d.ts.map +1 -0
- package/build-types/card/card/component.d.ts +3 -3
- package/build-types/card/card/component.d.ts.map +1 -1
- package/build-types/card/card/hook.d.ts +7 -2
- package/build-types/card/card/hook.d.ts.map +1 -1
- package/build-types/card/card/index.d.ts +2 -2
- package/build-types/card/card/index.d.ts.map +1 -1
- package/build-types/card/card-body/component.d.ts +3 -3
- package/build-types/card/card-body/component.d.ts.map +1 -1
- package/build-types/card/card-body/hook.d.ts +5 -2
- package/build-types/card/card-body/hook.d.ts.map +1 -1
- package/build-types/card/card-body/index.d.ts +2 -2
- package/build-types/card/card-body/index.d.ts.map +1 -1
- package/build-types/card/card-divider/component.d.ts +3 -3
- package/build-types/card/card-divider/component.d.ts.map +1 -1
- package/build-types/card/card-divider/hook.d.ts +5 -2
- package/build-types/card/card-divider/hook.d.ts.map +1 -1
- package/build-types/card/card-divider/index.d.ts +2 -2
- package/build-types/card/card-divider/index.d.ts.map +1 -1
- package/build-types/card/card-footer/component.d.ts +3 -3
- package/build-types/card/card-footer/component.d.ts.map +1 -1
- package/build-types/card/card-footer/hook.d.ts +5 -2
- package/build-types/card/card-footer/hook.d.ts.map +1 -1
- package/build-types/card/card-footer/index.d.ts +2 -2
- package/build-types/card/card-footer/index.d.ts.map +1 -1
- package/build-types/card/card-header/component.d.ts +3 -3
- package/build-types/card/card-header/component.d.ts.map +1 -1
- package/build-types/card/card-header/hook.d.ts +5 -2
- package/build-types/card/card-header/hook.d.ts.map +1 -1
- package/build-types/card/card-header/index.d.ts +2 -2
- package/build-types/card/card-header/index.d.ts.map +1 -1
- package/build-types/card/card-media/component.d.ts +3 -4
- package/build-types/card/card-media/component.d.ts.map +1 -1
- package/build-types/card/card-media/hook.d.ts +6 -5
- package/build-types/card/card-media/hook.d.ts.map +1 -1
- package/build-types/card/card-media/index.d.ts +2 -2
- package/build-types/card/card-media/index.d.ts.map +1 -1
- package/build-types/card/context.d.ts +3 -2
- package/build-types/card/context.d.ts.map +1 -1
- package/build-types/card/index.d.ts +6 -6
- package/build-types/card/index.d.ts.map +1 -1
- package/build-types/card/stories/index.d.ts +12 -0
- package/build-types/card/stories/index.d.ts.map +1 -0
- package/build-types/card/styles.d.ts +20 -22
- package/build-types/card/styles.d.ts.map +1 -1
- package/build-types/card/test/index.d.ts +2 -0
- package/build-types/card/test/index.d.ts.map +1 -0
- package/build-types/card/types.d.ts +7 -1
- package/build-types/card/types.d.ts.map +1 -1
- package/build-types/clipboard-button/index.d.ts +16 -0
- package/build-types/clipboard-button/index.d.ts.map +1 -0
- package/build-types/color-palette/index.d.ts.map +1 -1
- package/build-types/composite/index.d.ts +2 -0
- package/build-types/composite/index.d.ts.map +1 -0
- package/build-types/date-time/date/index.d.ts +1 -1
- package/build-types/date-time/date/index.d.ts.map +1 -1
- package/build-types/date-time/date/styles.d.ts +4 -0
- package/build-types/date-time/date/styles.d.ts.map +1 -1
- package/build-types/date-time/date-time/index.d.ts.map +1 -1
- package/build-types/date-time/date-time/styles.d.ts +13 -0
- package/build-types/date-time/date-time/styles.d.ts.map +1 -1
- package/build-types/date-time/time/styles.d.ts.map +1 -1
- package/build-types/disclosure/index.d.ts +2 -0
- package/build-types/disclosure/index.d.ts.map +1 -0
- package/build-types/dropdown-menu/index.d.ts.map +1 -1
- package/build-types/focusable-iframe/index.d.ts +8 -0
- package/build-types/focusable-iframe/index.d.ts.map +1 -0
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/test/index.d.ts +2 -0
- package/build-types/form-token-field/test/index.d.ts.map +1 -0
- package/build-types/higher-order/with-constrained-tabbing/index.d.ts +3 -0
- package/build-types/higher-order/with-constrained-tabbing/index.d.ts.map +1 -0
- package/build-types/higher-order/with-spoken-messages/index.d.ts +4 -0
- package/build-types/higher-order/with-spoken-messages/index.d.ts.map +1 -0
- package/build-types/isolated-event-container/index.d.ts +3 -0
- package/build-types/isolated-event-container/index.d.ts.map +1 -0
- package/build-types/mobile/inserter-button/sparkles.d.ts +3 -0
- package/build-types/mobile/inserter-button/sparkles.d.ts.map +1 -0
- package/build-types/navigable-container/menu.d.ts.map +1 -1
- package/build-types/popover/index.d.ts +0 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/radio-context/index.d.ts +6 -0
- package/build-types/radio-context/index.d.ts.map +1 -0
- package/build-types/text-highlight/index.d.ts +0 -3
- package/build-types/text-highlight/index.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/styles.d.ts +4 -0
- package/build-types/toggle-group-control/toggle-group-control/styles.d.ts.map +1 -1
- package/build-types/tooltip/index.d.ts.map +1 -1
- package/build-types/utils/strings.d.ts +8 -0
- package/build-types/utils/strings.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/alignment-matrix-control/styles/alignment-matrix-control-styles.js +1 -0
- package/src/autocomplete/get-default-use-items.js +6 -1
- package/src/autocomplete/index.js +2 -1
- package/src/card/card/{component.js → component.tsx} +13 -9
- package/src/card/card/{hook.js → hook.ts} +11 -11
- package/src/card/card/{index.js → index.ts} +0 -0
- package/src/card/card-body/{component.js → component.tsx} +13 -9
- package/src/card/card-body/{hook.js → hook.ts} +5 -5
- package/src/card/card-body/{index.js → index.ts} +0 -0
- package/src/card/card-divider/{component.js → component.tsx} +16 -10
- package/src/card/card-divider/{hook.js → hook.ts} +5 -5
- package/src/card/card-divider/{index.js → index.ts} +0 -0
- package/src/card/card-footer/{component.js → component.tsx} +13 -9
- package/src/card/card-footer/{hook.js → hook.ts} +5 -5
- package/src/card/card-footer/{index.js → index.ts} +0 -0
- package/src/card/card-header/{component.js → component.tsx} +13 -9
- package/src/card/card-header/{hook.js → hook.ts} +5 -5
- package/src/card/card-header/{index.js → index.ts} +0 -0
- package/src/card/card-media/{component.js → component.tsx} +13 -8
- package/src/card/card-media/{hook.js → hook.ts} +5 -5
- package/src/card/card-media/{index.js → index.ts} +0 -0
- package/src/card/{context.js → context.ts} +0 -0
- package/src/card/{index.js → index.ts} +0 -0
- package/src/card/stories/index.tsx +75 -0
- package/src/card/{styles.js → styles.ts} +0 -0
- package/src/card/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
- package/src/card/test/{index.js → index.tsx} +3 -3
- package/src/card/types.ts +8 -1
- package/src/clipboard-button/index.js +13 -0
- package/src/color-palette/index.js +8 -5
- package/src/color-palette/style.scss +0 -14
- package/src/color-palette/test/__snapshots__/index.js.snap +11 -4
- package/src/custom-gradient-picker/index.js +12 -0
- package/src/custom-gradient-picker/stories/index.js +3 -0
- package/src/date-time/date/index.tsx +26 -6
- package/src/date-time/date/styles.ts +6 -0
- package/src/date-time/date/test/index.tsx +6 -2
- package/src/date-time/date-time/index.tsx +3 -4
- package/src/date-time/date-time/styles.ts +9 -0
- package/src/date-time/time/styles.ts +1 -0
- package/src/drop-zone/index.js +2 -3
- package/src/dropdown-menu/index.js +1 -2
- package/src/dropdown-menu/index.native.js +0 -13
- package/src/dropdown-menu/test/index.js +54 -58
- package/src/focal-point-picker/README.md +3 -6
- package/src/focal-point-picker/controls.js +4 -4
- package/src/focal-point-picker/focal-point.js +2 -8
- package/src/focal-point-picker/grid.js +5 -41
- package/src/focal-point-picker/index.js +161 -303
- package/src/focal-point-picker/media.js +4 -28
- package/src/focal-point-picker/styles/focal-point-picker-style.js +5 -8
- package/src/focal-point-picker/test/index.js +1 -1
- package/src/focal-point-picker/utils.js +2 -6
- package/src/focusable-iframe/index.js +5 -0
- package/src/form-token-field/index.tsx +17 -23
- package/src/form-token-field/test/index.tsx +2106 -0
- package/src/gradient-picker/README.md +9 -0
- package/src/gradient-picker/index.js +9 -0
- package/src/gradient-picker/stories/index.js +1 -0
- package/src/guide/index.js +6 -3
- package/src/guide/test/index.js +138 -1
- package/src/higher-order/with-constrained-tabbing/index.js +1 -1
- package/src/higher-order/with-spoken-messages/index.js +2 -0
- package/src/isolated-event-container/index.js +3 -0
- package/src/mobile/global-styles-context/utils.native.js +7 -2
- package/src/navigable-container/menu.js +3 -7
- package/src/navigation/menu/menu-title-search.js +1 -2
- package/src/palette-edit/index.js +14 -10
- package/src/palette-edit/style.scss +3 -11
- package/src/placeholder/style.scss +1 -4
- package/src/popover/index.js +17 -35
- package/src/popover/stories/index.js +0 -1
- package/src/text-highlight/index.tsx +1 -5
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +62 -44
- package/src/toggle-group-control/toggle-group-control/component.tsx +3 -2
- package/src/toggle-group-control/toggle-group-control/styles.ts +5 -0
- package/src/tooltip/index.js +1 -5
- package/src/tree-grid/index.js +4 -9
- package/src/utils/strings.ts +11 -0
- package/tsconfig.json +45 -76
- package/tsconfig.tsbuildinfo +1 -1
- package/build/ui/__storybook-utils/example-grid.js +0 -88
- package/build/ui/__storybook-utils/example-grid.js.map +0 -1
- package/build/ui/__storybook-utils/index.js +0 -19
- package/build/ui/__storybook-utils/index.js.map +0 -1
- package/build/ui/__storybook-utils/page.js +0 -43
- package/build/ui/__storybook-utils/page.js.map +0 -1
- package/build/utils/keyboard.js +0 -41
- package/build/utils/keyboard.js.map +0 -1
- package/build-module/ui/__storybook-utils/example-grid.js +0 -69
- package/build-module/ui/__storybook-utils/example-grid.js.map +0 -1
- package/build-module/ui/__storybook-utils/index.js +0 -2
- package/build-module/ui/__storybook-utils/index.js.map +0 -1
- package/build-module/ui/__storybook-utils/page.js +0 -32
- package/build-module/ui/__storybook-utils/page.js.map +0 -1
- package/build-module/utils/keyboard.js +0 -33
- package/build-module/utils/keyboard.js.map +0 -1
- package/build-types/form-token-field/test/lib/fixtures.d.ts +0 -26
- package/build-types/form-token-field/test/lib/fixtures.d.ts.map +0 -1
- package/build-types/form-token-field/test/lib/token-field-wrapper.d.ts +0 -21
- package/build-types/form-token-field/test/lib/token-field-wrapper.d.ts.map +0 -1
- package/build-types/utils/keyboard.d.ts +0 -12
- package/build-types/utils/keyboard.d.ts.map +0 -1
- package/src/card/stories/index.js +0 -209
- package/src/form-token-field/test/index.js +0 -442
- package/src/form-token-field/test/lib/fixtures.js +0 -89
- package/src/form-token-field/test/lib/token-field-wrapper.tsx +0 -71
- package/src/guide/test/page-control.js +0 -40
- package/src/ui/__storybook-utils/example-grid.js +0 -61
- package/src/ui/__storybook-utils/index.js +0 -1
- package/src/ui/__storybook-utils/page.js +0 -29
- package/src/utils/keyboard.js +0 -28
- package/src/utils/test/keyboard.js +0 -34
|
@@ -5,10 +5,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default =
|
|
8
|
+
exports.default = FocalPointPicker;
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
12
14
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
15
|
|
|
14
16
|
var _i18n = require("@wordpress/i18n");
|
|
@@ -27,10 +29,10 @@ var _media = _interopRequireDefault(require("./media"));
|
|
|
27
29
|
|
|
28
30
|
var _focalPointPickerStyle = require("./styles/focal-point-picker-style");
|
|
29
31
|
|
|
30
|
-
var _math = require("../utils/math");
|
|
31
|
-
|
|
32
32
|
var _utils = require("./utils");
|
|
33
33
|
|
|
34
|
+
var _hooks = require("../utils/hooks");
|
|
35
|
+
|
|
34
36
|
/**
|
|
35
37
|
* External dependencies
|
|
36
38
|
*/
|
|
@@ -42,357 +44,185 @@ var _utils = require("./utils");
|
|
|
42
44
|
/**
|
|
43
45
|
* Internal dependencies
|
|
44
46
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
this.stopDrag();
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
this.onChangeAtControls = value => {
|
|
67
|
-
this.updateValue(value, () => {
|
|
68
|
-
this.props.onChange(this.state.percentages);
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
this.updateBounds = this.updateBounds.bind(this);
|
|
73
|
-
this.updateValue = this.updateValue.bind(this);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
componentDidMount() {
|
|
77
|
-
const {
|
|
78
|
-
defaultView
|
|
79
|
-
} = this.containerRef.current.ownerDocument;
|
|
80
|
-
defaultView.addEventListener('resize', this.updateBounds);
|
|
81
|
-
/*
|
|
82
|
-
* Set initial bound values.
|
|
83
|
-
*
|
|
84
|
-
* This is necessary for Safari:
|
|
85
|
-
* https://github.com/WordPress/gutenberg/issues/25814
|
|
86
|
-
*/
|
|
87
|
-
|
|
88
|
-
this.updateBounds();
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
componentDidUpdate(prevProps) {
|
|
92
|
-
if (prevProps.url !== this.props.url) {
|
|
93
|
-
this.ifDraggingStop();
|
|
47
|
+
const GRID_OVERLAY_TIMEOUT = 600;
|
|
48
|
+
|
|
49
|
+
function FocalPointPicker(_ref) {
|
|
50
|
+
let {
|
|
51
|
+
autoPlay = true,
|
|
52
|
+
className,
|
|
53
|
+
help,
|
|
54
|
+
label,
|
|
55
|
+
onChange,
|
|
56
|
+
onDrag,
|
|
57
|
+
onDragEnd,
|
|
58
|
+
onDragStart,
|
|
59
|
+
resolvePoint,
|
|
60
|
+
url,
|
|
61
|
+
value: valueProp = {
|
|
62
|
+
x: 0.5,
|
|
63
|
+
y: 0.5
|
|
94
64
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
65
|
+
} = _ref;
|
|
66
|
+
const [point, setPoint] = (0, _element.useState)(valueProp);
|
|
67
|
+
const [showGridOverlay, setShowGridOverlay] = (0, _element.useState)(false);
|
|
68
|
+
const {
|
|
69
|
+
startDrag,
|
|
70
|
+
endDrag,
|
|
71
|
+
isDragging
|
|
72
|
+
} = (0, _compose.__experimentalUseDragging)({
|
|
73
|
+
onDragStart: event => {
|
|
74
|
+
dragAreaRef.current.focus();
|
|
75
|
+
const value = getValueWithinDragArea(event);
|
|
76
|
+
onDragStart === null || onDragStart === void 0 ? void 0 : onDragStart(value, event);
|
|
77
|
+
setPoint(value);
|
|
78
|
+
},
|
|
79
|
+
onDragMove: event => {
|
|
80
|
+
// Prevents text-selection when dragging.
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
const value = getValueWithinDragArea(event);
|
|
83
|
+
onDrag === null || onDrag === void 0 ? void 0 : onDrag(value, event);
|
|
84
|
+
setPoint(value);
|
|
85
|
+
},
|
|
86
|
+
onDragEnd: event => {
|
|
87
|
+
onDragEnd === null || onDragEnd === void 0 ? void 0 : onDragEnd(event);
|
|
88
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(point);
|
|
116
89
|
}
|
|
117
|
-
}
|
|
90
|
+
}); // Uses the internal point while dragging or else the value from props.
|
|
91
|
+
|
|
92
|
+
const {
|
|
93
|
+
x,
|
|
94
|
+
y
|
|
95
|
+
} = isDragging ? point : valueProp;
|
|
96
|
+
const dragAreaRef = (0, _element.useRef)();
|
|
97
|
+
const [bounds, setBounds] = (0, _element.useState)(_utils.INITIAL_BOUNDS);
|
|
98
|
+
const refUpdateBounds = (0, _element.useRef)(() => {
|
|
99
|
+
const {
|
|
100
|
+
clientWidth: width,
|
|
101
|
+
clientHeight: height
|
|
102
|
+
} = dragAreaRef.current; // Falls back to initial bounds if the ref has no size. Since styles
|
|
103
|
+
// give the drag area dimensions even when the media has not loaded
|
|
104
|
+
// this should only happen in unit tests (jsdom).
|
|
118
105
|
|
|
119
|
-
|
|
106
|
+
setBounds(width > 0 && height > 0 ? {
|
|
107
|
+
width,
|
|
108
|
+
height
|
|
109
|
+
} : { ..._utils.INITIAL_BOUNDS
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
(0, _element.useEffect)(() => {
|
|
113
|
+
const updateBounds = refUpdateBounds.current;
|
|
120
114
|
const {
|
|
121
115
|
defaultView
|
|
122
|
-
} =
|
|
123
|
-
defaultView.
|
|
124
|
-
|
|
125
|
-
}
|
|
116
|
+
} = dragAreaRef.current.ownerDocument;
|
|
117
|
+
defaultView.addEventListener('resize', updateBounds);
|
|
118
|
+
return () => defaultView.removeEventListener('resize', updateBounds);
|
|
119
|
+
}, []); // Updates the bounds to cover cases of unspecified media or load failures.
|
|
126
120
|
|
|
127
|
-
|
|
128
|
-
const bounds = _utils.INITIAL_BOUNDS;
|
|
121
|
+
(0, _compose.useIsomorphicLayoutEffect)(() => void refUpdateBounds.current(), []);
|
|
129
122
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return bounds;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const dimensions = {
|
|
140
|
-
width: this.mediaRef.current.clientWidth,
|
|
141
|
-
height: this.mediaRef.current.clientHeight
|
|
142
|
-
};
|
|
143
|
-
const pickerDimensions = this.pickerDimensions();
|
|
144
|
-
const widthRatio = pickerDimensions.width / dimensions.width;
|
|
145
|
-
const heightRatio = pickerDimensions.height / dimensions.height;
|
|
146
|
-
|
|
147
|
-
if (heightRatio >= widthRatio) {
|
|
148
|
-
bounds.width = bounds.right = pickerDimensions.width;
|
|
149
|
-
bounds.height = dimensions.height * widthRatio;
|
|
150
|
-
bounds.top = (pickerDimensions.height - bounds.height) / 2;
|
|
151
|
-
bounds.bottom = bounds.top + bounds.height;
|
|
152
|
-
} else {
|
|
153
|
-
bounds.height = bounds.bottom = pickerDimensions.height;
|
|
154
|
-
bounds.width = dimensions.width * heightRatio;
|
|
155
|
-
bounds.left = (pickerDimensions.width - bounds.width) / 2;
|
|
156
|
-
bounds.right = bounds.left + bounds.width;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return bounds;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
updateValue() {
|
|
163
|
-
var _this$props$resolvePo, _this$props$resolvePo2, _this$props;
|
|
164
|
-
|
|
165
|
-
let nextValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
166
|
-
let callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
167
|
-
const resolvedValue = (_this$props$resolvePo = (_this$props$resolvePo2 = (_this$props = this.props).resolvePoint) === null || _this$props$resolvePo2 === void 0 ? void 0 : _this$props$resolvePo2.call(_this$props, nextValue)) !== null && _this$props$resolvePo !== void 0 ? _this$props$resolvePo : nextValue;
|
|
123
|
+
const getValueWithinDragArea = _ref2 => {
|
|
124
|
+
let {
|
|
125
|
+
clientX,
|
|
126
|
+
clientY,
|
|
127
|
+
shiftKey
|
|
128
|
+
} = _ref2;
|
|
168
129
|
const {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
} =
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
y: parseFloat(y).toFixed(2)
|
|
175
|
-
};
|
|
176
|
-
this.setState({
|
|
177
|
-
percentages: nextPercentage
|
|
178
|
-
}, callback);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
updateBounds() {
|
|
182
|
-
this.setState({
|
|
183
|
-
bounds: this.calculateBounds()
|
|
184
|
-
});
|
|
185
|
-
}
|
|
130
|
+
top,
|
|
131
|
+
left
|
|
132
|
+
} = dragAreaRef.current.getBoundingClientRect();
|
|
133
|
+
let nextX = (clientX - left) / bounds.width;
|
|
134
|
+
let nextY = (clientY - top) / bounds.height; // Enables holding shift to jump values by 10%.
|
|
186
135
|
|
|
187
|
-
|
|
188
|
-
|
|
136
|
+
if (shiftKey) {
|
|
137
|
+
nextX = Math.round(nextX / 0.1) * 0.1;
|
|
138
|
+
nextY = Math.round(nextY / 0.1) * 0.1;
|
|
139
|
+
}
|
|
189
140
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
isDragging: true
|
|
141
|
+
return getFinalValue({
|
|
142
|
+
x: nextX,
|
|
143
|
+
y: nextY
|
|
194
144
|
});
|
|
195
|
-
|
|
196
|
-
ownerDocument
|
|
197
|
-
} = this.containerRef.current;
|
|
198
|
-
ownerDocument.addEventListener('mouseup', this.onMouseUp);
|
|
199
|
-
ownerDocument.addEventListener('mousemove', this.onMouseMove);
|
|
200
|
-
const value = this.getValueFromPoint({
|
|
201
|
-
x: event.pageX,
|
|
202
|
-
y: event.pageY
|
|
203
|
-
}, event.shiftKey);
|
|
204
|
-
this.updateValue(value);
|
|
205
|
-
(_this$props$onDragSta = (_this$props2 = this.props).onDragStart) === null || _this$props$onDragSta === void 0 ? void 0 : _this$props$onDragSta.call(_this$props2, value, event);
|
|
206
|
-
}
|
|
145
|
+
};
|
|
207
146
|
|
|
208
|
-
|
|
209
|
-
var
|
|
147
|
+
const getFinalValue = value => {
|
|
148
|
+
var _resolvePoint;
|
|
210
149
|
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
this.props.onChange(this.state.percentages);
|
|
220
|
-
});
|
|
221
|
-
(_this$props$onDragEnd = (_this$props3 = this.props).onDragEnd) === null || _this$props$onDragEnd === void 0 ? void 0 : _this$props$onDragEnd.call(_this$props3, event);
|
|
222
|
-
}
|
|
150
|
+
const resolvedValue = (_resolvePoint = resolvePoint === null || resolvePoint === void 0 ? void 0 : resolvePoint(value)) !== null && _resolvePoint !== void 0 ? _resolvePoint : value;
|
|
151
|
+
resolvedValue.x = Math.max(0, Math.min(resolvedValue.x, 1));
|
|
152
|
+
resolvedValue.y = Math.max(0, Math.min(resolvedValue.y, 1));
|
|
153
|
+
return {
|
|
154
|
+
x: parseFloat(resolvedValue.x).toFixed(2),
|
|
155
|
+
y: parseFloat(resolvedValue.y).toFixed(2)
|
|
156
|
+
};
|
|
157
|
+
};
|
|
223
158
|
|
|
224
|
-
|
|
159
|
+
const arrowKeyStep = event => {
|
|
225
160
|
const {
|
|
226
161
|
code,
|
|
227
162
|
shiftKey
|
|
228
163
|
} = event;
|
|
229
164
|
if (!['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(code)) return;
|
|
230
165
|
event.preventDefault();
|
|
231
|
-
const
|
|
166
|
+
const value = {
|
|
167
|
+
x,
|
|
168
|
+
y
|
|
232
169
|
};
|
|
233
170
|
const step = shiftKey ? 0.1 : 0.01;
|
|
234
171
|
const delta = code === 'ArrowUp' || code === 'ArrowLeft' ? -1 * step : step;
|
|
235
172
|
const axis = code === 'ArrowUp' || code === 'ArrowDown' ? 'y' : 'x';
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
},
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
const {
|
|
292
|
-
clientHeight,
|
|
293
|
-
clientWidth
|
|
294
|
-
} = containerNode;
|
|
295
|
-
const {
|
|
296
|
-
top,
|
|
297
|
-
left
|
|
298
|
-
} = containerNode.getBoundingClientRect();
|
|
299
|
-
return {
|
|
300
|
-
width: clientWidth,
|
|
301
|
-
height: clientHeight,
|
|
302
|
-
top: top + document.body.scrollTop,
|
|
303
|
-
left
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
iconCoordinates() {
|
|
308
|
-
const {
|
|
309
|
-
bounds,
|
|
310
|
-
percentages: {
|
|
311
|
-
x,
|
|
312
|
-
y
|
|
313
|
-
}
|
|
314
|
-
} = this.state;
|
|
315
|
-
|
|
316
|
-
if (bounds.left === undefined || bounds.top === undefined) {
|
|
317
|
-
return {
|
|
318
|
-
left: '50%',
|
|
319
|
-
top: '50%'
|
|
320
|
-
};
|
|
173
|
+
value[axis] = parseFloat(value[axis]) + delta;
|
|
174
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(getFinalValue(value));
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const focalPointPosition = {
|
|
178
|
+
left: x * bounds.width,
|
|
179
|
+
top: y * bounds.height
|
|
180
|
+
};
|
|
181
|
+
const classes = (0, _classnames.default)('components-focal-point-picker-control', className);
|
|
182
|
+
const instanceId = (0, _compose.useInstanceId)(FocalPointPicker);
|
|
183
|
+
const id = `inspector-focal-point-picker-control-${instanceId}`;
|
|
184
|
+
(0, _hooks.useUpdateEffect)(() => {
|
|
185
|
+
setShowGridOverlay(true);
|
|
186
|
+
const timeout = window.setTimeout(() => {
|
|
187
|
+
setShowGridOverlay(false);
|
|
188
|
+
}, GRID_OVERLAY_TIMEOUT);
|
|
189
|
+
return () => window.clearTimeout(timeout);
|
|
190
|
+
}, [x, y]);
|
|
191
|
+
return (0, _element.createElement)(_baseControl.default, {
|
|
192
|
+
label: label,
|
|
193
|
+
id: id,
|
|
194
|
+
help: help,
|
|
195
|
+
className: classes
|
|
196
|
+
}, (0, _element.createElement)(_focalPointPickerStyle.MediaWrapper, {
|
|
197
|
+
className: "components-focal-point-picker-wrapper"
|
|
198
|
+
}, (0, _element.createElement)(_focalPointPickerStyle.MediaContainer, {
|
|
199
|
+
className: "components-focal-point-picker",
|
|
200
|
+
onKeyDown: arrowKeyStep,
|
|
201
|
+
onMouseDown: startDrag,
|
|
202
|
+
onBlur: () => {
|
|
203
|
+
if (isDragging) endDrag();
|
|
204
|
+
},
|
|
205
|
+
ref: dragAreaRef,
|
|
206
|
+
role: "button",
|
|
207
|
+
tabIndex: "-1"
|
|
208
|
+
}, (0, _element.createElement)(_grid.default, {
|
|
209
|
+
bounds: bounds,
|
|
210
|
+
showOverlay: showGridOverlay
|
|
211
|
+
}), (0, _element.createElement)(_media.default, {
|
|
212
|
+
alt: (0, _i18n.__)('Media preview'),
|
|
213
|
+
autoPlay: autoPlay,
|
|
214
|
+
onLoad: refUpdateBounds.current,
|
|
215
|
+
src: url
|
|
216
|
+
}), (0, _element.createElement)(_focalPoint.default, (0, _extends2.default)({}, focalPointPosition, {
|
|
217
|
+
isDragging: isDragging
|
|
218
|
+
})))), (0, _element.createElement)(_controls.default, {
|
|
219
|
+
point: {
|
|
220
|
+
x,
|
|
221
|
+
y
|
|
222
|
+
},
|
|
223
|
+
onChange: value => {
|
|
224
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(getFinalValue(value));
|
|
321
225
|
}
|
|
322
|
-
|
|
323
|
-
const {
|
|
324
|
-
width,
|
|
325
|
-
height
|
|
326
|
-
} = this.pickerDimensions();
|
|
327
|
-
return {
|
|
328
|
-
left: x * (width - bounds.left * 2) + bounds.left,
|
|
329
|
-
top: y * (height - bounds.top * 2) + bounds.top
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
render() {
|
|
334
|
-
const {
|
|
335
|
-
autoPlay,
|
|
336
|
-
className,
|
|
337
|
-
help,
|
|
338
|
-
instanceId,
|
|
339
|
-
label,
|
|
340
|
-
url
|
|
341
|
-
} = this.props;
|
|
342
|
-
const {
|
|
343
|
-
bounds,
|
|
344
|
-
isDragging,
|
|
345
|
-
percentages
|
|
346
|
-
} = this.state;
|
|
347
|
-
const iconCoordinates = this.iconCoordinates();
|
|
348
|
-
const classes = (0, _classnames.default)('components-focal-point-picker-control', className);
|
|
349
|
-
const id = `inspector-focal-point-picker-control-${instanceId}`;
|
|
350
|
-
return (0, _element.createElement)(_baseControl.default, {
|
|
351
|
-
label: label,
|
|
352
|
-
id: id,
|
|
353
|
-
help: help,
|
|
354
|
-
className: classes
|
|
355
|
-
}, (0, _element.createElement)(_focalPointPickerStyle.MediaWrapper, {
|
|
356
|
-
className: "components-focal-point-picker-wrapper"
|
|
357
|
-
}, (0, _element.createElement)(_focalPointPickerStyle.MediaContainer, {
|
|
358
|
-
className: "components-focal-point-picker",
|
|
359
|
-
onKeyDown: this.onKeyDown,
|
|
360
|
-
onMouseDown: this.onMouseDown,
|
|
361
|
-
onBlur: this.ifDraggingStop,
|
|
362
|
-
ref: this.containerRef,
|
|
363
|
-
role: "button",
|
|
364
|
-
tabIndex: "-1"
|
|
365
|
-
}, (0, _element.createElement)(_grid.default, {
|
|
366
|
-
bounds: bounds,
|
|
367
|
-
value: percentages.x + percentages.y
|
|
368
|
-
}), (0, _element.createElement)(_media.default, {
|
|
369
|
-
alt: (0, _i18n.__)('Media preview'),
|
|
370
|
-
autoPlay: autoPlay,
|
|
371
|
-
mediaRef: this.mediaRef,
|
|
372
|
-
onLoad: this.updateBounds,
|
|
373
|
-
src: url
|
|
374
|
-
}), (0, _element.createElement)(_focalPoint.default, {
|
|
375
|
-
coordinates: iconCoordinates,
|
|
376
|
-
isDragging: isDragging
|
|
377
|
-
}))), (0, _element.createElement)(_controls.default, {
|
|
378
|
-
percentages: percentages,
|
|
379
|
-
onChange: this.onChangeAtControls
|
|
380
|
-
}));
|
|
381
|
-
}
|
|
382
|
-
|
|
226
|
+
}));
|
|
383
227
|
}
|
|
384
|
-
|
|
385
|
-
exports.FocalPointPicker = FocalPointPicker;
|
|
386
|
-
FocalPointPicker.defaultProps = {
|
|
387
|
-
autoPlay: true,
|
|
388
|
-
value: {
|
|
389
|
-
x: 0.5,
|
|
390
|
-
y: 0.5
|
|
391
|
-
},
|
|
392
|
-
url: null
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
var _default = (0, _compose.withInstanceId)(FocalPointPicker);
|
|
396
|
-
|
|
397
|
-
exports.default = _default;
|
|
398
228
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/focal-point-picker/index.js"],"names":["FocalPointPicker","Component","constructor","props","arguments","state","isDragging","bounds","INITIAL_BOUNDS","percentages","value","containerRef","mediaRef","onMouseDown","startDrag","bind","onMouseUp","stopDrag","onKeyDown","onMouseMove","doDrag","ifDraggingStop","onChangeAtControls","updateValue","onChange","updateBounds","componentDidMount","defaultView","current","ownerDocument","addEventListener","componentDidUpdate","prevProps","url","x","y","setState","componentWillUnmount","removeEventListener","calculateBounds","clientWidth","clientHeight","dimensions","width","height","pickerDimensions","widthRatio","heightRatio","right","top","bottom","left","nextValue","callback","resolvedValue","resolvePoint","nextPercentage","parseFloat","toFixed","event","persist","focus","getValueFromPoint","pageX","pageY","shiftKey","onDragStart","onDragEnd","code","includes","preventDefault","next","step","delta","axis","onDrag","point","byTenths","relativePoint","Math","max","min","nextX","nextY","containerNode","getBoundingClientRect","document","body","scrollTop","iconCoordinates","undefined","render","autoPlay","className","help","instanceId","label","classes","id","defaultProps"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AAzBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AAaO,MAAMA,gBAAN,SAA+BC,kBAA/B,CAAyC;AAC/CC,EAAAA,WAAW,CAAEC,KAAF,EAAU;AACpB,UAAO,GAAGC,SAAV;AAEA,SAAKC,KAAL,GAAa;AACZC,MAAAA,UAAU,EAAE,KADA;AAEZC,MAAAA,MAAM,EAAEC,qBAFI;AAGZC,MAAAA,WAAW,EAAEN,KAAK,CAACO;AAHP,KAAb;AAMA,SAAKC,YAAL,GAAoB,yBAApB;AACA,SAAKC,QAAL,GAAgB,yBAAhB;AAEA,SAAKC,WAAL,GAAmB,KAAKC,SAAL,CAAeC,IAAf,CAAqB,IAArB,CAAnB;AACA,SAAKC,SAAL,GAAiB,KAAKC,QAAL,CAAcF,IAAd,CAAoB,IAApB,CAAjB;AACA,SAAKG,SAAL,GAAiB,KAAKA,SAAL,CAAeH,IAAf,CAAqB,IAArB,CAAjB;AACA,SAAKI,WAAL,GAAmB,KAAKC,MAAL,CAAYL,IAAZ,CAAkB,IAAlB,CAAnB;;AACA,SAAKM,cAAL,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MAAA,GAAG,EAAG,cAAI,eAAJ,CADP;AAEC,MAAA,QAAQ,EAAGyD,QAFZ;AAGC,MAAA,QAAQ,EAAG,KAAKhF,QAHjB;AAIC,MAAA,MAAM,EAAG,KAAKa,YAJf;AAKC,MAAA,GAAG,EAAGQ;AALP,MAbD,EAoBC,4BAAC,mBAAD;AACC,MAAA,WAAW,EAAGwD,eADf;AAEC,MAAA,UAAU,EAAGnF;AAFd,MApBD,CADD,CAND,EAiCC,4BAAC,iBAAD;AACC,MAAA,WAAW,EAAGG,WADf;AAEC,MAAA,QAAQ,EAAG,KAAKa;AAFjB,MAjCD,CADD;AAwCA;;AAhT8C;;;AAmThDtB,gBAAgB,CAACmG,YAAjB,GAAgC;AAC/BP,EAAAA,QAAQ,EAAE,IADqB;AAE/BlF,EAAAA,KAAK,EAAE;AACNwB,IAAAA,CAAC,EAAE,GADG;AAENC,IAAAA,CAAC,EAAE;AAFG,GAFwB;AAM/BF,EAAAA,GAAG,EAAE;AAN0B,CAAhC;;eASe,6BAAgBjC,gBAAhB,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Component, createRef } from '@wordpress/element';\nimport { withInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport Controls from './controls';\nimport FocalPoint from './focal-point';\nimport Grid from './grid';\nimport Media from './media';\nimport {\n\tMediaWrapper,\n\tMediaContainer,\n} from './styles/focal-point-picker-style';\nimport { roundClamp } from '../utils/math';\nimport { INITIAL_BOUNDS } from './utils';\n\nexport class FocalPointPicker extends Component {\n\tconstructor( props ) {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\tisDragging: false,\n\t\t\tbounds: INITIAL_BOUNDS,\n\t\t\tpercentages: props.value,\n\t\t};\n\n\t\tthis.containerRef = createRef();\n\t\tthis.mediaRef = createRef();\n\n\t\tthis.onMouseDown = this.startDrag.bind( this );\n\t\tthis.onMouseUp = this.stopDrag.bind( this );\n\t\tthis.onKeyDown = this.onKeyDown.bind( this );\n\t\tthis.onMouseMove = this.doDrag.bind( this );\n\t\tthis.ifDraggingStop = () => {\n\t\t\tif ( this.state.isDragging ) {\n\t\t\t\tthis.stopDrag();\n\t\t\t}\n\t\t};\n\t\tthis.onChangeAtControls = ( value ) => {\n\t\t\tthis.updateValue( value, () => {\n\t\t\t\tthis.props.onChange( this.state.percentages );\n\t\t\t} );\n\t\t};\n\n\t\tthis.updateBounds = this.updateBounds.bind( this );\n\t\tthis.updateValue = this.updateValue.bind( this );\n\t}\n\tcomponentDidMount() {\n\t\tconst { defaultView } = this.containerRef.current.ownerDocument;\n\t\tdefaultView.addEventListener( 'resize', this.updateBounds );\n\n\t\t/*\n\t\t * Set initial bound values.\n\t\t *\n\t\t * This is necessary for Safari:\n\t\t * https://github.com/WordPress/gutenberg/issues/25814\n\t\t */\n\t\tthis.updateBounds();\n\t}\n\tcomponentDidUpdate( prevProps ) {\n\t\tif ( prevProps.url !== this.props.url ) {\n\t\t\tthis.ifDraggingStop();\n\t\t}\n\t\t/*\n\t\t * Handles cases where the incoming value changes.\n\t\t * An example is the values resetting based on an UNDO action.\n\t\t */\n\t\tconst {\n\t\t\tisDragging,\n\t\t\tpercentages: { x, y },\n\t\t} = this.state;\n\t\tconst { value } = this.props;\n\t\tif ( ! isDragging && ( value.x !== x || value.y !== y ) ) {\n\t\t\tthis.setState( { percentages: this.props.value } );\n\t\t}\n\t}\n\tcomponentWillUnmount() {\n\t\tconst { defaultView } = this.containerRef.current.ownerDocument;\n\t\tdefaultView.removeEventListener( 'resize', this.updateBounds );\n\t\tthis.ifDraggingStop();\n\t}\n\tcalculateBounds() {\n\t\tconst bounds = INITIAL_BOUNDS;\n\n\t\tif ( ! this.mediaRef.current ) {\n\t\t\treturn bounds;\n\t\t}\n\n\t\t// Prevent division by zero when updateBounds runs in componentDidMount\n\t\tif (\n\t\t\tthis.mediaRef.current.clientWidth === 0 ||\n\t\t\tthis.mediaRef.current.clientHeight === 0\n\t\t) {\n\t\t\treturn bounds;\n\t\t}\n\n\t\tconst dimensions = {\n\t\t\twidth: this.mediaRef.current.clientWidth,\n\t\t\theight: this.mediaRef.current.clientHeight,\n\t\t};\n\n\t\tconst pickerDimensions = this.pickerDimensions();\n\n\t\tconst widthRatio = pickerDimensions.width / dimensions.width;\n\t\tconst heightRatio = pickerDimensions.height / dimensions.height;\n\n\t\tif ( heightRatio >= widthRatio ) {\n\t\t\tbounds.width = bounds.right = pickerDimensions.width;\n\t\t\tbounds.height = dimensions.height * widthRatio;\n\t\t\tbounds.top = ( pickerDimensions.height - bounds.height ) / 2;\n\t\t\tbounds.bottom = bounds.top + bounds.height;\n\t\t} else {\n\t\t\tbounds.height = bounds.bottom = pickerDimensions.height;\n\t\t\tbounds.width = dimensions.width * heightRatio;\n\t\t\tbounds.left = ( pickerDimensions.width - bounds.width ) / 2;\n\t\t\tbounds.right = bounds.left + bounds.width;\n\t\t}\n\t\treturn bounds;\n\t}\n\tupdateValue( nextValue = {}, callback ) {\n\t\tconst resolvedValue =\n\t\t\tthis.props.resolvePoint?.( nextValue ) ?? nextValue;\n\n\t\tconst { x, y } = resolvedValue;\n\n\t\tconst nextPercentage = {\n\t\t\tx: parseFloat( x ).toFixed( 2 ),\n\t\t\ty: parseFloat( y ).toFixed( 2 ),\n\t\t};\n\n\t\tthis.setState( { percentages: nextPercentage }, callback );\n\t}\n\tupdateBounds() {\n\t\tthis.setState( {\n\t\t\tbounds: this.calculateBounds(),\n\t\t} );\n\t}\n\tstartDrag( event ) {\n\t\tevent.persist();\n\t\tthis.containerRef.current.focus();\n\t\tthis.setState( { isDragging: true } );\n\t\tconst { ownerDocument } = this.containerRef.current;\n\t\townerDocument.addEventListener( 'mouseup', this.onMouseUp );\n\t\townerDocument.addEventListener( 'mousemove', this.onMouseMove );\n\t\tconst value = this.getValueFromPoint(\n\t\t\t{ x: event.pageX, y: event.pageY },\n\t\t\tevent.shiftKey\n\t\t);\n\t\tthis.updateValue( value );\n\t\tthis.props.onDragStart?.( value, event );\n\t}\n\tstopDrag( event ) {\n\t\tconst { ownerDocument } = this.containerRef.current;\n\t\townerDocument.removeEventListener( 'mouseup', this.onMouseUp );\n\t\townerDocument.removeEventListener( 'mousemove', this.onMouseMove );\n\t\tthis.setState( { isDragging: false }, () => {\n\t\t\tthis.props.onChange( this.state.percentages );\n\t\t} );\n\t\tthis.props.onDragEnd?.( event );\n\t}\n\tonKeyDown( event ) {\n\t\tconst { code, shiftKey } = event;\n\t\tif (\n\t\t\t! [ 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight' ].includes(\n\t\t\t\tcode\n\t\t\t)\n\t\t)\n\t\t\treturn;\n\n\t\tevent.preventDefault();\n\n\t\tconst next = { ...this.state.percentages };\n\t\tconst step = shiftKey ? 0.1 : 0.01;\n\t\tconst delta =\n\t\t\tcode === 'ArrowUp' || code === 'ArrowLeft' ? -1 * step : step;\n\t\tconst axis = code === 'ArrowUp' || code === 'ArrowDown' ? 'y' : 'x';\n\t\tconst value = parseFloat( next[ axis ] ) + delta;\n\n\t\tnext[ axis ] = roundClamp( value, 0, 1, step );\n\n\t\tthis.updateValue( next, () => {\n\t\t\tthis.props.onChange( this.state.percentages );\n\t\t} );\n\t}\n\tdoDrag( event ) {\n\t\t// Prevents text-selection when dragging.\n\t\tevent.preventDefault();\n\t\tconst value = this.getValueFromPoint(\n\t\t\t{ x: event.pageX, y: event.pageY },\n\t\t\tevent.shiftKey\n\t\t);\n\t\tthis.updateValue( value );\n\t\tthis.props.onDrag?.( value, event );\n\t}\n\tgetValueFromPoint( point, byTenths ) {\n\t\tconst { bounds } = this.state;\n\n\t\tconst pickerDimensions = this.pickerDimensions();\n\t\tconst relativePoint = {\n\t\t\tleft: point.x - pickerDimensions.left,\n\t\t\ttop: point.y - pickerDimensions.top,\n\t\t};\n\n\t\tconst left = Math.max(\n\t\t\tbounds.left,\n\t\t\tMath.min( relativePoint.left, bounds.right )\n\t\t);\n\t\tconst top = Math.max(\n\t\t\tbounds.top,\n\t\t\tMath.min( relativePoint.top, bounds.bottom )\n\t\t);\n\n\t\tlet nextX =\n\t\t\t( left - bounds.left ) /\n\t\t\t( pickerDimensions.width - bounds.left * 2 );\n\t\tlet nextY =\n\t\t\t( top - bounds.top ) / ( pickerDimensions.height - bounds.top * 2 );\n\n\t\t// Enables holding shift to jump values by 10%\n\t\tconst step = byTenths ? 0.1 : 0.01;\n\n\t\tnextX = roundClamp( nextX, 0, 1, step );\n\t\tnextY = roundClamp( nextY, 0, 1, step );\n\n\t\treturn { x: nextX, y: nextY };\n\t}\n\tpickerDimensions() {\n\t\tconst containerNode = this.containerRef.current;\n\n\t\tif ( ! containerNode ) {\n\t\t\treturn {\n\t\t\t\twidth: 0,\n\t\t\t\theight: 0,\n\t\t\t\tleft: 0,\n\t\t\t\ttop: 0,\n\t\t\t};\n\t\t}\n\n\t\tconst { clientHeight, clientWidth } = containerNode;\n\t\tconst { top, left } = containerNode.getBoundingClientRect();\n\n\t\treturn {\n\t\t\twidth: clientWidth,\n\t\t\theight: clientHeight,\n\t\t\ttop: top + document.body.scrollTop,\n\t\t\tleft,\n\t\t};\n\t}\n\ticonCoordinates() {\n\t\tconst {\n\t\t\tbounds,\n\t\t\tpercentages: { x, y },\n\t\t} = this.state;\n\n\t\tif ( bounds.left === undefined || bounds.top === undefined ) {\n\t\t\treturn {\n\t\t\t\tleft: '50%',\n\t\t\t\ttop: '50%',\n\t\t\t};\n\t\t}\n\n\t\tconst { width, height } = this.pickerDimensions();\n\t\treturn {\n\t\t\tleft: x * ( width - bounds.left * 2 ) + bounds.left,\n\t\t\ttop: y * ( height - bounds.top * 2 ) + bounds.top,\n\t\t};\n\t}\n\trender() {\n\t\tconst { autoPlay, className, help, instanceId, label, url } =\n\t\t\tthis.props;\n\t\tconst { bounds, isDragging, percentages } = this.state;\n\t\tconst iconCoordinates = this.iconCoordinates();\n\n\t\tconst classes = classnames(\n\t\t\t'components-focal-point-picker-control',\n\t\t\tclassName\n\t\t);\n\n\t\tconst id = `inspector-focal-point-picker-control-${ instanceId }`;\n\n\t\treturn (\n\t\t\t<BaseControl\n\t\t\t\tlabel={ label }\n\t\t\t\tid={ id }\n\t\t\t\thelp={ help }\n\t\t\t\tclassName={ classes }\n\t\t\t>\n\t\t\t\t<MediaWrapper className=\"components-focal-point-picker-wrapper\">\n\t\t\t\t\t<MediaContainer\n\t\t\t\t\t\tclassName=\"components-focal-point-picker\"\n\t\t\t\t\t\tonKeyDown={ this.onKeyDown }\n\t\t\t\t\t\tonMouseDown={ this.onMouseDown }\n\t\t\t\t\t\tonBlur={ this.ifDraggingStop }\n\t\t\t\t\t\tref={ this.containerRef }\n\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<Grid\n\t\t\t\t\t\t\tbounds={ bounds }\n\t\t\t\t\t\t\tvalue={ percentages.x + percentages.y }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Media\n\t\t\t\t\t\t\talt={ __( 'Media preview' ) }\n\t\t\t\t\t\t\tautoPlay={ autoPlay }\n\t\t\t\t\t\t\tmediaRef={ this.mediaRef }\n\t\t\t\t\t\t\tonLoad={ this.updateBounds }\n\t\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<FocalPoint\n\t\t\t\t\t\t\tcoordinates={ iconCoordinates }\n\t\t\t\t\t\t\tisDragging={ isDragging }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</MediaContainer>\n\t\t\t\t</MediaWrapper>\n\t\t\t\t<Controls\n\t\t\t\t\tpercentages={ percentages }\n\t\t\t\t\tonChange={ this.onChangeAtControls }\n\t\t\t\t/>\n\t\t\t</BaseControl>\n\t\t);\n\t}\n}\n\nFocalPointPicker.defaultProps = {\n\tautoPlay: true,\n\tvalue: {\n\t\tx: 0.5,\n\t\ty: 0.5,\n\t},\n\turl: null,\n};\n\nexport default withInstanceId( FocalPointPicker );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/focal-point-picker/index.js"],"names":["GRID_OVERLAY_TIMEOUT","FocalPointPicker","autoPlay","className","help","label","onChange","onDrag","onDragEnd","onDragStart","resolvePoint","url","value","valueProp","x","y","point","setPoint","showGridOverlay","setShowGridOverlay","startDrag","endDrag","isDragging","event","dragAreaRef","current","focus","getValueWithinDragArea","onDragMove","preventDefault","bounds","setBounds","INITIAL_BOUNDS","refUpdateBounds","clientWidth","width","clientHeight","height","updateBounds","defaultView","ownerDocument","addEventListener","removeEventListener","clientX","clientY","shiftKey","top","left","getBoundingClientRect","nextX","nextY","Math","round","getFinalValue","resolvedValue","max","min","parseFloat","toFixed","arrowKeyStep","code","includes","step","delta","axis","focalPointPosition","classes","instanceId","id","timeout","window","setTimeout","clearTimeout"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAKA;;AAEA;;AASA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AA7BA;AACA;AACA;;AAGA;AACA;AACA;;AASA;AACA;AACA;AAaA,MAAMA,oBAAoB,GAAG,GAA7B;;AAEe,SAASC,gBAAT,OAeX;AAAA,MAfsC;AACzCC,IAAAA,QAAQ,GAAG,IAD8B;AAEzCC,IAAAA,SAFyC;AAGzCC,IAAAA,IAHyC;AAIzCC,IAAAA,KAJyC;AAKzCC,IAAAA,QALyC;AAMzCC,IAAAA,MANyC;AAOzCC,IAAAA,SAPyC;AAQzCC,IAAAA,WARyC;AASzCC,IAAAA,YATyC;AAUzCC,IAAAA,GAVyC;AAWzCC,IAAAA,KAAK,EAAEC,SAAS,GAAG;AAClBC,MAAAA,CAAC,EAAE,GADe;AAElBC,MAAAA,CAAC,EAAE;AAFe;AAXsB,GAetC;AACH,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsB,uBAAUJ,SAAV,CAA5B;AACA,QAAM,CAAEK,eAAF,EAAmBC,kBAAnB,IAA0C,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AAC,qCAAD;AACC,IAAA,SAAS,EAAC,+BADX;AAEC,IAAA,SAAS,EAAGP,YAFb;AAGC,IAAA,WAAW,EAAGvC,SAHf;AAIC,IAAA,MAAM,EAAG,MAAM;AACd,UAAKE,UAAL,EAAkBD,OAAO;AACzB,KANF;AAOC,IAAA,GAAG,EAAGG,WAPP;AAQC,IAAA,IAAI,EAAC,QARN;AASC,IAAA,QAAQ,EAAC;AATV,KAWC,4BAAC,aAAD;AAAM,IAAA,MAAM,EAAGM,MAAf;AAAwB,IAAA,WAAW,EAAGZ;AAAtC,IAXD,EAYC,4BAAC,cAAD;AACC,IAAA,GAAG,EAAG,cAAI,eAAJ,CADP;AAEC,IAAA,QAAQ,EAAGhB,QAFZ;AAGC,IAAA,MAAM,EAAG+B,eAAe,CAACR,OAH1B;AAIC,IAAA,GAAG,EAAGd;AAJP,IAZD,EAkBC,4BAAC,mBAAD,6BACMsD,kBADN;AAEC,IAAA,UAAU,EAAG3C;AAFd,KAlBD,CADD,CAND,EA+BC,4BAAC,iBAAD;AACC,IAAA,KAAK,EAAG;AAAER,MAAAA,CAAF;AAAKC,MAAAA;AAAL,KADT;AAEC,IAAA,QAAQ,EAAKH,KAAF,IAAa;AACvBN,MAAAA,QAAQ,SAAR,IAAAA,QAAQ,WAAR,YAAAA,QAAQ,CAAI+C,aAAa,CAAEzC,KAAF,CAAjB,CAAR;AACA;AAJF,IA/BD,CADD;AAwCA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport {\n\t__experimentalUseDragging as useDragging,\n\tuseInstanceId,\n\tuseIsomorphicLayoutEffect,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport Controls from './controls';\nimport FocalPoint from './focal-point';\nimport Grid from './grid';\nimport Media from './media';\nimport {\n\tMediaWrapper,\n\tMediaContainer,\n} from './styles/focal-point-picker-style';\nimport { INITIAL_BOUNDS } from './utils';\nimport { useUpdateEffect } from '../utils/hooks';\n\nconst GRID_OVERLAY_TIMEOUT = 600;\n\nexport default function FocalPointPicker( {\n\tautoPlay = true,\n\tclassName,\n\thelp,\n\tlabel,\n\tonChange,\n\tonDrag,\n\tonDragEnd,\n\tonDragStart,\n\tresolvePoint,\n\turl,\n\tvalue: valueProp = {\n\t\tx: 0.5,\n\t\ty: 0.5,\n\t},\n} ) {\n\tconst [ point, setPoint ] = useState( valueProp );\n\tconst [ showGridOverlay, setShowGridOverlay ] = useState( false );\n\n\tconst { startDrag, endDrag, isDragging } = useDragging( {\n\t\tonDragStart: ( event ) => {\n\t\t\tdragAreaRef.current.focus();\n\t\t\tconst value = getValueWithinDragArea( event );\n\t\t\tonDragStart?.( value, event );\n\t\t\tsetPoint( value );\n\t\t},\n\t\tonDragMove: ( event ) => {\n\t\t\t// Prevents text-selection when dragging.\n\t\t\tevent.preventDefault();\n\t\t\tconst value = getValueWithinDragArea( event );\n\t\t\tonDrag?.( value, event );\n\t\t\tsetPoint( value );\n\t\t},\n\t\tonDragEnd: ( event ) => {\n\t\t\tonDragEnd?.( event );\n\t\t\tonChange?.( point );\n\t\t},\n\t} );\n\n\t// Uses the internal point while dragging or else the value from props.\n\tconst { x, y } = isDragging ? point : valueProp;\n\n\tconst dragAreaRef = useRef();\n\tconst [ bounds, setBounds ] = useState( INITIAL_BOUNDS );\n\tconst refUpdateBounds = useRef( () => {\n\t\tconst { clientWidth: width, clientHeight: height } =\n\t\t\tdragAreaRef.current;\n\t\t// Falls back to initial bounds if the ref has no size. Since styles\n\t\t// give the drag area dimensions even when the media has not loaded\n\t\t// this should only happen in unit tests (jsdom).\n\t\tsetBounds(\n\t\t\twidth > 0 && height > 0 ? { width, height } : { ...INITIAL_BOUNDS }\n\t\t);\n\t} );\n\n\tuseEffect( () => {\n\t\tconst updateBounds = refUpdateBounds.current;\n\t\tconst { defaultView } = dragAreaRef.current.ownerDocument;\n\t\tdefaultView.addEventListener( 'resize', updateBounds );\n\t\treturn () => defaultView.removeEventListener( 'resize', updateBounds );\n\t}, [] );\n\n\t// Updates the bounds to cover cases of unspecified media or load failures.\n\tuseIsomorphicLayoutEffect( () => void refUpdateBounds.current(), [] );\n\n\tconst getValueWithinDragArea = ( { clientX, clientY, shiftKey } ) => {\n\t\tconst { top, left } = dragAreaRef.current.getBoundingClientRect();\n\t\tlet nextX = ( clientX - left ) / bounds.width;\n\t\tlet nextY = ( clientY - top ) / bounds.height;\n\t\t// Enables holding shift to jump values by 10%.\n\t\tif ( shiftKey ) {\n\t\t\tnextX = Math.round( nextX / 0.1 ) * 0.1;\n\t\t\tnextY = Math.round( nextY / 0.1 ) * 0.1;\n\t\t}\n\t\treturn getFinalValue( { x: nextX, y: nextY } );\n\t};\n\n\tconst getFinalValue = ( value ) => {\n\t\tconst resolvedValue = resolvePoint?.( value ) ?? value;\n\t\tresolvedValue.x = Math.max( 0, Math.min( resolvedValue.x, 1 ) );\n\t\tresolvedValue.y = Math.max( 0, Math.min( resolvedValue.y, 1 ) );\n\t\treturn {\n\t\t\tx: parseFloat( resolvedValue.x ).toFixed( 2 ),\n\t\t\ty: parseFloat( resolvedValue.y ).toFixed( 2 ),\n\t\t};\n\t};\n\n\tconst arrowKeyStep = ( event ) => {\n\t\tconst { code, shiftKey } = event;\n\t\tif (\n\t\t\t! [ 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight' ].includes(\n\t\t\t\tcode\n\t\t\t)\n\t\t)\n\t\t\treturn;\n\n\t\tevent.preventDefault();\n\t\tconst value = { x, y };\n\t\tconst step = shiftKey ? 0.1 : 0.01;\n\t\tconst delta =\n\t\t\tcode === 'ArrowUp' || code === 'ArrowLeft' ? -1 * step : step;\n\t\tconst axis = code === 'ArrowUp' || code === 'ArrowDown' ? 'y' : 'x';\n\t\tvalue[ axis ] = parseFloat( value[ axis ] ) + delta;\n\t\tonChange?.( getFinalValue( value ) );\n\t};\n\n\tconst focalPointPosition = {\n\t\tleft: x * bounds.width,\n\t\ttop: y * bounds.height,\n\t};\n\n\tconst classes = classnames(\n\t\t'components-focal-point-picker-control',\n\t\tclassName\n\t);\n\n\tconst instanceId = useInstanceId( FocalPointPicker );\n\tconst id = `inspector-focal-point-picker-control-${ instanceId }`;\n\n\tuseUpdateEffect( () => {\n\t\tsetShowGridOverlay( true );\n\t\tconst timeout = window.setTimeout( () => {\n\t\t\tsetShowGridOverlay( false );\n\t\t}, GRID_OVERLAY_TIMEOUT );\n\n\t\treturn () => window.clearTimeout( timeout );\n\t}, [ x, y ] );\n\n\treturn (\n\t\t<BaseControl\n\t\t\tlabel={ label }\n\t\t\tid={ id }\n\t\t\thelp={ help }\n\t\t\tclassName={ classes }\n\t\t>\n\t\t\t<MediaWrapper className=\"components-focal-point-picker-wrapper\">\n\t\t\t\t<MediaContainer\n\t\t\t\t\tclassName=\"components-focal-point-picker\"\n\t\t\t\t\tonKeyDown={ arrowKeyStep }\n\t\t\t\t\tonMouseDown={ startDrag }\n\t\t\t\t\tonBlur={ () => {\n\t\t\t\t\t\tif ( isDragging ) endDrag();\n\t\t\t\t\t} }\n\t\t\t\t\tref={ dragAreaRef }\n\t\t\t\t\trole=\"button\"\n\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t>\n\t\t\t\t\t<Grid bounds={ bounds } showOverlay={ showGridOverlay } />\n\t\t\t\t\t<Media\n\t\t\t\t\t\talt={ __( 'Media preview' ) }\n\t\t\t\t\t\tautoPlay={ autoPlay }\n\t\t\t\t\t\tonLoad={ refUpdateBounds.current }\n\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t/>\n\t\t\t\t\t<FocalPoint\n\t\t\t\t\t\t{ ...focalPointPosition }\n\t\t\t\t\t\tisDragging={ isDragging }\n\t\t\t\t\t/>\n\t\t\t\t</MediaContainer>\n\t\t\t</MediaWrapper>\n\t\t\t<Controls\n\t\t\t\tpoint={ { x, y } }\n\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\tonChange?.( getFinalValue( value ) );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</BaseControl>\n\t);\n}\n"]}
|