@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
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = BoxControlVisualizer;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
|
-
var _boxControlVisualizerStyles = require("./styles/box-control-visualizer-styles");
|
|
15
|
-
|
|
16
|
-
var _utils = require("./utils");
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* WordPress dependencies
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Internal dependencies
|
|
24
|
-
*/
|
|
25
|
-
function BoxControlVisualizer(_ref) {
|
|
26
|
-
let {
|
|
27
|
-
children,
|
|
28
|
-
showValues = _utils.DEFAULT_VISUALIZER_VALUES,
|
|
29
|
-
values: valuesProp = _utils.DEFAULT_VALUES,
|
|
30
|
-
...props
|
|
31
|
-
} = _ref;
|
|
32
|
-
const isPositionAbsolute = !children;
|
|
33
|
-
return (0, _element.createElement)(_boxControlVisualizerStyles.Container, (0, _extends2.default)({}, props, {
|
|
34
|
-
isPositionAbsolute: isPositionAbsolute,
|
|
35
|
-
"aria-hidden": "true"
|
|
36
|
-
}), (0, _element.createElement)(Sides, {
|
|
37
|
-
showValues: showValues,
|
|
38
|
-
values: valuesProp
|
|
39
|
-
}), children);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function Sides(_ref2) {
|
|
43
|
-
let {
|
|
44
|
-
showValues = _utils.DEFAULT_VISUALIZER_VALUES,
|
|
45
|
-
values
|
|
46
|
-
} = _ref2;
|
|
47
|
-
const {
|
|
48
|
-
top,
|
|
49
|
-
right,
|
|
50
|
-
bottom,
|
|
51
|
-
left
|
|
52
|
-
} = values;
|
|
53
|
-
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(Top, {
|
|
54
|
-
isVisible: showValues.top,
|
|
55
|
-
value: top
|
|
56
|
-
}), (0, _element.createElement)(Right, {
|
|
57
|
-
isVisible: showValues.right,
|
|
58
|
-
value: right
|
|
59
|
-
}), (0, _element.createElement)(Bottom, {
|
|
60
|
-
isVisible: showValues.bottom,
|
|
61
|
-
value: bottom
|
|
62
|
-
}), (0, _element.createElement)(Left, {
|
|
63
|
-
isVisible: showValues.left,
|
|
64
|
-
value: left
|
|
65
|
-
}));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function Top(_ref3) {
|
|
69
|
-
let {
|
|
70
|
-
isVisible = false,
|
|
71
|
-
value
|
|
72
|
-
} = _ref3;
|
|
73
|
-
const height = value;
|
|
74
|
-
const animationProps = useSideAnimation(height);
|
|
75
|
-
const isActive = animationProps.isActive || isVisible;
|
|
76
|
-
return (0, _element.createElement)(_boxControlVisualizerStyles.TopView, {
|
|
77
|
-
isActive: isActive,
|
|
78
|
-
style: {
|
|
79
|
-
height
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function Right(_ref4) {
|
|
85
|
-
let {
|
|
86
|
-
isVisible = false,
|
|
87
|
-
value
|
|
88
|
-
} = _ref4;
|
|
89
|
-
const width = value;
|
|
90
|
-
const animationProps = useSideAnimation(width);
|
|
91
|
-
const isActive = animationProps.isActive || isVisible;
|
|
92
|
-
return (0, _element.createElement)(_boxControlVisualizerStyles.RightView, {
|
|
93
|
-
isActive: isActive,
|
|
94
|
-
style: {
|
|
95
|
-
width
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function Bottom(_ref5) {
|
|
101
|
-
let {
|
|
102
|
-
isVisible = false,
|
|
103
|
-
value
|
|
104
|
-
} = _ref5;
|
|
105
|
-
const height = value;
|
|
106
|
-
const animationProps = useSideAnimation(height);
|
|
107
|
-
const isActive = animationProps.isActive || isVisible;
|
|
108
|
-
return (0, _element.createElement)(_boxControlVisualizerStyles.BottomView, {
|
|
109
|
-
isActive: isActive,
|
|
110
|
-
style: {
|
|
111
|
-
height
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function Left(_ref6) {
|
|
117
|
-
let {
|
|
118
|
-
isVisible = false,
|
|
119
|
-
value
|
|
120
|
-
} = _ref6;
|
|
121
|
-
const width = value;
|
|
122
|
-
const animationProps = useSideAnimation(width);
|
|
123
|
-
const isActive = animationProps.isActive || isVisible;
|
|
124
|
-
return (0, _element.createElement)(_boxControlVisualizerStyles.LeftView, {
|
|
125
|
-
isActive: isActive,
|
|
126
|
-
style: {
|
|
127
|
-
width
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Custom hook that renders the "flash" animation whenever the value changes.
|
|
133
|
-
*
|
|
134
|
-
* @param {string} value Value of (box) side.
|
|
135
|
-
*/
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
function useSideAnimation(value) {
|
|
139
|
-
const [isActive, setIsActive] = (0, _element.useState)(false);
|
|
140
|
-
const valueRef = (0, _element.useRef)(value);
|
|
141
|
-
const timeoutRef = (0, _element.useRef)();
|
|
142
|
-
|
|
143
|
-
const clearTimer = () => {
|
|
144
|
-
if (timeoutRef.current) {
|
|
145
|
-
window.clearTimeout(timeoutRef.current);
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
(0, _element.useEffect)(() => {
|
|
150
|
-
if (value !== valueRef.current) {
|
|
151
|
-
setIsActive(true);
|
|
152
|
-
valueRef.current = value;
|
|
153
|
-
clearTimer();
|
|
154
|
-
timeoutRef.current = setTimeout(() => {
|
|
155
|
-
setIsActive(false);
|
|
156
|
-
}, 400);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return () => clearTimer();
|
|
160
|
-
}, [value]);
|
|
161
|
-
return {
|
|
162
|
-
isActive
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
//# sourceMappingURL=visualizer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/box-control/visualizer.js"],"names":["BoxControlVisualizer","children","showValues","DEFAULT_VISUALIZER_VALUES","values","valuesProp","DEFAULT_VALUES","props","isPositionAbsolute","Sides","top","right","bottom","left","Top","isVisible","value","height","animationProps","useSideAnimation","isActive","Right","width","Bottom","Left","setIsActive","valueRef","timeoutRef","clearTimer","current","window","clearTimeout","setTimeout"],"mappings":";;;;;;;;;AAGA;;;;AAKA;;AAOA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;AAUe,SAASA,oBAAT,OAKX;AAAA,MAL0C;AAC7CC,IAAAA,QAD6C;AAE7CC,IAAAA,UAAU,GAAGC,gCAFgC;AAG7CC,IAAAA,MAAM,EAAEC,UAAU,GAAGC,qBAHwB;AAI7C,OAAGC;AAJ0C,GAK1C;AACH,QAAMC,kBAAkB,GAAG,CAAEP,QAA7B;AACA,SACC,4BAAC,qCAAD,6BACMM,KADN;AAEC,IAAA,kBAAkB,EAAGC,kBAFtB;AAGC,mBAAY;AAHb,MAKC,4BAAC,KAAD;AAAO,IAAA,UAAU,EAAGN,UAApB;AAAiC,IAAA,MAAM,EAAGG;AAA1C,IALD,EAMGJ,QANH,CADD;AAUA;;AAED,SAASQ,KAAT,QAAqE;AAAA,MAArD;AAAEP,IAAAA,UAAU,GAAGC,gCAAf;AAA0CC,IAAAA;AAA1C,GAAqD;AACpE,QAAM;AAAEM,IAAAA,GAA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F,CAAX;AACAC,MAAAA,QAAQ,CAACG,OAAT,GAAmBb,KAAnB;AAEAY,MAAAA,UAAU;AAEVD,MAAAA,UAAU,CAACE,OAAX,GAAqBG,UAAU,CAAE,MAAM;AACtCP,QAAAA,WAAW,CAAE,KAAF,CAAX;AACA,OAF8B,EAE5B,GAF4B,CAA/B;AAGA;;AAED,WAAO,MAAMG,UAAU,EAAvB;AACA,GAbD,EAaG,CAAEZ,KAAF,CAbH;AAeA,SAAO;AACNI,IAAAA;AADM,GAAP;AAGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tContainer,\n\tTopView,\n\tRightView,\n\tBottomView,\n\tLeftView,\n} from './styles/box-control-visualizer-styles';\nimport { DEFAULT_VALUES, DEFAULT_VISUALIZER_VALUES } from './utils';\n\nexport default function BoxControlVisualizer( {\n\tchildren,\n\tshowValues = DEFAULT_VISUALIZER_VALUES,\n\tvalues: valuesProp = DEFAULT_VALUES,\n\t...props\n} ) {\n\tconst isPositionAbsolute = ! children;\n\treturn (\n\t\t<Container\n\t\t\t{ ...props }\n\t\t\tisPositionAbsolute={ isPositionAbsolute }\n\t\t\taria-hidden=\"true\"\n\t\t>\n\t\t\t<Sides showValues={ showValues } values={ valuesProp } />\n\t\t\t{ children }\n\t\t</Container>\n\t);\n}\n\nfunction Sides( { showValues = DEFAULT_VISUALIZER_VALUES, values } ) {\n\tconst { top, right, bottom, left } = values;\n\n\treturn (\n\t\t<>\n\t\t\t<Top isVisible={ showValues.top } value={ top } />\n\t\t\t<Right isVisible={ showValues.right } value={ right } />\n\t\t\t<Bottom isVisible={ showValues.bottom } value={ bottom } />\n\t\t\t<Left isVisible={ showValues.left } value={ left } />\n\t\t</>\n\t);\n}\n\nfunction Top( { isVisible = false, value } ) {\n\tconst height = value;\n\tconst animationProps = useSideAnimation( height );\n\tconst isActive = animationProps.isActive || isVisible;\n\n\treturn <TopView isActive={ isActive } style={ { height } } />;\n}\n\nfunction Right( { isVisible = false, value } ) {\n\tconst width = value;\n\tconst animationProps = useSideAnimation( width );\n\tconst isActive = animationProps.isActive || isVisible;\n\n\treturn <RightView isActive={ isActive } style={ { width } } />;\n}\n\nfunction Bottom( { isVisible = false, value } ) {\n\tconst height = value;\n\tconst animationProps = useSideAnimation( height );\n\tconst isActive = animationProps.isActive || isVisible;\n\n\treturn <BottomView isActive={ isActive } style={ { height } } />;\n}\n\nfunction Left( { isVisible = false, value } ) {\n\tconst width = value;\n\tconst animationProps = useSideAnimation( width );\n\tconst isActive = animationProps.isActive || isVisible;\n\n\treturn <LeftView isActive={ isActive } style={ { width } } />;\n}\n\n/**\n * Custom hook that renders the \"flash\" animation whenever the value changes.\n *\n * @param {string} value Value of (box) side.\n */\nfunction useSideAnimation( value ) {\n\tconst [ isActive, setIsActive ] = useState( false );\n\tconst valueRef = useRef( value );\n\tconst timeoutRef = useRef();\n\n\tconst clearTimer = () => {\n\t\tif ( timeoutRef.current ) {\n\t\t\twindow.clearTimeout( timeoutRef.current );\n\t\t}\n\t};\n\n\tuseEffect( () => {\n\t\tif ( value !== valueRef.current ) {\n\t\t\tsetIsActive( true );\n\t\t\tvalueRef.current = value;\n\n\t\t\tclearTimer();\n\n\t\t\ttimeoutRef.current = setTimeout( () => {\n\t\t\t\tsetIsActive( false );\n\t\t\t}, 400 );\n\t\t}\n\n\t\treturn () => clearTimer();\n\t}, [ value ] );\n\n\treturn {\n\t\tisActive,\n\t};\n}\n"]}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { createElement, Fragment } from "@wordpress/element";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* WordPress dependencies
|
|
6
|
-
*/
|
|
7
|
-
import { useRef, useEffect, useState } from '@wordpress/element';
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { Container, TopView, RightView, BottomView, LeftView } from './styles/box-control-visualizer-styles';
|
|
13
|
-
import { DEFAULT_VALUES, DEFAULT_VISUALIZER_VALUES } from './utils';
|
|
14
|
-
export default function BoxControlVisualizer(_ref) {
|
|
15
|
-
let {
|
|
16
|
-
children,
|
|
17
|
-
showValues = DEFAULT_VISUALIZER_VALUES,
|
|
18
|
-
values: valuesProp = DEFAULT_VALUES,
|
|
19
|
-
...props
|
|
20
|
-
} = _ref;
|
|
21
|
-
const isPositionAbsolute = !children;
|
|
22
|
-
return createElement(Container, _extends({}, props, {
|
|
23
|
-
isPositionAbsolute: isPositionAbsolute,
|
|
24
|
-
"aria-hidden": "true"
|
|
25
|
-
}), createElement(Sides, {
|
|
26
|
-
showValues: showValues,
|
|
27
|
-
values: valuesProp
|
|
28
|
-
}), children);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function Sides(_ref2) {
|
|
32
|
-
let {
|
|
33
|
-
showValues = DEFAULT_VISUALIZER_VALUES,
|
|
34
|
-
values
|
|
35
|
-
} = _ref2;
|
|
36
|
-
const {
|
|
37
|
-
top,
|
|
38
|
-
right,
|
|
39
|
-
bottom,
|
|
40
|
-
left
|
|
41
|
-
} = values;
|
|
42
|
-
return createElement(Fragment, null, createElement(Top, {
|
|
43
|
-
isVisible: showValues.top,
|
|
44
|
-
value: top
|
|
45
|
-
}), createElement(Right, {
|
|
46
|
-
isVisible: showValues.right,
|
|
47
|
-
value: right
|
|
48
|
-
}), createElement(Bottom, {
|
|
49
|
-
isVisible: showValues.bottom,
|
|
50
|
-
value: bottom
|
|
51
|
-
}), createElement(Left, {
|
|
52
|
-
isVisible: showValues.left,
|
|
53
|
-
value: left
|
|
54
|
-
}));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function Top(_ref3) {
|
|
58
|
-
let {
|
|
59
|
-
isVisible = false,
|
|
60
|
-
value
|
|
61
|
-
} = _ref3;
|
|
62
|
-
const height = value;
|
|
63
|
-
const animationProps = useSideAnimation(height);
|
|
64
|
-
const isActive = animationProps.isActive || isVisible;
|
|
65
|
-
return createElement(TopView, {
|
|
66
|
-
isActive: isActive,
|
|
67
|
-
style: {
|
|
68
|
-
height
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function Right(_ref4) {
|
|
74
|
-
let {
|
|
75
|
-
isVisible = false,
|
|
76
|
-
value
|
|
77
|
-
} = _ref4;
|
|
78
|
-
const width = value;
|
|
79
|
-
const animationProps = useSideAnimation(width);
|
|
80
|
-
const isActive = animationProps.isActive || isVisible;
|
|
81
|
-
return createElement(RightView, {
|
|
82
|
-
isActive: isActive,
|
|
83
|
-
style: {
|
|
84
|
-
width
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function Bottom(_ref5) {
|
|
90
|
-
let {
|
|
91
|
-
isVisible = false,
|
|
92
|
-
value
|
|
93
|
-
} = _ref5;
|
|
94
|
-
const height = value;
|
|
95
|
-
const animationProps = useSideAnimation(height);
|
|
96
|
-
const isActive = animationProps.isActive || isVisible;
|
|
97
|
-
return createElement(BottomView, {
|
|
98
|
-
isActive: isActive,
|
|
99
|
-
style: {
|
|
100
|
-
height
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function Left(_ref6) {
|
|
106
|
-
let {
|
|
107
|
-
isVisible = false,
|
|
108
|
-
value
|
|
109
|
-
} = _ref6;
|
|
110
|
-
const width = value;
|
|
111
|
-
const animationProps = useSideAnimation(width);
|
|
112
|
-
const isActive = animationProps.isActive || isVisible;
|
|
113
|
-
return createElement(LeftView, {
|
|
114
|
-
isActive: isActive,
|
|
115
|
-
style: {
|
|
116
|
-
width
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Custom hook that renders the "flash" animation whenever the value changes.
|
|
122
|
-
*
|
|
123
|
-
* @param {string} value Value of (box) side.
|
|
124
|
-
*/
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
function useSideAnimation(value) {
|
|
128
|
-
const [isActive, setIsActive] = useState(false);
|
|
129
|
-
const valueRef = useRef(value);
|
|
130
|
-
const timeoutRef = useRef();
|
|
131
|
-
|
|
132
|
-
const clearTimer = () => {
|
|
133
|
-
if (timeoutRef.current) {
|
|
134
|
-
window.clearTimeout(timeoutRef.current);
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
useEffect(() => {
|
|
139
|
-
if (value !== valueRef.current) {
|
|
140
|
-
setIsActive(true);
|
|
141
|
-
valueRef.current = value;
|
|
142
|
-
clearTimer();
|
|
143
|
-
timeoutRef.current = setTimeout(() => {
|
|
144
|
-
setIsActive(false);
|
|
145
|
-
}, 400);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return () => clearTimer();
|
|
149
|
-
}, [value]);
|
|
150
|
-
return {
|
|
151
|
-
isActive
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
//# sourceMappingURL=visualizer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/box-control/visualizer.js"],"names":["useRef","useEffect","useState","Container","TopView","RightView","BottomView","LeftView","DEFAULT_VALUES","DEFAULT_VISUALIZER_VALUES","BoxControlVisualizer","children","showValues","values","valuesProp","props","isPositionAbsolute","Sides","top","right","bottom","left","Top","isVisible","value","height","animationProps","useSideAnimation","isActive","Right","width","Bottom","Left","setIsActive","valueRef","timeoutRef","clearTimer","current","window","clearTimeout","setTimeout"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,SAAjB,EAA4BC,QAA5B,QAA4C,oBAA5C;AAEA;AACA;AACA;;AACA,SACCC,SADD,EAECC,OAFD,EAGCC,SAHD,EAICC,UAJD,EAKCC,QALD,QAMO,wCANP;AAOA,SAASC,cAAT,EAAyBC,yBAAzB,QAA0D,SAA1D;AAEA,eAA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AAAgC,IAAA,KAAK,EAAG;AAAEE,MAAAA;AAAF;AAAxC,IAAP;AACA;AAED;AACA;AACA;AACA;AACA;;;AACA,SAASH,gBAAT,CAA2BH,KAA3B,EAAmC;AAClC,QAAM,CAAEI,QAAF,EAAYK,WAAZ,IAA4B/B,QAAQ,CAAE,KAAF,CAA1C;AACA,QAAMgC,QAAQ,GAAGlC,MAAM,CAAEwB,KAAF,CAAvB;AACA,QAAMW,UAAU,GAAGnC,MAAM,EAAzB;;AAEA,QAAMoC,UAAU,GAAG,MAAM;AACxB,QAAKD,UAAU,CAACE,OAAhB,EAA0B;AACzBC,MAAAA,MAAM,CAACC,YAAP,CAAqBJ,UAAU,CAACE,OAAhC;AACA;AACD,GAJD;;AAMApC,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAKuB,KAAK,KAAKU,QAAQ,CAACG,OAAxB,EAAkC;AACjCJ,MAAAA,WAAW,CAAE,IAAF,CAAX;AACAC,MAAAA,QAAQ,CAACG,OAAT,GAAmBb,KAAnB;AAEAY,MAAAA,UAAU;AAEVD,MAAAA,UAAU,CAACE,OAAX,GAAqBG,UAAU,CAAE,MAAM;AACtCP,QAAAA,WAAW,CAAE,KAAF,CAAX;AACA,OAF8B,EAE5B,GAF4B,CAA/B;AAGA;;AAED,WAAO,MAAMG,UAAU,EAAvB;AACA,GAbQ,EAaN,CAAEZ,KAAF,CAbM,CAAT;AAeA,SAAO;AACNI,IAAAA;AADM,GAAP;AAGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tContainer,\n\tTopView,\n\tRightView,\n\tBottomView,\n\tLeftView,\n} from './styles/box-control-visualizer-styles';\nimport { DEFAULT_VALUES, DEFAULT_VISUALIZER_VALUES } from './utils';\n\nexport default function BoxControlVisualizer( {\n\tchildren,\n\tshowValues = DEFAULT_VISUALIZER_VALUES,\n\tvalues: valuesProp = DEFAULT_VALUES,\n\t...props\n} ) {\n\tconst isPositionAbsolute = ! children;\n\treturn (\n\t\t<Container\n\t\t\t{ ...props }\n\t\t\tisPositionAbsolute={ isPositionAbsolute }\n\t\t\taria-hidden=\"true\"\n\t\t>\n\t\t\t<Sides showValues={ showValues } values={ valuesProp } />\n\t\t\t{ children }\n\t\t</Container>\n\t);\n}\n\nfunction Sides( { showValues = DEFAULT_VISUALIZER_VALUES, values } ) {\n\tconst { top, right, bottom, left } = values;\n\n\treturn (\n\t\t<>\n\t\t\t<Top isVisible={ showValues.top } value={ top } />\n\t\t\t<Right isVisible={ showValues.right } value={ right } />\n\t\t\t<Bottom isVisible={ showValues.bottom } value={ bottom } />\n\t\t\t<Left isVisible={ showValues.left } value={ left } />\n\t\t</>\n\t);\n}\n\nfunction Top( { isVisible = false, value } ) {\n\tconst height = value;\n\tconst animationProps = useSideAnimation( height );\n\tconst isActive = animationProps.isActive || isVisible;\n\n\treturn <TopView isActive={ isActive } style={ { height } } />;\n}\n\nfunction Right( { isVisible = false, value } ) {\n\tconst width = value;\n\tconst animationProps = useSideAnimation( width );\n\tconst isActive = animationProps.isActive || isVisible;\n\n\treturn <RightView isActive={ isActive } style={ { width } } />;\n}\n\nfunction Bottom( { isVisible = false, value } ) {\n\tconst height = value;\n\tconst animationProps = useSideAnimation( height );\n\tconst isActive = animationProps.isActive || isVisible;\n\n\treturn <BottomView isActive={ isActive } style={ { height } } />;\n}\n\nfunction Left( { isVisible = false, value } ) {\n\tconst width = value;\n\tconst animationProps = useSideAnimation( width );\n\tconst isActive = animationProps.isActive || isVisible;\n\n\treturn <LeftView isActive={ isActive } style={ { width } } />;\n}\n\n/**\n * Custom hook that renders the \"flash\" animation whenever the value changes.\n *\n * @param {string} value Value of (box) side.\n */\nfunction useSideAnimation( value ) {\n\tconst [ isActive, setIsActive ] = useState( false );\n\tconst valueRef = useRef( value );\n\tconst timeoutRef = useRef();\n\n\tconst clearTimer = () => {\n\t\tif ( timeoutRef.current ) {\n\t\t\twindow.clearTimeout( timeoutRef.current );\n\t\t}\n\t};\n\n\tuseEffect( () => {\n\t\tif ( value !== valueRef.current ) {\n\t\t\tsetIsActive( true );\n\t\t\tvalueRef.current = value;\n\n\t\t\tclearTimer();\n\n\t\t\ttimeoutRef.current = setTimeout( () => {\n\t\t\t\tsetIsActive( false );\n\t\t\t}, 400 );\n\t\t}\n\n\t\treturn () => clearTimer();\n\t}, [ value ] );\n\n\treturn {\n\t\tisActive,\n\t};\n}\n"]}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useRef, useEffect, useState } from '@wordpress/element';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import {
|
|
10
|
-
Container,
|
|
11
|
-
TopView,
|
|
12
|
-
RightView,
|
|
13
|
-
BottomView,
|
|
14
|
-
LeftView,
|
|
15
|
-
} from './styles/box-control-visualizer-styles';
|
|
16
|
-
import { DEFAULT_VALUES, DEFAULT_VISUALIZER_VALUES } from './utils';
|
|
17
|
-
|
|
18
|
-
export default function BoxControlVisualizer( {
|
|
19
|
-
children,
|
|
20
|
-
showValues = DEFAULT_VISUALIZER_VALUES,
|
|
21
|
-
values: valuesProp = DEFAULT_VALUES,
|
|
22
|
-
...props
|
|
23
|
-
} ) {
|
|
24
|
-
const isPositionAbsolute = ! children;
|
|
25
|
-
return (
|
|
26
|
-
<Container
|
|
27
|
-
{ ...props }
|
|
28
|
-
isPositionAbsolute={ isPositionAbsolute }
|
|
29
|
-
aria-hidden="true"
|
|
30
|
-
>
|
|
31
|
-
<Sides showValues={ showValues } values={ valuesProp } />
|
|
32
|
-
{ children }
|
|
33
|
-
</Container>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function Sides( { showValues = DEFAULT_VISUALIZER_VALUES, values } ) {
|
|
38
|
-
const { top, right, bottom, left } = values;
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<>
|
|
42
|
-
<Top isVisible={ showValues.top } value={ top } />
|
|
43
|
-
<Right isVisible={ showValues.right } value={ right } />
|
|
44
|
-
<Bottom isVisible={ showValues.bottom } value={ bottom } />
|
|
45
|
-
<Left isVisible={ showValues.left } value={ left } />
|
|
46
|
-
</>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function Top( { isVisible = false, value } ) {
|
|
51
|
-
const height = value;
|
|
52
|
-
const animationProps = useSideAnimation( height );
|
|
53
|
-
const isActive = animationProps.isActive || isVisible;
|
|
54
|
-
|
|
55
|
-
return <TopView isActive={ isActive } style={ { height } } />;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function Right( { isVisible = false, value } ) {
|
|
59
|
-
const width = value;
|
|
60
|
-
const animationProps = useSideAnimation( width );
|
|
61
|
-
const isActive = animationProps.isActive || isVisible;
|
|
62
|
-
|
|
63
|
-
return <RightView isActive={ isActive } style={ { width } } />;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function Bottom( { isVisible = false, value } ) {
|
|
67
|
-
const height = value;
|
|
68
|
-
const animationProps = useSideAnimation( height );
|
|
69
|
-
const isActive = animationProps.isActive || isVisible;
|
|
70
|
-
|
|
71
|
-
return <BottomView isActive={ isActive } style={ { height } } />;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function Left( { isVisible = false, value } ) {
|
|
75
|
-
const width = value;
|
|
76
|
-
const animationProps = useSideAnimation( width );
|
|
77
|
-
const isActive = animationProps.isActive || isVisible;
|
|
78
|
-
|
|
79
|
-
return <LeftView isActive={ isActive } style={ { width } } />;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Custom hook that renders the "flash" animation whenever the value changes.
|
|
84
|
-
*
|
|
85
|
-
* @param {string} value Value of (box) side.
|
|
86
|
-
*/
|
|
87
|
-
function useSideAnimation( value ) {
|
|
88
|
-
const [ isActive, setIsActive ] = useState( false );
|
|
89
|
-
const valueRef = useRef( value );
|
|
90
|
-
const timeoutRef = useRef();
|
|
91
|
-
|
|
92
|
-
const clearTimer = () => {
|
|
93
|
-
if ( timeoutRef.current ) {
|
|
94
|
-
window.clearTimeout( timeoutRef.current );
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
useEffect( () => {
|
|
99
|
-
if ( value !== valueRef.current ) {
|
|
100
|
-
setIsActive( true );
|
|
101
|
-
valueRef.current = value;
|
|
102
|
-
|
|
103
|
-
clearTimer();
|
|
104
|
-
|
|
105
|
-
timeoutRef.current = setTimeout( () => {
|
|
106
|
-
setIsActive( false );
|
|
107
|
-
}, 400 );
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return () => clearTimer();
|
|
111
|
-
}, [ value ] );
|
|
112
|
-
|
|
113
|
-
return {
|
|
114
|
-
isActive,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { boolean, select, text } from '@storybook/addon-knobs';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { useState } from '@wordpress/element';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import InputControl from '../';
|
|
15
|
-
|
|
16
|
-
export default {
|
|
17
|
-
title: 'Components (Experimental)/InputControl',
|
|
18
|
-
component: InputControl,
|
|
19
|
-
parameters: {
|
|
20
|
-
knobs: { disable: false },
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
function Example() {
|
|
25
|
-
const [ value, setValue ] = useState( '' );
|
|
26
|
-
|
|
27
|
-
const props = {
|
|
28
|
-
disabled: boolean( 'disabled', false ),
|
|
29
|
-
hideLabelFromVision: boolean( 'hideLabelFromVision', false ),
|
|
30
|
-
isPressEnterToChange: boolean( 'isPressEnterToChange', false ),
|
|
31
|
-
label: text( 'label', 'Value' ),
|
|
32
|
-
labelPosition: select(
|
|
33
|
-
'labelPosition',
|
|
34
|
-
{
|
|
35
|
-
top: 'top',
|
|
36
|
-
side: 'side',
|
|
37
|
-
bottom: 'bottom',
|
|
38
|
-
},
|
|
39
|
-
'top'
|
|
40
|
-
),
|
|
41
|
-
placeholder: text( 'placeholder', 'Placeholder' ),
|
|
42
|
-
size: select(
|
|
43
|
-
'size',
|
|
44
|
-
{
|
|
45
|
-
default: 'default',
|
|
46
|
-
small: 'small',
|
|
47
|
-
'__unstable-large': '__unstable-large',
|
|
48
|
-
},
|
|
49
|
-
'default'
|
|
50
|
-
),
|
|
51
|
-
suffix: text( 'suffix', '' ),
|
|
52
|
-
prefix: text( 'prefix', '' ),
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const suffixMarkup = props.suffix ? <div>{ props.suffix }</div> : null;
|
|
56
|
-
const prefixMarkup = props.prefix ? <div>{ props.prefix }</div> : null;
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<InputControl
|
|
60
|
-
{ ...props }
|
|
61
|
-
onChange={ ( v ) => setValue( v ) }
|
|
62
|
-
prefix={ prefixMarkup }
|
|
63
|
-
suffix={ suffixMarkup }
|
|
64
|
-
value={ value }
|
|
65
|
-
/>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export const _default = () => {
|
|
70
|
-
return <Example />;
|
|
71
|
-
};
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { boolean, object, select, text } from '@storybook/addon-knobs';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { useState } from '@wordpress/element';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import SelectControl from '..';
|
|
15
|
-
|
|
16
|
-
export default {
|
|
17
|
-
title: 'Components/SelectControl',
|
|
18
|
-
component: SelectControl,
|
|
19
|
-
parameters: {
|
|
20
|
-
knobs: { disable: false },
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const SelectControlWithState = ( props ) => {
|
|
25
|
-
const [ selection, setSelection ] = useState();
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<SelectControl
|
|
29
|
-
{ ...props }
|
|
30
|
-
value={ selection }
|
|
31
|
-
onChange={ setSelection }
|
|
32
|
-
/>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const _default = () => {
|
|
37
|
-
const props = {
|
|
38
|
-
disabled: boolean( 'disabled', false ),
|
|
39
|
-
help: text( 'help', 'Help text to explain the select control.' ),
|
|
40
|
-
hideLabelFromVision: boolean( 'hideLabelFromVision', false ),
|
|
41
|
-
label: text( 'label', 'Value' ),
|
|
42
|
-
labelPosition: select(
|
|
43
|
-
'labelPosition',
|
|
44
|
-
{
|
|
45
|
-
top: 'top',
|
|
46
|
-
side: 'side',
|
|
47
|
-
bottom: 'bottom',
|
|
48
|
-
},
|
|
49
|
-
'top'
|
|
50
|
-
),
|
|
51
|
-
multiple: boolean( 'multiple', false ),
|
|
52
|
-
options: object( 'Options', [
|
|
53
|
-
{ value: null, label: 'Select an Option', disabled: true },
|
|
54
|
-
{ value: 'a', label: 'Option A' },
|
|
55
|
-
{ value: 'b', label: 'Option B' },
|
|
56
|
-
{ value: 'c', label: 'Option C' },
|
|
57
|
-
] ),
|
|
58
|
-
size: select(
|
|
59
|
-
'size',
|
|
60
|
-
{
|
|
61
|
-
default: 'default',
|
|
62
|
-
small: 'small',
|
|
63
|
-
'__unstable-large': '__unstable-large',
|
|
64
|
-
},
|
|
65
|
-
'default'
|
|
66
|
-
),
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
return <SelectControlWithState { ...props } />;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export const withCustomChildren = () => {
|
|
73
|
-
return (
|
|
74
|
-
<SelectControlWithState label="Value">
|
|
75
|
-
<option value="option-1">Option 1</option>
|
|
76
|
-
<option value="option-2" disabled>
|
|
77
|
-
Option 2 - Disabled
|
|
78
|
-
</option>
|
|
79
|
-
<option value="option-3">Option 3</option>
|
|
80
|
-
<optgroup label="Option Group 1">
|
|
81
|
-
<option value="option-group-1-option-1">
|
|
82
|
-
Option Group 1 - Option 1
|
|
83
|
-
</option>
|
|
84
|
-
<option value="option-group-1-option-2" disabled>
|
|
85
|
-
Option Group 1 - Option 2 - Disabled
|
|
86
|
-
</option>
|
|
87
|
-
<option value="option-group-1-option-3">
|
|
88
|
-
Option Group 1 - Option 3
|
|
89
|
-
</option>
|
|
90
|
-
</optgroup>
|
|
91
|
-
<optgroup label="Option Group 2">
|
|
92
|
-
<option value="option-group-2-option-1">
|
|
93
|
-
Option Group 2 - Option 1
|
|
94
|
-
</option>
|
|
95
|
-
<option value="option-group-2-option-2" disabled>
|
|
96
|
-
Option Group 2 - Option 2 - Disabled
|
|
97
|
-
</option>
|
|
98
|
-
<option value="option-group-2-option-3">
|
|
99
|
-
Option Group 2 - Option 3
|
|
100
|
-
</option>
|
|
101
|
-
</optgroup>
|
|
102
|
-
</SelectControlWithState>
|
|
103
|
-
);
|
|
104
|
-
};
|