@wordpress/components 25.15.0 → 25.16.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 +26 -0
- package/build/border-box-control/border-box-control/component.js.map +1 -1
- package/build/border-box-control/border-box-control/hook.js +3 -1
- package/build/border-box-control/border-box-control/hook.js.map +1 -1
- package/build/border-box-control/types.js.map +1 -1
- package/build/border-control/border-control/component.js +5 -1
- package/build/border-control/border-control/component.js.map +1 -1
- package/build/border-control/border-control/hook.js +18 -15
- package/build/border-control/border-control/hook.js.map +1 -1
- package/build/border-control/border-control-dropdown/component.js +2 -1
- package/build/border-control/border-control-dropdown/component.js.map +1 -1
- package/build/border-control/border-control-style-picker/component.js +21 -49
- package/build/border-control/border-control-style-picker/component.js.map +1 -1
- package/build/border-control/styles.js +15 -27
- package/build/border-control/styles.js.map +1 -1
- package/build/border-control/types.js.map +1 -1
- package/build/box-control/all-input-control.js +35 -29
- package/build/box-control/all-input-control.js.map +1 -1
- package/build/box-control/axial-input-controls.js +40 -54
- package/build/box-control/axial-input-controls.js.map +1 -1
- package/build/box-control/index.js +21 -24
- package/build/box-control/index.js.map +1 -1
- package/build/box-control/input-controls.js +45 -37
- package/build/box-control/input-controls.js.map +1 -1
- package/build/box-control/styles/box-control-styles.js +50 -112
- package/build/box-control/styles/box-control-styles.js.map +1 -1
- package/build/box-control/types.js.map +1 -1
- package/build/box-control/utils.js +123 -8
- package/build/box-control/utils.js.map +1 -1
- package/build/button/index.js +14 -16
- package/build/button/index.js.map +1 -1
- package/build/button/types.js.map +1 -1
- package/build/color-palette/index.native.js +11 -7
- package/build/color-palette/index.native.js.map +1 -1
- package/build/color-picker/hsl-input.js +55 -33
- package/build/color-picker/hsl-input.js.map +1 -1
- package/build/custom-select-control-v2/index.js +3 -2
- package/build/custom-select-control-v2/index.js.map +1 -1
- package/build/mobile/color-settings/palette.screen.native.js +8 -4
- package/build/mobile/color-settings/palette.screen.native.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/use-slot-fills.js +1 -1
- package/build/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -1
- package/build/theme/styles.js +11 -6
- package/build/theme/styles.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/utils.js +7 -1
- package/build/toggle-group-control/toggle-group-control/utils.js.map +1 -1
- package/build/tooltip/index.js +35 -8
- package/build/tooltip/index.js.map +1 -1
- package/build/tooltip/types.js.map +1 -1
- package/build-module/border-box-control/border-box-control/component.js.map +1 -1
- package/build-module/border-box-control/border-box-control/hook.js +3 -1
- package/build-module/border-box-control/border-box-control/hook.js.map +1 -1
- package/build-module/border-box-control/types.js.map +1 -1
- package/build-module/border-control/border-control/component.js +5 -1
- package/build-module/border-control/border-control/component.js.map +1 -1
- package/build-module/border-control/border-control/hook.js +18 -15
- package/build-module/border-control/border-control/hook.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/component.js +2 -1
- package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
- package/build-module/border-control/border-control-style-picker/component.js +21 -48
- package/build-module/border-control/border-control-style-picker/component.js.map +1 -1
- package/build-module/border-control/styles.js +14 -24
- package/build-module/border-control/styles.js.map +1 -1
- package/build-module/border-control/types.js.map +1 -1
- package/build-module/box-control/all-input-control.js +38 -28
- package/build-module/box-control/all-input-control.js.map +1 -1
- package/build-module/box-control/axial-input-controls.js +42 -57
- package/build-module/box-control/axial-input-controls.js.map +1 -1
- package/build-module/box-control/index.js +22 -25
- package/build-module/box-control/index.js.map +1 -1
- package/build-module/box-control/input-controls.js +47 -40
- package/build-module/box-control/input-controls.js.map +1 -1
- package/build-module/box-control/styles/box-control-styles.js +45 -105
- package/build-module/box-control/styles/box-control-styles.js.map +1 -1
- package/build-module/box-control/types.js.map +1 -1
- package/build-module/box-control/utils.js +121 -7
- package/build-module/box-control/utils.js.map +1 -1
- package/build-module/button/index.js +14 -16
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/types.js.map +1 -1
- package/build-module/color-palette/index.native.js +11 -7
- package/build-module/color-palette/index.native.js.map +1 -1
- package/build-module/color-picker/hsl-input.js +55 -33
- package/build-module/color-picker/hsl-input.js.map +1 -1
- package/build-module/custom-select-control-v2/index.js +3 -2
- package/build-module/custom-select-control-v2/index.js.map +1 -1
- package/build-module/mobile/color-settings/palette.screen.native.js +8 -4
- package/build-module/mobile/color-settings/palette.screen.native.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/use-slot-fills.js +1 -1
- package/build-module/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -1
- package/build-module/theme/styles.js +11 -2
- package/build-module/theme/styles.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/utils.js +7 -1
- package/build-module/toggle-group-control/toggle-group-control/utils.js.map +1 -1
- package/build-module/tooltip/index.js +34 -9
- package/build-module/tooltip/index.js.map +1 -1
- package/build-module/tooltip/types.js.map +1 -1
- package/build-style/style-rtl.css +6 -4
- package/build-style/style.css +6 -4
- package/build-types/border-box-control/border-box-control/component.d.ts +1 -0
- package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +3 -3
- package/build-types/border-box-control/stories/index.story.d.ts +2 -1
- package/build-types/border-box-control/stories/index.story.d.ts.map +1 -1
- package/build-types/border-box-control/types.d.ts +6 -0
- package/build-types/border-box-control/types.d.ts.map +1 -1
- package/build-types/border-control/border-control/component.d.ts +1 -0
- package/build-types/border-control/border-control/component.d.ts.map +1 -1
- package/build-types/border-control/border-control/hook.d.ts +2 -0
- package/build-types/border-control/border-control/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/component.d.ts +1 -0
- package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/hook.d.ts +1 -0
- package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control-style-picker/component.d.ts +3 -4
- package/build-types/border-control/border-control-style-picker/component.d.ts.map +1 -1
- package/build-types/border-control/stories/index.story.d.ts +12 -6
- package/build-types/border-control/stories/index.story.d.ts.map +1 -1
- package/build-types/border-control/styles.d.ts +0 -2
- package/build-types/border-control/styles.d.ts.map +1 -1
- package/build-types/border-control/types.d.ts +12 -1
- package/build-types/border-control/types.d.ts.map +1 -1
- package/build-types/box-control/all-input-control.d.ts +1 -1
- package/build-types/box-control/all-input-control.d.ts.map +1 -1
- package/build-types/box-control/axial-input-controls.d.ts +1 -1
- package/build-types/box-control/axial-input-controls.d.ts.map +1 -1
- package/build-types/box-control/index.d.ts +1 -1
- package/build-types/box-control/index.d.ts.map +1 -1
- package/build-types/box-control/input-controls.d.ts +1 -1
- package/build-types/box-control/input-controls.d.ts.map +1 -1
- package/build-types/box-control/stories/index.story.d.ts +24 -18
- package/build-types/box-control/stories/index.story.d.ts.map +1 -1
- package/build-types/box-control/styles/box-control-styles.d.ts +49 -23
- package/build-types/box-control/styles/box-control-styles.d.ts.map +1 -1
- package/build-types/box-control/types.d.ts +12 -12
- package/build-types/box-control/types.d.ts.map +1 -1
- package/build-types/box-control/utils.d.ts +2 -1
- package/build-types/box-control/utils.d.ts.map +1 -1
- package/build-types/button/deprecated.d.ts +1 -1
- package/build-types/button/index.d.ts.map +1 -1
- package/build-types/button/types.d.ts +7 -3
- package/build-types/button/types.d.ts.map +1 -1
- package/build-types/color-picker/hsl-input.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +1 -1
- package/build-types/custom-select-control-v2/index.d.ts.map +1 -1
- package/build-types/date-time/time/styles.d.ts +4 -4
- package/build-types/focal-point-picker/stories/index.story.d.ts +4 -4
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
- package/build-types/navigation/styles/navigation-styles.d.ts +1 -1
- package/build-types/navigator/navigator-back-button/hook.d.ts +2 -2
- package/build-types/navigator/navigator-button/hook.d.ts +2 -2
- package/build-types/number-control/index.d.ts +1 -1
- package/build-types/number-control/stories/index.story.d.ts +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts +1 -1
- package/build-types/search-control/index.d.ts +1 -1
- package/build-types/search-control/stories/index.story.d.ts +2 -2
- package/build-types/text-control/index.d.ts +1 -1
- package/build-types/textarea-control/index.d.ts +1 -1
- package/build-types/theme/styles.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control/utils.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts +1 -1
- package/build-types/toolbar/toolbar-button/index.d.ts +1 -1
- package/build-types/tooltip/index.d.ts +1 -1
- package/build-types/tooltip/index.d.ts.map +1 -1
- package/build-types/tooltip/stories/index.story.d.ts +10 -1
- package/build-types/tooltip/stories/index.story.d.ts.map +1 -1
- package/build-types/tooltip/types.d.ts +3 -0
- package/build-types/tooltip/types.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -1
- package/package.json +19 -19
- package/src/border-box-control/border-box-control/component.tsx +0 -1
- package/src/border-box-control/border-box-control/hook.ts +5 -1
- package/src/border-box-control/types.ts +6 -0
- package/src/border-control/border-control/component.tsx +4 -0
- package/src/border-control/border-control/hook.ts +22 -16
- package/src/border-control/border-control-dropdown/component.tsx +2 -1
- package/src/border-control/border-control-style-picker/component.tsx +31 -66
- package/src/border-control/styles.ts +0 -15
- package/src/border-control/types.ts +15 -1
- package/src/box-control/all-input-control.tsx +57 -34
- package/src/box-control/axial-input-controls.tsx +79 -69
- package/src/box-control/index.tsx +47 -54
- package/src/box-control/input-controls.tsx +114 -83
- package/src/box-control/styles/box-control-styles.ts +21 -61
- package/src/box-control/test/index.tsx +126 -18
- package/src/box-control/types.ts +10 -21
- package/src/box-control/utils.ts +43 -8
- package/src/button/README.md +1 -1
- package/src/button/index.tsx +21 -33
- package/src/button/test/index.tsx +122 -0
- package/src/button/types.ts +7 -3
- package/src/circular-option-picker/test/index.tsx +10 -16
- package/src/color-palette/index.native.js +18 -7
- package/src/color-picker/hsl-input.tsx +56 -30
- package/src/color-picker/test/index.tsx +190 -16
- package/src/custom-select-control-v2/index.tsx +5 -2
- package/src/mobile/color-settings/palette.screen.native.js +7 -5
- package/src/palette-edit/test/index.tsx +326 -10
- package/src/slot-fill/bubbles-virtually/use-slot-fills.ts +1 -1
- package/src/tabs/test/index.tsx +3 -1
- package/src/theme/styles.ts +3 -1
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +6 -6
- package/src/toggle-group-control/test/index.tsx +73 -36
- package/src/toggle-group-control/toggle-group-control/utils.ts +8 -3
- package/src/tooltip/README.md +4 -0
- package/src/tooltip/index.tsx +46 -8
- package/src/tooltip/stories/index.story.tsx +18 -1
- package/src/tooltip/test/index.tsx +77 -12
- package/src/tooltip/types.ts +4 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/border-control/border-control-style-picker/hook.js +0 -41
- package/build/border-control/border-control-style-picker/hook.js.map +0 -1
- package/build/box-control/styles/box-control-visualizer-styles.js +0 -93
- package/build/box-control/styles/box-control-visualizer-styles.js.map +0 -1
- package/build/box-control/unit-control.js +0 -76
- package/build/box-control/unit-control.js.map +0 -1
- package/build-module/border-control/border-control-style-picker/hook.js +0 -32
- package/build-module/border-control/border-control-style-picker/hook.js.map +0 -1
- package/build-module/box-control/styles/box-control-visualizer-styles.js +0 -86
- package/build-module/box-control/styles/box-control-visualizer-styles.js.map +0 -1
- package/build-module/box-control/unit-control.js +0 -68
- package/build-module/box-control/unit-control.js.map +0 -1
- package/build-types/border-control/border-control-style-picker/hook.d.ts +0 -267
- package/build-types/border-control/border-control-style-picker/hook.d.ts.map +0 -1
- package/build-types/box-control/styles/box-control-visualizer-styles.d.ts +0 -46
- package/build-types/box-control/styles/box-control-visualizer-styles.d.ts.map +0 -1
- package/build-types/box-control/unit-control.d.ts +0 -4
- package/build-types/box-control/unit-control.d.ts.map +0 -1
- package/src/border-control/border-control-style-picker/hook.ts +0 -35
- package/src/box-control/styles/box-control-visualizer-styles.ts +0 -75
- package/src/box-control/unit-control.tsx +0 -74
|
@@ -6,11 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.HslInput = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _colord = require("colord");
|
|
9
|
+
var _element = require("@wordpress/element");
|
|
9
10
|
var _inputWithSlider = require("./input-with-slider");
|
|
10
11
|
/**
|
|
11
12
|
* External dependencies
|
|
12
13
|
*/
|
|
13
14
|
|
|
15
|
+
/**
|
|
16
|
+
* WordPress dependencies
|
|
17
|
+
*/
|
|
18
|
+
|
|
14
19
|
/**
|
|
15
20
|
* Internal dependencies
|
|
16
21
|
*/
|
|
@@ -20,67 +25,84 @@ const HslInput = ({
|
|
|
20
25
|
onChange,
|
|
21
26
|
enableAlpha
|
|
22
27
|
}) => {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
const colorPropHSLA = (0, _element.useMemo)(() => color.toHsl(), [color]);
|
|
29
|
+
const [internalHSLA, setInternalHSLA] = (0, _element.useState)({
|
|
30
|
+
...colorPropHSLA
|
|
31
|
+
});
|
|
32
|
+
const isInternalColorSameAsReceivedColor = color.isEqual((0, _colord.colord)(internalHSLA));
|
|
33
|
+
(0, _element.useEffect)(() => {
|
|
34
|
+
if (!isInternalColorSameAsReceivedColor) {
|
|
35
|
+
// Keep internal HSLA color up to date with the received color prop
|
|
36
|
+
setInternalHSLA(colorPropHSLA);
|
|
37
|
+
}
|
|
38
|
+
}, [colorPropHSLA, isInternalColorSameAsReceivedColor]);
|
|
39
|
+
|
|
40
|
+
// If the internal color is equal to the received color prop, we can use the
|
|
41
|
+
// HSLA values from the local state which, compared to the received color prop,
|
|
42
|
+
// retain more details about the actual H and S values that the user selected,
|
|
43
|
+
// and thus allow for better UX when interacting with the H and S sliders.
|
|
44
|
+
const colorValue = isInternalColorSameAsReceivedColor ? internalHSLA : colorPropHSLA;
|
|
45
|
+
const updateHSLAValue = partialNewValue => {
|
|
46
|
+
const nextOnChangeValue = (0, _colord.colord)({
|
|
47
|
+
...colorValue,
|
|
48
|
+
...partialNewValue
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Fire `onChange` only if the resulting color is different from the
|
|
52
|
+
// current one.
|
|
53
|
+
// Otherwise, update the internal HSLA color to cause a re-render.
|
|
54
|
+
if (!color.isEqual(nextOnChangeValue)) {
|
|
55
|
+
onChange(nextOnChangeValue);
|
|
56
|
+
} else {
|
|
57
|
+
setInternalHSLA(prevHSLA => ({
|
|
58
|
+
...prevHSLA,
|
|
59
|
+
...partialNewValue
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
};
|
|
29
63
|
return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_inputWithSlider.InputWithSlider, {
|
|
30
64
|
min: 0,
|
|
31
65
|
max: 359,
|
|
32
66
|
label: "Hue",
|
|
33
67
|
abbreviation: "H",
|
|
34
|
-
value: h,
|
|
68
|
+
value: colorValue.h,
|
|
35
69
|
onChange: nextH => {
|
|
36
|
-
|
|
37
|
-
h: nextH
|
|
38
|
-
|
|
39
|
-
l,
|
|
40
|
-
a
|
|
41
|
-
}));
|
|
70
|
+
updateHSLAValue({
|
|
71
|
+
h: nextH
|
|
72
|
+
});
|
|
42
73
|
}
|
|
43
74
|
}), (0, _react.createElement)(_inputWithSlider.InputWithSlider, {
|
|
44
75
|
min: 0,
|
|
45
76
|
max: 100,
|
|
46
77
|
label: "Saturation",
|
|
47
78
|
abbreviation: "S",
|
|
48
|
-
value: s,
|
|
79
|
+
value: colorValue.s,
|
|
49
80
|
onChange: nextS => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
l,
|
|
54
|
-
a
|
|
55
|
-
}));
|
|
81
|
+
updateHSLAValue({
|
|
82
|
+
s: nextS
|
|
83
|
+
});
|
|
56
84
|
}
|
|
57
85
|
}), (0, _react.createElement)(_inputWithSlider.InputWithSlider, {
|
|
58
86
|
min: 0,
|
|
59
87
|
max: 100,
|
|
60
88
|
label: "Lightness",
|
|
61
89
|
abbreviation: "L",
|
|
62
|
-
value: l,
|
|
90
|
+
value: colorValue.l,
|
|
63
91
|
onChange: nextL => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
l: nextL,
|
|
68
|
-
a
|
|
69
|
-
}));
|
|
92
|
+
updateHSLAValue({
|
|
93
|
+
l: nextL
|
|
94
|
+
});
|
|
70
95
|
}
|
|
71
96
|
}), enableAlpha && (0, _react.createElement)(_inputWithSlider.InputWithSlider, {
|
|
72
97
|
min: 0,
|
|
73
98
|
max: 100,
|
|
74
99
|
label: "Alpha",
|
|
75
100
|
abbreviation: "A",
|
|
76
|
-
value: Math.trunc(100 * a),
|
|
101
|
+
value: Math.trunc(100 * colorValue.a),
|
|
77
102
|
onChange: nextA => {
|
|
78
|
-
|
|
79
|
-
h,
|
|
80
|
-
s,
|
|
81
|
-
l,
|
|
103
|
+
updateHSLAValue({
|
|
82
104
|
a: nextA / 100
|
|
83
|
-
})
|
|
105
|
+
});
|
|
84
106
|
}
|
|
85
107
|
}));
|
|
86
108
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_colord","require","_inputWithSlider","HslInput","color","onChange","enableAlpha","
|
|
1
|
+
{"version":3,"names":["_colord","require","_element","_inputWithSlider","HslInput","color","onChange","enableAlpha","colorPropHSLA","useMemo","toHsl","internalHSLA","setInternalHSLA","useState","isInternalColorSameAsReceivedColor","isEqual","colord","useEffect","colorValue","updateHSLAValue","partialNewValue","nextOnChangeValue","prevHSLA","_react","createElement","Fragment","InputWithSlider","min","max","label","abbreviation","value","h","nextH","s","nextS","l","nextL","Math","trunc","a","nextA","exports"],"sources":["@wordpress/components/src/color-picker/hsl-input.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport { colord } from 'colord';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InputWithSlider } from './input-with-slider';\nimport type { HslInputProps } from './types';\n\nexport const HslInput = ( { color, onChange, enableAlpha }: HslInputProps ) => {\n\tconst colorPropHSLA = useMemo( () => color.toHsl(), [ color ] );\n\n\tconst [ internalHSLA, setInternalHSLA ] = useState( { ...colorPropHSLA } );\n\n\tconst isInternalColorSameAsReceivedColor = color.isEqual(\n\t\tcolord( internalHSLA )\n\t);\n\n\tuseEffect( () => {\n\t\tif ( ! isInternalColorSameAsReceivedColor ) {\n\t\t\t// Keep internal HSLA color up to date with the received color prop\n\t\t\tsetInternalHSLA( colorPropHSLA );\n\t\t}\n\t}, [ colorPropHSLA, isInternalColorSameAsReceivedColor ] );\n\n\t// If the internal color is equal to the received color prop, we can use the\n\t// HSLA values from the local state which, compared to the received color prop,\n\t// retain more details about the actual H and S values that the user selected,\n\t// and thus allow for better UX when interacting with the H and S sliders.\n\tconst colorValue = isInternalColorSameAsReceivedColor\n\t\t? internalHSLA\n\t\t: colorPropHSLA;\n\n\tconst updateHSLAValue = (\n\t\tpartialNewValue: Partial< typeof colorPropHSLA >\n\t) => {\n\t\tconst nextOnChangeValue = colord( {\n\t\t\t...colorValue,\n\t\t\t...partialNewValue,\n\t\t} );\n\n\t\t// Fire `onChange` only if the resulting color is different from the\n\t\t// current one.\n\t\t// Otherwise, update the internal HSLA color to cause a re-render.\n\t\tif ( ! color.isEqual( nextOnChangeValue ) ) {\n\t\t\tonChange( nextOnChangeValue );\n\t\t} else {\n\t\t\tsetInternalHSLA( ( prevHSLA ) => ( {\n\t\t\t\t...prevHSLA,\n\t\t\t\t...partialNewValue,\n\t\t\t} ) );\n\t\t}\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<InputWithSlider\n\t\t\t\tmin={ 0 }\n\t\t\t\tmax={ 359 }\n\t\t\t\tlabel=\"Hue\"\n\t\t\t\tabbreviation=\"H\"\n\t\t\t\tvalue={ colorValue.h }\n\t\t\t\tonChange={ ( nextH: number ) => {\n\t\t\t\t\tupdateHSLAValue( { h: nextH } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<InputWithSlider\n\t\t\t\tmin={ 0 }\n\t\t\t\tmax={ 100 }\n\t\t\t\tlabel=\"Saturation\"\n\t\t\t\tabbreviation=\"S\"\n\t\t\t\tvalue={ colorValue.s }\n\t\t\t\tonChange={ ( nextS: number ) => {\n\t\t\t\t\tupdateHSLAValue( { s: nextS } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<InputWithSlider\n\t\t\t\tmin={ 0 }\n\t\t\t\tmax={ 100 }\n\t\t\t\tlabel=\"Lightness\"\n\t\t\t\tabbreviation=\"L\"\n\t\t\t\tvalue={ colorValue.l }\n\t\t\t\tonChange={ ( nextL: number ) => {\n\t\t\t\t\tupdateHSLAValue( { l: nextL } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ enableAlpha && (\n\t\t\t\t<InputWithSlider\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tmax={ 100 }\n\t\t\t\t\tlabel=\"Alpha\"\n\t\t\t\t\tabbreviation=\"A\"\n\t\t\t\t\tvalue={ Math.trunc( 100 * colorValue.a ) }\n\t\t\t\t\tonChange={ ( nextA: number ) => {\n\t\t\t\t\t\tupdateHSLAValue( { a: nextA / 100 } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,gBAAA,GAAAF,OAAA;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAIO,MAAMG,QAAQ,GAAGA,CAAE;EAAEC,K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47,7 +47,7 @@ function CustomSelect({
|
|
|
47
47
|
onChange,
|
|
48
48
|
size = 'default',
|
|
49
49
|
value,
|
|
50
|
-
renderSelectedValue
|
|
50
|
+
renderSelectedValue,
|
|
51
51
|
...props
|
|
52
52
|
}) {
|
|
53
53
|
const store = Ariakit.useSelectStore({
|
|
@@ -58,6 +58,7 @@ function CustomSelect({
|
|
|
58
58
|
const {
|
|
59
59
|
value: currentValue
|
|
60
60
|
} = store.useState();
|
|
61
|
+
const computedRenderSelectedValue = renderSelectedValue !== null && renderSelectedValue !== void 0 ? renderSelectedValue : defaultRenderSelectedValue;
|
|
61
62
|
return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(Styled.CustomSelectLabel, {
|
|
62
63
|
store: store
|
|
63
64
|
}, label), (0, _react.createElement)(Styled.CustomSelectButton, {
|
|
@@ -65,7 +66,7 @@ function CustomSelect({
|
|
|
65
66
|
size: size,
|
|
66
67
|
hasCustomRenderProp: !!renderSelectedValue,
|
|
67
68
|
store: store
|
|
68
|
-
},
|
|
69
|
+
}, computedRenderSelectedValue(currentValue), (0, _react.createElement)(Ariakit.SelectArrow, null)), (0, _react.createElement)(Styled.CustomSelectPopover, {
|
|
69
70
|
gutter: 12,
|
|
70
71
|
store: store,
|
|
71
72
|
sameWidth: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Ariakit","_interopRequireWildcard","require","_element","_i18n","Styled","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","CustomSelectContext","createContext","undefined","exports","defaultRenderSelectedValue","value","isValueEmpty","Array","isArray","length","__","sprintf","CustomSelect","children","defaultValue","label","onChange","size","renderSelectedValue","props","store","useSelectStore","setValue","nextValue","currentValue","useState","_react","createElement","Fragment","CustomSelectLabel","CustomSelectButton","hasCustomRenderProp","SelectArrow","CustomSelectPopover","gutter","sameWidth","Provider","CustomSelectItem","customSelectContext","useContext","SelectItemCheck"],"sources":["@wordpress/components/src/custom-select-control-v2/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport * as Ariakit from '@ariakit/react';\n/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport * as Styled from './styles';\nimport type {\n\tCustomSelectProps,\n\tCustomSelectItemProps,\n\tCustomSelectContext as CustomSelectContextType,\n} from './types';\nimport type { WordPressComponentProps } from '../context';\n\nexport const CustomSelectContext =\n\tcreateContext< CustomSelectContextType >( undefined );\n\nfunction defaultRenderSelectedValue( value: CustomSelectProps[ 'value' ] ) {\n\tconst isValueEmpty = Array.isArray( value )\n\t\t? value.length === 0\n\t\t: value === undefined || value === null;\n\n\tif ( isValueEmpty ) {\n\t\treturn __( 'Select an item' );\n\t}\n\n\tif ( Array.isArray( value ) ) {\n\t\treturn value.length === 1\n\t\t\t? value[ 0 ]\n\t\t\t: // translators: %s: number of items selected (it will always be 2 or more items)\n\t\t\t sprintf( __( '%s items selected' ), value.length );\n\t}\n\n\treturn value;\n}\n\nexport function CustomSelect( {\n\tchildren,\n\tdefaultValue,\n\tlabel,\n\tonChange,\n\tsize = 'default',\n\tvalue,\n\trenderSelectedValue
|
|
1
|
+
{"version":3,"names":["Ariakit","_interopRequireWildcard","require","_element","_i18n","Styled","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","CustomSelectContext","createContext","undefined","exports","defaultRenderSelectedValue","value","isValueEmpty","Array","isArray","length","__","sprintf","CustomSelect","children","defaultValue","label","onChange","size","renderSelectedValue","props","store","useSelectStore","setValue","nextValue","currentValue","useState","computedRenderSelectedValue","_react","createElement","Fragment","CustomSelectLabel","CustomSelectButton","hasCustomRenderProp","SelectArrow","CustomSelectPopover","gutter","sameWidth","Provider","CustomSelectItem","customSelectContext","useContext","SelectItemCheck"],"sources":["@wordpress/components/src/custom-select-control-v2/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport * as Ariakit from '@ariakit/react';\n/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport * as Styled from './styles';\nimport type {\n\tCustomSelectProps,\n\tCustomSelectItemProps,\n\tCustomSelectContext as CustomSelectContextType,\n} from './types';\nimport type { WordPressComponentProps } from '../context';\n\nexport const CustomSelectContext =\n\tcreateContext< CustomSelectContextType >( undefined );\n\nfunction defaultRenderSelectedValue( value: CustomSelectProps[ 'value' ] ) {\n\tconst isValueEmpty = Array.isArray( value )\n\t\t? value.length === 0\n\t\t: value === undefined || value === null;\n\n\tif ( isValueEmpty ) {\n\t\treturn __( 'Select an item' );\n\t}\n\n\tif ( Array.isArray( value ) ) {\n\t\treturn value.length === 1\n\t\t\t? value[ 0 ]\n\t\t\t: // translators: %s: number of items selected (it will always be 2 or more items)\n\t\t\t sprintf( __( '%s items selected' ), value.length );\n\t}\n\n\treturn value;\n}\n\nexport function CustomSelect( {\n\tchildren,\n\tdefaultValue,\n\tlabel,\n\tonChange,\n\tsize = 'default',\n\tvalue,\n\trenderSelectedValue,\n\t...props\n}: WordPressComponentProps< CustomSelectProps, 'button', false > ) {\n\tconst store = Ariakit.useSelectStore( {\n\t\tsetValue: ( nextValue ) => onChange?.( nextValue ),\n\t\tdefaultValue,\n\t\tvalue,\n\t} );\n\n\tconst { value: currentValue } = store.useState();\n\n\tconst computedRenderSelectedValue =\n\t\trenderSelectedValue ?? defaultRenderSelectedValue;\n\n\treturn (\n\t\t<>\n\t\t\t<Styled.CustomSelectLabel store={ store }>\n\t\t\t\t{ label }\n\t\t\t</Styled.CustomSelectLabel>\n\t\t\t<Styled.CustomSelectButton\n\t\t\t\t{ ...props }\n\t\t\t\tsize={ size }\n\t\t\t\thasCustomRenderProp={ !! renderSelectedValue }\n\t\t\t\tstore={ store }\n\t\t\t>\n\t\t\t\t{ computedRenderSelectedValue( currentValue ) }\n\t\t\t\t<Ariakit.SelectArrow />\n\t\t\t</Styled.CustomSelectButton>\n\t\t\t<Styled.CustomSelectPopover gutter={ 12 } store={ store } sameWidth>\n\t\t\t\t<CustomSelectContext.Provider value={ { store } }>\n\t\t\t\t\t{ children }\n\t\t\t\t</CustomSelectContext.Provider>\n\t\t\t</Styled.CustomSelectPopover>\n\t\t</>\n\t);\n}\n\nexport function CustomSelectItem( {\n\tchildren,\n\t...props\n}: WordPressComponentProps< CustomSelectItemProps, 'div', false > ) {\n\tconst customSelectContext = useContext( CustomSelectContext );\n\treturn (\n\t\t<Styled.CustomSelectItem\n\t\t\tstore={ customSelectContext?.store }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ children ?? props.value }\n\t\t\t<Ariakit.SelectItemCheck />\n\t\t</Styled.CustomSelectItem>\n\t);\n}\n"],"mappings":";;;;;;;;;AAIA,IAAAA,OAAA,GAAAC,uBAAA,CAAAC,OAAA;AAIA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAJ,uBAAA,CAAAC,OAAA;AAAmC,SAAAI,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAN,wBAAAU,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAA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mB;IAACC,MAAM,EAAG,EAAI;IAACf,KAAK,EAAGA,KAAO;IAACgB,SAAS;EAAA,GAClE,IAAAT,MAAA,CAAAC,aAAA,EAAC5B,mBAAmB,CAACqC,QAAQ;IAAChC,KAAK,EAAG;MAAEe;IAAM;EAAG,GAC9CP,QAC2B,CACH,CAC3B,CAAC;AAEL;AAEO,SAASyB,gBAAgBA,CAAE;EACjCzB,QAAQ;EACR,GAAGM;AAC4D,CAAC,EAAG;EACnE,MAAMoB,mBAAmB,GAAG,IAAAC,mBAAU,EAAExC,mBAAoB,CAAC;EAC7D,OACC,IAAA2B,MAAA,CAAAC,aAAA,EAACnD,MAAM,CAAC6D,gBAAgB;IACvBlB,KAAK,EAAGmB,mBAAmB,EAAEnB,KAAO;IAAA,GAC/BD;EAAK,GAERN,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAIM,KAAK,CAACd,KAAK,EACzB,IAAAsB,MAAA,CAAAC,aAAA,EAACxD,OAAO,CAACqE,eAAe,MAAE,CACF,CAAC;AAE5B"}
|
|
@@ -36,7 +36,6 @@ const HIT_SLOP = {
|
|
|
36
36
|
left: 8,
|
|
37
37
|
right: 8
|
|
38
38
|
};
|
|
39
|
-
const THEME_PALETTE_NAME = 'Theme';
|
|
40
39
|
const PaletteScreen = () => {
|
|
41
40
|
const route = (0, _native.useRoute)();
|
|
42
41
|
const navigation = (0, _native.useNavigation)();
|
|
@@ -59,10 +58,13 @@ const PaletteScreen = () => {
|
|
|
59
58
|
const [currentValue, setCurrentValue] = (0, _element.useState)(colorValue);
|
|
60
59
|
const isGradientColor = isGradient(currentValue);
|
|
61
60
|
const selectedSegmentIndex = isGradientColor ? 1 : 0;
|
|
62
|
-
const allAvailableColors = (0, _components.useMobileGlobalStylesColors)();
|
|
63
61
|
const [currentSegment, setCurrentSegment] = (0, _element.useState)(segments[selectedSegmentIndex]);
|
|
64
62
|
const isGradientSegment = currentSegment === _utils.colorsUtils.segments[1];
|
|
65
63
|
const currentSegmentColors = !isGradientSegment ? defaultSettings.colors : defaultSettings.gradients;
|
|
64
|
+
const allAvailableColors = (0, _components.useMobileGlobalStylesColors)();
|
|
65
|
+
const allAvailableGradients = currentSegmentColors.flatMap(({
|
|
66
|
+
gradients
|
|
67
|
+
}) => gradients).filter(Boolean);
|
|
66
68
|
const horizontalSeparatorStyle = (0, _compose.usePreferredColorSchemeStyle)(_style.default.horizontalSeparator, _style.default.horizontalSeparatorDark);
|
|
67
69
|
const clearButtonStyle = (0, _compose.usePreferredColorSchemeStyle)(_style.default.clearButton, _style.default.clearButtonDark);
|
|
68
70
|
const selectedColorTextStyle = (0, _compose.usePreferredColorSchemeStyle)(_style.default.colorText, _style.default.colorTextDark);
|
|
@@ -147,9 +149,11 @@ const PaletteScreen = () => {
|
|
|
147
149
|
const paletteSettings = {
|
|
148
150
|
colors: palette.colors,
|
|
149
151
|
gradients: palette.gradients,
|
|
150
|
-
allColors: allAvailableColors
|
|
152
|
+
allColors: allAvailableColors,
|
|
153
|
+
allGradients: allAvailableGradients
|
|
151
154
|
};
|
|
152
|
-
|
|
155
|
+
// Limit to show the custom indicator to the first available palette
|
|
156
|
+
const enableCustomColor = paletteKey === 0;
|
|
153
157
|
return (0, _react.createElement)(_colorPalette.default, {
|
|
154
158
|
enableCustomColor: enableCustomColor,
|
|
155
159
|
label: palette.name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_i18n","_element","_compose","_components","_native","_colorPalette","_interopRequireDefault","_colorIndicator","_navBar","_segmentedControl","_utils","_style","HIT_SLOP","top","bottom","left","right","THEME_PALETTE_NAME","PaletteScreen","route","useRoute","navigation","useNavigation","shouldEnableBottomSheetScroll","useContext","BottomSheetContext","label","onColorChange","onGradientChange","onColorCleared","colorValue","defaultSettings","hideNavigation","params","segments","isGradient","colorsUtils","currentValue","setCurrentValue","useState","isGradientColor","selectedSegmentIndex","allAvailableColors","useMobileGlobalStylesColors","currentSegment","setCurrentSegment","isGradientSegment","currentSegmentColors","colors","gradients","horizontalSeparatorStyle","usePreferredColorSchemeStyle","styles","horizontalSeparator","horizontalSeparatorDark","clearButtonStyle","clearButton","clearButtonDark","selectedColorTextStyle","colorText","colorTextDark","isSolidSegment","isCustomGadientShown","setColor","color","onClear","undefined","onCustomPress","navigate","screens","picker","gradientPicker","getClearButton","_react","createElement","TouchableWithoutFeedback","onPress","hitSlop","View","style","clearButtonContainer","Text","__","getFooter","default","segmentHandler","selectedIndex","indexOf","addonLeft","colorIndicator","addonRight","footer","flex","maxFontSizeMultiplier","selectable","toUpperCase","selectColorText","BackButton","goBack","Heading","colorPalettes","map","palette","paletteKey","paletteSettings","allColors","enableCustomColor","name","key","activeColor","Fragment","PanelBody","ColorControl","withColorIndicator","_default","exports"],"sources":["@wordpress/components/src/mobile/color-settings/palette.screen.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View, Text, TouchableWithoutFeedback } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState, useContext } from '@wordpress/element';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport {\n\tColorControl,\n\tPanelBody,\n\tBottomSheetContext,\n\tuseMobileGlobalStylesColors,\n} from '@wordpress/components';\nimport { useRoute, useNavigation } from '@react-navigation/native';\n\n/**\n * Internal dependencies\n */\nimport ColorPalette from '../../color-palette';\nimport ColorIndicator from '../../color-indicator';\nimport NavBar from '../bottom-sheet/nav-bar';\nimport SegmentedControls from '../segmented-control';\nimport { colorsUtils } from './utils';\n\nimport styles from './style.scss';\n\nconst HIT_SLOP = { top: 8, bottom: 8, left: 8, right: 8 };\nconst THEME_PALETTE_NAME = 'Theme';\n\nconst PaletteScreen = () => {\n\tconst route = useRoute();\n\tconst navigation = useNavigation();\n\tconst { shouldEnableBottomSheetScroll } = useContext( BottomSheetContext );\n\tconst {\n\t\tlabel,\n\t\tonColorChange,\n\t\tonGradientChange,\n\t\tonColorCleared,\n\t\tcolorValue,\n\t\tdefaultSettings,\n\t\thideNavigation = false,\n\t} = route.params || {};\n\tconst { segments, isGradient } = colorsUtils;\n\tconst [ currentValue, setCurrentValue ] = useState( colorValue );\n\tconst isGradientColor = isGradient( currentValue );\n\tconst selectedSegmentIndex = isGradientColor ? 1 : 0;\n\tconst allAvailableColors = useMobileGlobalStylesColors();\n\n\tconst [ currentSegment, setCurrentSegment ] = useState(\n\t\tsegments[ selectedSegmentIndex ]\n\t);\n\tconst isGradientSegment = currentSegment === colorsUtils.segments[ 1 ];\n\tconst currentSegmentColors = ! isGradientSegment\n\t\t? defaultSettings.colors\n\t\t: defaultSettings.gradients;\n\n\tconst horizontalSeparatorStyle = usePreferredColorSchemeStyle(\n\t\tstyles.horizontalSeparator,\n\t\tstyles.horizontalSeparatorDark\n\t);\n\tconst clearButtonStyle = usePreferredColorSchemeStyle(\n\t\tstyles.clearButton,\n\t\tstyles.clearButtonDark\n\t);\n\tconst selectedColorTextStyle = usePreferredColorSchemeStyle(\n\t\tstyles.colorText,\n\t\tstyles.colorTextDark\n\t);\n\n\tconst isSolidSegment = currentSegment === segments[ 0 ];\n\tconst isCustomGadientShown = ! isSolidSegment && isGradientColor;\n\n\tconst setColor = ( color ) => {\n\t\tsetCurrentValue( color );\n\t\tif ( isSolidSegment && onColorChange && onGradientChange ) {\n\t\t\tonColorChange( color );\n\t\t} else if ( isSolidSegment && onColorChange ) {\n\t\t\tonColorChange( color );\n\t\t} else if ( ! isSolidSegment && onGradientChange ) {\n\t\t\tonGradientChange( color );\n\t\t}\n\t};\n\n\tfunction onClear() {\n\t\tsetCurrentValue( undefined );\n\n\t\tif ( onColorCleared ) {\n\t\t\tonColorCleared();\n\t\t}\n\t}\n\n\tfunction onCustomPress() {\n\t\tif ( isSolidSegment ) {\n\t\t\tnavigation.navigate( colorsUtils.screens.picker, {\n\t\t\t\tcurrentValue,\n\t\t\t\tsetColor,\n\t\t\t} );\n\t\t} else {\n\t\t\tnavigation.navigate( colorsUtils.screens.gradientPicker, {\n\t\t\t\tsetColor,\n\t\t\t\tisGradientColor,\n\t\t\t\tcurrentValue,\n\t\t\t} );\n\t\t}\n\t}\n\n\tfunction getClearButton() {\n\t\treturn (\n\t\t\t<TouchableWithoutFeedback onPress={ onClear } hitSlop={ HIT_SLOP }>\n\t\t\t\t<View style={ styles.clearButtonContainer }>\n\t\t\t\t\t<Text style={ clearButtonStyle }>{ __( 'Reset' ) }</Text>\n\t\t\t\t</View>\n\t\t\t</TouchableWithoutFeedback>\n\t\t);\n\t}\n\n\tfunction getFooter() {\n\t\tif ( onGradientChange ) {\n\t\t\treturn (\n\t\t\t\t<SegmentedControls\n\t\t\t\t\tsegments={ segments }\n\t\t\t\t\tsegmentHandler={ setCurrentSegment }\n\t\t\t\t\tselectedIndex={ segments.indexOf( currentSegment ) }\n\t\t\t\t\taddonLeft={\n\t\t\t\t\t\tcurrentValue && (\n\t\t\t\t\t\t\t<ColorIndicator\n\t\t\t\t\t\t\t\tcolor={ currentValue }\n\t\t\t\t\t\t\t\tstyle={ styles.colorIndicator }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\taddonRight={ currentValue && getClearButton() }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\t\treturn (\n\t\t\t<View style={ styles.footer }>\n\t\t\t\t<View style={ styles.flex }>\n\t\t\t\t\t{ currentValue && (\n\t\t\t\t\t\t<ColorIndicator\n\t\t\t\t\t\t\tcolor={ currentValue }\n\t\t\t\t\t\t\tstyle={ styles.colorIndicator }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</View>\n\t\t\t\t{ currentValue ? (\n\t\t\t\t\t<Text\n\t\t\t\t\t\tstyle={ selectedColorTextStyle }\n\t\t\t\t\t\tmaxFontSizeMultiplier={ 2 }\n\t\t\t\t\t\tselectable\n\t\t\t\t\t>\n\t\t\t\t\t\t{ currentValue.toUpperCase() }\n\t\t\t\t\t</Text>\n\t\t\t\t) : (\n\t\t\t\t\t<Text\n\t\t\t\t\t\tstyle={ styles.selectColorText }\n\t\t\t\t\t\tmaxFontSizeMultiplier={ 2 }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Select a color above' ) }\n\t\t\t\t\t</Text>\n\t\t\t\t) }\n\t\t\t\t<View style={ styles.flex }>\n\t\t\t\t\t{ currentValue && getClearButton() }\n\t\t\t\t</View>\n\t\t\t</View>\n\t\t);\n\t}\n\treturn (\n\t\t<View>\n\t\t\t{ ! hideNavigation && (\n\t\t\t\t<NavBar>\n\t\t\t\t\t<NavBar.BackButton onPress={ navigation.goBack } />\n\t\t\t\t\t<NavBar.Heading>{ label } </NavBar.Heading>\n\t\t\t\t</NavBar>\n\t\t\t) }\n\n\t\t\t<View style={ styles.colorPalettes }>\n\t\t\t\t{ currentSegmentColors.map( ( palette, paletteKey ) => {\n\t\t\t\t\tconst paletteSettings = {\n\t\t\t\t\t\tcolors: palette.colors,\n\t\t\t\t\t\tgradients: palette.gradients,\n\t\t\t\t\t\tallColors: allAvailableColors,\n\t\t\t\t\t};\n\t\t\t\t\tconst enableCustomColor =\n\t\t\t\t\t\t! isGradientSegment &&\n\t\t\t\t\t\tpalette.name === THEME_PALETTE_NAME;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\t\tenableCustomColor={ enableCustomColor }\n\t\t\t\t\t\t\tlabel={ palette.name }\n\t\t\t\t\t\t\tkey={ paletteKey }\n\t\t\t\t\t\t\tsetColor={ setColor }\n\t\t\t\t\t\t\tactiveColor={ currentValue }\n\t\t\t\t\t\t\tisGradientColor={ isGradientColor }\n\t\t\t\t\t\t\tcurrentSegment={ currentSegment }\n\t\t\t\t\t\t\tonCustomPress={ onCustomPress }\n\t\t\t\t\t\t\tshouldEnableBottomSheetScroll={\n\t\t\t\t\t\t\t\tshouldEnableBottomSheetScroll\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdefaultSettings={ paletteSettings }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</View>\n\n\t\t\t{ isCustomGadientShown && (\n\t\t\t\t<>\n\t\t\t\t\t<View style={ horizontalSeparatorStyle } />\n\t\t\t\t\t<PanelBody>\n\t\t\t\t\t\t<ColorControl\n\t\t\t\t\t\t\tlabel={ __( 'Customize Gradient' ) }\n\t\t\t\t\t\t\tonPress={ onCustomPress }\n\t\t\t\t\t\t\twithColorIndicator={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<View style={ horizontalSeparatorStyle } />\n\t\t\t{ getFooter() }\n\t\t</View>\n\t);\n};\n\nexport default PaletteScreen;\n"],"mappings":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAMA,IAAAK,OAAA,GAAAL,OAAA;AAKA,IAAAM,aAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,eAAA,GAAAD,sBAAA,CAAAP,OAAA;AACA,IAAAS,OAAA,GAAAF,sBAAA,CAAAP,OAAA;AACA,IAAAU,iBAAA,GAAAH,sBAAA,CAAAP,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AAEA,IAAAY,MAAA,GAAAL,sBAAA,CAAAP,OAAA;AA5BA;AACA;AACA;;AAGA;AACA;AACA;;AAYA;AACA;AACA;;AASA,MAAMa,QAAQ,GAAG;EAAEC,GAAG,EAAE,CAAC;EAAEC,MAAM,EAAE,CAAC;EAAEC,IAAI,EAAE,CAAC;EAAEC,KAAK,EAAE;AAAE,CAAC;AACzD,MAAMC,kBAAkB,GAAG,OAAO;AAElC,MAAMC,aAAa,GAAGA,CAAA,KAAM;EAC3B,MAAMC,KAAK,GAAG,IAAAC,gBAAQ,EAAC,CAAC;EACxB,MAAMC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rB8C,WAAW,EAAGxE,YAAc;MAC5BG,eAAe,EAAGA,eAAiB;MACnCI,cAAc,EAAGA,cAAgB;MACjCuB,aAAa,EAAGA,aAAe;MAC/B5C,6BAA6B,EAC5BA,6BACA;MACDQ,eAAe,EAAGyE;IAAiB,CACnC,CAAC;EAEJ,CAAE,CACG,CAAC,EAEL1C,oBAAoB,IACrB,IAAAW,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAqC,QAAA,QACC,IAAArC,MAAA,CAAAC,aAAA,EAAC5E,YAAA,CAAAgF,IAAI;IAACC,KAAK,EAAG7B;EAA0B,CAAE,CAAC,EAC3C,IAAAuB,MAAA,CAAAC,aAAA,EAACvE,WAAA,CAAA4G,SAAS,QACT,IAAAtC,MAAA,CAAAC,aAAA,EAACvE,WAAA,CAAA6G,YAAY;IACZtF,KAAK,EAAG,IAAAwD,QAAE,EAAE,oBAAqB,CAAG;IACpCN,OAAO,EAAGT,aAAe;IACzB8C,kBAAkB,EAAG;EAAO,CAC5B,CACS,CACV,CACF,EACD,IAAAxC,MAAA,CAAAC,aAAA,EAAC5E,YAAA,CAAAgF,IAAI;IAACC,KAAK,EAAG7B;EAA0B,CAAE,CAAC,EACzCiC,SAAS,CAAC,CACP,CAAC;AAET,CAAC;AAAC,IAAA+B,QAAA,GAEahG,aAAa;AAAAiG,OAAA,CAAA/B,OAAA,GAAA8B,QAAA"}
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_i18n","_element","_compose","_components","_native","_colorPalette","_interopRequireDefault","_colorIndicator","_navBar","_segmentedControl","_utils","_style","HIT_SLOP","top","bottom","left","right","PaletteScreen","route","useRoute","navigation","useNavigation","shouldEnableBottomSheetScroll","useContext","BottomSheetContext","label","onColorChange","onGradientChange","onColorCleared","colorValue","defaultSettings","hideNavigation","params","segments","isGradient","colorsUtils","currentValue","setCurrentValue","useState","isGradientColor","selectedSegmentIndex","currentSegment","setCurrentSegment","isGradientSegment","currentSegmentColors","colors","gradients","allAvailableColors","useMobileGlobalStylesColors","allAvailableGradients","flatMap","filter","Boolean","horizontalSeparatorStyle","usePreferredColorSchemeStyle","styles","horizontalSeparator","horizontalSeparatorDark","clearButtonStyle","clearButton","clearButtonDark","selectedColorTextStyle","colorText","colorTextDark","isSolidSegment","isCustomGadientShown","setColor","color","onClear","undefined","onCustomPress","navigate","screens","picker","gradientPicker","getClearButton","_react","createElement","TouchableWithoutFeedback","onPress","hitSlop","View","style","clearButtonContainer","Text","__","getFooter","default","segmentHandler","selectedIndex","indexOf","addonLeft","colorIndicator","addonRight","footer","flex","maxFontSizeMultiplier","selectable","toUpperCase","selectColorText","BackButton","goBack","Heading","colorPalettes","map","palette","paletteKey","paletteSettings","allColors","allGradients","enableCustomColor","name","key","activeColor","Fragment","PanelBody","ColorControl","withColorIndicator","_default","exports"],"sources":["@wordpress/components/src/mobile/color-settings/palette.screen.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View, Text, TouchableWithoutFeedback } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState, useContext } from '@wordpress/element';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport {\n\tColorControl,\n\tPanelBody,\n\tBottomSheetContext,\n\tuseMobileGlobalStylesColors,\n} from '@wordpress/components';\nimport { useRoute, useNavigation } from '@react-navigation/native';\n\n/**\n * Internal dependencies\n */\nimport ColorPalette from '../../color-palette';\nimport ColorIndicator from '../../color-indicator';\nimport NavBar from '../bottom-sheet/nav-bar';\nimport SegmentedControls from '../segmented-control';\nimport { colorsUtils } from './utils';\n\nimport styles from './style.scss';\n\nconst HIT_SLOP = { top: 8, bottom: 8, left: 8, right: 8 };\n\nconst PaletteScreen = () => {\n\tconst route = useRoute();\n\tconst navigation = useNavigation();\n\tconst { shouldEnableBottomSheetScroll } = useContext( BottomSheetContext );\n\tconst {\n\t\tlabel,\n\t\tonColorChange,\n\t\tonGradientChange,\n\t\tonColorCleared,\n\t\tcolorValue,\n\t\tdefaultSettings,\n\t\thideNavigation = false,\n\t} = route.params || {};\n\tconst { segments, isGradient } = colorsUtils;\n\tconst [ currentValue, setCurrentValue ] = useState( colorValue );\n\tconst isGradientColor = isGradient( currentValue );\n\tconst selectedSegmentIndex = isGradientColor ? 1 : 0;\n\n\tconst [ currentSegment, setCurrentSegment ] = useState(\n\t\tsegments[ selectedSegmentIndex ]\n\t);\n\tconst isGradientSegment = currentSegment === colorsUtils.segments[ 1 ];\n\tconst currentSegmentColors = ! isGradientSegment\n\t\t? defaultSettings.colors\n\t\t: defaultSettings.gradients;\n\tconst allAvailableColors = useMobileGlobalStylesColors();\n\tconst allAvailableGradients = currentSegmentColors\n\t\t.flatMap( ( { gradients } ) => gradients )\n\t\t.filter( Boolean );\n\n\tconst horizontalSeparatorStyle = usePreferredColorSchemeStyle(\n\t\tstyles.horizontalSeparator,\n\t\tstyles.horizontalSeparatorDark\n\t);\n\tconst clearButtonStyle = usePreferredColorSchemeStyle(\n\t\tstyles.clearButton,\n\t\tstyles.clearButtonDark\n\t);\n\tconst selectedColorTextStyle = usePreferredColorSchemeStyle(\n\t\tstyles.colorText,\n\t\tstyles.colorTextDark\n\t);\n\n\tconst isSolidSegment = currentSegment === segments[ 0 ];\n\tconst isCustomGadientShown = ! isSolidSegment && isGradientColor;\n\n\tconst setColor = ( color ) => {\n\t\tsetCurrentValue( color );\n\t\tif ( isSolidSegment && onColorChange && onGradientChange ) {\n\t\t\tonColorChange( color );\n\t\t} else if ( isSolidSegment && onColorChange ) {\n\t\t\tonColorChange( color );\n\t\t} else if ( ! isSolidSegment && onGradientChange ) {\n\t\t\tonGradientChange( color );\n\t\t}\n\t};\n\n\tfunction onClear() {\n\t\tsetCurrentValue( undefined );\n\n\t\tif ( onColorCleared ) {\n\t\t\tonColorCleared();\n\t\t}\n\t}\n\n\tfunction onCustomPress() {\n\t\tif ( isSolidSegment ) {\n\t\t\tnavigation.navigate( colorsUtils.screens.picker, {\n\t\t\t\tcurrentValue,\n\t\t\t\tsetColor,\n\t\t\t} );\n\t\t} else {\n\t\t\tnavigation.navigate( colorsUtils.screens.gradientPicker, {\n\t\t\t\tsetColor,\n\t\t\t\tisGradientColor,\n\t\t\t\tcurrentValue,\n\t\t\t} );\n\t\t}\n\t}\n\n\tfunction getClearButton() {\n\t\treturn (\n\t\t\t<TouchableWithoutFeedback onPress={ onClear } hitSlop={ HIT_SLOP }>\n\t\t\t\t<View style={ styles.clearButtonContainer }>\n\t\t\t\t\t<Text style={ clearButtonStyle }>{ __( 'Reset' ) }</Text>\n\t\t\t\t</View>\n\t\t\t</TouchableWithoutFeedback>\n\t\t);\n\t}\n\n\tfunction getFooter() {\n\t\tif ( onGradientChange ) {\n\t\t\treturn (\n\t\t\t\t<SegmentedControls\n\t\t\t\t\tsegments={ segments }\n\t\t\t\t\tsegmentHandler={ setCurrentSegment }\n\t\t\t\t\tselectedIndex={ segments.indexOf( currentSegment ) }\n\t\t\t\t\taddonLeft={\n\t\t\t\t\t\tcurrentValue && (\n\t\t\t\t\t\t\t<ColorIndicator\n\t\t\t\t\t\t\t\tcolor={ currentValue }\n\t\t\t\t\t\t\t\tstyle={ styles.colorIndicator }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\taddonRight={ currentValue && getClearButton() }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\t\treturn (\n\t\t\t<View style={ styles.footer }>\n\t\t\t\t<View style={ styles.flex }>\n\t\t\t\t\t{ currentValue && (\n\t\t\t\t\t\t<ColorIndicator\n\t\t\t\t\t\t\tcolor={ currentValue }\n\t\t\t\t\t\t\tstyle={ styles.colorIndicator }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</View>\n\t\t\t\t{ currentValue ? (\n\t\t\t\t\t<Text\n\t\t\t\t\t\tstyle={ selectedColorTextStyle }\n\t\t\t\t\t\tmaxFontSizeMultiplier={ 2 }\n\t\t\t\t\t\tselectable\n\t\t\t\t\t>\n\t\t\t\t\t\t{ currentValue.toUpperCase() }\n\t\t\t\t\t</Text>\n\t\t\t\t) : (\n\t\t\t\t\t<Text\n\t\t\t\t\t\tstyle={ styles.selectColorText }\n\t\t\t\t\t\tmaxFontSizeMultiplier={ 2 }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Select a color above' ) }\n\t\t\t\t\t</Text>\n\t\t\t\t) }\n\t\t\t\t<View style={ styles.flex }>\n\t\t\t\t\t{ currentValue && getClearButton() }\n\t\t\t\t</View>\n\t\t\t</View>\n\t\t);\n\t}\n\treturn (\n\t\t<View>\n\t\t\t{ ! hideNavigation && (\n\t\t\t\t<NavBar>\n\t\t\t\t\t<NavBar.BackButton onPress={ navigation.goBack } />\n\t\t\t\t\t<NavBar.Heading>{ label } </NavBar.Heading>\n\t\t\t\t</NavBar>\n\t\t\t) }\n\n\t\t\t<View style={ styles.colorPalettes }>\n\t\t\t\t{ currentSegmentColors.map( ( palette, paletteKey ) => {\n\t\t\t\t\tconst paletteSettings = {\n\t\t\t\t\t\tcolors: palette.colors,\n\t\t\t\t\t\tgradients: palette.gradients,\n\t\t\t\t\t\tallColors: allAvailableColors,\n\t\t\t\t\t\tallGradients: allAvailableGradients,\n\t\t\t\t\t};\n\t\t\t\t\t// Limit to show the custom indicator to the first available palette\n\t\t\t\t\tconst enableCustomColor = paletteKey === 0;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\t\tenableCustomColor={ enableCustomColor }\n\t\t\t\t\t\t\tlabel={ palette.name }\n\t\t\t\t\t\t\tkey={ paletteKey }\n\t\t\t\t\t\t\tsetColor={ setColor }\n\t\t\t\t\t\t\tactiveColor={ currentValue }\n\t\t\t\t\t\t\tisGradientColor={ isGradientColor }\n\t\t\t\t\t\t\tcurrentSegment={ currentSegment }\n\t\t\t\t\t\t\tonCustomPress={ onCustomPress }\n\t\t\t\t\t\t\tshouldEnableBottomSheetScroll={\n\t\t\t\t\t\t\t\tshouldEnableBottomSheetScroll\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdefaultSettings={ paletteSettings }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</View>\n\n\t\t\t{ isCustomGadientShown && (\n\t\t\t\t<>\n\t\t\t\t\t<View style={ horizontalSeparatorStyle } />\n\t\t\t\t\t<PanelBody>\n\t\t\t\t\t\t<ColorControl\n\t\t\t\t\t\t\tlabel={ __( 'Customize Gradient' ) }\n\t\t\t\t\t\t\tonPress={ onCustomPress }\n\t\t\t\t\t\t\twithColorIndicator={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<View style={ horizontalSeparatorStyle } />\n\t\t\t{ getFooter() }\n\t\t</View>\n\t);\n};\n\nexport default PaletteScreen;\n"],"mappings":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAMA,IAAAK,OAAA,GAAAL,OAAA;AAKA,IAAAM,aAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,eAAA,GAAAD,sBAAA,CAAAP,OAAA;AACA,IAAAS,OAAA,GAAAF,sBAAA,CAAAP,OAAA;AACA,IAAAU,iBAAA,GAAAH,sBAAA,CAAAP,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AAEA,IAAAY,MAAA,GAAAL,sBAAA,CAAAP,OAAA;AA5BA;AACA;AACA;;AAGA;AACA;AACA;;AAYA;AACA;AACA;;AASA,MAAMa,QAAQ,GAAG;EAAEC,GAAG,EAAE,CAAC;EAAEC,MAAM,EAAE,CAAC;EAAEC,IAAI,EAAE,CAAC;EAAEC,KAAK,EAAE;AAAE,CAAC;AAEzD,MAAMC,aAAa,GAAGA,CAAA,KAAM;EAC3B,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E1C,OACC,IAAA9B,MAAA,CAAAC,aAAA,EAACxE,aAAA,CAAAkF,OAAY;MACZuB,iBAAiB,EAAGA,iBAAmB;MACvCrF,KAAK,EAAGgF,OAAO,CAACM,IAAM;MACtBC,GAAG,EAAGN,UAAY;MAClBxC,QAAQ,EAAGA,QAAU;MACrB+C,WAAW,EAAG7E,YAAc;MAC5BG,eAAe,EAAGA,eAAiB;MACnCE,cAAc,EAAGA,cAAgB;MACjC6B,aAAa,EAAGA,aAAe;MAC/BhD,6BAA6B,EAC5BA,6BACA;MACDQ,eAAe,EAAG6E;IAAiB,CACnC,CAAC;EAEJ,CAAE,CACG,CAAC,EAEL1C,oBAAoB,IACrB,IAAAW,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAsC,QAAA,QACC,IAAAtC,MAAA,CAAAC,aAAA,EAAC/E,YAAA,CAAAmF,IAAI;IAACC,KAAK,EAAG7B;EAA0B,CAAE,CAAC,EAC3C,IAAAuB,MAAA,CAAAC,aAAA,EAAC1E,WAAA,CAAAgH,SAAS,QACT,IAAAvC,MAAA,CAAAC,aAAA,EAAC1E,WAAA,CAAAiH,YAAY;IACZ3F,KAAK,EAAG,IAAA4D,QAAE,EAAE,oBAAqB,CAAG;IACpCN,OAAO,EAAGT,aAAe;IACzB+C,kBAAkB,EAAG;EAAO,CAC5B,CACS,CACV,CACF,EACD,IAAAzC,MAAA,CAAAC,aAAA,EAAC/E,YAAA,CAAAmF,IAAI;IAACC,KAAK,EAAG7B;EAA0B,CAAE,CAAC,EACzCiC,SAAS,CAAC,CACP,CAAC;AAET,CAAC;AAAC,IAAAgC,QAAA,GAEarG,aAAa;AAAAsG,OAAA,CAAAhC,OAAA,GAAA+B,QAAA"}
|
|
@@ -27,7 +27,7 @@ function useSlotFills(name) {
|
|
|
27
27
|
});
|
|
28
28
|
// The important bit here is that this call ensures that the hook
|
|
29
29
|
// only causes a re-render if the "fills" of a given slot name
|
|
30
|
-
// change
|
|
30
|
+
// change, not any fills.
|
|
31
31
|
return fills.get(name);
|
|
32
32
|
}
|
|
33
33
|
//# sourceMappingURL=use-slot-fills.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_valtio","require","_element","_slotFillContext","_interopRequireDefault","useSlotFills","name","registry","useContext","SlotFillContext","fills","useSnapshot","sync","get"],"sources":["@wordpress/components/src/slot-fill/bubbles-virtually/use-slot-fills.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport { useSnapshot } from 'valtio';\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport SlotFillContext from './slot-fill-context';\nimport type { SlotKey } from '../types';\n\nexport default function useSlotFills( name: SlotKey ) {\n\tconst registry = useContext( SlotFillContext );\n\tconst fills = useSnapshot( registry.fills, { sync: true } );\n\t// The important bit here is that this call ensures that the hook\n\t// only causes a re-render if the \"fills\" of a given slot name\n\t// change
|
|
1
|
+
{"version":3,"names":["_valtio","require","_element","_slotFillContext","_interopRequireDefault","useSlotFills","name","registry","useContext","SlotFillContext","fills","useSnapshot","sync","get"],"sources":["@wordpress/components/src/slot-fill/bubbles-virtually/use-slot-fills.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport { useSnapshot } from 'valtio';\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport SlotFillContext from './slot-fill-context';\nimport type { SlotKey } from '../types';\n\nexport default function useSlotFills( name: SlotKey ) {\n\tconst registry = useContext( SlotFillContext );\n\tconst fills = useSnapshot( registry.fills, { sync: true } );\n\t// The important bit here is that this call ensures that the hook\n\t// only causes a re-render if the \"fills\" of a given slot name\n\t// change, not any fills.\n\treturn fills.get( name );\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAIe,SAASI,YAAYA,CAAEC,IAAa,EAAG;EACrD,MAAMC,QAAQ,GAAG,IAAAC,mBAAU,EAAEC,wBAAgB,CAAC;EAC9C,MAAMC,KAAK,GAAG,IAAAC,mBAAW,EAAEJ,QAAQ,CAACG,KAAK,EAAE;IAAEE,IAAI,EAAE;EAAK,CAAE,CAAC;EAC3D;EACA;EACA;EACA,OAAOF,KAAK,CAACG,GAAG,CAAEP,IAAK,CAAC;AACzB"}
|
package/build/theme/styles.js
CHANGED
|
@@ -7,15 +7,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.colorVariables = exports.Wrapper = void 0;
|
|
8
8
|
var _base = _interopRequireDefault(require("@emotion/styled/base"));
|
|
9
9
|
var _react = require("@emotion/react");
|
|
10
|
-
|
|
11
|
-
* External dependencies
|
|
12
|
-
*/
|
|
13
|
-
|
|
10
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
14
11
|
const colorVariables = ({
|
|
15
12
|
colors
|
|
16
13
|
}) => {
|
|
17
14
|
const shades = Object.entries(colors.gray || {}).map(([k, v]) => `--wp-components-color-gray-${k}: ${v};`).join('');
|
|
18
|
-
return [/*#__PURE__*/(0, _react.css)("--wp-components-color-accent:", colors.accent, ";--wp-components-color-accent-darker-10:", colors.accentDarker10, ";--wp-components-color-accent-darker-20:", colors.accentDarker20, ";--wp-components-color-accent-inverted:", colors.accentInverted, ";--wp-components-color-background:", colors.background, ";--wp-components-color-foreground:", colors.foreground, ";--wp-components-color-foreground-inverted:", colors.foregroundInverted, ";", shades, ";" + (process.env.NODE_ENV === "production" ? "" : ";label:colorVariables;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
15
|
+
return [/*#__PURE__*/(0, _react.css)("--wp-components-color-accent:", colors.accent, ";--wp-components-color-accent-darker-10:", colors.accentDarker10, ";--wp-components-color-accent-darker-20:", colors.accentDarker20, ";--wp-components-color-accent-inverted:", colors.accentInverted, ";--wp-components-color-background:", colors.background, ";--wp-components-color-foreground:", colors.foreground, ";--wp-components-color-foreground-inverted:", colors.foregroundInverted, ";", shades, ";" + (process.env.NODE_ENV === "production" ? "" : ";label:colorVariables;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvdGhlbWUvc3R5bGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQWlCSyIsImZpbGUiOiJAd29yZHByZXNzL2NvbXBvbmVudHMvc3JjL3RoZW1lL3N0eWxlcy50cyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogRXh0ZXJuYWwgZGVwZW5kZW5jaWVzXG4gKi9cbmltcG9ydCBzdHlsZWQgZnJvbSAnQGVtb3Rpb24vc3R5bGVkJztcbmltcG9ydCB7IGNzcyB9IGZyb20gJ0BlbW90aW9uL3JlYWN0JztcblxuLyoqXG4gKiBJbnRlcm5hbCBkZXBlbmRlbmNpZXNcbiAqL1xuaW1wb3J0IHR5cGUgeyBUaGVtZU91dHB1dFZhbHVlcyB9IGZyb20gJy4vdHlwZXMnO1xuXG5leHBvcnQgY29uc3QgY29sb3JWYXJpYWJsZXMgPSAoIHsgY29sb3JzIH06IFRoZW1lT3V0cHV0VmFsdWVzICkgPT4ge1xuXHRjb25zdCBzaGFkZXMgPSBPYmplY3QuZW50cmllcyggY29sb3JzLmdyYXkgfHwge30gKVxuXHRcdC5tYXAoICggWyBrLCB2IF0gKSA9PiBgLS13cC1jb21wb25lbnRzLWNvbG9yLWdyYXktJHsgayB9OiAkeyB2IH07YCApXG5cdFx0LmpvaW4oICcnICk7XG5cblx0cmV0dXJuIFtcblx0XHRjc3NgXG5cdFx0XHQtLXdwLWNvbXBvbmVudHMtY29sb3ItYWNjZW50OiAkeyBjb2xvcnMuYWNjZW50IH07XG5cdFx0XHQtLXdwLWNvbXBvbmVudHMtY29sb3ItYWNjZW50LWRhcmtlci0xMDogJHsgY29sb3JzLmFjY2VudERhcmtlcjEwIH07XG5cdFx0XHQtLXdwLWNvbXBvbmVudHMtY29sb3ItYWNjZW50LWRhcmtlci0yMDogJHsgY29sb3JzLmFjY2VudERhcmtlcjIwIH07XG5cdFx0XHQtLXdwLWNvbXBvbmVudHMtY29sb3ItYWNjZW50LWludmVydGVkOiAkeyBjb2xvcnMuYWNjZW50SW52ZXJ0ZWQgfTtcblxuXHRcdFx0LS13cC1jb21wb25lbnRzLWNvbG9yLWJhY2tncm91bmQ6ICR7IGNvbG9ycy5iYWNrZ3JvdW5kIH07XG5cdFx0XHQtLXdwLWNvbXBvbmVudHMtY29sb3ItZm9yZWdyb3VuZDogJHsgY29sb3JzLmZvcmVncm91bmQgfTtcblx0XHRcdC0td3AtY29tcG9uZW50cy1jb2xvci1mb3JlZ3JvdW5kLWludmVydGVkOiAkeyBjb2xvcnMuZm9yZWdyb3VuZEludmVydGVkIH07XG5cblx0XHRcdCR7IHNoYWRlcyB9XG5cdFx0YCxcblx0XTtcbn07XG5cbmV4cG9ydCBjb25zdCBXcmFwcGVyID0gc3R5bGVkLmRpdmBcblx0Y29sb3I6IHZhciggLS13cC1jb21wb25lbnRzLWNvbG9yLWZvcmVncm91bmQsIGN1cnJlbnRDb2xvciApO1xuYDtcbiJdfQ== */")];
|
|
19
16
|
};
|
|
20
17
|
exports.colorVariables = colorVariables;
|
|
21
18
|
const Wrapper = (0, _base.default)("div", process.env.NODE_ENV === "production" ? {
|
|
@@ -23,6 +20,14 @@ const Wrapper = (0, _base.default)("div", process.env.NODE_ENV === "production"
|
|
|
23
20
|
} : {
|
|
24
21
|
target: "e1krjpvb0",
|
|
25
22
|
label: "Wrapper"
|
|
26
|
-
})(process.env.NODE_ENV === "production" ?
|
|
23
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
24
|
+
name: "1a3idx0",
|
|
25
|
+
styles: "color:var( --wp-components-color-foreground, currentColor )"
|
|
26
|
+
} : {
|
|
27
|
+
name: "1a3idx0",
|
|
28
|
+
styles: "color:var( --wp-components-color-foreground, currentColor )",
|
|
29
|
+
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvdGhlbWUvc3R5bGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQWdDaUMiLCJmaWxlIjoiQHdvcmRwcmVzcy9jb21wb25lbnRzL3NyYy90aGVtZS9zdHlsZXMudHMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEV4dGVybmFsIGRlcGVuZGVuY2llc1xuICovXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XG5pbXBvcnQgeyBjc3MgfSBmcm9tICdAZW1vdGlvbi9yZWFjdCc7XG5cbi8qKlxuICogSW50ZXJuYWwgZGVwZW5kZW5jaWVzXG4gKi9cbmltcG9ydCB0eXBlIHsgVGhlbWVPdXRwdXRWYWx1ZXMgfSBmcm9tICcuL3R5cGVzJztcblxuZXhwb3J0IGNvbnN0IGNvbG9yVmFyaWFibGVzID0gKCB7IGNvbG9ycyB9OiBUaGVtZU91dHB1dFZhbHVlcyApID0+IHtcblx0Y29uc3Qgc2hhZGVzID0gT2JqZWN0LmVudHJpZXMoIGNvbG9ycy5ncmF5IHx8IHt9IClcblx0XHQubWFwKCAoIFsgaywgdiBdICkgPT4gYC0td3AtY29tcG9uZW50cy1jb2xvci1ncmF5LSR7IGsgfTogJHsgdiB9O2AgKVxuXHRcdC5qb2luKCAnJyApO1xuXG5cdHJldHVybiBbXG5cdFx0Y3NzYFxuXHRcdFx0LS13cC1jb21wb25lbnRzLWNvbG9yLWFjY2VudDogJHsgY29sb3JzLmFjY2VudCB9O1xuXHRcdFx0LS13cC1jb21wb25lbnRzLWNvbG9yLWFjY2VudC1kYXJrZXItMTA6ICR7IGNvbG9ycy5hY2NlbnREYXJrZXIxMCB9O1xuXHRcdFx0LS13cC1jb21wb25lbnRzLWNvbG9yLWFjY2VudC1kYXJrZXItMjA6ICR7IGNvbG9ycy5hY2NlbnREYXJrZXIyMCB9O1xuXHRcdFx0LS13cC1jb21wb25lbnRzLWNvbG9yLWFjY2VudC1pbnZlcnRlZDogJHsgY29sb3JzLmFjY2VudEludmVydGVkIH07XG5cblx0XHRcdC0td3AtY29tcG9uZW50cy1jb2xvci1iYWNrZ3JvdW5kOiAkeyBjb2xvcnMuYmFja2dyb3VuZCB9O1xuXHRcdFx0LS13cC1jb21wb25lbnRzLWNvbG9yLWZvcmVncm91bmQ6ICR7IGNvbG9ycy5mb3JlZ3JvdW5kIH07XG5cdFx0XHQtLXdwLWNvbXBvbmVudHMtY29sb3ItZm9yZWdyb3VuZC1pbnZlcnRlZDogJHsgY29sb3JzLmZvcmVncm91bmRJbnZlcnRlZCB9O1xuXG5cdFx0XHQkeyBzaGFkZXMgfVxuXHRcdGAsXG5cdF07XG59O1xuXG5leHBvcnQgY29uc3QgV3JhcHBlciA9IHN0eWxlZC5kaXZgXG5cdGNvbG9yOiB2YXIoIC0td3AtY29tcG9uZW50cy1jb2xvci1mb3JlZ3JvdW5kLCBjdXJyZW50Q29sb3IgKTtcbmA7XG4iXX0= */",
|
|
30
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
31
|
+
});
|
|
27
32
|
exports.Wrapper = Wrapper;
|
|
28
33
|
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","colorVariables","colors","shades","Object","entries","gray","map","k","v","join","css","accent","accentDarker10","accentDarker20","accentInverted","background","foreground","foregroundInverted","process","env","NODE_ENV","exports","Wrapper","_base","default","target","label"],"sources":["@wordpress/components/src/theme/styles.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport styled from '@emotion/styled';\nimport { css } from '@emotion/react';\n\n/**\n * Internal dependencies\n */\nimport type { ThemeOutputValues } from './types';\n\nexport const colorVariables = ( { colors }: ThemeOutputValues ) => {\n\tconst shades = Object.entries( colors.gray || {} )\n\t\t.map( ( [ k, v ] ) => `--wp-components-color-gray-${ k }: ${ v };` )\n\t\t.join( '' );\n\n\treturn [\n\t\tcss`\n\t\t\t--wp-components-color-accent: ${ colors.accent };\n\t\t\t--wp-components-color-accent-darker-10: ${ colors.accentDarker10 };\n\t\t\t--wp-components-color-accent-darker-20: ${ colors.accentDarker20 };\n\t\t\t--wp-components-color-accent-inverted: ${ colors.accentInverted };\n\n\t\t\t--wp-components-color-background: ${ colors.background };\n\t\t\t--wp-components-color-foreground: ${ colors.foreground };\n\t\t\t--wp-components-color-foreground-inverted: ${ colors.foregroundInverted };\n\n\t\t\t${ shades }\n\t\t`,\n\t];\n};\n\nexport const Wrapper = styled.div
|
|
1
|
+
{"version":3,"names":["_react","require","_EMOTION_STRINGIFIED_CSS_ERROR__","colorVariables","colors","shades","Object","entries","gray","map","k","v","join","css","accent","accentDarker10","accentDarker20","accentInverted","background","foreground","foregroundInverted","process","env","NODE_ENV","exports","Wrapper","_base","default","target","label","name","styles","toString"],"sources":["@wordpress/components/src/theme/styles.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport styled from '@emotion/styled';\nimport { css } from '@emotion/react';\n\n/**\n * Internal dependencies\n */\nimport type { ThemeOutputValues } from './types';\n\nexport const colorVariables = ( { colors }: ThemeOutputValues ) => {\n\tconst shades = Object.entries( colors.gray || {} )\n\t\t.map( ( [ k, v ] ) => `--wp-components-color-gray-${ k }: ${ v };` )\n\t\t.join( '' );\n\n\treturn [\n\t\tcss`\n\t\t\t--wp-components-color-accent: ${ colors.accent };\n\t\t\t--wp-components-color-accent-darker-10: ${ colors.accentDarker10 };\n\t\t\t--wp-components-color-accent-darker-20: ${ colors.accentDarker20 };\n\t\t\t--wp-components-color-accent-inverted: ${ colors.accentInverted };\n\n\t\t\t--wp-components-color-background: ${ colors.background };\n\t\t\t--wp-components-color-foreground: ${ colors.foreground };\n\t\t\t--wp-components-color-foreground-inverted: ${ colors.foregroundInverted };\n\n\t\t\t${ shades }\n\t\t`,\n\t];\n};\n\nexport const Wrapper = styled.div`\n\tcolor: var( --wp-components-color-foreground, currentColor );\n`;\n"],"mappings":";;;;;;;;AAIA,IAAAA,MAAA,GAAAC,OAAA;AAAqC,SAAAC,iCAAA;AAO9B,MAAMC,cAAc,GAAGA,CAAE;EAAEC;AAA0B,CAAC,KAAM;EAClE,MAAMC,MAAM,GAAGC,MAAM,CAACC,OAAO,CAAEH,MAAM,CAACI,IAAI,IAAI,CAAC,CAAE,CAAC,CAChDC,GAAG,CAAE,CAAE,CAAEC,CAAC,EAAEC,CAAC,CAAE,KAAO,8BAA8BD,CAAG,KAAKC,CAAG,GAAG,CAAC,CACnEC,IAAI,CAAE,EAAG,CAAC;EAEZ,OAAO,kBACNC,UAAG,mCAC+BT,MAAM,CAACU,MAAM,8CACHV,MAAM,CAACW,cAAc,8CACrBX,MAAM,CAACY,cAAc,6CACtBZ,MAAM,CAACa,cAAc,wCAE1Bb,MAAM,CAACc,UAAU,wCACjBd,MAAM,CAACe,UAAU,iDACRf,MAAM,CAACgB,kBAAkB,OAEpEf,MAAM,SAAAgB,OAAA,CAAAC,GAAA,CAAAC,QAAA,oDAAAF,OAAA,CAAAC,GAAA,CAAAC,QAAA,gvDAEV;AACF,CAAC;AAACC,OAAA,CAAArB,cAAA,GAAAA,cAAA;AAEK,MAAMsB,OAAO,OAAAC,KAAA,CAAAC,OAAA,SAAAN,OAAA,CAAAC,GAAA,CAAAC,QAAA;EAAAK,MAAA;AAAA;EAAAA,MAAA;EAAAC,KAAA;AAAA,GAAAR,OAAA,CAAAC,GAAA,CAAAC,QAAA;EAAAO,IAAA;EAAAC,MAAA;AAAA;EAAAD,IAAA;EAAAC,MAAA;EAAAtB,GAAA;EAAAuB,QAAA,EAAA9B;AAAA,EAEnB;AAACsB,OAAA,CAAAC,OAAA,GAAAA,OAAA"}
|
|
@@ -18,12 +18,18 @@ var _element = require("@wordpress/element");
|
|
|
18
18
|
* @param valueProp The received `value`
|
|
19
19
|
*/
|
|
20
20
|
function useComputeControlledOrUncontrolledValue(valueProp) {
|
|
21
|
+
const isInitialRender = (0, _element.useRef)(true);
|
|
21
22
|
const prevValueProp = (0, _compose.usePrevious)(valueProp);
|
|
22
23
|
const prevIsControlled = (0, _element.useRef)(false);
|
|
24
|
+
(0, _element.useEffect)(() => {
|
|
25
|
+
if (isInitialRender.current) {
|
|
26
|
+
isInitialRender.current = false;
|
|
27
|
+
}
|
|
28
|
+
}, []);
|
|
23
29
|
|
|
24
30
|
// Assume the component is being used in controlled mode on the first re-render
|
|
25
31
|
// that has a different `valueProp` from the previous render.
|
|
26
|
-
const isControlled = prevIsControlled.current ||
|
|
32
|
+
const isControlled = prevIsControlled.current || !isInitialRender.current && prevValueProp !== valueProp;
|
|
27
33
|
(0, _element.useEffect)(() => {
|
|
28
34
|
prevIsControlled.current = isControlled;
|
|
29
35
|
}, [isControlled]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_compose","require","_element","useComputeControlledOrUncontrolledValue","valueProp","
|
|
1
|
+
{"version":3,"names":["_compose","require","_element","useComputeControlledOrUncontrolledValue","valueProp","isInitialRender","useRef","prevValueProp","usePrevious","prevIsControlled","useEffect","current","isControlled","value","defaultValue","undefined"],"sources":["@wordpress/components/src/toggle-group-control/toggle-group-control/utils.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { usePrevious } from '@wordpress/compose';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { ToggleGroupControlProps } from '../types';\n\ntype ValueProp = ToggleGroupControlProps[ 'value' ];\n\n/**\n * Used to determine, via an internal heuristics, whether an `undefined` value\n * received for the `value` prop should be interpreted as the component being\n * used in uncontrolled mode, or as an \"empty\" value for controlled mode.\n *\n * @param valueProp The received `value`\n */\nexport function useComputeControlledOrUncontrolledValue(\n\tvalueProp: ValueProp\n): { value: ValueProp; defaultValue: ValueProp } {\n\tconst isInitialRender = useRef( true );\n\tconst prevValueProp = usePrevious( valueProp );\n\tconst prevIsControlled = useRef( false );\n\n\tuseEffect( () => {\n\t\tif ( isInitialRender.current ) {\n\t\t\tisInitialRender.current = false;\n\t\t}\n\t}, [] );\n\n\t// Assume the component is being used in controlled mode on the first re-render\n\t// that has a different `valueProp` from the previous render.\n\tconst isControlled =\n\t\tprevIsControlled.current ||\n\t\t( ! isInitialRender.current && prevValueProp !== valueProp );\n\tuseEffect( () => {\n\t\tprevIsControlled.current = isControlled;\n\t}, [ isControlled ] );\n\n\tif ( isControlled ) {\n\t\t// When in controlled mode, use `''` instead of `undefined`\n\t\treturn { value: valueProp ?? '', defaultValue: undefined };\n\t}\n\n\t// When in uncontrolled mode, the `value` should be intended as the initial value\n\treturn { value: undefined, defaultValue: valueProp };\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,uCAAuCA,CACtDC,SAAoB,EAC4B;EAChD,MAAMC,eAAe,GAAG,IAAAC,eAAM,EAAE,IAAK,CAAC;EACtC,MAAMC,aAAa,GAAG,IAAAC,oBAAW,EAAEJ,SAAU,CAAC;EAC9C,MAAMK,gBAAgB,GAAG,IAAAH,eAAM,EAAE,KAAM,CAAC;EAExC,IAAAI,kBAAS,EAAE,MAAM;IAChB,IAAKL,eAAe,CAACM,OAAO,EAAG;MAC9BN,eAAe,CAACM,OAAO,GAAG,KAAK;IAChC;EACD,CAAC,EAAE,EAAG,CAAC;;EAEP;EACA;EACA,MAAMC,YAAY,GACjBH,gBAAgB,CAACE,OAAO,IACtB,CAAEN,eAAe,CAACM,OAAO,IAAIJ,aAAa,KAAKH,SAAW;EAC7D,IAAAM,kBAAS,EAAE,MAAM;IAChBD,gBAAgB,CAACE,OAAO,GAAGC,YAAY;EACxC,CAAC,EAAE,CAAEA,YAAY,CAAG,CAAC;EAErB,IAAKA,YAAY,EAAG;IACnB;IACA,OAAO;MAAEC,KAAK,EAAET,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EAAE;MAAEU,YAAY,EAAEC;IAAU,CAAC;EAC3D;;EAEA;EACA,OAAO;IAAEF,KAAK,EAAEE,SAAS;IAAED,YAAY,EAAEV;EAAU,CAAC;AACrD"}
|
package/build/tooltip/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default = exports.TOOLTIP_DELAY = void 0;
|
|
7
|
+
exports.default = exports.Tooltip = exports.TOOLTIP_DELAY = void 0;
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var Ariakit = _interopRequireWildcard(require("@ariakit/react"));
|
|
10
10
|
var _compose = require("@wordpress/compose");
|
|
@@ -23,12 +23,19 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
23
23
|
* WordPress dependencies
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
+
const TooltipInternalContext = (0, _element.createContext)({
|
|
27
|
+
isNestedInTooltip: false
|
|
28
|
+
});
|
|
29
|
+
|
|
26
30
|
/**
|
|
27
31
|
* Time over anchor to wait before showing tooltip
|
|
28
32
|
*/
|
|
29
33
|
const TOOLTIP_DELAY = 700;
|
|
30
34
|
exports.TOOLTIP_DELAY = TOOLTIP_DELAY;
|
|
31
|
-
|
|
35
|
+
const CONTEXT_VALUE = {
|
|
36
|
+
isNestedInTooltip: true
|
|
37
|
+
};
|
|
38
|
+
function UnforwardedTooltip(props, ref) {
|
|
32
39
|
const {
|
|
33
40
|
children,
|
|
34
41
|
delay = TOOLTIP_DELAY,
|
|
@@ -36,8 +43,12 @@ function Tooltip(props) {
|
|
|
36
43
|
placement,
|
|
37
44
|
position,
|
|
38
45
|
shortcut,
|
|
39
|
-
text
|
|
46
|
+
text,
|
|
47
|
+
...restProps
|
|
40
48
|
} = props;
|
|
49
|
+
const {
|
|
50
|
+
isNestedInTooltip
|
|
51
|
+
} = (0, _element.useContext)(TooltipInternalContext);
|
|
41
52
|
const baseId = (0, _compose.useInstanceId)(Tooltip, 'tooltip');
|
|
42
53
|
const describedById = text || shortcut ? baseId : undefined;
|
|
43
54
|
const isOnlyChild = _element.Children.count(children) === 1;
|
|
@@ -45,7 +56,7 @@ function Tooltip(props) {
|
|
|
45
56
|
if (!isOnlyChild) {
|
|
46
57
|
if ('development' === process.env.NODE_ENV) {
|
|
47
58
|
// eslint-disable-next-line no-console
|
|
48
|
-
console.error('Tooltip should be called with only a single child element.');
|
|
59
|
+
console.error('wp-components.Tooltip should be called with only a single child element.');
|
|
49
60
|
}
|
|
50
61
|
}
|
|
51
62
|
|
|
@@ -64,17 +75,31 @@ function Tooltip(props) {
|
|
|
64
75
|
});
|
|
65
76
|
}
|
|
66
77
|
computedPlacement = computedPlacement || 'bottom';
|
|
67
|
-
|
|
78
|
+
|
|
79
|
+
// Removing the `Ariakit` namespace from the hook name allows ESLint to
|
|
80
|
+
// properly identify the hook, and apply the correct linting rules.
|
|
81
|
+
const useAriakitTooltipStore = Ariakit.useTooltipStore;
|
|
82
|
+
const tooltipStore = useAriakitTooltipStore({
|
|
68
83
|
placement: computedPlacement,
|
|
69
84
|
showTimeout: delay
|
|
70
85
|
});
|
|
71
|
-
|
|
86
|
+
if (isNestedInTooltip) {
|
|
87
|
+
return isOnlyChild ? (0, _react.createElement)(Ariakit.Role, {
|
|
88
|
+
...restProps,
|
|
89
|
+
render: children
|
|
90
|
+
}) : children;
|
|
91
|
+
}
|
|
92
|
+
return (0, _react.createElement)(TooltipInternalContext.Provider, {
|
|
93
|
+
value: CONTEXT_VALUE
|
|
94
|
+
}, (0, _react.createElement)(Ariakit.TooltipAnchor, {
|
|
72
95
|
onClick: hideOnClick ? tooltipStore.hide : undefined,
|
|
73
96
|
store: tooltipStore,
|
|
74
|
-
render: isOnlyChild ? children : undefined
|
|
97
|
+
render: isOnlyChild ? children : undefined,
|
|
98
|
+
ref: ref
|
|
75
99
|
}, isOnlyChild ? undefined : children), isOnlyChild && (text || shortcut) && (0, _react.createElement)(Ariakit.Tooltip, {
|
|
76
|
-
|
|
100
|
+
...restProps,
|
|
77
101
|
className: "components-tooltip",
|
|
102
|
+
unmountOnHide: true,
|
|
78
103
|
gutter: 4,
|
|
79
104
|
id: describedById,
|
|
80
105
|
overflowPadding: 0.5,
|
|
@@ -84,6 +109,8 @@ function Tooltip(props) {
|
|
|
84
109
|
shortcut: shortcut
|
|
85
110
|
})));
|
|
86
111
|
}
|
|
112
|
+
const Tooltip = (0, _element.forwardRef)(UnforwardedTooltip);
|
|
113
|
+
exports.Tooltip = Tooltip;
|
|
87
114
|
var _default = Tooltip;
|
|
88
115
|
exports.default = _default;
|
|
89
116
|
//# sourceMappingURL=index.js.map
|