@wordpress/components 19.8.3 → 19.10.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 +42 -0
- package/CONTRIBUTING.md +80 -7
- package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js +11 -11
- package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
- package/build/angle-picker-control/angle-circle.js +5 -7
- package/build/angle-picker-control/angle-circle.js.map +1 -1
- package/build/box-control/index.js +0 -21
- package/build/box-control/index.js.map +1 -1
- package/build/box-control/utils.js +1 -8
- package/build/box-control/utils.js.map +1 -1
- package/build/button/index.js +3 -5
- package/build/button/index.js.map +1 -1
- package/build/circular-option-picker/index.js +1 -2
- package/build/circular-option-picker/index.js.map +1 -1
- package/build/disabled/index.js +4 -76
- package/build/disabled/index.js.map +1 -1
- package/build/heading/hook.js +1 -1
- package/build/heading/hook.js.map +1 -1
- package/build/input-control/index.js +27 -4
- package/build/input-control/index.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +42 -30
- package/build/input-control/styles/input-control-styles.js.map +1 -1
- package/build/mobile/bottom-sheet-select-control/index.native.js +1 -0
- package/build/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build/navigation/styles/navigation-styles.js +12 -12
- package/build/navigation/styles/navigation-styles.js.map +1 -1
- package/build/notice/index.native.js +44 -40
- package/build/notice/index.native.js.map +1 -1
- package/build/notice/list.native.js +27 -45
- package/build/notice/list.native.js.map +1 -1
- package/build/popover/index.js +6 -52
- package/build/popover/index.js.map +1 -1
- package/build/sandbox/index.js +2 -2
- package/build/sandbox/index.js.map +1 -1
- package/build/select-control/index.js +31 -4
- package/build/select-control/index.js.map +1 -1
- package/build/select-control/styles/select-control-styles.js +8 -8
- package/build/select-control/styles/select-control-styles.js.map +1 -1
- package/build/surface/styles.js +8 -8
- package/build/surface/styles.js.map +1 -1
- package/build/text/hook.js +5 -5
- package/build/text/hook.js.map +1 -1
- package/build/text/styles/text-mixins.native.js +1 -1
- package/build/text/styles/text-mixins.native.js.map +1 -1
- package/build/text/styles.js +7 -7
- package/build/text/styles.js.map +1 -1
- package/build/text-control/index.js +35 -28
- package/build/text-control/index.js.map +1 -1
- package/build/text-control/types.js +6 -0
- package/build/text-control/types.js.map +1 -0
- package/build/toggle-group-control/toggle-group-control-option-icon/component.js +6 -4
- package/build/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
- package/build/tools-panel/tools-panel-header/component.js +52 -36
- package/build/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build/ui/spinner/component.js +1 -1
- package/build/ui/spinner/component.js.map +1 -1
- package/build/unit-control/index.js +3 -3
- package/build/unit-control/index.js.map +1 -1
- package/build/unit-control/styles/unit-control-styles.js +11 -20
- package/build/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build/unit-control/utils.js.map +1 -1
- package/build/utils/colors-values.js +9 -24
- package/build/utils/colors-values.js.map +1 -1
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js +11 -11
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
- package/build-module/angle-picker-control/angle-circle.js +5 -7
- package/build-module/angle-picker-control/angle-circle.js.map +1 -1
- package/build-module/box-control/index.js +1 -20
- package/build-module/box-control/index.js.map +1 -1
- package/build-module/box-control/utils.js +0 -6
- package/build-module/box-control/utils.js.map +1 -1
- package/build-module/button/index.js +3 -4
- package/build-module/button/index.js.map +1 -1
- package/build-module/circular-option-picker/index.js +1 -2
- package/build-module/circular-option-picker/index.js.map +1 -1
- package/build-module/disabled/index.js +5 -76
- package/build-module/disabled/index.js.map +1 -1
- package/build-module/heading/hook.js +1 -1
- package/build-module/heading/hook.js.map +1 -1
- package/build-module/input-control/index.js +24 -3
- package/build-module/input-control/index.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +42 -30
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/mobile/bottom-sheet-select-control/index.native.js +1 -0
- package/build-module/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build-module/navigation/styles/navigation-styles.js +13 -13
- package/build-module/navigation/styles/navigation-styles.js.map +1 -1
- package/build-module/notice/index.native.js +45 -41
- package/build-module/notice/index.native.js.map +1 -1
- package/build-module/notice/list.native.js +28 -46
- package/build-module/notice/list.native.js.map +1 -1
- package/build-module/popover/index.js +6 -52
- package/build-module/popover/index.js.map +1 -1
- package/build-module/sandbox/index.js +2 -2
- package/build-module/sandbox/index.js.map +1 -1
- package/build-module/select-control/index.js +29 -3
- package/build-module/select-control/index.js.map +1 -1
- package/build-module/select-control/styles/select-control-styles.js +8 -8
- package/build-module/select-control/styles/select-control-styles.js.map +1 -1
- package/build-module/surface/styles.js +8 -8
- package/build-module/surface/styles.js.map +1 -1
- package/build-module/text/hook.js +5 -5
- package/build-module/text/hook.js.map +1 -1
- package/build-module/text/styles/text-mixins.native.js +2 -2
- package/build-module/text/styles/text-mixins.native.js.map +1 -1
- package/build-module/text/styles.js +7 -7
- package/build-module/text/styles.js.map +1 -1
- package/build-module/text-control/index.js +35 -27
- package/build-module/text-control/index.js.map +1 -1
- package/build-module/text-control/types.js +2 -0
- package/build-module/text-control/types.js.map +1 -0
- package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js +1 -5
- package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel-header/component.js +51 -36
- package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build-module/ui/spinner/component.js +1 -1
- package/build-module/ui/spinner/component.js.map +1 -1
- package/build-module/unit-control/index.js +3 -3
- package/build-module/unit-control/index.js.map +1 -1
- package/build-module/unit-control/styles/unit-control-styles.js +11 -20
- package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build-module/unit-control/utils.js.map +1 -1
- package/build-module/utils/colors-values.js +19 -23
- package/build-module/utils/colors-values.js.map +1 -1
- package/build-style/style-rtl.css +24 -0
- package/build-style/style.css +24 -0
- package/build-types/button/index.d.ts.map +1 -1
- package/build-types/circular-option-picker/index.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +3 -3
- package/build-types/disabled/index.d.ts.map +1 -1
- package/build-types/input-control/index.d.ts +23 -3
- package/build-types/input-control/index.d.ts.map +1 -1
- package/build-types/input-control/input-field.d.ts +1 -1
- package/build-types/input-control/input-field.d.ts.map +1 -1
- package/build-types/input-control/stories/index.d.ts +5 -5
- package/build-types/input-control/styles/input-control-styles.d.ts +1 -0
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/input-control/types.d.ts +79 -3
- package/build-types/input-control/types.d.ts.map +1 -1
- package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
- package/build-types/popover/index.d.ts +0 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/select-control/index.d.ts +30 -26
- package/build-types/select-control/index.d.ts.map +1 -1
- package/build-types/select-control/stories/index.d.ts +23 -0
- package/build-types/select-control/stories/index.d.ts.map +1 -0
- package/build-types/select-control/styles/select-control-styles.d.ts +3 -4
- package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/select-control/test/select-control.d.ts +2 -0
- package/build-types/select-control/test/select-control.d.ts.map +1 -0
- package/build-types/select-control/types.d.ts +52 -1
- package/build-types/select-control/types.d.ts.map +1 -1
- package/build-types/text-control/index.d.ts +32 -0
- package/build-types/text-control/index.d.ts.map +1 -0
- package/build-types/text-control/stories/index.d.ts +13 -0
- package/build-types/text-control/stories/index.d.ts.map +1 -0
- package/build-types/text-control/types.d.ts +25 -0
- package/build-types/text-control/types.d.ts.map +1 -0
- package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
- package/build-types/tools-panel/types.d.ts +0 -1
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts +2 -2
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
- package/build-types/unit-control/test/index.d.ts +2 -0
- package/build-types/unit-control/test/index.d.ts.map +1 -0
- package/build-types/unit-control/test/utils.d.ts +2 -0
- package/build-types/unit-control/test/utils.d.ts.map +1 -0
- package/build-types/unit-control/types.d.ts +1 -1
- package/build-types/unit-control/types.d.ts.map +1 -1
- package/build-types/unit-control/utils.d.ts +3 -3
- package/build-types/unit-control/utils.d.ts.map +1 -1
- package/build-types/utils/colors-values.d.ts +6 -146
- package/build-types/utils/colors-values.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/alignment-matrix-control/styles/alignment-matrix-control-styles.js +5 -3
- package/src/angle-picker-control/angle-circle.js +3 -3
- package/src/box-control/README.md +0 -74
- package/src/box-control/index.js +0 -15
- package/src/box-control/stories/index.js +0 -29
- package/src/box-control/utils.js +0 -7
- package/src/button/index.js +2 -4
- package/src/button/test/index.js +16 -1
- package/src/circular-option-picker/index.js +1 -2
- package/src/color-palette/README.md +0 -1
- package/src/color-palette/test/__snapshots__/index.js.snap +2 -3
- package/src/confirm-dialog/stories/index.js +87 -99
- package/src/date-time/stories/index.js +19 -0
- package/src/date-time/test/date.js +107 -78
- package/src/dimension-control/test/__snapshots__/index.test.js.snap +4 -4
- package/src/disabled/index.js +5 -90
- package/src/form-file-upload/test/index.js +15 -12
- package/src/heading/hook.ts +1 -1
- package/src/heading/test/__snapshots__/index.js.snap +3 -3
- package/src/input-control/README.md +3 -3
- package/src/input-control/index.tsx +23 -3
- package/src/input-control/stories/index.tsx +63 -0
- package/src/input-control/styles/input-control-styles.tsx +20 -7
- package/src/input-control/types.ts +79 -2
- package/src/menu-item/style.scss +10 -0
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/test/navigation-container.native.js +8 -1
- package/src/mobile/bottom-sheet-select-control/index.native.js +1 -0
- package/src/mobile/html-text-input/style.android.scss +1 -0
- package/src/mobile/html-text-input/style.ios.scss +1 -0
- package/src/mobile/link-settings/test/link-settings-navigation.native.js +9 -1
- package/src/navigation/styles/navigation-styles.js +5 -5
- package/src/notice/index.native.js +44 -54
- package/src/notice/list.native.js +27 -51
- package/src/notice/style.native.scss +1 -0
- package/src/popover/index.js +5 -51
- package/src/query-controls/README.md +2 -2
- package/src/sandbox/index.js +2 -2
- package/src/select-control/README.md +2 -2
- package/src/select-control/index.tsx +30 -29
- package/src/select-control/stories/index.tsx +90 -0
- package/src/select-control/styles/select-control-styles.ts +10 -9
- package/src/select-control/test/{select-control.js → select-control.tsx} +2 -2
- package/src/select-control/types.ts +66 -1
- package/src/surface/styles.js +1 -1
- package/src/text/hook.js +1 -1
- package/src/text/styles/text-mixins.native.js +2 -2
- package/src/text/styles.js +1 -1
- package/src/text/test/__snapshots__/{index.js.snap → index.tsx.snap} +16 -0
- package/src/text/test/{index.js → index.tsx} +12 -6
- package/src/text-control/index.tsx +84 -0
- package/src/text-control/stories/index.tsx +66 -0
- package/src/text-control/types.ts +29 -0
- package/src/toggle-group-control/toggle-group-control-option-icon/component.tsx +1 -5
- package/src/toolbar-group/style.scss +20 -0
- package/src/tools-panel/test/__snapshots__/index.js.snap +2 -2
- package/src/tools-panel/test/index.js +71 -18
- package/src/tools-panel/tools-panel-header/component.tsx +75 -33
- package/src/tools-panel/types.ts +0 -1
- package/src/tooltip/test/index.js +6 -0
- package/src/ui/spinner/component.js +1 -1
- package/src/ui/spinner/test/__snapshots__/index.js.snap +3 -3
- package/src/unit-control/index.tsx +2 -5
- package/src/unit-control/styles/unit-control-styles.ts +3 -13
- package/src/unit-control/test/__snapshots__/index.tsx.snap +33 -0
- package/src/unit-control/test/{index.js → index.tsx} +214 -165
- package/src/unit-control/test/{utils.js → utils.ts} +38 -19
- package/src/unit-control/types.ts +4 -1
- package/src/unit-control/utils.ts +5 -3
- package/src/utils/colors-values.js +18 -22
- package/tsconfig.json +9 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/box-control/visualizer.js +0 -165
- package/build/box-control/visualizer.js.map +0 -1
- package/build-module/box-control/visualizer.js +0 -154
- package/build-module/box-control/visualizer.js.map +0 -1
- package/src/box-control/visualizer.js +0 -116
- package/src/input-control/stories/index.js +0 -71
- package/src/select-control/stories/index.js +0 -104
- package/src/text-control/index.js +0 -72
- package/src/text-control/stories/index.js +0 -46
|
@@ -9,27 +9,27 @@ import { css } from '@emotion/react';
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { COLORS, CONFIG } from '../utils';
|
|
12
|
-
export const Text = /*#__PURE__*/css("color:", COLORS.
|
|
12
|
+
export const Text = /*#__PURE__*/css("color:", COLORS.gray[900], ";line-height:", CONFIG.fontLineHeightBase, ";margin:0;" + (process.env.NODE_ENV === "production" ? "" : ";label:Text;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvdGV4dC9zdHlsZXMuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBVXVCIiwiZmlsZSI6IkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvdGV4dC9zdHlsZXMuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEV4dGVybmFsIGRlcGVuZGVuY2llc1xuICovXG5pbXBvcnQgeyBjc3MgfSBmcm9tICdAZW1vdGlvbi9yZWFjdCc7XG5cbi8qKlxuICogSW50ZXJuYWwgZGVwZW5kZW5jaWVzXG4gKi9cbmltcG9ydCB7IENPTE9SUywgQ09ORklHIH0gZnJvbSAnLi4vdXRpbHMnO1xuXG5leHBvcnQgY29uc3QgVGV4dCA9IGNzc2Bcblx0Y29sb3I6ICR7IENPTE9SUy5ncmF5WyA5MDAgXSB9O1xuXHRsaW5lLWhlaWdodDogJHsgQ09ORklHLmZvbnRMaW5lSGVpZ2h0QmFzZSB9O1xuXHRtYXJnaW46IDA7XG5gO1xuXG5leHBvcnQgY29uc3QgYmxvY2sgPSBjc3NgXG5cdGRpc3BsYXk6IGJsb2NrO1xuYDtcblxuZXhwb3J0IGNvbnN0IHBvc2l0aXZlID0gY3NzYFxuXHRjb2xvcjogJHsgQ09MT1JTLmFsZXJ0LmdyZWVuIH07XG5gO1xuXG5leHBvcnQgY29uc3QgZGVzdHJ1Y3RpdmUgPSBjc3NgXG5cdGNvbG9yOiAkeyBDT0xPUlMuYWxlcnQucmVkIH07XG5gO1xuXG5leHBvcnQgY29uc3QgbXV0ZWQgPSBjc3NgXG5cdGNvbG9yOiAkeyBDT0xPUlMubWVkaXVtR3JheS50ZXh0IH07XG5gO1xuXG5leHBvcnQgY29uc3QgaGlnaGxpZ2h0ZXJUZXh0ID0gY3NzYFxuXHRtYXJrIHtcblx0XHRiYWNrZ3JvdW5kOiAkeyBDT0xPUlMuYWxlcnQueWVsbG93IH07XG5cdFx0Ym9yZGVyLXJhZGl1czogMnB4O1xuXHRcdGJveC1zaGFkb3c6IDAgMCAwIDFweCByZ2JhKCAwLCAwLCAwLCAwLjA1ICkgaW5zZXQsXG5cdFx0XHQwIC0xcHggMCByZ2JhKCAwLCAwLCAwLCAwLjEgKSBpbnNldDtcblx0fVxuYDtcblxuZXhwb3J0IGNvbnN0IHVwcGVyQ2FzZSA9IGNzc2Bcblx0dGV4dC10cmFuc2Zvcm06IHVwcGVyY2FzZTtcbmA7XG4iXX0= */");
|
|
13
13
|
export const block = process.env.NODE_ENV === "production" ? {
|
|
14
14
|
name: "4zleql",
|
|
15
15
|
styles: "display:block"
|
|
16
16
|
} : {
|
|
17
17
|
name: "14aceuy-block",
|
|
18
18
|
styles: "display:block;label:block;",
|
|
19
|
-
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
19
|
+
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvdGV4dC9zdHlsZXMuanMiXSw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MCwgMC4wNSApIGluc2V0LFxuXHRcdFx0MCAtMXB4IDAgcmdiYSggMCwgMCwgMCwgMC4xICkgaW5zZXQ7XG5cdH1cbmA7XG5cbmV4cG9ydCBjb25zdCB1cHBlckNhc2UgPSBjc3NgXG5cdHRleHQtdHJhbnNmb3JtOiB1cHBlcmNhc2U7XG5gO1xuIl19 */",
|
|
20
20
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
21
21
|
};
|
|
22
|
-
export const positive = /*#__PURE__*/css("color:", COLORS.alert.green, ";" + (process.env.NODE_ENV === "production" ? "" : ";label:positive;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
23
|
-
export const destructive = /*#__PURE__*/css("color:", COLORS.alert.red, ";" + (process.env.NODE_ENV === "production" ? "" : ";label:destructive;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
24
|
-
export const muted = /*#__PURE__*/css("color:", COLORS.mediumGray.text, ";" + (process.env.NODE_ENV === "production" ? "" : ";label:muted;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
25
|
-
export const highlighterText = /*#__PURE__*/css("mark{background:", COLORS.alert.yellow, ";border-radius:2px;box-shadow:0 0 0 1px rgba( 0, 0, 0, 0.05 ) inset,0 -1px 0 rgba( 0, 0, 0, 0.1 ) inset;}" + (process.env.NODE_ENV === "production" ? "" : ";label:highlighterText;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
22
|
+
export const positive = /*#__PURE__*/css("color:", COLORS.alert.green, ";" + (process.env.NODE_ENV === "production" ? "" : ";label:positive;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvdGV4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HggcmdiYSggMCwgMCwgMCwgMC4wNSApIGluc2V0LFxuXHRcdFx0MCAtMXB4IDAgcmdiYSggMCwgMCwgMCwgMC4xICkgaW5zZXQ7XG5cdH1cbmA7XG5cbmV4cG9ydCBjb25zdCB1cHBlckNhc2UgPSBjc3NgXG5cdHRleHQtdHJhbnNmb3JtOiB1cHBlcmNhc2U7XG5gO1xuIl19 */");
|
|
23
|
+
export const destructive = /*#__PURE__*/css("color:", COLORS.alert.red, ";" + (process.env.NODE_ENV === "production" ? "" : ";label:destructive;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvdGV4dC9zdHlsZXMuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBd0I4QiIsImZpbGUiOiJAd29yZHByZXNzL2NvbXBvbmVudHMvc3JjL3RleHQvc3R5bGVzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBFeHRlcm5hbCBkZXBlbmRlbmNpZXNcbiAqL1xuaW1wb3J0IHsgY3NzIH0gZnJvbSAnQGVtb3Rpb24vcmVhY3QnO1xuXG4vKipcbiAqIEludGVybmFsIGRlcGVuZGVuY2llc1xuICovXG5pbXBvcnQgeyBDT0xPUlMsIENPTkZJRyB9IGZyb20gJy4uL3V0aWxzJztcblxuZXhwb3J0IGNvbnN0IFRleHQgPSBjc3NgXG5cdGNvbG9yOiAkeyBDT0xPUlMuZ3JheVsgOTAwIF0gfTtcblx0bGluZS1oZWlnaHQ6ICR7IENPTkZJRy5mb250TGluZUhlaWdodEJhc2UgfTtcblx0bWFyZ2luOiAwO1xuYDtcblxuZXhwb3J0IGNvbnN0IGJsb2NrID0gY3NzYFxuXHRkaXNwbGF5OiBibG9jaztcbmA7XG5cbmV4cG9ydCBjb25zdCBwb3NpdGl2ZSA9IGNzc2Bcblx0Y29sb3I6ICR7IENPTE9SUy5hbGVydC5ncmVlbiB9O1xuYDtcblxuZXhwb3J0IGNvbnN0IGRlc3RydWN0aXZlID0gY3NzYFxuXHRjb2xvcjogJHsgQ09MT1JTLmFsZXJ0LnJlZCB9O1xuYDtcblxuZXhwb3J0IGNvbnN0IG11dGVkID0gY3NzYFxuXHRjb2xvcjogJHsgQ09MT1JTLm1lZGl1bUdyYXkudGV4dCB9O1xuYDtcblxuZXhwb3J0IGNvbnN0IGhpZ2hsaWdodGVyVGV4dCA9IGNzc2Bcblx0bWFyayB7XG5cdFx0YmFja2dyb3VuZDogJHsgQ09MT1JTLmFsZXJ0LnllbGxvdyB9O1xuXHRcdGJvcmRlci1yYWRpdXM6IDJweDtcblx0XHRib3gtc2hhZG93OiAwIDAgMCAxcHggcmdiYSggMCwgMCwgMCwgMC4wNSApIGluc2V0LFxuXHRcdFx0MCAtMXB4IDAgcmdiYSggMCwgMCwgMCwgMC4xICkgaW5zZXQ7XG5cdH1cbmA7XG5cbmV4cG9ydCBjb25zdCB1cHBlckNhc2UgPSBjc3NgXG5cdHRleHQtdHJhbnNmb3JtOiB1cHBlcmNhc2U7XG5gO1xuIl19 */");
|
|
24
|
+
export const muted = /*#__PURE__*/css("color:", COLORS.mediumGray.text, ";" + (process.env.NODE_ENV === "production" ? "" : ";label:muted;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvdGV4dC9zdHlsZXMuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBNEJ3QiIsImZpbGUiOiJAd29yZHByZXNzL2NvbXBvbmVudHMvc3JjL3RleHQvc3R5bGVzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBFeHRlcm5hbCBkZXBlbmRlbmNpZXNcbiAqL1xuaW1wb3J0IHsgY3NzIH0gZnJvbSAnQGVtb3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PURE__*/css("mark{background:", COLORS.alert.yellow, ";border-radius:2px;box-shadow:0 0 0 1px rgba( 0, 0, 0, 0.05 ) inset,0 -1px 0 rgba( 0, 0, 0, 0.1 ) inset;}" + (process.env.NODE_ENV === "production" ? "" : ";label:highlighterText;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvdGV4dC9zdHlsZXMuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBZ0NrQyIsImZpbGUiOiJAd29yZHByZXNzL2NvbXBvbmVudHMvc3JjL3RleHQvc3R5bGVzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBFeHRlcm5hbCBkZXBlbmRlbmNpZXNcbiAqL1xuaW1wb3J0IHsgY3NzIH0gZnJvbSAnQGVtb3Rpb24vcmVhY3QnO1xuXG4vKipcbiAqIEludGVybmFsIGRlcGVuZGVuY2llc1xuICovXG5pbXBvcnQgeyBDT0xPUlMsIENPTkZJRyB9IGZyb20gJy4uL3V0aWxzJztcblxuZXhwb3J0IGNvbnN0IFRleHQgPSBjc3NgXG5cdGNvbG9yOiAkeyBDT0xPUlMuZ3JheVsgOTAwIF0gfTtcblx0bGluZS1oZWlnaHQ6ICR7IENPTkZJRy5mb250TGluZUhlaWdodEJhc2UgfTtcblx0bWFyZ2luOiAwO1xuYDtcblxuZXhwb3J0IGNvbnN0IGJsb2NrID0gY3NzYFxuXHRkaXNwbGF5OiBibG9jaztcbmA7XG5cbmV4cG9ydCBjb25zdCBwb3NpdGl2ZSA9IGNzc2Bcblx0Y29sb3I6ICR7IENPTE9SUy5hbGVydC5ncmVlbiB9O1xuYDtcblxuZXhwb3J0IGNvbnN0IGRlc3RydWN0aXZlID0gY3NzYFxuXHRjb2xvcjogJHsgQ09MT1JTLmFsZXJ0LnJlZCB9O1xuYDtcblxuZXhwb3J0IGNvbnN0IG11dGVkID0gY3NzYFxuXHRjb2xvcjogJHsgQ09MT1JTLm1lZGl1bUdyYXkudGV4dCB9O1xuYDtcblxuZXhwb3J0IGNvbnN0IGhpZ2hsaWdodGVyVGV4dCA9IGNzc2Bcblx0bWFyayB7XG5cdFx0YmFja2dyb3VuZDogJHsgQ09MT1JTLmFsZXJ0LnllbGxvdyB9O1xuXHRcdGJvcmRlci1yYWRpdXM6IDJweDtcblx0XHRib3gtc2hhZG93OiAwIDAgMCAxcHggcmdiYSggMCwgMCwgMCwgMC4wNSApIGluc2V0LFxuXHRcdFx0MCAtMXB4IDAgcmdiYSggMCwgMCwgMCwgMC4xICkgaW5zZXQ7XG5cdH1cbmA7XG5cbmV4cG9ydCBjb25zdCB1cHBlckNhc2UgPSBjc3NgXG5cdHRleHQtdHJhbnNmb3JtOiB1cHBlcmNhc2U7XG5gO1xuIl19 */");
|
|
26
26
|
export const upperCase = process.env.NODE_ENV === "production" ? {
|
|
27
27
|
name: "50zrmy",
|
|
28
28
|
styles: "text-transform:uppercase"
|
|
29
29
|
} : {
|
|
30
30
|
name: "1mrt3zt-upperCase",
|
|
31
31
|
styles: "text-transform:uppercase;label:upperCase;",
|
|
32
|
-
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
32
|
+
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvdGV4dC9zdHlsZXMuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBeUM0QiIsImZpbGUiOiJAd29yZHByZXNzL2NvbXBvbmVudHMvc3JjL3RleHQvc3R5bGVzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBFeHRlcm5hbCBkZXBlbmRlbmNpZXNcbiAqL1xuaW1wb3J0IHsgY3NzIH0gZnJvbSAnQGVtb3Rpb24vcmVhY3QnO1xuXG4vKipcb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|
};
|
|
35
35
|
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/text/styles.js"],"names":["css","COLORS","CONFIG","Text","
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/text/styles.js"],"names":["css","COLORS","CONFIG","Text","gray","fontLineHeightBase","block","positive","alert","green","destructive","red","muted","mediumGray","text","highlighterText","yellow","upperCase"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,gBAApB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,MAAjB,QAA+B,UAA/B;AAEA,OAAO,MAAMC,IAAI,gBAAGH,GAAH,WACNC,MAAM,CAACG,IAAP,CAAa,GAAb,CADM,mBAEAF,MAAM,CAACG,kBAFP,+gDAAV;AAMP,OAAO,MAAMC,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAX;AAIP,OAAO,MAAMC,QAAQ,gBAAGP,GAAH,WACVC,MAAM,CAACO,KAAP,CAAaC,KADH,0gDAAd;AAIP,OAAO,MAAMC,WAAW,gBAAGV,GAAH,WACbC,MAAM,CAACO,KAAP,CAAaG,GADA,6gDAAjB;AAIP,OAAO,MAAMC,KAAK,gBAAGZ,GAAH,WACPC,MAAM,CAACY,UAAP,CAAkBC,IADX,ugDAAX;AAIP,OAAO,MAAMC,eAAe,gBAAGf,GAAH,qBAEXC,MAAM,CAACO,KAAP,CAAaQ,MAFF,ynDAArB;AASP,OAAO,MAAMC,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { css } from '@emotion/react';\n\n/**\n * Internal dependencies\n */\nimport { COLORS, CONFIG } from '../utils';\n\nexport const Text = css`\n\tcolor: ${ COLORS.gray[ 900 ] };\n\tline-height: ${ CONFIG.fontLineHeightBase };\n\tmargin: 0;\n`;\n\nexport const block = css`\n\tdisplay: block;\n`;\n\nexport const positive = css`\n\tcolor: ${ COLORS.alert.green };\n`;\n\nexport const destructive = css`\n\tcolor: ${ COLORS.alert.red };\n`;\n\nexport const muted = css`\n\tcolor: ${ COLORS.mediumGray.text };\n`;\n\nexport const highlighterText = css`\n\tmark {\n\t\tbackground: ${ COLORS.alert.yellow };\n\t\tborder-radius: 2px;\n\t\tbox-shadow: 0 0 0 1px rgba( 0, 0, 0, 0.05 ) inset,\n\t\t\t0 -1px 0 rgba( 0, 0, 0, 0.1 ) inset;\n\t}\n`;\n\nexport const upperCase = css`\n\ttext-transform: uppercase;\n`;\n"]}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { createElement } from "@wordpress/element";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* External dependencies
|
|
6
|
+
*/
|
|
7
|
+
|
|
4
8
|
/**
|
|
5
9
|
* WordPress dependencies
|
|
6
10
|
*/
|
|
@@ -11,27 +15,9 @@ import { forwardRef } from '@wordpress/element';
|
|
|
11
15
|
*/
|
|
12
16
|
|
|
13
17
|
import BaseControl from '../base-control';
|
|
14
|
-
/**
|
|
15
|
-
* @typedef OwnProps
|
|
16
|
-
* @property {string} label Label for the control.
|
|
17
|
-
* @property {boolean} [hideLabelFromVision] Whether to accessibly hide the label.
|
|
18
|
-
* @property {string} value Value of the input.
|
|
19
|
-
* @property {string} [help] Optional help text for the control.
|
|
20
|
-
* @property {string} [className] Classname passed to BaseControl wrapper
|
|
21
|
-
* @property {(value: string) => void} onChange Handle changes.
|
|
22
|
-
* @property {string} [type='text'] Type of the input.
|
|
23
|
-
*/
|
|
24
18
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
* @param {Props} props Props
|
|
30
|
-
* @param {import('react').ForwardedRef<HTMLInputElement>} ref
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
function TextControl(_ref, ref) {
|
|
34
|
-
let {
|
|
19
|
+
function UnforwardedTextControl(props, ref) {
|
|
20
|
+
const {
|
|
35
21
|
label,
|
|
36
22
|
hideLabelFromVision,
|
|
37
23
|
value,
|
|
@@ -39,14 +25,12 @@ function TextControl(_ref, ref) {
|
|
|
39
25
|
className,
|
|
40
26
|
onChange,
|
|
41
27
|
type = 'text',
|
|
42
|
-
...
|
|
43
|
-
} =
|
|
28
|
+
...additionalProps
|
|
29
|
+
} = props;
|
|
44
30
|
const instanceId = useInstanceId(TextControl);
|
|
45
31
|
const id = `inspector-text-control-${instanceId}`;
|
|
46
32
|
|
|
47
|
-
const onChangeValue = (
|
|
48
|
-
/** @type {import('react').ChangeEvent<HTMLInputElement>} */
|
|
49
|
-
event) => onChange(event.target.value);
|
|
33
|
+
const onChangeValue = event => onChange(event.target.value);
|
|
50
34
|
|
|
51
35
|
return createElement(BaseControl, {
|
|
52
36
|
label: label,
|
|
@@ -62,8 +46,32 @@ function TextControl(_ref, ref) {
|
|
|
62
46
|
onChange: onChangeValue,
|
|
63
47
|
"aria-describedby": !!help ? id + '__help' : undefined,
|
|
64
48
|
ref: ref
|
|
65
|
-
},
|
|
49
|
+
}, additionalProps)));
|
|
66
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* TextControl components let users enter and edit text.
|
|
53
|
+
*
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```jsx
|
|
57
|
+
* import { TextControl } from '@wordpress/components';
|
|
58
|
+
* import { useState } from '@wordpress/element';
|
|
59
|
+
*
|
|
60
|
+
* const MyTextControl = () => {
|
|
61
|
+
* const [ className, setClassName ] = useState( '' );
|
|
62
|
+
*
|
|
63
|
+
* return (
|
|
64
|
+
* <TextControl
|
|
65
|
+
* label="Additional CSS Class"
|
|
66
|
+
* value={ className }
|
|
67
|
+
* onChange={ ( value ) => setClassName( value ) }
|
|
68
|
+
* />
|
|
69
|
+
* );
|
|
70
|
+
* };
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
|
|
67
74
|
|
|
68
|
-
export
|
|
75
|
+
export const TextControl = forwardRef(UnforwardedTextControl);
|
|
76
|
+
export default TextControl;
|
|
69
77
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/text-control/index.
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/text-control/index.tsx"],"names":["useInstanceId","forwardRef","BaseControl","UnforwardedTextControl","props","ref","label","hideLabelFromVision","value","help","className","onChange","type","additionalProps","instanceId","TextControl","id","onChangeValue","event","target","undefined"],"mappings":";;;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,oBAA9B;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,WAAP,MAAwB,iBAAxB;;AAIA,SAASC,sBAAT,CACCC,KADD,EAECC,GAFD,EAGE;AACD,QAAM;AACLC,IAAAA,KADK;AAELC,IAAAA,mBAFK;AAGLC,IAAAA,KAHK;AAILC,IAAAA,IAJK;AAKLC,IAAAA,SALK;AAMLC,IAAAA,QANK;AAOLC,IAAAA,IAAI,GAAG,MAPF;AAQL,OAAGC;AARE,MASFT,KATJ;AAUA,QAAMU,UAAU,GAAGd,aAAa,CAAEe,WAAF,CAAhC;AACA,QAAMC,EAAE,GAAI,0BAA0BF,UAAY,EAAlD;;AACA,QAAMG,aAAa,GAAKC,KAAF,IACrBP,QAAQ,CAAEO,KAAK,CAACC,MAAN,CAAaX,KAAf,CADT;;AAGA,SACC,cAAC,WAAD;AACC,IAAA,KAAK,EAAGF,KADT;AAEC,IAAA,mBAAmB,EAAGC,mBAFvB;AAGC,IAAA,EAAE,EAAGS,EAHN;AAIC,IAAA,IAAI,EAAGP,IAJR;AAKC,IAAA,SAAS,EAAGC;AALb,KAOC;AACC,IAAA,SAAS,EAAC,gCADX;AAEC,IAAA,IAAI,EAAGE,IAFR;AAGC,IAAA,EAAE,EAAGI,EAHN;AAIC,IAAA,KAAK,EAAGR,KAJT;AAKC,IAAA,QAAQ,EAAGS,aALZ;AAMC,wBAAmB,CAAC,CAAER,IAAH,GAAUO,EAAE,GAAG,QAAf,GAA0BI,SAN9C;AAOC,IAAA,GAAG,EAAGf;AAPP,KAQMQ,eARN,EAPD,CADD;AAoBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAME,WAAW,GAAGd,UAAU,CAAEE,sBAAF,CAA9B;AAEP,eAAeY,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { ChangeEvent, ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport type { WordPressComponentProps } from '../ui/context';\nimport type { TextControlProps } from './types';\n\nfunction UnforwardedTextControl(\n\tprops: WordPressComponentProps< TextControlProps, 'input', false >,\n\tref: ForwardedRef< HTMLInputElement >\n) {\n\tconst {\n\t\tlabel,\n\t\thideLabelFromVision,\n\t\tvalue,\n\t\thelp,\n\t\tclassName,\n\t\tonChange,\n\t\ttype = 'text',\n\t\t...additionalProps\n\t} = props;\n\tconst instanceId = useInstanceId( TextControl );\n\tconst id = `inspector-text-control-${ instanceId }`;\n\tconst onChangeValue = ( event: ChangeEvent< HTMLInputElement > ) =>\n\t\tonChange( event.target.value );\n\n\treturn (\n\t\t<BaseControl\n\t\t\tlabel={ label }\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\tid={ id }\n\t\t\thelp={ help }\n\t\t\tclassName={ className }\n\t\t>\n\t\t\t<input\n\t\t\t\tclassName=\"components-text-control__input\"\n\t\t\t\ttype={ type }\n\t\t\t\tid={ id }\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ onChangeValue }\n\t\t\t\taria-describedby={ !! help ? id + '__help' : undefined }\n\t\t\t\tref={ ref }\n\t\t\t\t{ ...additionalProps }\n\t\t\t/>\n\t\t</BaseControl>\n\t);\n}\n\n/**\n * TextControl components let users enter and edit text.\n *\n *\n * @example\n * ```jsx\n * import { TextControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyTextControl = () => {\n * const [ className, setClassName ] = useState( '' );\n *\n * return (\n * <TextControl\n * label=\"Additional CSS Class\"\n * value={ className }\n * onChange={ ( value ) => setClassName( value ) }\n * />\n * );\n * };\n * ```\n */\nexport const TextControl = forwardRef( UnforwardedTextControl );\n\nexport default TextControl;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { createElement } from "@wordpress/element";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* WordPress dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { Icon } from '@wordpress/icons';
|
|
7
3
|
/**
|
|
8
4
|
* Internal dependencies
|
|
9
5
|
*/
|
|
10
|
-
|
|
11
6
|
import { ToggleGroupControlOptionBase } from '../toggle-group-control-option-base';
|
|
7
|
+
import Icon from '../../icon';
|
|
12
8
|
export default function ToggleGroupControlOptionIcon(props) {
|
|
13
9
|
const {
|
|
14
10
|
icon,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/toggle-group-control/toggle-group-control-option-icon/component.tsx"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/toggle-group-control/toggle-group-control-option-icon/component.tsx"],"names":["ToggleGroupControlOptionBase","Icon","ToggleGroupControlOptionIcon","props","icon","restProps"],"mappings":";;AAAA;AACA;AACA;AAGA,SAASA,4BAAT,QAA6C,qCAA7C;AACA,OAAOC,IAAP,MAAiB,YAAjB;AAEA,eAAe,SAASC,4BAAT,CACdC,KADc,EAMb;AACD,QAAM;AAAEC,IAAAA,IAAF;AAAQ,OAAGC;AAAX,MAAyBF,KAA/B;AACA,SACC,cAAC,4BAAD,EAAmCE,SAAnC,EACC,cAAC,IAAD;AAAM,IAAA,IAAI,EAAGD;AAAb,IADD,CADD;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../../ui/context';\nimport type { ToggleGroupControlOptionIconProps } from '../types';\nimport { ToggleGroupControlOptionBase } from '../toggle-group-control-option-base';\nimport Icon from '../../icon';\n\nexport default function ToggleGroupControlOptionIcon(\n\tprops: WordPressComponentProps<\n\t\tToggleGroupControlOptionIconProps,\n\t\t'button',\n\t\tfalse\n\t>\n) {\n\tconst { icon, ...restProps } = props;\n\treturn (\n\t\t<ToggleGroupControlOptionBase { ...restProps }>\n\t\t\t<Icon icon={ icon } />\n\t\t</ToggleGroupControlOptionBase>\n\t);\n}\n\n/**\n * `ToggleGroupControlOptionIcon` is a form component which is meant to be used as a\n * child of `ToggleGroupControl` and displays an icon.\n *\n * @example\n * ```jsx\n *\n * import {\n *\t__experimentalToggleGroupControl as ToggleGroupControl,\n *\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n * from '@wordpress/components';\n * import { formatLowercase, formatUppercase } from '@wordpress/icons';\n *\n * function Example() {\n *\treturn (\n *\t\t<ToggleGroupControl label=\"my label\" value=\"vertical\" isBlock>\n *\t\t\t<ToggleGroupControlOptionIcon\n *\t\t\t\tvalue=\"uppercase\"\n *\t\t\t\ticon={ formatUppercase }\n *\t\t\t/>\n *\t\t\t<ToggleGroupControlOptionIcon\n *\t\t\t\tvalue=\"lowercase\"\n *\t\t\t\ticon={ formatLowercase }\n *\t\t\t/>\n *\t\t</ToggleGroupControl>\n *\t);\n * }\n ** ```\n */\n"]}
|
|
@@ -8,6 +8,7 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
8
8
|
/**
|
|
9
9
|
* WordPress dependencies
|
|
10
10
|
*/
|
|
11
|
+
import { speak } from '@wordpress/a11y';
|
|
11
12
|
import { check, reset, moreVertical, plus } from '@wordpress/icons';
|
|
12
13
|
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
13
14
|
/**
|
|
@@ -22,12 +23,9 @@ import { Heading } from '../../heading';
|
|
|
22
23
|
import { useToolsPanelHeader } from './hook';
|
|
23
24
|
import { contextConnect } from '../../ui/context';
|
|
24
25
|
|
|
25
|
-
const noop = () => {};
|
|
26
|
-
|
|
27
26
|
const DefaultControlsGroup = _ref => {
|
|
28
27
|
let {
|
|
29
28
|
items,
|
|
30
|
-
onClose,
|
|
31
29
|
toggleItem
|
|
32
30
|
} = _ref;
|
|
33
31
|
|
|
@@ -37,20 +35,28 @@ const DefaultControlsGroup = _ref => {
|
|
|
37
35
|
|
|
38
36
|
return createElement(MenuGroup, null, items.map(_ref2 => {
|
|
39
37
|
let [label, hasValue] = _ref2;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
|
|
39
|
+
if (hasValue) {
|
|
40
|
+
return createElement(MenuItem, {
|
|
41
|
+
key: label,
|
|
42
|
+
role: "menuitem",
|
|
43
|
+
icon: reset,
|
|
44
|
+
label: sprintf( // translators: %s: The name of the control being reset e.g. "Padding".
|
|
45
|
+
__('Reset %s'), label),
|
|
46
|
+
onClick: () => {
|
|
47
|
+
toggleItem(label);
|
|
48
|
+
speak(sprintf( // translators: %s: The name of the control being reset e.g. "Padding".
|
|
49
|
+
__('%s reset to default'), label), 'assertive');
|
|
50
|
+
}
|
|
51
|
+
}, label);
|
|
52
|
+
}
|
|
53
|
+
|
|
43
54
|
return createElement(MenuItem, {
|
|
44
55
|
key: label,
|
|
45
|
-
|
|
56
|
+
role: "menuitemcheckbox",
|
|
57
|
+
icon: check,
|
|
46
58
|
isSelected: true,
|
|
47
|
-
disabled:
|
|
48
|
-
label: itemLabel,
|
|
49
|
-
onClick: () => {
|
|
50
|
-
toggleItem(label);
|
|
51
|
-
onClose();
|
|
52
|
-
},
|
|
53
|
-
role: "menuitemcheckbox"
|
|
59
|
+
"aria-disabled": true
|
|
54
60
|
}, label);
|
|
55
61
|
}));
|
|
56
62
|
};
|
|
@@ -58,7 +64,6 @@ const DefaultControlsGroup = _ref => {
|
|
|
58
64
|
const OptionalControlsGroup = _ref3 => {
|
|
59
65
|
let {
|
|
60
66
|
items,
|
|
61
|
-
onClose,
|
|
62
67
|
toggleItem
|
|
63
68
|
} = _ref3;
|
|
64
69
|
|
|
@@ -77,8 +82,15 @@ const OptionalControlsGroup = _ref3 => {
|
|
|
77
82
|
isSelected: isSelected,
|
|
78
83
|
label: itemLabel,
|
|
79
84
|
onClick: () => {
|
|
85
|
+
if (isSelected) {
|
|
86
|
+
speak(sprintf( // translators: %s: The name of the control being reset e.g. "Padding".
|
|
87
|
+
__('%s hidden and reset to default'), label), 'assertive');
|
|
88
|
+
} else {
|
|
89
|
+
speak(sprintf( // translators: %s: The name of the control being reset e.g. "Padding".
|
|
90
|
+
__('%s is now visible'), label), 'assertive');
|
|
91
|
+
}
|
|
92
|
+
|
|
80
93
|
toggleItem(label);
|
|
81
|
-
onClose();
|
|
82
94
|
},
|
|
83
95
|
role: "menuitemcheckbox"
|
|
84
96
|
}, label);
|
|
@@ -105,7 +117,13 @@ const ToolsPanelHeader = (props, forwardedRef) => {
|
|
|
105
117
|
const defaultItems = Object.entries((menuItems === null || menuItems === void 0 ? void 0 : menuItems.default) || {});
|
|
106
118
|
const optionalItems = Object.entries((menuItems === null || menuItems === void 0 ? void 0 : menuItems.optional) || {});
|
|
107
119
|
const dropDownMenuIcon = areAllOptionalControlsHidden ? plus : moreVertical;
|
|
108
|
-
const dropDownMenuLabelText =
|
|
120
|
+
const dropDownMenuLabelText = sprintf( // translators: %s: The name of the tool e.g. "Color" or "Typography".
|
|
121
|
+
_x('%s options', 'Button label to reveal tool panel options'), labelText);
|
|
122
|
+
const dropdownMenuDescriptionText = areAllOptionalControlsHidden ? __('All options are currently hidden') : undefined;
|
|
123
|
+
const canResetAll = [...defaultItems, ...optionalItems].some(_ref5 => {
|
|
124
|
+
let [, isSelected] = _ref5;
|
|
125
|
+
return isSelected;
|
|
126
|
+
});
|
|
109
127
|
return createElement(HStack, _extends({}, headerProps, {
|
|
110
128
|
ref: forwardedRef
|
|
111
129
|
}), createElement(Heading, {
|
|
@@ -118,28 +136,25 @@ const ToolsPanelHeader = (props, forwardedRef) => {
|
|
|
118
136
|
className: dropdownMenuClassName
|
|
119
137
|
},
|
|
120
138
|
toggleProps: {
|
|
121
|
-
isSmall: true
|
|
139
|
+
isSmall: true,
|
|
140
|
+
describedBy: dropdownMenuDescriptionText
|
|
122
141
|
}
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
toggleItem: toggleItem
|
|
135
|
-
}), createElement(MenuGroup, null, createElement(MenuItem, {
|
|
136
|
-
variant: 'tertiary',
|
|
137
|
-
onClick: () => {
|
|
142
|
+
}, () => createElement(Fragment, null, createElement(DefaultControlsGroup, {
|
|
143
|
+
items: defaultItems,
|
|
144
|
+
toggleItem: toggleItem
|
|
145
|
+
}), createElement(OptionalControlsGroup, {
|
|
146
|
+
items: optionalItems,
|
|
147
|
+
toggleItem: toggleItem
|
|
148
|
+
}), createElement(MenuGroup, null, createElement(MenuItem, {
|
|
149
|
+
"aria-disabled": !canResetAll,
|
|
150
|
+
variant: 'tertiary',
|
|
151
|
+
onClick: () => {
|
|
152
|
+
if (canResetAll) {
|
|
138
153
|
resetAll();
|
|
139
|
-
|
|
154
|
+
speak(__('All options reset'), 'assertive');
|
|
140
155
|
}
|
|
141
|
-
}
|
|
142
|
-
}));
|
|
156
|
+
}
|
|
157
|
+
}, __('Reset all'))))));
|
|
143
158
|
};
|
|
144
159
|
|
|
145
160
|
const ConnectedToolsPanelHeader = contextConnect(ToolsPanelHeader, 'ToolsPanelHeader');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel-header/component.tsx"],"names":["check","reset","moreVertical","plus","__","_x","sprintf","DropdownMenu","MenuGroup","MenuItem","HStack","Heading","useToolsPanelHeader","contextConnect","noop","DefaultControlsGroup","items","onClose","toggleItem","length","map","label","hasValue","icon","itemLabel","undefined","OptionalControlsGroup","isSelected","ToolsPanelHeader","props","forwardedRef","areAllOptionalControlsHidden","dropdownMenuClassName","hasMenuItems","headingClassName","labelText","menuItems","resetAll","headerProps","defaultItems","Object","entries","default","optionalItems","optional","dropDownMenuIcon","dropDownMenuLabelText","className","isSmall","ConnectedToolsPanelHeader"],"mappings":";;;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,KAAT,EAAgBC,KAAhB,EAAuBC,YAAvB,EAAqCC,IAArC,QAAiD,kBAAjD;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,qBAAzB;AACA,OAAOC,SAAP,MAAsB,kBAAtB;AACA,OAAOC,QAAP,MAAqB,iBAArB;AACA,SAASC,MAAT,QAAuB,eAAvB;AACA,SAASC,OAAT,QAAwB,eAAxB;AACA,SAASC,mBAAT,QAAoC,QAApC;AACA,SAASC,cAAT,QAAwD,kBAAxD;;AAMA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,MAAMC,oBAAoB,GAAG,QAIQ;AAAA,MAJN;AAC9BC,IAAAA,KAD8B;AAE9BC,IAAAA,OAF8B;AAG9BC,IAAAA;AAH8B,GAIM;;AACpC,MAAK,CAAEF,KAAK,CAACG,MAAb,EAAsB;AACrB,WAAO,IAAP;AACA;;AAED,SACC,cAAC,SAAD,QACGH,KA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YAAY,IACb,cAAC,YAAD;AACC,IAAA,IAAI,EAAGY,gBADR;AAEC,IAAA,KAAK,EAAGC,qBAFT;AAGC,IAAA,SAAS,EAAG;AAAEC,MAAAA,SAAS,EAAEf;AAAb,KAHb;AAIC,IAAA,WAAW,EAAG;AAAEgB,MAAAA,OAAO,EAAE;AAAX;AAJf,KAMG;AAAA,QAAE;AAAE/B,MAAAA,OAAO,GAAGH;AAAZ,KAAF;AAAA,WACD,8BACC,cAAC,oBAAD;AACC,MAAA,KAAK,EAAGyB,YADT;AAEC,MAAA,OAAO,EAAGtB,OAFX;AAGC,MAAA,UAAU,EAAGC;AAHd,MADD,EAMC,cAAC,qBAAD;AACC,MAAA,KAAK,EAAGyB,aADT;AAEC,MAAA,OAAO,EAAG1B,OAFX;AAGC,MAAA,UAAU,EAAGC;AAHd,MAND,EAWC,cAAC,SAAD,QACC,cAAC,QAAD;AACC,MAAA,OAAO,EAAG,UADX;AAEC,MAAA,OAAO,EAAG,MAAM;AACfmB,QAAAA,QAAQ;AACRpB,QAAAA,OAAO;AACP;AALF,OAOGb,EAAE,CAAE,WAAF,CAPL,CADD,CAXD,CADC;AAAA,GANH,CALF,CADD;AAyCA,CAvED;;AAyEA,MAAM6C,yBAAyB,GAAGpC,cAAc,CAC/Ce,gBAD+C,EAE/C,kBAF+C,CAAhD;AAKA,eAAeqB,yBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { check, reset, moreVertical, plus } from '@wordpress/icons';\nimport { __, _x, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport DropdownMenu from '../../dropdown-menu';\nimport MenuGroup from '../../menu-group';\nimport MenuItem from '../../menu-item';\nimport { HStack } from '../../h-stack';\nimport { Heading } from '../../heading';\nimport { useToolsPanelHeader } from './hook';\nimport { contextConnect, WordPressComponentProps } from '../../ui/context';\nimport type {\n\tToolsPanelControlsGroupProps,\n\tToolsPanelHeaderProps,\n} from '../types';\n\nconst noop = () => {};\n\nconst DefaultControlsGroup = ( {\n\titems,\n\tonClose,\n\ttoggleItem,\n}: ToolsPanelControlsGroupProps ) => {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<MenuGroup>\n\t\t\t{ items.map( ( [ label, hasValue ] ) => {\n\t\t\t\tconst icon = hasValue ? reset : check;\n\t\t\t\tconst itemLabel = hasValue\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t__( 'Reset %s' ),\n\t\t\t\t\t\t\tlabel\n\t\t\t\t\t )\n\t\t\t\t\t: undefined;\n\n\t\t\t\treturn (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\tisSelected={ true }\n\t\t\t\t\t\tdisabled={ ! hasValue }\n\t\t\t\t\t\tlabel={ itemLabel }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\ttoggleItem( label );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</MenuGroup>\n\t);\n};\n\nconst OptionalControlsGroup = ( {\n\titems,\n\tonClose,\n\ttoggleItem,\n}: ToolsPanelControlsGroupProps ) => {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<MenuGroup>\n\t\t\t{ items.map( ( [ label, isSelected ] ) => {\n\t\t\t\tconst itemLabel = isSelected\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: %s: The name of the control being hidden and reset e.g. \"Padding\".\n\t\t\t\t\t\t\t__( 'Hide and reset %s' ),\n\t\t\t\t\t\t\tlabel\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: %s: The name of the control to display e.g. \"Padding\".\n\t\t\t\t\t\t\t__( 'Show %s' ),\n\t\t\t\t\t\t\tlabel\n\t\t\t\t\t );\n\n\t\t\t\treturn (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\ticon={ isSelected && check }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tlabel={ itemLabel }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\ttoggleItem( label );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</MenuGroup>\n\t);\n};\n\nconst ToolsPanelHeader = (\n\tprops: WordPressComponentProps< ToolsPanelHeaderProps, 'h2' >,\n\tforwardedRef: ForwardedRef< any >\n) => {\n\tconst {\n\t\tareAllOptionalControlsHidden,\n\t\tdropdownMenuClassName,\n\t\thasMenuItems,\n\t\theadingClassName,\n\t\tlabel: labelText,\n\t\tmenuItems,\n\t\tresetAll,\n\t\ttoggleItem,\n\t\t...headerProps\n\t} = useToolsPanelHeader( props );\n\n\tif ( ! labelText ) {\n\t\treturn null;\n\t}\n\n\tconst defaultItems = Object.entries( menuItems?.default || {} );\n\tconst optionalItems = Object.entries( menuItems?.optional || {} );\n\tconst dropDownMenuIcon = areAllOptionalControlsHidden ? plus : moreVertical;\n\tconst dropDownMenuLabelText = areAllOptionalControlsHidden\n\t\t? _x(\n\t\t\t\t'View and add options',\n\t\t\t\t'Button label to reveal tool panel options'\n\t\t )\n\t\t: _x( 'View options', 'Button label to reveal tool panel options' );\n\n\treturn (\n\t\t<HStack { ...headerProps } ref={ forwardedRef }>\n\t\t\t<Heading level={ 2 } className={ headingClassName }>\n\t\t\t\t{ labelText }\n\t\t\t</Heading>\n\t\t\t{ hasMenuItems && (\n\t\t\t\t<DropdownMenu\n\t\t\t\t\ticon={ dropDownMenuIcon }\n\t\t\t\t\tlabel={ dropDownMenuLabelText }\n\t\t\t\t\tmenuProps={ { className: dropdownMenuClassName } }\n\t\t\t\t\ttoggleProps={ { isSmall: true } }\n\t\t\t\t>\n\t\t\t\t\t{ ( { onClose = noop } ) => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<DefaultControlsGroup\n\t\t\t\t\t\t\t\titems={ defaultItems }\n\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t\ttoggleItem={ toggleItem }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<OptionalControlsGroup\n\t\t\t\t\t\t\t\titems={ optionalItems }\n\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t\ttoggleItem={ toggleItem }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tvariant={ 'tertiary' }\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tresetAll();\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Reset all' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</DropdownMenu>\n\t\t\t) }\n\t\t</HStack>\n\t);\n};\n\nconst ConnectedToolsPanelHeader = contextConnect(\n\tToolsPanelHeader,\n\t'ToolsPanelHeader'\n);\n\nexport default ConnectedToolsPanelHeader;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel-header/component.tsx"],"names":["speak","check","reset","moreVertical","plus","__","_x","sprintf","DropdownMenu","MenuGroup","MenuItem","HStack","Heading","useToolsPanelHeader","contextConnect","DefaultControlsGroup","items","toggleItem","length","map","label","hasValue","OptionalControlsGroup","isSelected","itemLabel","ToolsPanelHeader","props","forwardedRef","areAllOptionalControlsHidden","dropdownMenuClassName","hasMenuItems","headingClassName","labelText","menuItems","resetAll","headerProps","defaultItems","Object","entries","default","optionalItems","optional","dropDownMenuIcon","dropDownMenuLabelText","dropdownMenuDescriptionText","undefined","canResetAll","some","className","isSmall","describedBy","ConnectedToolsPanelHeader"],"mappings":";;;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,KAAT,QAAsB,iBAAtB;AACA,SAASC,KAAT,EAAgBC,KAAhB,EAAuBC,YAAvB,EAAqCC,IAArC,QAAiD,kBAAjD;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,qBAAzB;AACA,OAAOC,SAAP,MAAsB,kBAAtB;AACA,OAAOC,QAAP,MAAqB,iBAArB;AACA,SAASC,MAAT,QAAuB,eAAvB;AACA,SAASC,OAAT,QAAwB,eAAxB;AACA,SAASC,mBAAT,QAAoC,QAApC;AACA,SAASC,cAAT,QAAwD,kBAAxD;;AAMA,MAAMC,oBAAoB,GAAG,QAGQ;AAAA,MAHN;AAC9BC,IAAAA,KAD8B;AAE9BC,IAAAA;AAF8B,GAGM;;AACpC,MAAK,CAAED,KAAK,CAACE,MAAb,EAAsB;AACrB,WAAO,IAAP;AACA;;AAED,SACC,cAAC,SAAD,QACGF,KAAK,CAACG,GAAN,CAAW,SAA2B;AAAA,QAAzB,CAAEC,KAAF,EAASC,QAAT,CAAyB;;AACvC,QAAKA,QAAL,EAAgB;AACf,aACC,cAAC,QAAD;AACC,QAAA,GAAG,EAAGD,KADP;AAEC,QAAA,IAAI,EAAC,UAFN;AAGC,QAAA,IAAI,EAAGlB,KAHR;AAIC,QAAA,KAAK,EAAGK,OAAO,EACd;AACAF,QAAA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dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { check, reset, moreVertical, plus } from '@wordpress/icons';\nimport { __, _x, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport DropdownMenu from '../../dropdown-menu';\nimport MenuGroup from '../../menu-group';\nimport MenuItem from '../../menu-item';\nimport { HStack } from '../../h-stack';\nimport { Heading } from '../../heading';\nimport { useToolsPanelHeader } from './hook';\nimport { contextConnect, WordPressComponentProps } from '../../ui/context';\nimport type {\n\tToolsPanelControlsGroupProps,\n\tToolsPanelHeaderProps,\n} from '../types';\n\nconst DefaultControlsGroup = ( {\n\titems,\n\ttoggleItem,\n}: ToolsPanelControlsGroupProps ) => {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<MenuGroup>\n\t\t\t{ items.map( ( [ label, hasValue ] ) => {\n\t\t\t\tif ( hasValue ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\ticon={ reset }\n\t\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t__( 'Reset %s' ),\n\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\ttoggleItem( label );\n\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t\t\t__( '%s reset to default' ),\n\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\ticon={ check }\n\t\t\t\t\t\tisSelected\n\t\t\t\t\t\taria-disabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</MenuGroup>\n\t);\n};\n\nconst OptionalControlsGroup = ( {\n\titems,\n\ttoggleItem,\n}: ToolsPanelControlsGroupProps ) => {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<MenuGroup>\n\t\t\t{ items.map( ( [ label, isSelected ] ) => {\n\t\t\t\tconst itemLabel = isSelected\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: %s: The name of the control being hidden and reset e.g. \"Padding\".\n\t\t\t\t\t\t\t__( 'Hide and reset %s' ),\n\t\t\t\t\t\t\tlabel\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: %s: The name of the control to display e.g. \"Padding\".\n\t\t\t\t\t\t\t__( 'Show %s' ),\n\t\t\t\t\t\t\tlabel\n\t\t\t\t\t );\n\n\t\t\t\treturn (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\ticon={ isSelected && check }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tlabel={ itemLabel }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( isSelected ) {\n\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t\t\t__( '%s hidden and reset to default' ),\n\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t\t\t__( '%s is now visible' ),\n\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttoggleItem( label );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</MenuGroup>\n\t);\n};\n\nconst ToolsPanelHeader = (\n\tprops: WordPressComponentProps< ToolsPanelHeaderProps, 'h2' >,\n\tforwardedRef: ForwardedRef< any >\n) => {\n\tconst {\n\t\tareAllOptionalControlsHidden,\n\t\tdropdownMenuClassName,\n\t\thasMenuItems,\n\t\theadingClassName,\n\t\tlabel: labelText,\n\t\tmenuItems,\n\t\tresetAll,\n\t\ttoggleItem,\n\t\t...headerProps\n\t} = useToolsPanelHeader( props );\n\n\tif ( ! labelText ) {\n\t\treturn null;\n\t}\n\n\tconst defaultItems = Object.entries( menuItems?.default || {} );\n\tconst optionalItems = Object.entries( menuItems?.optional || {} );\n\tconst dropDownMenuIcon = areAllOptionalControlsHidden ? plus : moreVertical;\n\tconst dropDownMenuLabelText = sprintf(\n\t\t// translators: %s: The name of the tool e.g. \"Color\" or \"Typography\".\n\t\t_x( '%s options', 'Button label to reveal tool panel options' ),\n\t\tlabelText\n\t);\n\tconst dropdownMenuDescriptionText = areAllOptionalControlsHidden\n\t\t? __( 'All options are currently hidden' )\n\t\t: undefined;\n\n\tconst canResetAll = [ ...defaultItems, ...optionalItems ].some(\n\t\t( [ , isSelected ] ) => isSelected\n\t);\n\n\treturn (\n\t\t<HStack { ...headerProps } ref={ forwardedRef }>\n\t\t\t<Heading level={ 2 } className={ headingClassName }>\n\t\t\t\t{ labelText }\n\t\t\t</Heading>\n\t\t\t{ hasMenuItems && (\n\t\t\t\t<DropdownMenu\n\t\t\t\t\ticon={ dropDownMenuIcon }\n\t\t\t\t\tlabel={ dropDownMenuLabelText }\n\t\t\t\t\tmenuProps={ { className: dropdownMenuClassName } }\n\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\tisSmall: true,\n\t\t\t\t\t\tdescribedBy: dropdownMenuDescriptionText,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ () => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<DefaultControlsGroup\n\t\t\t\t\t\t\t\titems={ defaultItems }\n\t\t\t\t\t\t\t\ttoggleItem={ toggleItem }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<OptionalControlsGroup\n\t\t\t\t\t\t\t\titems={ optionalItems }\n\t\t\t\t\t\t\t\ttoggleItem={ toggleItem }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\taria-disabled={ ! canResetAll }\n\t\t\t\t\t\t\t\t\tvariant={ 'tertiary' }\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tif ( canResetAll ) {\n\t\t\t\t\t\t\t\t\t\t\tresetAll();\n\t\t\t\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\t\t\t\t__( 'All options reset' ),\n\t\t\t\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Reset all' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</DropdownMenu>\n\t\t\t) }\n\t\t</HStack>\n\t);\n};\n\nconst ConnectedToolsPanelHeader = contextConnect(\n\tToolsPanelHeader,\n\t'ToolsPanelHeader'\n);\n\nexport default ConnectedToolsPanelHeader;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/ui/spinner/component.js"],"names":["BarsView","BarsWrapperView","ContainerView","BASE_SIZE","WRAPPER_SIZE","contextConnect","useContextSystem","COLORS","Spinner","props","forwardedRef","color","
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/ui/spinner/component.js"],"names":["BarsView","BarsWrapperView","ContainerView","BASE_SIZE","WRAPPER_SIZE","contextConnect","useContextSystem","COLORS","Spinner","props","forwardedRef","color","gray","size","otherProps","ratio","scale","transform","styles","height","width"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,eAAnB,EAAoCC,aAApC,QAAyD,UAAzD;AACA,SAASC,SAAT,EAAoBC,YAApB,QAAwC,SAAxC;AACA,SAASC,cAAT,EAAyBC,gBAAzB,QAAiD,YAAjD;AACA,SAASC,MAAT,QAAuB,2BAAvB;AAEA;;AACA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;;AACA,SAASC,OAAT,CAAkBC,KAAlB,EAAyBC,YAAzB,EAAwC;AACvC,QAAM;AACLC,IAAAA,KAAK,GAAGJ,MAAM,CAACK,IAAP,CAAa,GAAb,CADH;AAELC,IAAAA,IAAI,GAAGV,SAFF;AAGL,OAAGW;AAHE,MAIFR,gBAAgB,CAAEG,KAAF,EAAS,SAAT,CAJpB;AAKA,QAAMM,KAAK,GAAGF,IAAI,GAAGV,SAArB;AACA,QAAMa,KAAK,GAAKD,KAAK,GAAGZ,SAAV,GAAwBC,YAAtC;AACA,QAAMa,SAAS,GAAI,SAASD,KAAO,GAAnC;AAEA,QAAME,MAAM,GAAG;AAAED,IAAAA;AAAF,GAAf;AAEA,SACC,cAAC,aAAD,eACMH,UADN;AAEC,iBAAY,IAFb;AAGC,IAAA,GAAG,EAAGJ,YAHP;AAIC,IAAA,KAAK,EAAG;AAAES,MAAAA,MAAM,EAAEN,IAAV;AAAgBO,MAAAA,KAAK,EAAEP;AAAvB;AAJT,MAMC,cAAC,eAAD;AAAiB,mBAAc,IAA/B;AAAsC,IAAA,KAAK,EAAGK;AAA9C,KACC,cAAC,QAAD;AAAU,IAAA,KAAK,EAAG;AAAEP,MAAAA;AAAF;AAAlB,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,IADD,EAEC;AAAK,IAAA,SAAS,EAAC;AAAf,IAFD,EAGC;AAAK,IAAA,SAAS,EAAC;AAAf,IAHD,EAIC;AAAK,IAAA,SAAS,EAAC;AAAf,IAJD,EAKC;AAAK,IAAA,SAAS,EAAC;AAAf,IALD,EAMC;AAAK,IAAA,SAAS,EAAC;AAAf,IAND,EAOC;AAAK,IAAA,SAAS,EAAC;AAAf,IAPD,EAQC;AAAK,IAAA,SAAS,EAAC;AAAf,IARD,EASC;AAAK,IAAA,SAAS,EAAC;AAAf,IATD,EAUC;AAAK,IAAA,SAAS,EAAC;AAAf,IAVD,EAWC;AAAK,IAAA,SAAS,EAAC;AAAf,IAXD,EAYC;AAAK,IAAA,SAAS,EAAC;AAAf,IAZD,CADD,CAND,CADD;AAyBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,eAAeN,cAAc,CAAEG,OAAF,EAAW,SAAX,CAA7B","sourcesContent":["/**\n * Internal dependencies\n */\nimport { BarsView, BarsWrapperView, ContainerView } from './styles';\nimport { BASE_SIZE, WRAPPER_SIZE } from './utils';\nimport { contextConnect, useContextSystem } from '../context';\nimport { COLORS } from '../../utils/colors-values';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @typedef Props\n * @property {import('react').CSSProperties['color']} [color] Color of `Spinner`.\n * @property {number} [size=16] Size of `Spinner`.\n */\n/* eslint-enable jsdoc/valid-types */\n\n/**\n *\n * @param {import('../context').WordPressComponentProps<Props, 'div'>} props\n * @param {import('react').ForwardedRef<any>} forwardedRef\n */\nfunction Spinner( props, forwardedRef ) {\n\tconst {\n\t\tcolor = COLORS.gray[ 900 ],\n\t\tsize = BASE_SIZE,\n\t\t...otherProps\n\t} = useContextSystem( props, 'Spinner' );\n\tconst ratio = size / BASE_SIZE;\n\tconst scale = ( ratio * BASE_SIZE ) / WRAPPER_SIZE;\n\tconst transform = `scale(${ scale })`;\n\n\tconst styles = { transform };\n\n\treturn (\n\t\t<ContainerView\n\t\t\t{ ...otherProps }\n\t\t\taria-busy={ true }\n\t\t\tref={ forwardedRef }\n\t\t\tstyle={ { height: size, width: size } }\n\t\t>\n\t\t\t<BarsWrapperView aria-hidden={ true } style={ styles }>\n\t\t\t\t<BarsView style={ { color } }>\n\t\t\t\t\t<div className=\"InnerBar1\" />\n\t\t\t\t\t<div className=\"InnerBar2\" />\n\t\t\t\t\t<div className=\"InnerBar3\" />\n\t\t\t\t\t<div className=\"InnerBar4\" />\n\t\t\t\t\t<div className=\"InnerBar5\" />\n\t\t\t\t\t<div className=\"InnerBar6\" />\n\t\t\t\t\t<div className=\"InnerBar7\" />\n\t\t\t\t\t<div className=\"InnerBar8\" />\n\t\t\t\t\t<div className=\"InnerBar9\" />\n\t\t\t\t\t<div className=\"InnerBar10\" />\n\t\t\t\t\t<div className=\"InnerBar11\" />\n\t\t\t\t\t<div className=\"InnerBar12\" />\n\t\t\t\t</BarsView>\n\t\t\t</BarsWrapperView>\n\t\t</ContainerView>\n\t);\n}\n\n/**\n * `Spinner` is a component that notify users that their action is being processed.\n *\n * @example\n * ```jsx\n * import { Spinner } from `@wordpress/components/ui`;\n *\n * function Example() {\n * \treturn (\n * \t\t<Spinner />\n * \t);\n * }\n * ```\n */\nexport default contextConnect( Spinner, 'Spinner' );\n"]}
|
|
@@ -59,7 +59,7 @@ function UnforwardedUnitControl(unitControlProps, forwardedRef) {
|
|
|
59
59
|
const nonNullValueProp = valueProp !== null && valueProp !== void 0 ? valueProp : undefined;
|
|
60
60
|
const units = useMemo(() => getUnitsWithCurrentUnit(nonNullValueProp, unitProp, unitsProp), [nonNullValueProp, unitProp, unitsProp]);
|
|
61
61
|
const [parsedQuantity, parsedUnit] = getParsedQuantityAndUnit(nonNullValueProp, unitProp, units);
|
|
62
|
-
const [unit, setUnit] = useControlledState(unitProp, {
|
|
62
|
+
const [unit, setUnit] = useControlledState(units.length === 1 ? units[0].value : unitProp, {
|
|
63
63
|
initial: parsedUnit,
|
|
64
64
|
fallback: ''
|
|
65
65
|
});
|
|
@@ -116,8 +116,8 @@ function UnforwardedUnitControl(unitControlProps, forwardedRef) {
|
|
|
116
116
|
const changeProps = {
|
|
117
117
|
event,
|
|
118
118
|
data
|
|
119
|
-
};
|
|
120
|
-
|
|
119
|
+
}; // The `onChange` callback already gets called, no need to call it explicitely.
|
|
120
|
+
|
|
121
121
|
onUnitChange === null || onUnitChange === void 0 ? void 0 : onUnitChange(validParsedUnit, changeProps);
|
|
122
122
|
setUnit(validParsedUnit);
|
|
123
123
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/unit-control/index.tsx"],"names":["omit","classnames","deprecated","forwardRef","useMemo","useRef","useEffect","__","inputControlActionTypes","Root","ValueInput","UnitSelectControl","CSS_UNITS","getParsedQuantityAndUnit","getUnitsWithCurrentUnit","getValidParsedQuantityAndUnit","useControlledState","UnforwardedUnitControl","unitControlProps","forwardedRef","__unstableStateReducer","stateReducerProp","autoComplete","className","disabled","disableUnits","isPressEnterToChange","isResetValueOnUnitChange","isUnitSelectTabbable","label","onChange","onChangeProp","onUnitChange","size","style","unit","unitProp","units","unitsProp","value","valueProp","onBlur","onBlurProp","props","since","hint","version","nonNullValueProp","undefined","parsedQuantity","parsedUnit","setUnit","initial","fallback","refParsedQuantity","classes","handleOnQuantityChange","nextQuantityValue","changeProps","onChangeValue","join","handleOnUnitChange","nextUnitValue","data","nextValue","default","mayUpdateUnit","event","isNaN","Number","currentTarget","current","validParsedQuantity","validParsedUnit","Array","isArray","find","option","handleOnBlur","handleOnKeyDown","key","unitControlStateReducer","state","action","nextState","type","COMMIT","toString","stateReducer","baseState","inputSuffix","step","activeUnit","UnitControl","parseQuantityAndUnitFromRawValue","useCustomUnits"],"mappings":";;;AAAA;AACA;AACA;AASA,SAASA,IAAT,QAAqB,QAArB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,UAAT,EAAqBC,OAArB,EAA8BC,MAA9B,EAAsCC,SAAtC,QAAuD,oBAAvD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AAEA,OAAO,KAAKC,uBAAZ,MAAyC,kCAAzC;AACA,SAASC,IAAT,EAAeC,UAAf,QAAiC,8BAAjC;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,SACCC,SADD,EAECC,wBAFD,EAGCC,uBAHD,EAICC,6BAJD,QAKO,SALP;AAMA,SAASC,kBAAT,QAAmC,gBAAnC;;AAIA,SAASC,sBAAT,CACCC,gBADD,EAMCC,YAND,EAOE;AACD,QAAM;AACLC,IAAAA,sBAAsB,EAAEC,gBADnB;AAELC,IAAAA,YAAY,GAAG,KAFV;AAGLC,IAAAA,SAHK;AAILC,IAAAA,QAAQ,GAAG,KAJN;AAKLC,IAAAA,YAAY,GAAG,KALV;AAMLC,IAAAA,oBAAoB,GAAG,KANlB;AAOLC,IAAAA,wBAAwB,GAAG,KAPtB;AAQLC,IAAAA,oBAAoB,GAAG,IARlB;AASLC,IAAAA,KATK;AAULC,IAAAA,QAAQ,EAAEC,YAVL;AAWLC,IAAAA,YAXK;A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AAlB1B,KADD,CADD;AAwBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAMK,WAAW,GAAG1F,UAAU,CAAEc,sBAAF,CAA9B;AAEP,SAAS6E,gCAAT,EAA2CC,cAA3C,QAAiE,SAAjE;AACA,eAAeF,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type {\n\tFocusEventHandler,\n\tKeyboardEvent,\n\tForwardedRef,\n\tSyntheticEvent,\n\tChangeEvent,\n\tPointerEvent,\n} from 'react';\nimport { omit } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { forwardRef, useMemo, useRef, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../ui/context';\nimport * as inputControlActionTypes from '../input-control/reducer/actions';\nimport { Root, ValueInput } from './styles/unit-control-styles';\nimport UnitSelectControl from './unit-select-control';\nimport {\n\tCSS_UNITS,\n\tgetParsedQuantityAndUnit,\n\tgetUnitsWithCurrentUnit,\n\tgetValidParsedQuantityAndUnit,\n} from './utils';\nimport { useControlledState } from '../utils/hooks';\nimport type { UnitControlProps, UnitControlOnChangeCallback } from './types';\nimport type { StateReducer } from '../input-control/reducer/state';\n\nfunction UnforwardedUnitControl(\n\tunitControlProps: WordPressComponentProps<\n\t\tUnitControlProps,\n\t\t'input',\n\t\tfalse\n\t>,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst {\n\t\t__unstableStateReducer: stateReducerProp,\n\t\tautoComplete = 'off',\n\t\tclassName,\n\t\tdisabled = false,\n\t\tdisableUnits = false,\n\t\tisPressEnterToChange = false,\n\t\tisResetValueOnUnitChange = false,\n\t\tisUnitSelectTabbable = true,\n\t\tlabel,\n\t\tonChange: onChangeProp,\n\t\tonUnitChange,\n\t\tsize = 'default',\n\t\tstyle,\n\t\tunit: unitProp,\n\t\tunits: unitsProp = CSS_UNITS,\n\t\tvalue: valueProp,\n\t\tonBlur: onBlurProp,\n\t\t...props\n\t} = unitControlProps;\n\n\tif ( 'unit' in unitControlProps ) {\n\t\tdeprecated( 'UnitControl unit prop', {\n\t\t\tsince: '5.6',\n\t\t\thint: 'The unit should be provided within the `value` prop.',\n\t\t\tversion: '6.2',\n\t\t} );\n\t}\n\n\t// The `value` prop, in theory, should not be `null`, but the following line\n\t// ensures it fallback to `undefined` in case a consumer of `UnitControl`\n\t// still passes `null` as a `value`.\n\tconst nonNullValueProp = valueProp ?? undefined;\n\tconst units = useMemo(\n\t\t() => getUnitsWithCurrentUnit( nonNullValueProp, unitProp, unitsProp ),\n\t\t[ nonNullValueProp, unitProp, unitsProp ]\n\t);\n\tconst [ parsedQuantity, parsedUnit ] = getParsedQuantityAndUnit(\n\t\tnonNullValueProp,\n\t\tunitProp,\n\t\tunits\n\t);\n\n\tconst [ unit, setUnit ] = useControlledState< string | undefined >(\n\t\tunitProp,\n\t\t{\n\t\t\tinitial: parsedUnit,\n\t\t\tfallback: '',\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tif ( parsedUnit !== undefined ) {\n\t\t\tsetUnit( parsedUnit );\n\t\t}\n\t}, [ parsedUnit ] );\n\n\t// Stores parsed value for hand-off in state reducer.\n\tconst refParsedQuantity = useRef< number | undefined >( undefined );\n\n\tconst classes = classnames( 'components-unit-control', className );\n\n\tconst handleOnQuantityChange = (\n\t\tnextQuantityValue: number | string | undefined,\n\t\tchangeProps: {\n\t\t\tevent:\n\t\t\t\t| ChangeEvent< HTMLInputElement >\n\t\t\t\t| PointerEvent< HTMLInputElement >;\n\t\t}\n\t) => {\n\t\tif (\n\t\t\tnextQuantityValue === '' ||\n\t\t\ttypeof nextQuantityValue === 'undefined' ||\n\t\t\tnextQuantityValue === null\n\t\t) {\n\t\t\tonChangeProp?.( '', changeProps );\n\t\t\treturn;\n\t\t}\n\n\t\t/*\n\t\t * Customizing the onChange callback.\n\t\t * This allows as to broadcast a combined value+unit to onChange.\n\t\t */\n\t\tconst onChangeValue = getValidParsedQuantityAndUnit(\n\t\t\tnextQuantityValue,\n\t\t\tunits,\n\t\t\tparsedQuantity,\n\t\t\tunit\n\t\t).join( '' );\n\n\t\tonChangeProp?.( onChangeValue, changeProps );\n\t};\n\n\tconst handleOnUnitChange: UnitControlOnChangeCallback = (\n\t\tnextUnitValue,\n\t\tchangeProps\n\t) => {\n\t\tconst { data } = changeProps;\n\n\t\tlet nextValue = `${ parsedQuantity ?? '' }${ nextUnitValue }`;\n\n\t\tif ( isResetValueOnUnitChange && data?.default !== undefined ) {\n\t\t\tnextValue = `${ data.default }${ nextUnitValue }`;\n\t\t}\n\n\t\tonChangeProp?.( nextValue, changeProps );\n\t\tonUnitChange?.( nextUnitValue, changeProps );\n\n\t\tsetUnit( nextUnitValue );\n\t};\n\n\tconst mayUpdateUnit = ( event: SyntheticEvent< HTMLInputElement > ) => {\n\t\tif ( ! isNaN( Number( event.currentTarget.value ) ) ) {\n\t\t\trefParsedQuantity.current = undefined;\n\t\t\treturn;\n\t\t}\n\t\tconst [\n\t\t\tvalidParsedQuantity,\n\t\t\tvalidParsedUnit,\n\t\t] = getValidParsedQuantityAndUnit(\n\t\t\tevent.currentTarget.value,\n\t\t\tunits,\n\t\t\tparsedQuantity,\n\t\t\tunit\n\t\t);\n\n\t\trefParsedQuantity.current = validParsedQuantity;\n\n\t\tif ( isPressEnterToChange && validParsedUnit !== unit ) {\n\t\t\tconst data = Array.isArray( units )\n\t\t\t\t? units.find( ( option ) => option.value === validParsedUnit )\n\t\t\t\t: undefined;\n\t\t\tconst changeProps = { event, data };\n\n\t\t\tonChangeProp?.(\n\t\t\t\t`${ validParsedQuantity ?? '' }${ validParsedUnit }`,\n\t\t\t\tchangeProps\n\t\t\t);\n\t\t\tonUnitChange?.( validParsedUnit, changeProps );\n\n\t\t\tsetUnit( validParsedUnit );\n\t\t}\n\t};\n\n\tconst handleOnBlur: FocusEventHandler< HTMLInputElement > = ( event ) => {\n\t\tmayUpdateUnit( event );\n\t\tonBlurProp?.( event );\n\t};\n\n\tconst handleOnKeyDown = ( event: KeyboardEvent< HTMLInputElement > ) => {\n\t\tconst { key } = event;\n\t\tif ( key === 'Enter' ) {\n\t\t\tmayUpdateUnit( event );\n\t\t}\n\t};\n\n\t/**\n\t * \"Middleware\" function that intercepts updates from InputControl.\n\t * This allows us to tap into actions to transform the (next) state for\n\t * InputControl.\n\t *\n\t * @param state State from InputControl\n\t * @param action Action triggering state change\n\t * @return The updated state to apply to InputControl\n\t */\n\tconst unitControlStateReducer: StateReducer = ( state, action ) => {\n\t\tconst nextState = { ...state };\n\n\t\t/*\n\t\t * On commits (when pressing ENTER and on blur if\n\t\t * isPressEnterToChange is true), if a parse has been performed\n\t\t * then use that result to update the state.\n\t\t */\n\t\tif ( action.type === inputControlActionTypes.COMMIT ) {\n\t\t\tif ( refParsedQuantity.current !== undefined ) {\n\t\t\t\tnextState.value = (\n\t\t\t\t\trefParsedQuantity.current ?? ''\n\t\t\t\t).toString();\n\t\t\t\trefParsedQuantity.current = undefined;\n\t\t\t}\n\t\t}\n\n\t\treturn nextState;\n\t};\n\n\tlet stateReducer: StateReducer = unitControlStateReducer;\n\tif ( stateReducerProp ) {\n\t\tstateReducer = ( state, action ) => {\n\t\t\tconst baseState = unitControlStateReducer( state, action );\n\t\t\treturn stateReducerProp( baseState, action );\n\t\t};\n\t}\n\n\tconst inputSuffix = ! disableUnits ? (\n\t\t<UnitSelectControl\n\t\t\taria-label={ __( 'Select unit' ) }\n\t\t\tdisabled={ disabled }\n\t\t\tisUnitSelectTabbable={ isUnitSelectTabbable }\n\t\t\tonChange={ handleOnUnitChange }\n\t\t\tsize={ size }\n\t\t\tunit={ unit }\n\t\t\tunits={ units }\n\t\t\tonBlur={ onBlurProp }\n\t\t/>\n\t) : null;\n\n\tlet step = props.step;\n\n\t/*\n\t * If no step prop has been passed, lookup the active unit and\n\t * try to get step from `units`, or default to a value of `1`\n\t */\n\tif ( ! step && units ) {\n\t\tconst activeUnit = units.find( ( option ) => option.value === unit );\n\t\tstep = activeUnit?.step ?? 1;\n\t}\n\n\treturn (\n\t\t<Root className=\"components-unit-control-wrapper\" style={ style }>\n\t\t\t<ValueInput\n\t\t\t\taria-label={ label }\n\t\t\t\ttype={ isPressEnterToChange ? 'text' : 'number' }\n\t\t\t\t{ ...omit( props, [ 'children' ] ) }\n\t\t\t\tautoComplete={ autoComplete }\n\t\t\t\tclassName={ classes }\n\t\t\t\tdisabled={ disabled }\n\t\t\t\tdisableUnits={ disableUnits }\n\t\t\t\tisPressEnterToChange={ isPressEnterToChange }\n\t\t\t\tlabel={ label }\n\t\t\t\tonBlur={ handleOnBlur }\n\t\t\t\tonKeyDown={ handleOnKeyDown }\n\t\t\t\tonChange={ handleOnQuantityChange }\n\t\t\t\tref={ forwardedRef }\n\t\t\t\tsize={ size }\n\t\t\t\tsuffix={ inputSuffix }\n\t\t\t\tvalue={ parsedQuantity ?? '' }\n\t\t\t\tstep={ step }\n\t\t\t\t__unstableStateReducer={ stateReducer }\n\t\t\t/>\n\t\t</Root>\n\t);\n}\n\n/**\n * `UnitControl` allows the user to set a numeric quantity as well as a unit (e.g. `px`).\n *\n *\n * @example\n * ```jsx\n * import { __experimentalUnitControl as UnitControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const Example = () => {\n * const [ value, setValue ] = useState( '10px' );\n *\n * return <UnitControl onChange={ setValue } value={ value } />;\n * };\n * ```\n */\nexport const UnitControl = forwardRef( UnforwardedUnitControl );\n\nexport { parseQuantityAndUnitFromRawValue, useCustomUnits } from './utils';\nexport default UnitControl;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/unit-control/index.tsx"],"names":["omit","classnames","deprecated","forwardRef","useMemo","useRef","useEffect","__","inputControlActionTypes","Root","ValueInput","UnitSelectControl","CSS_UNITS","getParsedQuantityAndUnit","getUnitsWithCurrentUnit","getValidParsedQuantityAndUnit","useControlledState","UnforwardedUnitControl","unitControlProps","forwardedRef","__unstableStateReducer","stateReducerProp","autoComplete","className","disabled","disableUnits","isPressEnterToChange","isResetValueOnUnitChange","isUnitSelectTabbable","label","onChange","onChangeProp","onUnitChange","size","style","unit","unitProp","units","unitsProp","value","valueProp","onBlur","onBlurProp","props","since","hint","version","nonNullValueProp","undefined","parsedQuantity","parsedUnit","setUnit","length","initial","fallback","refParsedQuantity","classes","handleOnQuantityChange","nextQuantityValue","changeProps","onChangeValue","join","handleOnUnitChange","nextUnitValue","data","nextValue","default","mayUpdateUnit","event","isNaN","Number","currentTarget","current","validParsedQuantity","validParsedUnit","Array","isArray","find","option","handleOnBlur","handleOnKeyDown","key","unitControlStateReducer","state","action","nextState","type","COMMIT","toString","stateReducer","baseState","inputSuffix","step","activeUnit","UnitControl","parseQuantityAndUnitFromRawValue","useCustomUnits"],"mappings":";;;AAAA;AACA;AACA;AASA,SAASA,IAAT,QAAqB,QAArB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,UAAT,EAAqBC,OAArB,EAA8BC,MAA9B,EAAsCC,SAAtC,QAAuD,oBAAvD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AAEA,OAAO,KAAKC,uBAAZ,MAAyC,kCAAzC;AACA,SAASC,IAAT,EAAeC,UAAf,QAAiC,8BAAjC;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,SACCC,SADD,EAECC,wBAFD,EAGCC,uBAHD,EAICC,6BAJD,QAKO,SALP;AAMA,SAASC,kBAAT,QAAmC,gBAAnC;;AAIA,SAASC,sBAAT,CACCC,gBADD,EAMCC,YAND,EAOE;AACD,QAAM;AACLC,IAAAA,sBAAsB,EAAEC,gBADnB;AAELC,IAAAA,YAAY,GAAG,KAFV;AAGLC,IAAAA,SAHK;AAILC,IAAAA,QAAQ,GAAG,KAJN;AAKLC,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AAgBC,IAAA,KAAK,EAAG1C,cAAH,aAAGA,cAAH,cAAGA,cAAH,GAAqB,EAhB3B;AAiBC,IAAA,IAAI,EAAG2C,IAjBR;AAkBC,IAAA,sBAAsB,EAAGH;AAlB1B,KADD,CADD;AAwBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAMK,WAAW,GAAG3F,UAAU,CAAEc,sBAAF,CAA9B;AAEP,SAAS8E,gCAAT,EAA2CC,cAA3C,QAAiE,SAAjE;AACA,eAAeF,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type {\n\tFocusEventHandler,\n\tKeyboardEvent,\n\tForwardedRef,\n\tSyntheticEvent,\n\tChangeEvent,\n\tPointerEvent,\n} from 'react';\nimport { omit } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { forwardRef, useMemo, useRef, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../ui/context';\nimport * as inputControlActionTypes from '../input-control/reducer/actions';\nimport { Root, ValueInput } from './styles/unit-control-styles';\nimport UnitSelectControl from './unit-select-control';\nimport {\n\tCSS_UNITS,\n\tgetParsedQuantityAndUnit,\n\tgetUnitsWithCurrentUnit,\n\tgetValidParsedQuantityAndUnit,\n} from './utils';\nimport { useControlledState } from '../utils/hooks';\nimport type { UnitControlProps, UnitControlOnChangeCallback } from './types';\nimport type { StateReducer } from '../input-control/reducer/state';\n\nfunction UnforwardedUnitControl(\n\tunitControlProps: WordPressComponentProps<\n\t\tUnitControlProps,\n\t\t'input',\n\t\tfalse\n\t>,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst {\n\t\t__unstableStateReducer: stateReducerProp,\n\t\tautoComplete = 'off',\n\t\tclassName,\n\t\tdisabled = false,\n\t\tdisableUnits = false,\n\t\tisPressEnterToChange = false,\n\t\tisResetValueOnUnitChange = false,\n\t\tisUnitSelectTabbable = true,\n\t\tlabel,\n\t\tonChange: onChangeProp,\n\t\tonUnitChange,\n\t\tsize = 'default',\n\t\tstyle,\n\t\tunit: unitProp,\n\t\tunits: unitsProp = CSS_UNITS,\n\t\tvalue: valueProp,\n\t\tonBlur: onBlurProp,\n\t\t...props\n\t} = unitControlProps;\n\n\tif ( 'unit' in unitControlProps ) {\n\t\tdeprecated( 'UnitControl unit prop', {\n\t\t\tsince: '5.6',\n\t\t\thint: 'The unit should be provided within the `value` prop.',\n\t\t\tversion: '6.2',\n\t\t} );\n\t}\n\n\t// The `value` prop, in theory, should not be `null`, but the following line\n\t// ensures it fallback to `undefined` in case a consumer of `UnitControl`\n\t// still passes `null` as a `value`.\n\tconst nonNullValueProp = valueProp ?? undefined;\n\tconst units = useMemo(\n\t\t() => getUnitsWithCurrentUnit( nonNullValueProp, unitProp, unitsProp ),\n\t\t[ nonNullValueProp, unitProp, unitsProp ]\n\t);\n\tconst [ parsedQuantity, parsedUnit ] = getParsedQuantityAndUnit(\n\t\tnonNullValueProp,\n\t\tunitProp,\n\t\tunits\n\t);\n\n\tconst [ unit, setUnit ] = useControlledState< string | undefined >(\n\t\tunits.length === 1 ? units[ 0 ].value : unitProp,\n\t\t{\n\t\t\tinitial: parsedUnit,\n\t\t\tfallback: '',\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tif ( parsedUnit !== undefined ) {\n\t\t\tsetUnit( parsedUnit );\n\t\t}\n\t}, [ parsedUnit ] );\n\n\t// Stores parsed value for hand-off in state reducer.\n\tconst refParsedQuantity = useRef< number | undefined >( undefined );\n\n\tconst classes = classnames( 'components-unit-control', className );\n\n\tconst handleOnQuantityChange = (\n\t\tnextQuantityValue: number | string | undefined,\n\t\tchangeProps: {\n\t\t\tevent:\n\t\t\t\t| ChangeEvent< HTMLInputElement >\n\t\t\t\t| PointerEvent< HTMLInputElement >;\n\t\t}\n\t) => {\n\t\tif (\n\t\t\tnextQuantityValue === '' ||\n\t\t\ttypeof nextQuantityValue === 'undefined' ||\n\t\t\tnextQuantityValue === null\n\t\t) {\n\t\t\tonChangeProp?.( '', changeProps );\n\t\t\treturn;\n\t\t}\n\n\t\t/*\n\t\t * Customizing the onChange callback.\n\t\t * This allows as to broadcast a combined value+unit to onChange.\n\t\t */\n\t\tconst onChangeValue = getValidParsedQuantityAndUnit(\n\t\t\tnextQuantityValue,\n\t\t\tunits,\n\t\t\tparsedQuantity,\n\t\t\tunit\n\t\t).join( '' );\n\n\t\tonChangeProp?.( onChangeValue, changeProps );\n\t};\n\n\tconst handleOnUnitChange: UnitControlOnChangeCallback = (\n\t\tnextUnitValue,\n\t\tchangeProps\n\t) => {\n\t\tconst { data } = changeProps;\n\n\t\tlet nextValue = `${ parsedQuantity ?? '' }${ nextUnitValue }`;\n\n\t\tif ( isResetValueOnUnitChange && data?.default !== undefined ) {\n\t\t\tnextValue = `${ data.default }${ nextUnitValue }`;\n\t\t}\n\n\t\tonChangeProp?.( nextValue, changeProps );\n\t\tonUnitChange?.( nextUnitValue, changeProps );\n\n\t\tsetUnit( nextUnitValue );\n\t};\n\n\tconst mayUpdateUnit = ( event: SyntheticEvent< HTMLInputElement > ) => {\n\t\tif ( ! isNaN( Number( event.currentTarget.value ) ) ) {\n\t\t\trefParsedQuantity.current = undefined;\n\t\t\treturn;\n\t\t}\n\t\tconst [\n\t\t\tvalidParsedQuantity,\n\t\t\tvalidParsedUnit,\n\t\t] = getValidParsedQuantityAndUnit(\n\t\t\tevent.currentTarget.value,\n\t\t\tunits,\n\t\t\tparsedQuantity,\n\t\t\tunit\n\t\t);\n\n\t\trefParsedQuantity.current = validParsedQuantity;\n\n\t\tif ( isPressEnterToChange && validParsedUnit !== unit ) {\n\t\t\tconst data = Array.isArray( units )\n\t\t\t\t? units.find( ( option ) => option.value === validParsedUnit )\n\t\t\t\t: undefined;\n\t\t\tconst changeProps = { event, data };\n\n\t\t\t// The `onChange` callback already gets called, no need to call it explicitely.\n\t\t\tonUnitChange?.( validParsedUnit, changeProps );\n\n\t\t\tsetUnit( validParsedUnit );\n\t\t}\n\t};\n\n\tconst handleOnBlur: FocusEventHandler< HTMLInputElement > = ( event ) => {\n\t\tmayUpdateUnit( event );\n\t\tonBlurProp?.( event );\n\t};\n\n\tconst handleOnKeyDown = ( event: KeyboardEvent< HTMLInputElement > ) => {\n\t\tconst { key } = event;\n\t\tif ( key === 'Enter' ) {\n\t\t\tmayUpdateUnit( event );\n\t\t}\n\t};\n\n\t/**\n\t * \"Middleware\" function that intercepts updates from InputControl.\n\t * This allows us to tap into actions to transform the (next) state for\n\t * InputControl.\n\t *\n\t * @param state State from InputControl\n\t * @param action Action triggering state change\n\t * @return The updated state to apply to InputControl\n\t */\n\tconst unitControlStateReducer: StateReducer = ( state, action ) => {\n\t\tconst nextState = { ...state };\n\n\t\t/*\n\t\t * On commits (when pressing ENTER and on blur if\n\t\t * isPressEnterToChange is true), if a parse has been performed\n\t\t * then use that result to update the state.\n\t\t */\n\t\tif ( action.type === inputControlActionTypes.COMMIT ) {\n\t\t\tif ( refParsedQuantity.current !== undefined ) {\n\t\t\t\tnextState.value = (\n\t\t\t\t\trefParsedQuantity.current ?? ''\n\t\t\t\t).toString();\n\t\t\t\trefParsedQuantity.current = undefined;\n\t\t\t}\n\t\t}\n\n\t\treturn nextState;\n\t};\n\n\tlet stateReducer: StateReducer = unitControlStateReducer;\n\tif ( stateReducerProp ) {\n\t\tstateReducer = ( state, action ) => {\n\t\t\tconst baseState = unitControlStateReducer( state, action );\n\t\t\treturn stateReducerProp( baseState, action );\n\t\t};\n\t}\n\n\tconst inputSuffix = ! disableUnits ? (\n\t\t<UnitSelectControl\n\t\t\taria-label={ __( 'Select unit' ) }\n\t\t\tdisabled={ disabled }\n\t\t\tisUnitSelectTabbable={ isUnitSelectTabbable }\n\t\t\tonChange={ handleOnUnitChange }\n\t\t\tsize={ size }\n\t\t\tunit={ unit }\n\t\t\tunits={ units }\n\t\t\tonBlur={ onBlurProp }\n\t\t/>\n\t) : null;\n\n\tlet step = props.step;\n\n\t/*\n\t * If no step prop has been passed, lookup the active unit and\n\t * try to get step from `units`, or default to a value of `1`\n\t */\n\tif ( ! step && units ) {\n\t\tconst activeUnit = units.find( ( option ) => option.value === unit );\n\t\tstep = activeUnit?.step ?? 1;\n\t}\n\n\treturn (\n\t\t<Root className=\"components-unit-control-wrapper\" style={ style }>\n\t\t\t<ValueInput\n\t\t\t\taria-label={ label }\n\t\t\t\ttype={ isPressEnterToChange ? 'text' : 'number' }\n\t\t\t\t{ ...omit( props, [ 'children' ] ) }\n\t\t\t\tautoComplete={ autoComplete }\n\t\t\t\tclassName={ classes }\n\t\t\t\tdisabled={ disabled }\n\t\t\t\tdisableUnits={ disableUnits }\n\t\t\t\tisPressEnterToChange={ isPressEnterToChange }\n\t\t\t\tlabel={ label }\n\t\t\t\tonBlur={ handleOnBlur }\n\t\t\t\tonKeyDown={ handleOnKeyDown }\n\t\t\t\tonChange={ handleOnQuantityChange }\n\t\t\t\tref={ forwardedRef }\n\t\t\t\tsize={ size }\n\t\t\t\tsuffix={ inputSuffix }\n\t\t\t\tvalue={ parsedQuantity ?? '' }\n\t\t\t\tstep={ step }\n\t\t\t\t__unstableStateReducer={ stateReducer }\n\t\t\t/>\n\t\t</Root>\n\t);\n}\n\n/**\n * `UnitControl` allows the user to set a numeric quantity as well as a unit (e.g. `px`).\n *\n *\n * @example\n * ```jsx\n * import { __experimentalUnitControl as UnitControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const Example = () => {\n * const [ value, setValue ] = useState( '10px' );\n *\n * return <UnitControl onChange={ setValue } value={ value } />;\n * };\n * ```\n */\nexport const UnitControl = forwardRef( UnforwardedUnitControl );\n\nexport { parseQuantityAndUnitFromRawValue, useCustomUnits } from './utils';\nexport default UnitControl;\n"]}
|