@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
|
@@ -12,16 +12,14 @@ import { FocalPointWrapper, PointerIconPathFill, PointerIconPathOutline, Pointer
|
|
|
12
12
|
import classnames from 'classnames';
|
|
13
13
|
export default function FocalPoint(_ref) {
|
|
14
14
|
let {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
top: '50%'
|
|
18
|
-
},
|
|
15
|
+
left = '50%',
|
|
16
|
+
top = '50%',
|
|
19
17
|
...props
|
|
20
18
|
} = _ref;
|
|
21
19
|
const classes = classnames('components-focal-point-picker__icon_container');
|
|
22
20
|
const style = {
|
|
23
|
-
left
|
|
24
|
-
top
|
|
21
|
+
left,
|
|
22
|
+
top
|
|
25
23
|
};
|
|
26
24
|
return createElement(FocalPointWrapper, _extends({}, props, {
|
|
27
25
|
className: classes,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/focal-point-picker/focal-point.js"],"names":["FocalPointWrapper","PointerIconPathFill","PointerIconPathOutline","PointerIconSVG","classnames","FocalPoint","
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/focal-point-picker/focal-point.js"],"names":["FocalPointWrapper","PointerIconPathFill","PointerIconPathOutline","PointerIconSVG","classnames","FocalPoint","left","top","props","classes","style"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,iBADD,EAECC,mBAFD,EAGCC,sBAHD,EAICC,cAJD,QAKO,4BALP;AAOA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA,eAAe,SAASC,UAAT,OAA+D;AAAA,MAA1C;AAAEC,IAAAA,IAAI,GAAG,KAAT;AAAgBC,IAAAA,GAAG,GAAG,KAAtB;AAA6B,OAAGC;AAAhC,GAA0C;AAC7E,QAAMC,OAAO,GAAGL,UAAU,CACzB,+CADyB,CAA1B;AAIA,QAAMM,KAAK,GAAG;AAAEJ,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAAd;AAEA,SACC,cAAC,iBAAD,eAAwBC,KAAxB;AAAgC,IAAA,SAAS,EAAGC,OAA5C;AAAsD,IAAA,KAAK,EAAGC;AAA9D,MACC,cAAC,cAAD;AACC,IAAA,SAAS,EAAC,qCADX;AAEC,IAAA,KAAK,EAAC,4BAFP;AAGC,IAAA,OAAO,EAAC;AAHT,KAKC,cAAC,sBAAD;AACC,IAAA,SAAS,EAAC,6CADX;AAEC,IAAA,CAAC,EAAC;AAFH,IALD,EASC,cAAC,mBAAD;AACC,IAAA,SAAS,EAAC,0CADX;AAEC,IAAA,CAAC,EAAC;AAFH,IATD,CADD,CADD;AAkBA","sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tFocalPointWrapper,\n\tPointerIconPathFill,\n\tPointerIconPathOutline,\n\tPointerIconSVG,\n} from './styles/focal-point-style';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\nexport default function FocalPoint( { left = '50%', top = '50%', ...props } ) {\n\tconst classes = classnames(\n\t\t'components-focal-point-picker__icon_container'\n\t);\n\n\tconst style = { left, top };\n\n\treturn (\n\t\t<FocalPointWrapper { ...props } className={ classes } style={ style }>\n\t\t\t<PointerIconSVG\n\t\t\t\tclassName=\"components-focal-point-picker__icon\"\n\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\tviewBox=\"0 0 30 30\"\n\t\t\t>\n\t\t\t\t<PointerIconPathOutline\n\t\t\t\t\tclassName=\"components-focal-point-picker__icon-outline\"\n\t\t\t\t\td=\"M15 1C7.3 1 1 7.3 1 15s6.3 14 14 14 14-6.3 14-14S22.7 1 15 1zm0 22c-4.4 0-8-3.6-8-8s3.6-8 8-8 8 3.6 8 8-3.6 8-8 8z\"\n\t\t\t\t/>\n\t\t\t\t<PointerIconPathFill\n\t\t\t\t\tclassName=\"components-focal-point-picker__icon-fill\"\n\t\t\t\t\td=\"M15 3C8.4 3 3 8.4 3 15s5.4 12 12 12 12-5.4 12-12S21.6 3 15 3zm0 22C9.5 25 5 20.5 5 15S9.5 5 15 5s10 4.5 10 10-4.5 10-10 10z\"\n\t\t\t\t/>\n\t\t\t</PointerIconSVG>\n\t\t</FocalPointWrapper>\n\t);\n}\n"]}
|
|
@@ -1,30 +1,21 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { createElement } from "@wordpress/element";
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* WordPress dependencies
|
|
6
|
-
*/
|
|
7
|
-
import { useState } from '@wordpress/element';
|
|
8
4
|
/**
|
|
9
5
|
* Internal dependencies
|
|
10
6
|
*/
|
|
11
|
-
|
|
12
7
|
import { GridView, GridLineX, GridLineY } from './styles/focal-point-picker-style';
|
|
13
|
-
import { useUpdateEffect } from '../utils/hooks';
|
|
14
8
|
export default function FocalPointPickerGrid(_ref) {
|
|
15
9
|
let {
|
|
16
|
-
bounds
|
|
17
|
-
value,
|
|
10
|
+
bounds,
|
|
18
11
|
...props
|
|
19
12
|
} = _ref;
|
|
20
|
-
|
|
21
|
-
const style = {
|
|
22
|
-
width: bounds.width,
|
|
23
|
-
height: bounds.height
|
|
24
|
-
};
|
|
25
|
-
return createElement(GridView, _extends({}, props, animationProps, {
|
|
13
|
+
return createElement(GridView, _extends({}, props, {
|
|
26
14
|
className: "components-focal-point-picker__grid",
|
|
27
|
-
style:
|
|
15
|
+
style: {
|
|
16
|
+
width: bounds.width,
|
|
17
|
+
height: bounds.height
|
|
18
|
+
}
|
|
28
19
|
}), createElement(GridLineX, {
|
|
29
20
|
style: {
|
|
30
21
|
top: '33%'
|
|
@@ -43,23 +34,4 @@ export default function FocalPointPickerGrid(_ref) {
|
|
|
43
34
|
}
|
|
44
35
|
}));
|
|
45
36
|
}
|
|
46
|
-
/**
|
|
47
|
-
* Custom hook that renders the "flash" animation whenever the value changes.
|
|
48
|
-
*
|
|
49
|
-
* @param {string} value Value of (box) side.
|
|
50
|
-
*/
|
|
51
|
-
|
|
52
|
-
function useRevealAnimation(value) {
|
|
53
|
-
const [isActive, setIsActive] = useState(false);
|
|
54
|
-
useUpdateEffect(() => {
|
|
55
|
-
setIsActive(true);
|
|
56
|
-
const timeout = window.setTimeout(() => {
|
|
57
|
-
setIsActive(false);
|
|
58
|
-
}, 600);
|
|
59
|
-
return () => window.clearTimeout(timeout);
|
|
60
|
-
}, [value]);
|
|
61
|
-
return {
|
|
62
|
-
isActive
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
37
|
//# sourceMappingURL=grid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/focal-point-picker/grid.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/focal-point-picker/grid.js"],"names":["GridView","GridLineX","GridLineY","FocalPointPickerGrid","bounds","props","width","height","top","left"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,QADD,EAECC,SAFD,EAGCC,SAHD,QAIO,mCAJP;AAMA,eAAe,SAASC,oBAAT,OAAsD;AAAA,MAAvB;AAAEC,IAAAA,MAAF;AAAU,OAAGC;AAAb,GAAuB;AACpE,SACC,cAAC,QAAD,eACMA,KADN;AAEC,IAAA,SAAS,EAAC,qCAFX;AAGC,IAAA,KAAK,EAAG;AACPC,MAAAA,KAAK,EAAEF,MAAM,CAACE,KADP;AAEPC,MAAAA,MAAM,EAAEH,MAAM,CAACG;AAFR;AAHT,MAQC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAG;AAAEC,MAAAA,GAAG,EAAE;AAAP;AAAnB,IARD,EASC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAG;AAAEA,MAAAA,GAAG,EAAE;AAAP;AAAnB,IATD,EAUC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAG;AAAEC,MAAAA,IAAI,EAAE;AAAR;AAAnB,IAVD,EAWC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAG;AAAEA,MAAAA,IAAI,EAAE;AAAR;AAAnB,IAXD,CADD;AAeA","sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tGridView,\n\tGridLineX,\n\tGridLineY,\n} from './styles/focal-point-picker-style';\n\nexport default function FocalPointPickerGrid( { bounds, ...props } ) {\n\treturn (\n\t\t<GridView\n\t\t\t{ ...props }\n\t\t\tclassName=\"components-focal-point-picker__grid\"\n\t\t\tstyle={ {\n\t\t\t\twidth: bounds.width,\n\t\t\t\theight: bounds.height,\n\t\t\t} }\n\t\t>\n\t\t\t<GridLineX style={ { top: '33%' } } />\n\t\t\t<GridLineX style={ { top: '66%' } } />\n\t\t\t<GridLineY style={ { left: '33%' } } />\n\t\t\t<GridLineY style={ { left: '66%' } } />\n\t\t</GridView>\n\t);\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import { createElement } from "@wordpress/element";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -9,8 +10,8 @@ import classnames from 'classnames';
|
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
12
|
import { __ } from '@wordpress/i18n';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
13
|
+
import { useEffect, useRef, useState } from '@wordpress/element';
|
|
14
|
+
import { __experimentalUseDragging as useDragging, useInstanceId, useIsomorphicLayoutEffect } from '@wordpress/compose';
|
|
14
15
|
/**
|
|
15
16
|
* Internal dependencies
|
|
16
17
|
*/
|
|
@@ -21,354 +22,186 @@ import FocalPoint from './focal-point';
|
|
|
21
22
|
import Grid from './grid';
|
|
22
23
|
import Media from './media';
|
|
23
24
|
import { MediaWrapper, MediaContainer } from './styles/focal-point-picker-style';
|
|
24
|
-
import { roundClamp } from '../utils/math';
|
|
25
25
|
import { INITIAL_BOUNDS } from './utils';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.stopDrag();
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
this.onChangeAtControls = value => {
|
|
48
|
-
this.updateValue(value, () => {
|
|
49
|
-
this.props.onChange(this.state.percentages);
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
this.updateBounds = this.updateBounds.bind(this);
|
|
54
|
-
this.updateValue = this.updateValue.bind(this);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
componentDidMount() {
|
|
58
|
-
const {
|
|
59
|
-
defaultView
|
|
60
|
-
} = this.containerRef.current.ownerDocument;
|
|
61
|
-
defaultView.addEventListener('resize', this.updateBounds);
|
|
62
|
-
/*
|
|
63
|
-
* Set initial bound values.
|
|
64
|
-
*
|
|
65
|
-
* This is necessary for Safari:
|
|
66
|
-
* https://github.com/WordPress/gutenberg/issues/25814
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
this.updateBounds();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
componentDidUpdate(prevProps) {
|
|
73
|
-
if (prevProps.url !== this.props.url) {
|
|
74
|
-
this.ifDraggingStop();
|
|
26
|
+
import { useUpdateEffect } from '../utils/hooks';
|
|
27
|
+
const GRID_OVERLAY_TIMEOUT = 600;
|
|
28
|
+
export default function FocalPointPicker(_ref) {
|
|
29
|
+
let {
|
|
30
|
+
autoPlay = true,
|
|
31
|
+
className,
|
|
32
|
+
help,
|
|
33
|
+
label,
|
|
34
|
+
onChange,
|
|
35
|
+
onDrag,
|
|
36
|
+
onDragEnd,
|
|
37
|
+
onDragStart,
|
|
38
|
+
resolvePoint,
|
|
39
|
+
url,
|
|
40
|
+
value: valueProp = {
|
|
41
|
+
x: 0.5,
|
|
42
|
+
y: 0.5
|
|
75
43
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
44
|
+
} = _ref;
|
|
45
|
+
const [point, setPoint] = useState(valueProp);
|
|
46
|
+
const [showGridOverlay, setShowGridOverlay] = useState(false);
|
|
47
|
+
const {
|
|
48
|
+
startDrag,
|
|
49
|
+
endDrag,
|
|
50
|
+
isDragging
|
|
51
|
+
} = useDragging({
|
|
52
|
+
onDragStart: event => {
|
|
53
|
+
dragAreaRef.current.focus();
|
|
54
|
+
const value = getValueWithinDragArea(event);
|
|
55
|
+
onDragStart === null || onDragStart === void 0 ? void 0 : onDragStart(value, event);
|
|
56
|
+
setPoint(value);
|
|
57
|
+
},
|
|
58
|
+
onDragMove: event => {
|
|
59
|
+
// Prevents text-selection when dragging.
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
const value = getValueWithinDragArea(event);
|
|
62
|
+
onDrag === null || onDrag === void 0 ? void 0 : onDrag(value, event);
|
|
63
|
+
setPoint(value);
|
|
64
|
+
},
|
|
65
|
+
onDragEnd: event => {
|
|
66
|
+
onDragEnd === null || onDragEnd === void 0 ? void 0 : onDragEnd(event);
|
|
67
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(point);
|
|
97
68
|
}
|
|
98
|
-
}
|
|
69
|
+
}); // Uses the internal point while dragging or else the value from props.
|
|
70
|
+
|
|
71
|
+
const {
|
|
72
|
+
x,
|
|
73
|
+
y
|
|
74
|
+
} = isDragging ? point : valueProp;
|
|
75
|
+
const dragAreaRef = useRef();
|
|
76
|
+
const [bounds, setBounds] = useState(INITIAL_BOUNDS);
|
|
77
|
+
const refUpdateBounds = useRef(() => {
|
|
78
|
+
const {
|
|
79
|
+
clientWidth: width,
|
|
80
|
+
clientHeight: height
|
|
81
|
+
} = dragAreaRef.current; // Falls back to initial bounds if the ref has no size. Since styles
|
|
82
|
+
// give the drag area dimensions even when the media has not loaded
|
|
83
|
+
// this should only happen in unit tests (jsdom).
|
|
99
84
|
|
|
100
|
-
|
|
85
|
+
setBounds(width > 0 && height > 0 ? {
|
|
86
|
+
width,
|
|
87
|
+
height
|
|
88
|
+
} : { ...INITIAL_BOUNDS
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
const updateBounds = refUpdateBounds.current;
|
|
101
93
|
const {
|
|
102
94
|
defaultView
|
|
103
|
-
} =
|
|
104
|
-
defaultView.
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
calculateBounds() {
|
|
109
|
-
const bounds = INITIAL_BOUNDS;
|
|
110
|
-
|
|
111
|
-
if (!this.mediaRef.current) {
|
|
112
|
-
return bounds;
|
|
113
|
-
} // Prevent division by zero when updateBounds runs in componentDidMount
|
|
95
|
+
} = dragAreaRef.current.ownerDocument;
|
|
96
|
+
defaultView.addEventListener('resize', updateBounds);
|
|
97
|
+
return () => defaultView.removeEventListener('resize', updateBounds);
|
|
98
|
+
}, []); // Updates the bounds to cover cases of unspecified media or load failures.
|
|
114
99
|
|
|
100
|
+
useIsomorphicLayoutEffect(() => void refUpdateBounds.current(), []);
|
|
115
101
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
height: this.mediaRef.current.clientHeight
|
|
123
|
-
};
|
|
124
|
-
const pickerDimensions = this.pickerDimensions();
|
|
125
|
-
const widthRatio = pickerDimensions.width / dimensions.width;
|
|
126
|
-
const heightRatio = pickerDimensions.height / dimensions.height;
|
|
127
|
-
|
|
128
|
-
if (heightRatio >= widthRatio) {
|
|
129
|
-
bounds.width = bounds.right = pickerDimensions.width;
|
|
130
|
-
bounds.height = dimensions.height * widthRatio;
|
|
131
|
-
bounds.top = (pickerDimensions.height - bounds.height) / 2;
|
|
132
|
-
bounds.bottom = bounds.top + bounds.height;
|
|
133
|
-
} else {
|
|
134
|
-
bounds.height = bounds.bottom = pickerDimensions.height;
|
|
135
|
-
bounds.width = dimensions.width * heightRatio;
|
|
136
|
-
bounds.left = (pickerDimensions.width - bounds.width) / 2;
|
|
137
|
-
bounds.right = bounds.left + bounds.width;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return bounds;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
updateValue() {
|
|
144
|
-
var _this$props$resolvePo, _this$props$resolvePo2, _this$props;
|
|
145
|
-
|
|
146
|
-
let nextValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
147
|
-
let callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
148
|
-
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;
|
|
102
|
+
const getValueWithinDragArea = _ref2 => {
|
|
103
|
+
let {
|
|
104
|
+
clientX,
|
|
105
|
+
clientY,
|
|
106
|
+
shiftKey
|
|
107
|
+
} = _ref2;
|
|
149
108
|
const {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
} =
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
y: parseFloat(y).toFixed(2)
|
|
156
|
-
};
|
|
157
|
-
this.setState({
|
|
158
|
-
percentages: nextPercentage
|
|
159
|
-
}, callback);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
updateBounds() {
|
|
163
|
-
this.setState({
|
|
164
|
-
bounds: this.calculateBounds()
|
|
165
|
-
});
|
|
166
|
-
}
|
|
109
|
+
top,
|
|
110
|
+
left
|
|
111
|
+
} = dragAreaRef.current.getBoundingClientRect();
|
|
112
|
+
let nextX = (clientX - left) / bounds.width;
|
|
113
|
+
let nextY = (clientY - top) / bounds.height; // Enables holding shift to jump values by 10%.
|
|
167
114
|
|
|
168
|
-
|
|
169
|
-
|
|
115
|
+
if (shiftKey) {
|
|
116
|
+
nextX = Math.round(nextX / 0.1) * 0.1;
|
|
117
|
+
nextY = Math.round(nextY / 0.1) * 0.1;
|
|
118
|
+
}
|
|
170
119
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
isDragging: true
|
|
120
|
+
return getFinalValue({
|
|
121
|
+
x: nextX,
|
|
122
|
+
y: nextY
|
|
175
123
|
});
|
|
176
|
-
|
|
177
|
-
ownerDocument
|
|
178
|
-
} = this.containerRef.current;
|
|
179
|
-
ownerDocument.addEventListener('mouseup', this.onMouseUp);
|
|
180
|
-
ownerDocument.addEventListener('mousemove', this.onMouseMove);
|
|
181
|
-
const value = this.getValueFromPoint({
|
|
182
|
-
x: event.pageX,
|
|
183
|
-
y: event.pageY
|
|
184
|
-
}, event.shiftKey);
|
|
185
|
-
this.updateValue(value);
|
|
186
|
-
(_this$props$onDragSta = (_this$props2 = this.props).onDragStart) === null || _this$props$onDragSta === void 0 ? void 0 : _this$props$onDragSta.call(_this$props2, value, event);
|
|
187
|
-
}
|
|
124
|
+
};
|
|
188
125
|
|
|
189
|
-
|
|
190
|
-
var
|
|
126
|
+
const getFinalValue = value => {
|
|
127
|
+
var _resolvePoint;
|
|
191
128
|
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
this.props.onChange(this.state.percentages);
|
|
201
|
-
});
|
|
202
|
-
(_this$props$onDragEnd = (_this$props3 = this.props).onDragEnd) === null || _this$props$onDragEnd === void 0 ? void 0 : _this$props$onDragEnd.call(_this$props3, event);
|
|
203
|
-
}
|
|
129
|
+
const resolvedValue = (_resolvePoint = resolvePoint === null || resolvePoint === void 0 ? void 0 : resolvePoint(value)) !== null && _resolvePoint !== void 0 ? _resolvePoint : value;
|
|
130
|
+
resolvedValue.x = Math.max(0, Math.min(resolvedValue.x, 1));
|
|
131
|
+
resolvedValue.y = Math.max(0, Math.min(resolvedValue.y, 1));
|
|
132
|
+
return {
|
|
133
|
+
x: parseFloat(resolvedValue.x).toFixed(2),
|
|
134
|
+
y: parseFloat(resolvedValue.y).toFixed(2)
|
|
135
|
+
};
|
|
136
|
+
};
|
|
204
137
|
|
|
205
|
-
|
|
138
|
+
const arrowKeyStep = event => {
|
|
206
139
|
const {
|
|
207
140
|
code,
|
|
208
141
|
shiftKey
|
|
209
142
|
} = event;
|
|
210
143
|
if (!['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(code)) return;
|
|
211
144
|
event.preventDefault();
|
|
212
|
-
const
|
|
145
|
+
const value = {
|
|
146
|
+
x,
|
|
147
|
+
y
|
|
213
148
|
};
|
|
214
149
|
const step = shiftKey ? 0.1 : 0.01;
|
|
215
150
|
const delta = code === 'ArrowUp' || code === 'ArrowLeft' ? -1 * step : step;
|
|
216
151
|
const axis = code === 'ArrowUp' || code === 'ArrowDown' ? 'y' : 'x';
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
},
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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
|
-
const {
|
|
273
|
-
clientHeight,
|
|
274
|
-
clientWidth
|
|
275
|
-
} = containerNode;
|
|
276
|
-
const {
|
|
277
|
-
top,
|
|
278
|
-
left
|
|
279
|
-
} = containerNode.getBoundingClientRect();
|
|
280
|
-
return {
|
|
281
|
-
width: clientWidth,
|
|
282
|
-
height: clientHeight,
|
|
283
|
-
top: top + document.body.scrollTop,
|
|
284
|
-
left
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
iconCoordinates() {
|
|
289
|
-
const {
|
|
290
|
-
bounds,
|
|
291
|
-
percentages: {
|
|
292
|
-
x,
|
|
293
|
-
y
|
|
294
|
-
}
|
|
295
|
-
} = this.state;
|
|
296
|
-
|
|
297
|
-
if (bounds.left === undefined || bounds.top === undefined) {
|
|
298
|
-
return {
|
|
299
|
-
left: '50%',
|
|
300
|
-
top: '50%'
|
|
301
|
-
};
|
|
152
|
+
value[axis] = parseFloat(value[axis]) + delta;
|
|
153
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(getFinalValue(value));
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const focalPointPosition = {
|
|
157
|
+
left: x * bounds.width,
|
|
158
|
+
top: y * bounds.height
|
|
159
|
+
};
|
|
160
|
+
const classes = classnames('components-focal-point-picker-control', className);
|
|
161
|
+
const instanceId = useInstanceId(FocalPointPicker);
|
|
162
|
+
const id = `inspector-focal-point-picker-control-${instanceId}`;
|
|
163
|
+
useUpdateEffect(() => {
|
|
164
|
+
setShowGridOverlay(true);
|
|
165
|
+
const timeout = window.setTimeout(() => {
|
|
166
|
+
setShowGridOverlay(false);
|
|
167
|
+
}, GRID_OVERLAY_TIMEOUT);
|
|
168
|
+
return () => window.clearTimeout(timeout);
|
|
169
|
+
}, [x, y]);
|
|
170
|
+
return createElement(BaseControl, {
|
|
171
|
+
label: label,
|
|
172
|
+
id: id,
|
|
173
|
+
help: help,
|
|
174
|
+
className: classes
|
|
175
|
+
}, createElement(MediaWrapper, {
|
|
176
|
+
className: "components-focal-point-picker-wrapper"
|
|
177
|
+
}, createElement(MediaContainer, {
|
|
178
|
+
className: "components-focal-point-picker",
|
|
179
|
+
onKeyDown: arrowKeyStep,
|
|
180
|
+
onMouseDown: startDrag,
|
|
181
|
+
onBlur: () => {
|
|
182
|
+
if (isDragging) endDrag();
|
|
183
|
+
},
|
|
184
|
+
ref: dragAreaRef,
|
|
185
|
+
role: "button",
|
|
186
|
+
tabIndex: "-1"
|
|
187
|
+
}, createElement(Grid, {
|
|
188
|
+
bounds: bounds,
|
|
189
|
+
showOverlay: showGridOverlay
|
|
190
|
+
}), createElement(Media, {
|
|
191
|
+
alt: __('Media preview'),
|
|
192
|
+
autoPlay: autoPlay,
|
|
193
|
+
onLoad: refUpdateBounds.current,
|
|
194
|
+
src: url
|
|
195
|
+
}), createElement(FocalPoint, _extends({}, focalPointPosition, {
|
|
196
|
+
isDragging: isDragging
|
|
197
|
+
})))), createElement(Controls, {
|
|
198
|
+
point: {
|
|
199
|
+
x,
|
|
200
|
+
y
|
|
201
|
+
},
|
|
202
|
+
onChange: value => {
|
|
203
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(getFinalValue(value));
|
|
302
204
|
}
|
|
303
|
-
|
|
304
|
-
const {
|
|
305
|
-
width,
|
|
306
|
-
height
|
|
307
|
-
} = this.pickerDimensions();
|
|
308
|
-
return {
|
|
309
|
-
left: x * (width - bounds.left * 2) + bounds.left,
|
|
310
|
-
top: y * (height - bounds.top * 2) + bounds.top
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
render() {
|
|
315
|
-
const {
|
|
316
|
-
autoPlay,
|
|
317
|
-
className,
|
|
318
|
-
help,
|
|
319
|
-
instanceId,
|
|
320
|
-
label,
|
|
321
|
-
url
|
|
322
|
-
} = this.props;
|
|
323
|
-
const {
|
|
324
|
-
bounds,
|
|
325
|
-
isDragging,
|
|
326
|
-
percentages
|
|
327
|
-
} = this.state;
|
|
328
|
-
const iconCoordinates = this.iconCoordinates();
|
|
329
|
-
const classes = classnames('components-focal-point-picker-control', className);
|
|
330
|
-
const id = `inspector-focal-point-picker-control-${instanceId}`;
|
|
331
|
-
return createElement(BaseControl, {
|
|
332
|
-
label: label,
|
|
333
|
-
id: id,
|
|
334
|
-
help: help,
|
|
335
|
-
className: classes
|
|
336
|
-
}, createElement(MediaWrapper, {
|
|
337
|
-
className: "components-focal-point-picker-wrapper"
|
|
338
|
-
}, createElement(MediaContainer, {
|
|
339
|
-
className: "components-focal-point-picker",
|
|
340
|
-
onKeyDown: this.onKeyDown,
|
|
341
|
-
onMouseDown: this.onMouseDown,
|
|
342
|
-
onBlur: this.ifDraggingStop,
|
|
343
|
-
ref: this.containerRef,
|
|
344
|
-
role: "button",
|
|
345
|
-
tabIndex: "-1"
|
|
346
|
-
}, createElement(Grid, {
|
|
347
|
-
bounds: bounds,
|
|
348
|
-
value: percentages.x + percentages.y
|
|
349
|
-
}), createElement(Media, {
|
|
350
|
-
alt: __('Media preview'),
|
|
351
|
-
autoPlay: autoPlay,
|
|
352
|
-
mediaRef: this.mediaRef,
|
|
353
|
-
onLoad: this.updateBounds,
|
|
354
|
-
src: url
|
|
355
|
-
}), createElement(FocalPoint, {
|
|
356
|
-
coordinates: iconCoordinates,
|
|
357
|
-
isDragging: isDragging
|
|
358
|
-
}))), createElement(Controls, {
|
|
359
|
-
percentages: percentages,
|
|
360
|
-
onChange: this.onChangeAtControls
|
|
361
|
-
}));
|
|
362
|
-
}
|
|
363
|
-
|
|
205
|
+
}));
|
|
364
206
|
}
|
|
365
|
-
FocalPointPicker.defaultProps = {
|
|
366
|
-
autoPlay: true,
|
|
367
|
-
value: {
|
|
368
|
-
x: 0.5,
|
|
369
|
-
y: 0.5
|
|
370
|
-
},
|
|
371
|
-
url: null
|
|
372
|
-
};
|
|
373
|
-
export default withInstanceId(FocalPointPicker);
|
|
374
207
|
//# sourceMappingURL=index.js.map
|