@wordpress/components 23.6.0 → 23.7.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 +32 -4
- package/build/angle-picker-control/angle-circle.js +1 -4
- package/build/angle-picker-control/angle-circle.js.map +1 -1
- package/build/angle-picker-control/index.js +10 -22
- package/build/angle-picker-control/index.js.map +1 -1
- package/build/angle-picker-control/styles/angle-picker-control-styles.js +24 -15
- package/build/angle-picker-control/styles/angle-picker-control-styles.js.map +1 -1
- package/build/animate/index.js +27 -19
- package/build/animate/index.js.map +1 -1
- package/build/animate/types.js.map +1 -0
- package/build/box-control/axial-input-controls.js.map +1 -1
- package/build/color-picker/color-input.js +0 -4
- package/build/color-picker/color-input.js.map +1 -1
- package/build/color-picker/component.js +5 -4
- package/build/color-picker/component.js.map +1 -1
- package/build/color-picker/hex-input.js.map +1 -1
- package/build/color-picker/hsl-input.js.map +1 -1
- package/build/color-picker/input-with-slider.js.map +1 -1
- package/build/color-picker/legacy-adapter.js.map +1 -1
- package/build/color-picker/picker.js.map +1 -1
- package/build/color-picker/rgb-input.js.map +1 -1
- package/build/color-picker/use-deprecated-props.js.map +1 -1
- package/build/custom-gradient-picker/constants.js +1 -1
- package/build/custom-gradient-picker/constants.js.map +1 -1
- package/build/custom-gradient-picker/gradient-bar/constants.js.map +1 -1
- package/build/custom-gradient-picker/gradient-bar/control-points.js +9 -5
- package/build/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
- package/build/custom-gradient-picker/gradient-bar/index.js +14 -9
- package/build/custom-gradient-picker/gradient-bar/index.js.map +1 -1
- package/build/custom-gradient-picker/gradient-bar/utils.js +34 -54
- package/build/custom-gradient-picker/gradient-bar/utils.js.map +1 -1
- package/build/custom-gradient-picker/index.js +45 -16
- package/build/custom-gradient-picker/index.js.map +1 -1
- package/build/custom-gradient-picker/serializer.js +14 -4
- package/build/custom-gradient-picker/serializer.js.map +1 -1
- package/build/custom-gradient-picker/styles/custom-gradient-picker-styles.js +6 -6
- package/build/custom-gradient-picker/styles/custom-gradient-picker-styles.js.map +1 -1
- package/build/custom-gradient-picker/types.js +6 -0
- package/build/custom-gradient-picker/types.js.map +1 -0
- package/build/custom-gradient-picker/utils.js +17 -12
- package/build/custom-gradient-picker/utils.js.map +1 -1
- package/build/{color-list-picker → duotone-picker/color-list-picker}/index.js +5 -5
- package/build/duotone-picker/color-list-picker/index.js.map +1 -0
- package/build/duotone-picker/color-list-picker/types.js +6 -0
- package/build/duotone-picker/color-list-picker/types.js.map +1 -0
- package/build/duotone-picker/custom-duotone-bar.js.map +1 -1
- package/build/duotone-picker/duotone-picker.js +39 -2
- package/build/duotone-picker/duotone-picker.js.map +1 -1
- package/build/duotone-picker/duotone-swatch.js.map +1 -1
- package/build/duotone-picker/index.js.map +1 -1
- package/build/duotone-picker/types.js +6 -0
- package/build/duotone-picker/types.js.map +1 -0
- package/build/duotone-picker/utils.js +13 -11
- package/build/duotone-picker/utils.js.map +1 -1
- package/build/form-token-field/index.js +9 -3
- package/build/form-token-field/index.js.map +1 -1
- package/build/gradient-picker/index.js +61 -9
- package/build/gradient-picker/index.js.map +1 -1
- package/build/gradient-picker/types.js +6 -0
- package/build/gradient-picker/types.js.map +1 -0
- package/build/palette-edit/index.js +1 -2
- package/build/palette-edit/index.js.map +1 -1
- package/build/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build/sandbox/index.native.js +80 -67
- package/build/sandbox/index.native.js.map +1 -1
- package/build/tab-panel/index.js +1 -1
- package/build/tab-panel/index.js.map +1 -1
- package/build/tools-panel/tools-panel/hook.js +45 -6
- package/build/tools-panel/tools-panel/hook.js.map +1 -1
- package/build/utils/input/input-control.js +1 -1
- package/build/utils/input/input-control.js.map +1 -1
- package/build-module/angle-picker-control/angle-circle.js +1 -4
- package/build-module/angle-picker-control/angle-circle.js.map +1 -1
- package/build-module/angle-picker-control/index.js +12 -21
- package/build-module/angle-picker-control/index.js.map +1 -1
- package/build-module/angle-picker-control/styles/angle-picker-control-styles.js +20 -13
- package/build-module/angle-picker-control/styles/angle-picker-control-styles.js.map +1 -1
- package/build-module/animate/index.js +25 -17
- package/build-module/animate/index.js.map +1 -1
- package/build-module/box-control/axial-input-controls.js.map +1 -1
- package/build-module/color-picker/color-input.js +0 -4
- package/build-module/color-picker/color-input.js.map +1 -1
- package/build-module/color-picker/component.js +3 -3
- package/build-module/color-picker/component.js.map +1 -1
- package/build-module/color-picker/hex-input.js.map +1 -1
- package/build-module/color-picker/hsl-input.js.map +1 -1
- package/build-module/color-picker/input-with-slider.js.map +1 -1
- package/build-module/color-picker/legacy-adapter.js.map +1 -1
- package/build-module/color-picker/picker.js +4 -0
- package/build-module/color-picker/picker.js.map +1 -1
- package/build-module/color-picker/rgb-input.js.map +1 -1
- package/build-module/color-picker/use-deprecated-props.js.map +1 -1
- package/build-module/custom-gradient-picker/constants.js +1 -1
- package/build-module/custom-gradient-picker/constants.js.map +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/constants.js.map +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/control-points.js +9 -4
- package/build-module/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/index.js +14 -8
- package/build-module/custom-gradient-picker/gradient-bar/index.js.map +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/utils.js +34 -54
- package/build-module/custom-gradient-picker/gradient-bar/utils.js.map +1 -1
- package/build-module/custom-gradient-picker/index.js +44 -17
- package/build-module/custom-gradient-picker/index.js.map +1 -1
- package/build-module/custom-gradient-picker/serializer.js +14 -4
- package/build-module/custom-gradient-picker/serializer.js.map +1 -1
- package/build-module/custom-gradient-picker/styles/custom-gradient-picker-styles.js +6 -6
- package/build-module/custom-gradient-picker/styles/custom-gradient-picker-styles.js.map +1 -1
- package/build-module/custom-gradient-picker/types.js +2 -0
- package/build-module/custom-gradient-picker/utils.js +17 -12
- package/build-module/custom-gradient-picker/utils.js.map +1 -1
- package/build-module/{color-list-picker → duotone-picker/color-list-picker}/index.js +5 -5
- package/build-module/duotone-picker/color-list-picker/index.js.map +1 -0
- package/build-module/duotone-picker/color-list-picker/types.js +2 -0
- package/build-module/duotone-picker/color-list-picker/types.js.map +1 -0
- package/build-module/duotone-picker/custom-duotone-bar.js.map +1 -1
- package/build-module/duotone-picker/duotone-picker.js +38 -2
- package/build-module/duotone-picker/duotone-picker.js.map +1 -1
- package/build-module/duotone-picker/duotone-swatch.js.map +1 -1
- package/build-module/duotone-picker/index.js.map +1 -1
- package/build-module/duotone-picker/types.js +2 -0
- package/build-module/duotone-picker/types.js.map +1 -0
- package/build-module/duotone-picker/utils.js +17 -11
- package/build-module/duotone-picker/utils.js.map +1 -1
- package/build-module/form-token-field/index.js +9 -4
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/gradient-picker/index.js +61 -10
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/gradient-picker/types.js +2 -0
- package/build-module/gradient-picker/types.js.map +1 -0
- package/build-module/palette-edit/index.js +1 -2
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build-module/sandbox/index.native.js +70 -58
- package/build-module/sandbox/index.native.js.map +1 -1
- package/build-module/tab-panel/index.js +2 -2
- package/build-module/tab-panel/index.js.map +1 -1
- package/build-module/tools-panel/tools-panel/hook.js +45 -6
- package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
- package/build-module/utils/input/input-control.js +1 -1
- package/build-module/utils/input/input-control.js.map +1 -1
- package/build-style/style-rtl.css +40 -28
- package/build-style/style.css +42 -28
- package/build-types/angle-picker-control/angle-circle.d.ts.map +1 -1
- package/build-types/angle-picker-control/index.d.ts.map +1 -1
- package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts +5 -0
- package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts.map +1 -1
- package/build-types/animate/index.d.ts +27 -22
- package/build-types/animate/index.d.ts.map +1 -1
- package/build-types/animate/stories/index.d.ts +18 -0
- package/build-types/animate/stories/index.d.ts.map +1 -0
- package/build-types/animate/types.d.ts +30 -0
- package/build-types/animate/types.d.ts.map +1 -0
- package/build-types/color-picker/color-input.d.ts +1 -11
- package/build-types/color-picker/color-input.d.ts.map +1 -1
- package/build-types/color-picker/component.d.ts +8 -9
- package/build-types/color-picker/component.d.ts.map +1 -1
- package/build-types/color-picker/hex-input.d.ts +1 -10
- package/build-types/color-picker/hex-input.d.ts.map +1 -1
- package/build-types/color-picker/hsl-input.d.ts +1 -10
- package/build-types/color-picker/hsl-input.d.ts.map +1 -1
- package/build-types/color-picker/input-with-slider.d.ts +1 -9
- package/build-types/color-picker/input-with-slider.d.ts.map +1 -1
- package/build-types/color-picker/legacy-adapter.d.ts +1 -3
- package/build-types/color-picker/legacy-adapter.d.ts.map +1 -1
- package/build-types/color-picker/picker.d.ts +4 -7
- package/build-types/color-picker/picker.d.ts.map +1 -1
- package/build-types/color-picker/rgb-input.d.ts +1 -10
- package/build-types/color-picker/rgb-input.d.ts.map +1 -1
- package/build-types/color-picker/stories/index.d.ts +19 -0
- package/build-types/color-picker/stories/index.d.ts.map +1 -0
- package/build-types/color-picker/test/index.d.ts +2 -0
- package/build-types/color-picker/test/index.d.ts.map +1 -0
- package/build-types/color-picker/types.d.ts +105 -1
- package/build-types/color-picker/types.d.ts.map +1 -1
- package/build-types/color-picker/use-deprecated-props.d.ts +1 -44
- package/build-types/color-picker/use-deprecated-props.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/constants.d.ts +8 -8
- package/build-types/custom-gradient-picker/constants.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/gradient-bar/constants.d.ts +7 -7
- package/build-types/custom-gradient-picker/gradient-bar/constants.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/gradient-bar/control-points.d.ts +5 -22
- package/build-types/custom-gradient-picker/gradient-bar/control-points.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/gradient-bar/index.d.ts +3 -9
- package/build-types/custom-gradient-picker/gradient-bar/index.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/gradient-bar/test/utils.d.ts +2 -0
- package/build-types/custom-gradient-picker/gradient-bar/test/utils.d.ts.map +1 -0
- package/build-types/custom-gradient-picker/gradient-bar/utils.d.ts +44 -92
- package/build-types/custom-gradient-picker/gradient-bar/utils.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/index.d.ts +27 -6
- package/build-types/custom-gradient-picker/index.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/serializer.d.ts +13 -16
- package/build-types/custom-gradient-picker/serializer.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/stories/index.d.ts +12 -0
- package/build-types/custom-gradient-picker/stories/index.d.ts.map +1 -0
- package/build-types/custom-gradient-picker/styles/custom-gradient-picker-styles.d.ts +3 -2
- package/build-types/custom-gradient-picker/styles/custom-gradient-picker-styles.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/test/serializer.d.ts +2 -0
- package/build-types/custom-gradient-picker/test/serializer.d.ts.map +1 -0
- package/build-types/custom-gradient-picker/types.d.ts +120 -0
- package/build-types/custom-gradient-picker/types.d.ts.map +1 -0
- package/build-types/custom-gradient-picker/utils.d.ts +12 -4
- package/build-types/custom-gradient-picker/utils.d.ts.map +1 -1
- package/build-types/duotone-picker/color-list-picker/index.d.ts.map +1 -0
- package/build-types/{color-list-picker → duotone-picker/color-list-picker}/types.d.ts +2 -2
- package/build-types/duotone-picker/color-list-picker/types.d.ts.map +1 -0
- package/build-types/duotone-picker/custom-duotone-bar.d.ts +6 -0
- package/build-types/duotone-picker/custom-duotone-bar.d.ts.map +1 -0
- package/build-types/duotone-picker/duotone-picker.d.ts +38 -0
- package/build-types/duotone-picker/duotone-picker.d.ts.map +1 -0
- package/build-types/duotone-picker/duotone-swatch.d.ts +5 -0
- package/build-types/duotone-picker/duotone-swatch.d.ts.map +1 -0
- package/build-types/duotone-picker/index.d.ts +3 -0
- package/build-types/duotone-picker/index.d.ts.map +1 -0
- package/build-types/duotone-picker/stories/duotone-picker.d.ts +12 -0
- package/build-types/duotone-picker/stories/duotone-picker.d.ts.map +1 -0
- package/build-types/duotone-picker/stories/duotone-swatch.d.ts +14 -0
- package/build-types/duotone-picker/stories/duotone-swatch.d.ts.map +1 -0
- package/build-types/duotone-picker/types.d.ts +60 -0
- package/build-types/duotone-picker/types.d.ts.map +1 -0
- package/build-types/duotone-picker/utils.d.ts +52 -0
- package/build-types/duotone-picker/utils.d.ts.map +1 -0
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/types.d.ts +6 -0
- package/build-types/form-token-field/types.d.ts.map +1 -1
- package/build-types/gradient-picker/index.d.ts +49 -11
- package/build-types/gradient-picker/index.d.ts.map +1 -1
- package/build-types/gradient-picker/stories/index.d.ts +14 -0
- package/build-types/gradient-picker/stories/index.d.ts.map +1 -0
- package/build-types/gradient-picker/types.d.ts +87 -0
- package/build-types/gradient-picker/types.d.ts.map +1 -0
- package/build-types/palette-edit/index.d.ts.map +1 -1
- package/build-types/resizable-box/resize-tooltip/utils.d.ts +1 -1
- package/build-types/resizable-box/resize-tooltip/utils.d.ts.map +1 -1
- package/build-types/tab-panel/index.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
- package/build-types/tools-panel/types.d.ts +1 -0
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/build-types/utils/input/input-control.d.ts.map +1 -1
- package/package.json +19 -19
- package/src/angle-picker-control/angle-circle.tsx +0 -1
- package/src/angle-picker-control/index.tsx +14 -27
- package/src/angle-picker-control/styles/angle-picker-control-styles.tsx +16 -9
- package/src/animate/index.tsx +75 -0
- package/src/animate/stories/index.tsx +102 -0
- package/src/animate/types.ts +32 -0
- package/src/border-box-control/stories/index.tsx +1 -1
- package/src/box-control/axial-input-controls.tsx +1 -1
- package/src/circular-option-picker/style.scss +10 -0
- package/src/color-indicator/style.scss +1 -0
- package/src/color-picker/README.md +2 -2
- package/src/color-picker/color-input.tsx +1 -12
- package/src/color-picker/component.tsx +9 -18
- package/src/color-picker/hex-input.tsx +2 -7
- package/src/color-picker/hsl-input.tsx +2 -7
- package/src/color-picker/input-with-slider.tsx +1 -9
- package/src/color-picker/legacy-adapter.tsx +1 -2
- package/src/color-picker/picker.tsx +5 -6
- package/src/color-picker/rgb-input.tsx +2 -7
- package/src/color-picker/stories/index.tsx +51 -0
- package/src/color-picker/test/{index.js → index.tsx} +36 -18
- package/src/color-picker/types.ts +128 -1
- package/src/color-picker/use-deprecated-props.ts +2 -53
- package/src/combobox-control/stories/index.tsx +1 -1
- package/src/custom-gradient-picker/{constants.js → constants.ts} +2 -2
- package/src/custom-gradient-picker/gradient-bar/{control-points.js → control-points.tsx} +171 -134
- package/src/custom-gradient-picker/gradient-bar/{index.js → index.tsx} +32 -10
- package/src/custom-gradient-picker/gradient-bar/test/{utils.js → utils.ts} +58 -31
- package/src/custom-gradient-picker/gradient-bar/utils.ts +193 -0
- package/src/custom-gradient-picker/{index.js → index.tsx} +63 -22
- package/src/custom-gradient-picker/serializer.ts +82 -0
- package/src/custom-gradient-picker/stories/index.tsx +45 -0
- package/src/custom-gradient-picker/style.scss +25 -4
- package/src/custom-gradient-picker/test/{serializer.js → serializer.ts} +39 -33
- package/src/custom-gradient-picker/types.ts +137 -0
- package/src/custom-gradient-picker/{utils.js → utils.ts} +37 -22
- package/src/custom-select-control/test/index.js +6 -4
- package/src/{color-list-picker → duotone-picker/color-list-picker}/index.tsx +7 -6
- package/src/{color-list-picker → duotone-picker/color-list-picker}/types.ts +2 -2
- package/src/duotone-picker/{custom-duotone-bar.js → custom-duotone-bar.tsx} +7 -1
- package/src/duotone-picker/{duotone-picker.js → duotone-picker.tsx} +39 -2
- package/src/duotone-picker/{duotone-swatch.js → duotone-swatch.tsx} +2 -1
- package/src/duotone-picker/stories/{duotone-picker.js → duotone-picker.tsx} +15 -8
- package/src/duotone-picker/stories/{duotone-swatch.js → duotone-swatch.tsx} +9 -3
- package/src/duotone-picker/types.ts +61 -0
- package/src/duotone-picker/{utils.js → utils.ts} +29 -14
- package/src/flex/flex-item/README.md +1 -1
- package/src/form-token-field/README.md +1 -0
- package/src/form-token-field/index.tsx +10 -3
- package/src/form-token-field/style.scss +0 -7
- package/src/form-token-field/test/index.tsx +1 -0
- package/src/form-token-field/types.ts +6 -0
- package/src/gradient-picker/README.md +16 -23
- package/src/gradient-picker/{index.js → index.tsx} +70 -16
- package/src/gradient-picker/stories/{index.js → index.tsx} +19 -8
- package/src/gradient-picker/types.ts +89 -0
- package/src/item-group/test/index.js +5 -3
- package/src/palette-edit/index.tsx +4 -5
- package/src/resizable-box/resize-tooltip/utils.ts +1 -1
- package/src/sandbox/index.native.js +71 -78
- package/src/slot-fill/test/slot.js +8 -6
- package/src/style.scss +1 -1
- package/src/tab-panel/index.tsx +7 -2
- package/src/tools-panel/test/index.tsx +86 -0
- package/src/tools-panel/tools-panel/hook.ts +44 -4
- package/src/tools-panel/types.ts +1 -0
- package/src/tooltip/test/index.js +251 -301
- package/src/utils/input/input-control.js +1 -0
- package/tsconfig.json +1 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/color-list-picker/index.js.map +0 -1
- package/build-module/color-list-picker/index.js.map +0 -1
- package/build-types/color-list-picker/index.d.ts.map +0 -1
- package/build-types/color-list-picker/types.d.ts.map +0 -1
- package/src/animate/index.js +0 -60
- package/src/animate/stories/index.js +0 -53
- package/src/color-picker/stories/index.js +0 -41
- package/src/custom-gradient-picker/gradient-bar/utils.js +0 -189
- package/src/custom-gradient-picker/serializer.js +0 -48
- package/src/custom-gradient-picker/stories/index.js +0 -33
- /package/build/{color-list-picker → animate}/types.js +0 -0
- /package/build-module/{color-list-picker → animate}/types.js +0 -0
- /package/build-module/{color-list-picker → animate}/types.js.map +0 -0
- /package/{build/color-list-picker → build-module/custom-gradient-picker}/types.js.map +0 -0
- /package/build-types/{color-list-picker → duotone-picker/color-list-picker}/index.d.ts +0 -0
- /package/src/custom-gradient-picker/gradient-bar/{constants.js → constants.ts} +0 -0
- /package/src/custom-gradient-picker/styles/{custom-gradient-picker-styles.js → custom-gradient-picker-styles.tsx} +0 -0
- /package/src/{color-list-picker → duotone-picker/color-list-picker}/style.scss +0 -0
- /package/src/duotone-picker/{index.js → index.ts} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/color-list-picker/index.tsx"],"names":["ColorOption","label","value","colors","disableCustomColors","enableAlpha","onChange","isOpen","setIsOpen","prev","swatch","ColorListPicker","labels","map","index","newColor","newColors","slice"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAIA;AACA;AACA;AAQA,SAASA,WAAT,OAOsB;AAAA,MAPA;AACrBC,IAAAA,KADqB;AAErBC,IAAAA,KAFqB;AAGrBC,IAAAA,MAHqB;AAIrBC,IAAAA,mBAJqB;AAKrBC,IAAAA,WALqB;AAMrBC,IAAAA;AANqB,GAOA;AACrB,QAAM,CAAEC,MAAF,EAAUC,SAAV,IAAwB,uBAAU,KAAV,CAA9B;AACA,SACC,qDACC,4BAAC,eAAD;AACC,IAAA,SAAS,EAAC,6CADX;AAEC,IAAA,OAAO,EAAG,MAAMA,SAAS,CAAIC,IAAF,IAAY,CAAEA,IAAhB;AAF1B,KAIC,4BAAC,cAAD;AAAQ,IAAA,OAAO,EAAC,YAAhB;AAA6B,IAAA,OAAO,EAAG;AAAvC,KACGP,KAAK,GACN,4BAAC,uBAAD;AACC,IAAA,UAAU,EAAGA,KADd;AAEC,IAAA,SAAS,EAAC;AAFX,IADM,GAMN,4BAAC,aAAD;AAAM,IAAA,IAAI,EAAGQ;AAAb,IAPF,EASC,0CAAQT,KAAR,CATD,CAJD,CADD,EAiBGM,MAAM,IACP,4BAAC,qBAAD;AACC,IAAA,SAAS,EAAC,4CADX;AAEC,IAAA,MAAM,EAAGJ,MAFV;AAGC,IAAA,KAAK,EAAGD,KAHT;AAIC,IAAA,SAAS,EAAG,KAJb;AAKC,IAAA,QAAQ,EAAGI,QALZ;AAMC,IAAA,mBAAmB,EAAGF,mBANvB;AAOC,IAAA,WAAW,EAAGC;AAPf,IAlBF,CADD;AA+BA;;AAED,SAASM,eAAT,QAO0B;AAAA,MAPA;AACzBR,IAAAA,MADyB;AAEzBS,IAAAA,MAFyB;AAGzBV,IAAAA,KAAK,GAAG,EAHiB;AAIzBE,IAAAA,mBAJyB;AAKzBC,IAAAA,WALyB;AAMzBC,IAAAA;AANyB,GAOA;AACzB,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGM,MAAM,CAACC,GAAP,CAAY,CAAEZ,KAAF,EAASa,KAAT,KACb,4BAAC,WAAD;AACC,IAAA,GAAG,EAAGA,KADP;AAEC,IAAA,KAAK,EAAGb,KAFT;AAGC,IAAA,KAAK,EAAGC,KAAK,CAAEY,KAAF,CAHd;AAIC,IAAA,MAAM,EAAGX,MAJV;AAKC,IAAA,mBAAmB,EAAGC,mBALvB;AAMC,IAAA,WAAW,EAAGC,WANf;AAOC,IAAA,QAAQ,EAAKU,QAAF,IAAgB;AAC1B,YAAMC,SAAS,GAAGd,KAAK,CAACe,KAAN,EAAlB;AACAD,MAAAA,SAAS,CAAEF,KAAF,CAAT,GAAqBC,QAArB;AACAT,MAAAA,QAAQ,CAAEU,SAAF,CAAR;AACA;AAXF,IADC,CADH,CADD;AAmBA;;eAEcL,e","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { swatch } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport ColorPalette from '../color-palette';\nimport ColorIndicator from '../color-indicator';\nimport Icon from '../icon';\nimport { HStack } from '../h-stack';\nimport type { ColorListPickerProps, ColorOptionProps } from './types';\n\nfunction ColorOption( {\n\tlabel,\n\tvalue,\n\tcolors,\n\tdisableCustomColors,\n\tenableAlpha,\n\tonChange,\n}: ColorOptionProps ) {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName=\"components-color-list-picker__swatch-button\"\n\t\t\t\tonClick={ () => setIsOpen( ( prev ) => ! prev ) }\n\t\t\t>\n\t\t\t\t<HStack justify=\"flex-start\" spacing={ 2 }>\n\t\t\t\t\t{ value ? (\n\t\t\t\t\t\t<ColorIndicator\n\t\t\t\t\t\t\tcolorValue={ value }\n\t\t\t\t\t\t\tclassName=\"components-color-list-picker__swatch-color\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<Icon icon={ swatch } />\n\t\t\t\t\t) }\n\t\t\t\t\t<span>{ label }</span>\n\t\t\t\t</HStack>\n\t\t\t</Button>\n\t\t\t{ isOpen && (\n\t\t\t\t<ColorPalette\n\t\t\t\t\tclassName=\"components-color-list-picker__color-picker\"\n\t\t\t\t\tcolors={ colors }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tclearable={ false }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction ColorListPicker( {\n\tcolors,\n\tlabels,\n\tvalue = [],\n\tdisableCustomColors,\n\tenableAlpha,\n\tonChange,\n}: ColorListPickerProps ) {\n\treturn (\n\t\t<div className=\"components-color-list-picker\">\n\t\t\t{ labels.map( ( label, index ) => (\n\t\t\t\t<ColorOption\n\t\t\t\t\tkey={ index }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tvalue={ value[ index ] }\n\t\t\t\t\tcolors={ colors }\n\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\t\tonChange={ ( newColor ) => {\n\t\t\t\t\t\tconst newColors = value.slice();\n\t\t\t\t\t\tnewColors[ index ] = newColor;\n\t\t\t\t\t\tonChange( newColors );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</div>\n\t);\n}\n\nexport default ColorListPicker;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/color-list-picker/index.tsx"],"names":["useState","swatch","Button","ColorPalette","ColorIndicator","Icon","HStack","ColorOption","label","value","colors","disableCustomColors","enableAlpha","onChange","isOpen","setIsOpen","prev","ColorListPicker","labels","map","index","newColor","newColors","slice"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,oBAAzB;AACA,SAASC,MAAT,QAAuB,kBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,IAAP,MAAiB,SAAjB;AACA,SAASC,MAAT,QAAuB,YAAvB;;AAGA,SAASC,WAAT,OAOsB;AAAA,MAPA;AACrBC,IAAAA,KADqB;AAErBC,IAAAA,KAFqB;AAGrBC,IAAAA,MAHqB;AAIrBC,IAAAA,mBAJqB;AAKrBC,IAAAA,WALqB;AAMrBC,IAAAA;AANqB,GAOA;AACrB,QAAM,CAAEC,MAAF,EAAUC,SAAV,IAAwBf,QAAQ,CAAE,KAAF,CAAtC;AACA,SACC,8BACC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,6CADX;AAEC,IAAA,OAAO,EAAG,MAAMe,SAAS,CAAIC,IAAF,IAAY,CAAEA,IAAhB;AAF1B,KAIC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,YAAhB;AAA6B,IAAA,OAAO,EAAG;AAAvC,KACGP,KAAK,GACN,cAAC,cAAD;AACC,IAAA,UAAU,EAAGA,KADd;AAEC,IAAA,SAAS,EAAC;AAFX,IADM,GAMN,cAAC,IAAD;AAAM,IAAA,IAAI,EAAGR;AAAb,IAPF,EASC,4BAAQO,KAAR,CATD,CAJD,CADD,EAiBGM,MAAM,IACP,cAAC,YAAD;AACC,IAAA,SAAS,EAAC,4CADX;AAEC,IAAA,MAAM,EAAGJ,MAFV;AAGC,IAAA,KAAK,EAAGD,KAHT;AAIC,IAAA,SAAS,EAAG,KAJb;AAKC,IAAA,QAAQ,EAAGI,QALZ;AAMC,IAAA,mBAAmB,EAAGF,mBANvB;AAOC,IAAA,WAAW,EAAGC;AAPf,IAlBF,CADD;AA+BA;;AAED,SAASK,eAAT,QAO0B;AAAA,MAPA;AACzBP,IAAAA,MADyB;AAEzBQ,IAAAA,MAFyB;AAGzBT,IAAAA,KAAK,GAAG,EAHiB;AAIzBE,IAAAA,mBAJyB;AAKzBC,IAAAA,WALyB;AAMzBC,IAAAA;AANyB,GAOA;AACzB,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGK,MAAM,CAACC,GAAP,CAAY,CAAEX,KAAF,EAASY,KAAT,KACb,cAAC,WAAD;AACC,IAAA,GAAG,EAAGA,KADP;AAEC,IAAA,KAAK,EAAGZ,KAFT;AAGC,IAAA,KAAK,EAAGC,KAAK,CAAEW,KAAF,CAHd;AAIC,IAAA,MAAM,EAAGV,MAJV;AAKC,IAAA,mBAAmB,EAAGC,mBALvB;AAMC,IAAA,WAAW,EAAGC,WANf;AAOC,IAAA,QAAQ,EAAKS,QAAF,IAAgB;AAC1B,YAAMC,SAAS,GAAGb,KAAK,CAACc,KAAN,EAAlB;AACAD,MAAAA,SAAS,CAAEF,KAAF,CAAT,GAAqBC,QAArB;AACAR,MAAAA,QAAQ,CAAES,SAAF,CAAR;AACA;AAXF,IADC,CADH,CADD;AAmBA;;AAED,eAAeL,eAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { swatch } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport ColorPalette from '../color-palette';\nimport ColorIndicator from '../color-indicator';\nimport Icon from '../icon';\nimport { HStack } from '../h-stack';\nimport type { ColorListPickerProps, ColorOptionProps } from './types';\n\nfunction ColorOption( {\n\tlabel,\n\tvalue,\n\tcolors,\n\tdisableCustomColors,\n\tenableAlpha,\n\tonChange,\n}: ColorOptionProps ) {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName=\"components-color-list-picker__swatch-button\"\n\t\t\t\tonClick={ () => setIsOpen( ( prev ) => ! prev ) }\n\t\t\t>\n\t\t\t\t<HStack justify=\"flex-start\" spacing={ 2 }>\n\t\t\t\t\t{ value ? (\n\t\t\t\t\t\t<ColorIndicator\n\t\t\t\t\t\t\tcolorValue={ value }\n\t\t\t\t\t\t\tclassName=\"components-color-list-picker__swatch-color\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<Icon icon={ swatch } />\n\t\t\t\t\t) }\n\t\t\t\t\t<span>{ label }</span>\n\t\t\t\t</HStack>\n\t\t\t</Button>\n\t\t\t{ isOpen && (\n\t\t\t\t<ColorPalette\n\t\t\t\t\tclassName=\"components-color-list-picker__color-picker\"\n\t\t\t\t\tcolors={ colors }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tclearable={ false }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction ColorListPicker( {\n\tcolors,\n\tlabels,\n\tvalue = [],\n\tdisableCustomColors,\n\tenableAlpha,\n\tonChange,\n}: ColorListPickerProps ) {\n\treturn (\n\t\t<div className=\"components-color-list-picker\">\n\t\t\t{ labels.map( ( label, index ) => (\n\t\t\t\t<ColorOption\n\t\t\t\t\tkey={ index }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tvalue={ value[ index ] }\n\t\t\t\t\tcolors={ colors }\n\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\t\tonChange={ ( newColor ) => {\n\t\t\t\t\t\tconst newColors = value.slice();\n\t\t\t\t\t\tnewColors[ index ] = newColor;\n\t\t\t\t\t\tonChange( newColors );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</div>\n\t);\n}\n\nexport default ColorListPicker;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/color-list-picker/index.tsx"],"names":[],"mappings":";AAcA,OAAO,KAAK,EAAE,oBAAoB,EAAoB,MAAM,SAAS,CAAC;AA4CtE,iBAAS,eAAe,CAAE,EACzB,MAAM,EACN,MAAM,EACN,KAAU,EACV,mBAAmB,EACnB,WAAW,EACX,QAAQ,GACR,EAAE,oBAAoB,eAoBtB;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/color-list-picker/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,MAAM,MAAM,oBAAoB,GAAG;IAClC;;;;;OAKG;IACH,MAAM,EAAE,KAAK,CAAE;QACd,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,WAAW,CAAE,aAAa,CAAE,OAAO,CAAE,CAAE,CAAC;KAC/C,CAAE,CAAC;IACJ;;OAEG;IACH,MAAM,EAAE,KAAK,CAAE,MAAM,CAAE,CAAC;IACxB;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAE,MAAM,GAAG,SAAS,CAAE,CAAC;IACpC;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,QAAQ,EAAE,CAAE,QAAQ,EAAE,KAAK,CAAE,MAAM,GAAG,SAAS,CAAE,KAAM,IAAI,CAAC;CAC5D,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAClC,oBAAoB,EACpB,QAAQ,GAAG,qBAAqB,GAAG,aAAa,CAChD,GAAG;IACH,KAAK,EAAE,oBAAoB,CAAE,QAAQ,CAAE,CAAE,MAAM,CAAE,CAAC;IAClD,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,CAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,KAAM,IAAI,CAAC;CACnD,CAAC"}
|
package/src/animate/index.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import classnames from 'classnames';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @typedef {'top' | 'top left' | 'top right' | 'middle' | 'middle left' | 'middle right' | 'bottom' | 'bottom left' | 'bottom right'} AppearOrigin
|
|
8
|
-
* @typedef {'left' | 'right'} SlideInOrigin
|
|
9
|
-
* @typedef {{ type: 'appear'; origin?: AppearOrigin }} AppearOptions
|
|
10
|
-
* @typedef {{ type: 'slide-in'; origin?: SlideInOrigin }} SlideInOptions
|
|
11
|
-
* @typedef {{ type: 'loading' }} LoadingOptions
|
|
12
|
-
* @typedef {AppearOptions | SlideInOptions | LoadingOptions} GetAnimateOptions
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/* eslint-disable jsdoc/valid-types */
|
|
16
|
-
/**
|
|
17
|
-
* @param {GetAnimateOptions['type']} type The animation type
|
|
18
|
-
* @return {'top' | 'left'} Default origin
|
|
19
|
-
*/
|
|
20
|
-
function getDefaultOrigin( type ) {
|
|
21
|
-
return type === 'appear' ? 'top' : 'left';
|
|
22
|
-
}
|
|
23
|
-
/* eslint-enable jsdoc/valid-types */
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @param {GetAnimateOptions} options
|
|
27
|
-
*
|
|
28
|
-
* @return {string | undefined} ClassName that applies the animations
|
|
29
|
-
*/
|
|
30
|
-
export function getAnimateClassName( options ) {
|
|
31
|
-
if ( options.type === 'loading' ) {
|
|
32
|
-
return classnames( 'components-animate__loading' );
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const { type, origin = getDefaultOrigin( type ) } = options;
|
|
36
|
-
|
|
37
|
-
if ( type === 'appear' ) {
|
|
38
|
-
const [ yAxis, xAxis = 'center' ] = origin.split( ' ' );
|
|
39
|
-
return classnames( 'components-animate__appear', {
|
|
40
|
-
[ 'is-from-' + xAxis ]: xAxis !== 'center',
|
|
41
|
-
[ 'is-from-' + yAxis ]: yAxis !== 'middle',
|
|
42
|
-
} );
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if ( type === 'slide-in' ) {
|
|
46
|
-
return classnames(
|
|
47
|
-
'components-animate__slide-in',
|
|
48
|
-
'is-from-' + origin
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// @ts-ignore Reason: Planned for deprecation
|
|
56
|
-
export default function Animate( { type, options = {}, children } ) {
|
|
57
|
-
return children( {
|
|
58
|
-
className: getAnimateClassName( { type, ...options } ),
|
|
59
|
-
} );
|
|
60
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal dependencies
|
|
3
|
-
*/
|
|
4
|
-
import Animate from '../';
|
|
5
|
-
import Notice from '../../notice';
|
|
6
|
-
|
|
7
|
-
export default { title: 'Components/Animate', component: Animate };
|
|
8
|
-
|
|
9
|
-
export const _default = () => (
|
|
10
|
-
<Animate>
|
|
11
|
-
{ ( { className } ) => (
|
|
12
|
-
<Notice className={ className } status="success">
|
|
13
|
-
<p>{ `No default animation. Use one of type = "appear", "slide-in", or "loading".` }</p>
|
|
14
|
-
</Notice>
|
|
15
|
-
) }
|
|
16
|
-
</Animate>
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
// Unexported helper for different origins.
|
|
20
|
-
const Appear = ( { origin } ) => (
|
|
21
|
-
<Animate type="appear" options={ { origin } }>
|
|
22
|
-
{ ( { className } ) => (
|
|
23
|
-
<Notice className={ className } status="success">
|
|
24
|
-
<p>Appear animation. Origin: { origin }.</p>
|
|
25
|
-
</Notice>
|
|
26
|
-
) }
|
|
27
|
-
</Animate>
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
export const appearTopLeft = () => <Appear origin="top left" />;
|
|
31
|
-
export const appearTopRight = () => <Appear origin="top right" />;
|
|
32
|
-
export const appearBottomLeft = () => <Appear origin="bottom left" />;
|
|
33
|
-
export const appearBottomRight = () => <Appear origin="bottom right" />;
|
|
34
|
-
|
|
35
|
-
export const loading = () => (
|
|
36
|
-
<Animate type="loading">
|
|
37
|
-
{ ( { className } ) => (
|
|
38
|
-
<Notice className={ className } status="success">
|
|
39
|
-
<p>Loading animation.</p>
|
|
40
|
-
</Notice>
|
|
41
|
-
) }
|
|
42
|
-
</Animate>
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
export const slideIn = () => (
|
|
46
|
-
<Animate type="slide-in">
|
|
47
|
-
{ ( { className } ) => (
|
|
48
|
-
<Notice className={ className } status="success">
|
|
49
|
-
<p>Slide-in animation.</p>
|
|
50
|
-
</Notice>
|
|
51
|
-
) }
|
|
52
|
-
</Animate>
|
|
53
|
-
);
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useState } from '@wordpress/element';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { ColorPicker } from '..';
|
|
10
|
-
|
|
11
|
-
export default {
|
|
12
|
-
component: ColorPicker,
|
|
13
|
-
title: 'Components/ColorPicker',
|
|
14
|
-
argTypes: {
|
|
15
|
-
color: { control: { type: null } },
|
|
16
|
-
copyFormat: {
|
|
17
|
-
control: { type: 'select' },
|
|
18
|
-
options: [ 'rgb', 'hsl', 'hex', undefined ],
|
|
19
|
-
},
|
|
20
|
-
// We can't use a `on*` regex because this component will switch to
|
|
21
|
-
// legacy mode when an onChangeComplete prop is passed.
|
|
22
|
-
onChange: { action: 'onChange' },
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const Template = ( { onChange, ...props } ) => {
|
|
27
|
-
const [ color, setColor ] = useState();
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<ColorPicker
|
|
31
|
-
{ ...props }
|
|
32
|
-
color={ color }
|
|
33
|
-
onChange={ ( ...changeArgs ) => {
|
|
34
|
-
onChange( ...changeArgs );
|
|
35
|
-
setColor( ...changeArgs );
|
|
36
|
-
} }
|
|
37
|
-
/>
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const Default = Template.bind( {} );
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Internal dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { MINIMUM_DISTANCE_BETWEEN_POINTS } from './constants';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Control point for the gradient bar.
|
|
10
|
-
*
|
|
11
|
-
* @typedef {Object} ControlPoint
|
|
12
|
-
* @property {string} color Color of the control point.
|
|
13
|
-
* @property {number} position Integer position of the control point as a percentage.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Color as parsed from the gradient by gradient-parser.
|
|
18
|
-
*
|
|
19
|
-
* @typedef {Object} Color
|
|
20
|
-
* @property {string} r Red component.
|
|
21
|
-
* @property {string} g Green component.
|
|
22
|
-
* @property {string} b Green component.
|
|
23
|
-
* @property {string} [a] Optional alpha component.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Clamps a number between 0 and 100.
|
|
28
|
-
*
|
|
29
|
-
* @param {number} value Value to clamp.
|
|
30
|
-
*
|
|
31
|
-
* @return {number} Value clamped between 0 and 100.
|
|
32
|
-
*/
|
|
33
|
-
export function clampPercent( value ) {
|
|
34
|
-
return Math.max( 0, Math.min( 100, value ) );
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Check if a control point is overlapping with another.
|
|
39
|
-
*
|
|
40
|
-
* @param {ControlPoint[]} value Array of control points.
|
|
41
|
-
* @param {number} initialIndex Index of the position to test.
|
|
42
|
-
* @param {number} newPosition New position of the control point.
|
|
43
|
-
* @param {number} minDistance Distance considered to be overlapping.
|
|
44
|
-
*
|
|
45
|
-
* @return {boolean} True if the point is overlapping.
|
|
46
|
-
*/
|
|
47
|
-
export function isOverlapping(
|
|
48
|
-
value,
|
|
49
|
-
initialIndex,
|
|
50
|
-
newPosition,
|
|
51
|
-
minDistance = MINIMUM_DISTANCE_BETWEEN_POINTS
|
|
52
|
-
) {
|
|
53
|
-
const initialPosition = value[ initialIndex ].position;
|
|
54
|
-
const minPosition = Math.min( initialPosition, newPosition );
|
|
55
|
-
const maxPosition = Math.max( initialPosition, newPosition );
|
|
56
|
-
|
|
57
|
-
return value.some( ( { position }, index ) => {
|
|
58
|
-
return (
|
|
59
|
-
index !== initialIndex &&
|
|
60
|
-
( Math.abs( position - newPosition ) < minDistance ||
|
|
61
|
-
( minPosition < position && position < maxPosition ) )
|
|
62
|
-
);
|
|
63
|
-
} );
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Adds a control point from an array and returns the new array.
|
|
68
|
-
*
|
|
69
|
-
* @param {ControlPoint[]} points Array of control points.
|
|
70
|
-
* @param {number} position Position to insert the new point.
|
|
71
|
-
* @param {Color} color Color to update the control point at index.
|
|
72
|
-
*
|
|
73
|
-
* @return {ControlPoint[]} New array of control points.
|
|
74
|
-
*/
|
|
75
|
-
export function addControlPoint( points, position, color ) {
|
|
76
|
-
const nextIndex = points.findIndex(
|
|
77
|
-
( point ) => point.position > position
|
|
78
|
-
);
|
|
79
|
-
const newPoint = { color, position };
|
|
80
|
-
const newPoints = points.slice();
|
|
81
|
-
newPoints.splice( nextIndex - 1, 0, newPoint );
|
|
82
|
-
return newPoints;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Removes a control point from an array and returns the new array.
|
|
87
|
-
*
|
|
88
|
-
* @param {ControlPoint[]} points Array of control points.
|
|
89
|
-
* @param {number} index Index to remove.
|
|
90
|
-
*
|
|
91
|
-
* @return {ControlPoint[]} New array of control points.
|
|
92
|
-
*/
|
|
93
|
-
export function removeControlPoint( points, index ) {
|
|
94
|
-
return points.filter( ( point, pointIndex ) => {
|
|
95
|
-
return pointIndex !== index;
|
|
96
|
-
} );
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Updates a control point from an array and returns the new array.
|
|
101
|
-
*
|
|
102
|
-
* @param {ControlPoint[]} points Array of control points.
|
|
103
|
-
* @param {number} index Index to update.
|
|
104
|
-
* @param {ControlPoint[]} newPoint New control point to replace the index.
|
|
105
|
-
*
|
|
106
|
-
* @return {ControlPoint[]} New array of control points.
|
|
107
|
-
*/
|
|
108
|
-
export function updateControlPoint( points, index, newPoint ) {
|
|
109
|
-
const newValue = points.slice();
|
|
110
|
-
newValue[ index ] = newPoint;
|
|
111
|
-
return newValue;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Updates the position of a control point from an array and returns the new array.
|
|
116
|
-
*
|
|
117
|
-
* @param {ControlPoint[]} points Array of control points.
|
|
118
|
-
* @param {number} index Index to update.
|
|
119
|
-
* @param {number} newPosition Position to move the control point at index.
|
|
120
|
-
*
|
|
121
|
-
* @return {ControlPoint[]} New array of control points.
|
|
122
|
-
*/
|
|
123
|
-
export function updateControlPointPosition( points, index, newPosition ) {
|
|
124
|
-
if ( isOverlapping( points, index, newPosition ) ) {
|
|
125
|
-
return points;
|
|
126
|
-
}
|
|
127
|
-
const newPoint = {
|
|
128
|
-
...points[ index ],
|
|
129
|
-
position: newPosition,
|
|
130
|
-
};
|
|
131
|
-
return updateControlPoint( points, index, newPoint );
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Updates the position of a control point from an array and returns the new array.
|
|
136
|
-
*
|
|
137
|
-
* @param {ControlPoint[]} points Array of control points.
|
|
138
|
-
* @param {number} index Index to update.
|
|
139
|
-
* @param {Color} newColor Color to update the control point at index.
|
|
140
|
-
*
|
|
141
|
-
* @return {ControlPoint[]} New array of control points.
|
|
142
|
-
*/
|
|
143
|
-
export function updateControlPointColor( points, index, newColor ) {
|
|
144
|
-
const newPoint = {
|
|
145
|
-
...points[ index ],
|
|
146
|
-
color: newColor,
|
|
147
|
-
};
|
|
148
|
-
return updateControlPoint( points, index, newPoint );
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Updates the position of a control point from an array and returns the new array.
|
|
153
|
-
*
|
|
154
|
-
* @param {ControlPoint[]} points Array of control points.
|
|
155
|
-
* @param {number} position Position of the color stop.
|
|
156
|
-
* @param {string} newColor Color to update the control point at index.
|
|
157
|
-
*
|
|
158
|
-
* @return {ControlPoint[]} New array of control points.
|
|
159
|
-
*/
|
|
160
|
-
export function updateControlPointColorByPosition(
|
|
161
|
-
points,
|
|
162
|
-
position,
|
|
163
|
-
newColor
|
|
164
|
-
) {
|
|
165
|
-
const index = points.findIndex( ( point ) => point.position === position );
|
|
166
|
-
return updateControlPointColor( points, index, newColor );
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Gets the horizontal coordinate when dragging a control point with the mouse.
|
|
171
|
-
*
|
|
172
|
-
* @param {number} mouseXCoordinate Horizontal coordinate of the mouse position.
|
|
173
|
-
* @param {Element} containerElement Container for the gradient picker.
|
|
174
|
-
*
|
|
175
|
-
* @return {number | undefined} Whole number percentage from the left.
|
|
176
|
-
*/
|
|
177
|
-
export function getHorizontalRelativeGradientPosition(
|
|
178
|
-
mouseXCoordinate,
|
|
179
|
-
containerElement
|
|
180
|
-
) {
|
|
181
|
-
if ( ! containerElement ) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
const { x, width } = containerElement.getBoundingClientRect();
|
|
185
|
-
const absolutePositionValue = mouseXCoordinate - x;
|
|
186
|
-
return Math.round(
|
|
187
|
-
clampPercent( ( absolutePositionValue * 100 ) / width )
|
|
188
|
-
);
|
|
189
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
|
|
3
|
-
export function serializeGradientColor( { type, value } ) {
|
|
4
|
-
if ( type === 'literal' ) {
|
|
5
|
-
return value;
|
|
6
|
-
}
|
|
7
|
-
if ( type === 'hex' ) {
|
|
8
|
-
return `#${ value }`;
|
|
9
|
-
}
|
|
10
|
-
return `${ type }(${ value.join( ',' ) })`;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function serializeGradientPosition( position ) {
|
|
14
|
-
if ( ! position ) {
|
|
15
|
-
return '';
|
|
16
|
-
}
|
|
17
|
-
const { value, type } = position;
|
|
18
|
-
return `${ value }${ type }`;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function serializeGradientColorStop( { type, value, length } ) {
|
|
22
|
-
return `${ serializeGradientColor( {
|
|
23
|
-
type,
|
|
24
|
-
value,
|
|
25
|
-
} ) } ${ serializeGradientPosition( length ) }`;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function serializeGradientOrientation( orientation ) {
|
|
29
|
-
if ( ! orientation || orientation.type !== 'angular' ) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
return `${ orientation.value }deg`;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function serializeGradient( { type, orientation, colorStops } ) {
|
|
36
|
-
const serializedOrientation = serializeGradientOrientation( orientation );
|
|
37
|
-
const serializedColorStops = colorStops
|
|
38
|
-
.sort( ( colorStop1, colorStop2 ) => {
|
|
39
|
-
return (
|
|
40
|
-
( colorStop1?.length?.value ?? 0 ) -
|
|
41
|
-
( colorStop2?.length?.value ?? 0 )
|
|
42
|
-
);
|
|
43
|
-
} )
|
|
44
|
-
.map( serializeGradientColorStop );
|
|
45
|
-
return `${ type }(${ [ serializedOrientation, ...serializedColorStops ]
|
|
46
|
-
.filter( Boolean )
|
|
47
|
-
.join( ',' ) })`;
|
|
48
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useState } from '@wordpress/element';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import CustomGradientPicker from '../';
|
|
10
|
-
|
|
11
|
-
export default {
|
|
12
|
-
title: 'Components/CustomGradientPicker',
|
|
13
|
-
component: CustomGradientPicker,
|
|
14
|
-
argTypes: {
|
|
15
|
-
__nextHasNoMargin: { control: { type: 'boolean' } },
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const CustomGradientPickerWithState = ( props ) => {
|
|
20
|
-
const [ gradient, setGradient ] = useState();
|
|
21
|
-
return (
|
|
22
|
-
<CustomGradientPicker
|
|
23
|
-
{ ...props }
|
|
24
|
-
value={ gradient }
|
|
25
|
-
onChange={ setGradient }
|
|
26
|
-
/>
|
|
27
|
-
);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const Default = CustomGradientPickerWithState.bind( {} );
|
|
31
|
-
Default.args = {
|
|
32
|
-
__nextHasNoMargin: true,
|
|
33
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|