@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
package/build/button/index.js
CHANGED
|
@@ -14,8 +14,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
14
14
|
|
|
15
15
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
16
16
|
|
|
17
|
-
var _lodash = require("lodash");
|
|
18
|
-
|
|
19
17
|
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
|
|
20
18
|
|
|
21
19
|
var _compose = require("@wordpress/compose");
|
|
@@ -158,8 +156,8 @@ function Button(props, ref) {
|
|
|
158
156
|
const shouldShowTooltip = !trulyDisabled && ( // An explicit tooltip is passed or...
|
|
159
157
|
showTooltip && label || // There's a shortcut or...
|
|
160
158
|
shortcut || // There's a label and...
|
|
161
|
-
!!label &&
|
|
162
|
-
!children
|
|
159
|
+
!!label && // The children are empty and...
|
|
160
|
+
!(children !== null && children !== void 0 && children.length) && // The tooltip is not explicitly disabled.
|
|
163
161
|
false !== showTooltip);
|
|
164
162
|
const descriptionId = describedBy ? instanceId : null;
|
|
165
163
|
const describedById = additionalProps['aria-describedby'] || descriptionId;
|
|
@@ -183,7 +181,7 @@ function Button(props, ref) {
|
|
|
183
181
|
}
|
|
184
182
|
|
|
185
183
|
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_tooltip.default, {
|
|
186
|
-
text: describedBy ? describedBy : label,
|
|
184
|
+
text: children !== null && children !== void 0 && children.length && describedBy ? describedBy : label,
|
|
187
185
|
shortcut: shortcut,
|
|
188
186
|
position: tooltipPosition
|
|
189
187
|
}, element), describedBy && (0, _element.createElement)(_visuallyHidden.VisuallyHidden, null, (0, _element.createElement)("span", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/button/index.js"],"names":["disabledEventsOnDisabledButton","useDeprecatedProps","isDefault","isPrimary","isSecondary","isTertiary","isLink","variant","otherProps","computedVariant","since","alternative","version","Button","props","ref","href","target","isSmall","isPressed","isBusy","isDestructive","className","disabled","icon","iconPosition","iconSize","showTooltip","tooltipPosition","shortcut","label","children","text","__experimentalIsFocusable","isFocusable","describedBy","additionalProps","instanceId","classes","trulyDisabled","Tag","undefined","tagProps","type","disabledEvent","event","stopPropagation","preventDefault","shouldShowTooltip","length","descriptionId","describedById","element"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/button/index.js"],"names":["disabledEventsOnDisabledButton","useDeprecatedProps","isDefault","isPrimary","isSecondary","isTertiary","isLink","variant","otherProps","computedVariant","since","alternative","version","Button","props","ref","href","target","isSmall","isPressed","isBusy","isDestructive","className","disabled","icon","iconPosition","iconSize","showTooltip","tooltipPosition","shortcut","label","children","text","__experimentalIsFocusable","isFocusable","describedBy","additionalProps","instanceId","classes","trulyDisabled","Tag","undefined","tagProps","type","disabledEvent","event","stopPropagation","preventDefault","shouldShowTooltip","length","descriptionId","describedById","element"],"mappings":";;;;;;;;;;AAUA;;;;AANA;;AAKA;;AAEA;;AAKA;;AACA;;AACA;;AAlBA;;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AAKA,MAAMA,8BAA8B,GAAG,CAAE,aAAF,EAAiB,SAAjB,CAAvC;;AAEA,SAASC,kBAAT,OAQI;AAAA,MARyB;AAC5BC,IAAAA,SAD4B;AAE5BC,IAAAA,SAF4B;AAG5BC,IAAAA,WAH4B;AAI5BC,IAAAA,UAJ4B;AAK5BC,IAAAA,MAL4B;AAM5BC,IAAAA,OAN4B;AAO5B,OAAGC;AAPyB,GAQzB;AACH,MAAIC,eAAe,GAAGF,OAAtB;;AAEA,MAAKJ,SAAL,EAAiB;AAAA;;AAChB,wBAAAM,eAAe,UAAf,qDAAAA,eAAe,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AA7B,CADD,CATF,CADD;AAgBA;;eAEc,yBAAYtB,MAAZ,C","sourcesContent":["// @ts-nocheck\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { forwardRef } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Tooltip from '../tooltip';\nimport Icon from '../icon';\nimport { VisuallyHidden } from '../visually-hidden';\n\nconst disabledEventsOnDisabledButton = [ 'onMouseDown', 'onClick' ];\n\nfunction useDeprecatedProps( {\n\tisDefault,\n\tisPrimary,\n\tisSecondary,\n\tisTertiary,\n\tisLink,\n\tvariant,\n\t...otherProps\n} ) {\n\tlet computedVariant = variant;\n\n\tif ( isPrimary ) {\n\t\tcomputedVariant ??= 'primary';\n\t}\n\n\tif ( isTertiary ) {\n\t\tcomputedVariant ??= 'tertiary';\n\t}\n\n\tif ( isSecondary ) {\n\t\tcomputedVariant ??= 'secondary';\n\t}\n\n\tif ( isDefault ) {\n\t\tdeprecated( 'Button isDefault prop', {\n\t\t\tsince: '5.4',\n\t\t\talternative: 'variant=\"secondary\"',\n\t\t\tversion: '6.2',\n\t\t} );\n\n\t\tcomputedVariant ??= 'secondary';\n\t}\n\n\tif ( isLink ) {\n\t\tcomputedVariant ??= 'link';\n\t}\n\n\treturn {\n\t\t...otherProps,\n\t\tvariant: computedVariant,\n\t};\n}\n\nexport function Button( props, ref ) {\n\tconst {\n\t\thref,\n\t\ttarget,\n\t\tisSmall,\n\t\tisPressed,\n\t\tisBusy,\n\t\tisDestructive,\n\t\tclassName,\n\t\tdisabled,\n\t\ticon,\n\t\ticonPosition = 'left',\n\t\ticonSize,\n\t\tshowTooltip,\n\t\ttooltipPosition,\n\t\tshortcut,\n\t\tlabel,\n\t\tchildren,\n\t\ttext,\n\t\tvariant,\n\t\t__experimentalIsFocusable: isFocusable,\n\t\tdescribedBy,\n\t\t...additionalProps\n\t} = useDeprecatedProps( props );\n\tconst instanceId = useInstanceId(\n\t\tButton,\n\t\t'components-button__description'\n\t);\n\n\tconst classes = classnames( 'components-button', className, {\n\t\t'is-secondary': variant === 'secondary',\n\t\t'is-primary': variant === 'primary',\n\t\t'is-small': isSmall,\n\t\t'is-tertiary': variant === 'tertiary',\n\t\t'is-pressed': isPressed,\n\t\t'is-busy': isBusy,\n\t\t'is-link': variant === 'link',\n\t\t'is-destructive': isDestructive,\n\t\t'has-text': !! icon && !! children,\n\t\t'has-icon': !! icon,\n\t} );\n\n\tconst trulyDisabled = disabled && ! isFocusable;\n\tconst Tag = href !== undefined && ! trulyDisabled ? 'a' : 'button';\n\tconst tagProps =\n\t\tTag === 'a'\n\t\t\t? { href, target }\n\t\t\t: {\n\t\t\t\t\ttype: 'button',\n\t\t\t\t\tdisabled: trulyDisabled,\n\t\t\t\t\t'aria-pressed': isPressed,\n\t\t\t };\n\n\tif ( disabled && isFocusable ) {\n\t\t// In this case, the button will be disabled, but still focusable and\n\t\t// perceivable by screen reader users.\n\t\ttagProps[ 'aria-disabled' ] = true;\n\n\t\tfor ( const disabledEvent of disabledEventsOnDisabledButton ) {\n\t\t\tadditionalProps[ disabledEvent ] = ( event ) => {\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tevent.preventDefault();\n\t\t\t};\n\t\t}\n\t}\n\n\t// Should show the tooltip if...\n\tconst shouldShowTooltip =\n\t\t! trulyDisabled &&\n\t\t// An explicit tooltip is passed or...\n\t\t( ( showTooltip && label ) ||\n\t\t\t// There's a shortcut or...\n\t\t\tshortcut ||\n\t\t\t// There's a label and...\n\t\t\t( !! label &&\n\t\t\t\t// The children are empty and...\n\t\t\t\t! children?.length &&\n\t\t\t\t// The tooltip is not explicitly disabled.\n\t\t\t\tfalse !== showTooltip ) );\n\n\tconst descriptionId = describedBy ? instanceId : null;\n\n\tconst describedById =\n\t\tadditionalProps[ 'aria-describedby' ] || descriptionId;\n\n\tconst element = (\n\t\t<Tag\n\t\t\t{ ...tagProps }\n\t\t\t{ ...additionalProps }\n\t\t\tclassName={ classes }\n\t\t\taria-label={ additionalProps[ 'aria-label' ] || label }\n\t\t\taria-describedby={ describedById }\n\t\t\tref={ ref }\n\t\t>\n\t\t\t{ icon && iconPosition === 'left' && (\n\t\t\t\t<Icon icon={ icon } size={ iconSize } />\n\t\t\t) }\n\t\t\t{ text && <>{ text }</> }\n\t\t\t{ icon && iconPosition === 'right' && (\n\t\t\t\t<Icon icon={ icon } size={ iconSize } />\n\t\t\t) }\n\t\t\t{ children }\n\t\t</Tag>\n\t);\n\n\tif ( ! shouldShowTooltip ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ element }\n\t\t\t\t{ describedBy && (\n\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t<span id={ descriptionId }>{ describedBy }</span>\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Tooltip\n\t\t\t\ttext={ children?.length && describedBy ? describedBy : label }\n\t\t\t\tshortcut={ shortcut }\n\t\t\t\tposition={ tooltipPosition }\n\t\t\t>\n\t\t\t\t{ element }\n\t\t\t</Tooltip>\n\t\t\t{ describedBy && (\n\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t<span id={ descriptionId }>{ describedBy }</span>\n\t\t\t\t</VisuallyHidden>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default forwardRef( Button );\n"]}
|
|
@@ -87,8 +87,7 @@ function ButtonAction(_ref4) {
|
|
|
87
87
|
} = _ref4;
|
|
88
88
|
return (0, _element.createElement)(_button.default, (0, _extends2.default)({
|
|
89
89
|
className: (0, _classnames.default)('components-circular-option-picker__clear', className),
|
|
90
|
-
|
|
91
|
-
variant: "secondary"
|
|
90
|
+
variant: "tertiary"
|
|
92
91
|
}, additionalProps), children);
|
|
93
92
|
}
|
|
94
93
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/circular-option-picker/index.js"],"names":["Option","className","isSelected","selectedIconProps","tooltipText","additionalProps","optionButton","check","DropdownLinkAction","buttonProps","dropdownProps","linkText","isOpen","onToggle","ButtonAction","children","CircularOptionPicker","actions","options"],"mappings":";;;;;;;;;;;;;AAIA;;AAKA;;AAKA;;AACA;;AACA;;AAhBA;;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAKA,SAASA,MAAT,OAMI;AAAA,MANa;AAChBC,IAAAA,SADgB;AAEhBC,IAAAA,UAFgB;AAGhBC,IAAAA,iBAHgB;AAIhBC,IAAAA,WAJgB;AAKhB,OAAGC;AALa,GAMb;AACH,QAAMC,YAAY,GACjB,4BAAC,eAAD;AACC,IAAA,SAAS,EAAGJ,UADb;AAEC,IAAA,SAAS,EAAC;AAFX,KAGMG,eAHN,EADD;AAOA,SACC;AACC,IAAA,SAAS,EAAG,yBACXJ,SADW,EAEX,mDAFW;AADb,KAMGG,WAAW,GACZ,4BAAC,gBAAD;AAAS,IAAA,IAAI,EAAGA;AAAhB,KAAgCE,YAAhC,CADY,GAGZA,YATF,EAWGJ,UAAU,IACX,4BAAC,WAAD;AACC,IAAA,IAAI,EAAGK;AADR,KAEQJ,iBAAiB,GAAGA,iBAAH,GAAuB,EAFhD,EAZF,CADD;AAoBA;;AAED,SAASK,kBAAT,QAKI;AAAA,MALyB;AAC5BC,IAAAA,WAD4B;AAE5BR,IAAAA,SAF4B;AAG5BS,IAAAA,aAH4B;AAI5BC,IAAAA;AAJ4B,GAKzB;AACH,SACC,4BAAC,iBAAD;AACC,IAAA,SAAS,EAAG,yBACX,yDADW,EAEXV,SAFW,CADb;AAKC,IAAA,YAAY,EAAG;AAAA,UAAE;AAAEW,QAAAA,MAAF;AAAUC,QAAAA;AAAV,OAAF;AAAA,aACd,4BAAC,eAAD;AACC,yBAAgBD,MADjB;AAEC,yBAAc,MAFf;AAGC,QAAA,OAAO,EAAGC,QAHX;AAIC,QAAA,OAAO,EAAC;AAJT,SAKMJ,WALN,GAOGE,QAPH,CADc;AAAA;AALhB,KAgBMD,aAhBN,EADD;AAoBA;;AAED,SAASI,YAAT,QAAqE;AAAA,MAA9C;AAAEb,IAAAA,SAAF;AAAac,IAAAA,QAAb;AAAuB,OAAGV;AAA1B,GAA8C;AACpE,SACC,4BAAC,eAAD;AACC,IAAA,SAAS,EAAG,yBACX,0CADW,EAEXJ,SAFW,CADb;AAKC,IAAA,OAAO,
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/circular-option-picker/index.js"],"names":["Option","className","isSelected","selectedIconProps","tooltipText","additionalProps","optionButton","check","DropdownLinkAction","buttonProps","dropdownProps","linkText","isOpen","onToggle","ButtonAction","children","CircularOptionPicker","actions","options"],"mappings":";;;;;;;;;;;;;AAIA;;AAKA;;AAKA;;AACA;;AACA;;AAhBA;;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAKA,SAASA,MAAT,OAMI;AAAA,MANa;AAChBC,IAAAA,SADgB;AAEhBC,IAAAA,UAFgB;AAGhBC,IAAAA,iBAHgB;AAIhBC,IAAAA,WAJgB;AAKhB,OAAGC;AALa,GAMb;AACH,QAAMC,YAAY,GACjB,4BAAC,eAAD;AACC,IAAA,SAAS,EAAGJ,UADb;AAEC,IAAA,SAAS,EAAC;AAFX,KAGMG,eAHN,EADD;AAOA,SACC;AACC,IAAA,SAAS,EAAG,yBACXJ,SADW,EAEX,mDAFW;AADb,KAMGG,WAAW,GACZ,4BAAC,gBAAD;AAAS,IAAA,IAAI,EAAGA;AAAhB,KAAgCE,YAAhC,CADY,GAGZA,YATF,EAWGJ,UAAU,IACX,4BAAC,WAAD;AACC,IAAA,IAAI,EAAGK;AADR,KAEQJ,iBAAiB,GAAGA,iBAAH,GAAuB,EAFhD,EAZF,CADD;AAoBA;;AAED,SAASK,kBAAT,QAKI;AAAA,MALyB;AAC5BC,IAAAA,WAD4B;AAE5BR,IAAAA,SAF4B;AAG5BS,IAAAA,aAH4B;AAI5BC,IAAAA;AAJ4B,GAKzB;AACH,SACC,4BAAC,iBAAD;AACC,IAAA,SAAS,EAAG,yBACX,yDADW,EAEXV,SAFW,CADb;AAKC,IAAA,YAAY,EAAG;AAAA,UAAE;AAAEW,QAAAA,MAAF;AAAUC,QAAAA;AAAV,OAAF;AAAA,aACd,4BAAC,eAAD;AACC,yBAAgBD,MADjB;AAEC,yBAAc,MAFf;AAGC,QAAA,OAAO,EAAGC,QAHX;AAIC,QAAA,OAAO,EAAC;AAJT,SAKMJ,WALN,GAOGE,QAPH,CADc;AAAA;AALhB,KAgBMD,aAhBN,EADD;AAoBA;;AAED,SAASI,YAAT,QAAqE;AAAA,MAA9C;AAAEb,IAAAA,SAAF;AAAac,IAAAA,QAAb;AAAuB,OAAGV;AAA1B,GAA8C;AACpE,SACC,4BAAC,eAAD;AACC,IAAA,SAAS,EAAG,yBACX,0CADW,EAEXJ,SAFW,CADb;AAKC,IAAA,OAAO,EAAC;AALT,KAMMI,eANN,GAQGU,QARH,CADD;AAYA;;AAEc,SAASC,oBAAT,QAKX;AAAA,MAL0C;AAC7CC,IAAAA,OAD6C;AAE7ChB,IAAAA,SAF6C;AAG7CiB,IAAAA,OAH6C;AAI7CH,IAAAA;AAJ6C,GAK1C;AACH,SACC;AACC,IAAA,SAAS,EAAG,yBACX,mCADW,EAEXd,SAFW;AADb,KAMC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGiB,OADH,CAND,EASGH,QATH,EAUGE,OAAO,IACR;AAAK,IAAA,SAAS,EAAC;AAAf,KACGA,OADH,CAXF,CADD;AAkBA;;AAEDD,oBAAoB,CAAChB,MAArB,GAA8BA,MAA9B;AACAgB,oBAAoB,CAACF,YAArB,GAAoCA,YAApC;AACAE,oBAAoB,CAACR,kBAArB,GAA0CA,kBAA1C","sourcesContent":["// @ts-nocheck\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Icon, check } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport Dropdown from '../dropdown';\nimport Tooltip from '../tooltip';\n\nfunction Option( {\n\tclassName,\n\tisSelected,\n\tselectedIconProps,\n\ttooltipText,\n\t...additionalProps\n} ) {\n\tconst optionButton = (\n\t\t<Button\n\t\t\tisPressed={ isSelected }\n\t\t\tclassName=\"components-circular-option-picker__option\"\n\t\t\t{ ...additionalProps }\n\t\t/>\n\t);\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames(\n\t\t\t\tclassName,\n\t\t\t\t'components-circular-option-picker__option-wrapper'\n\t\t\t) }\n\t\t>\n\t\t\t{ tooltipText ? (\n\t\t\t\t<Tooltip text={ tooltipText }>{ optionButton }</Tooltip>\n\t\t\t) : (\n\t\t\t\toptionButton\n\t\t\t) }\n\t\t\t{ isSelected && (\n\t\t\t\t<Icon\n\t\t\t\t\ticon={ check }\n\t\t\t\t\t{ ...( selectedIconProps ? selectedIconProps : {} ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction DropdownLinkAction( {\n\tbuttonProps,\n\tclassName,\n\tdropdownProps,\n\tlinkText,\n} ) {\n\treturn (\n\t\t<Dropdown\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-circular-option-picker__dropdown-link-action',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t{ ...buttonProps }\n\t\t\t\t>\n\t\t\t\t\t{ linkText }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ ...dropdownProps }\n\t\t/>\n\t);\n}\n\nfunction ButtonAction( { className, children, ...additionalProps } ) {\n\treturn (\n\t\t<Button\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-circular-option-picker__clear',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\tvariant=\"tertiary\"\n\t\t\t{ ...additionalProps }\n\t\t>\n\t\t\t{ children }\n\t\t</Button>\n\t);\n}\n\nexport default function CircularOptionPicker( {\n\tactions,\n\tclassName,\n\toptions,\n\tchildren,\n} ) {\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-circular-option-picker',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t>\n\t\t\t<div className=\"components-circular-option-picker__swatches\">\n\t\t\t\t{ options }\n\t\t\t</div>\n\t\t\t{ children }\n\t\t\t{ actions && (\n\t\t\t\t<div className=\"components-circular-option-picker__custom-clear-wrapper\">\n\t\t\t\t\t{ actions }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nCircularOptionPicker.Option = Option;\nCircularOptionPicker.ButtonAction = ButtonAction;\nCircularOptionPicker.DropdownLinkAction = DropdownLinkAction;\n"]}
|
package/build/disabled/index.js
CHANGED
|
@@ -11,11 +11,9 @@ var _element = require("@wordpress/element");
|
|
|
11
11
|
|
|
12
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
13
|
|
|
14
|
-
var _lodash = require("lodash");
|
|
15
|
-
|
|
16
14
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
17
15
|
|
|
18
|
-
var
|
|
16
|
+
var _compose = require("@wordpress/compose");
|
|
19
17
|
|
|
20
18
|
var _disabledStyles = require("./styles/disabled-styles");
|
|
21
19
|
|
|
@@ -35,17 +33,6 @@ const {
|
|
|
35
33
|
Consumer,
|
|
36
34
|
Provider
|
|
37
35
|
} = Context;
|
|
38
|
-
/**
|
|
39
|
-
* Names of control nodes which qualify for disabled behavior.
|
|
40
|
-
*
|
|
41
|
-
* See WHATWG HTML Standard: 4.10.18.5: "Enabling and disabling form controls: the disabled attribute".
|
|
42
|
-
*
|
|
43
|
-
* @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#enabling-and-disabling-form-controls:-the-disabled-attribute
|
|
44
|
-
*
|
|
45
|
-
* @type {string[]}
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
const DISABLED_ELIGIBLE_NODE_NAMES = ['BUTTON', 'FIELDSET', 'INPUT', 'OPTGROUP', 'OPTION', 'SELECT', 'TEXTAREA'];
|
|
49
36
|
/**
|
|
50
37
|
* @typedef OwnProps
|
|
51
38
|
* @property {string} [className] Classname for the disabled element.
|
|
@@ -66,67 +53,8 @@ function Disabled(_ref) {
|
|
|
66
53
|
...props
|
|
67
54
|
} = _ref;
|
|
68
55
|
|
|
69
|
-
/** @type {import('react').
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
const disable = () => {
|
|
73
|
-
if (!node.current) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
_dom.focus.focusable.find(node.current).forEach(focusable => {
|
|
78
|
-
if ((0, _lodash.includes)(DISABLED_ELIGIBLE_NODE_NAMES, focusable.nodeName)) {
|
|
79
|
-
focusable.setAttribute('disabled', '');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (focusable.nodeName === 'A') {
|
|
83
|
-
focusable.setAttribute('tabindex', '-1');
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const tabIndex = focusable.getAttribute('tabindex');
|
|
87
|
-
|
|
88
|
-
if (tabIndex !== null && tabIndex !== '-1') {
|
|
89
|
-
focusable.removeAttribute('tabindex');
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (focusable.hasAttribute('contenteditable')) {
|
|
93
|
-
focusable.setAttribute('contenteditable', 'false');
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}; // Debounce re-disable since disabling process itself will incur
|
|
97
|
-
// additional mutations which should be ignored.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const debouncedDisable = (0, _element.useCallback)((0, _lodash.debounce)(disable, undefined, {
|
|
101
|
-
leading: true
|
|
102
|
-
}), []);
|
|
103
|
-
(0, _element.useLayoutEffect)(() => {
|
|
104
|
-
if (!isDisabled) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
disable();
|
|
109
|
-
/** @type {MutationObserver | undefined} */
|
|
110
|
-
|
|
111
|
-
let observer;
|
|
112
|
-
|
|
113
|
-
if (node.current) {
|
|
114
|
-
observer = new window.MutationObserver(debouncedDisable);
|
|
115
|
-
observer.observe(node.current, {
|
|
116
|
-
childList: true,
|
|
117
|
-
attributes: true,
|
|
118
|
-
subtree: true
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return () => {
|
|
123
|
-
if (observer) {
|
|
124
|
-
observer.disconnect();
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
debouncedDisable.cancel();
|
|
128
|
-
};
|
|
129
|
-
}, []);
|
|
56
|
+
/** @type {import('react').RefCallback<HTMLDivElement>} */
|
|
57
|
+
const ref = (0, _compose.__experimentalUseDisabled)();
|
|
130
58
|
|
|
131
59
|
if (!isDisabled) {
|
|
132
60
|
return (0, _element.createElement)(Provider, {
|
|
@@ -137,7 +65,7 @@ function Disabled(_ref) {
|
|
|
137
65
|
return (0, _element.createElement)(Provider, {
|
|
138
66
|
value: true
|
|
139
67
|
}, (0, _element.createElement)(_disabledStyles.StyledWrapper, (0, _extends2.default)({
|
|
140
|
-
ref:
|
|
68
|
+
ref: ref,
|
|
141
69
|
className: (0, _classnames.default)(className, 'components-disabled')
|
|
142
70
|
}, props), children));
|
|
143
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/disabled/index.js"],"names":["Context","Consumer","Provider","
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/disabled/index.js"],"names":["Context","Consumer","Provider","Disabled","className","children","isDisabled","props","ref"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAKA;;AAMA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAGA,MAAMA,OAAO,GAAG,4BAAe,KAAf,CAAhB;AACA,MAAM;AAAEC,EAAAA,QAAF;AAAYC,EAAAA;AAAZ,IAAyBF,OAA/B;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AACA,SAASG,QAAT,OAA0E;AAAA,MAAvD;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,QAAb;AAAuBC,IAAAA,UAAU,GAAG,IAApC;AAA0C,OAAGC;AAA7C,GAAuD;;AACzE;AACA,QAAMC,GAAG,GAAG,yCAAZ;;AAEA,MAAK,CAAEF,UAAP,EAAoB;AACnB,WAAO,4BAAC,QAAD;AAAU,MAAA,KAAK,EAAG;AAAlB,OAA4BD,QAA5B,CAAP;AACA;;AAED,SACC,4BAAC,QAAD;AAAU,IAAA,KAAK,EAAG;AAAlB,KACC,4BAAC,6BAAD;AACC,IAAA,GAAG,EAAGG,GADP;AAEC,IAAA,SAAS,EAAG,yBAAYJ,SAAZ,EAAuB,qBAAvB;AAFb,KAGMG,KAHN,GAKGF,QALH,CADD,CADD;AAWA;;AAEDF,QAAQ,CAACH,OAAT,GAAmBA,OAAnB;AACAG,QAAQ,CAACF,QAAT,GAAoBA,QAApB;eAEeE,Q","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __experimentalUseDisabled as useDisabled } from '@wordpress/compose';\nimport { createContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { StyledWrapper } from './styles/disabled-styles';\n\nconst Context = createContext( false );\nconst { Consumer, Provider } = Context;\n\n/**\n * @typedef OwnProps\n * @property {string} [className] Classname for the disabled element.\n * @property {import('react').ReactNode} children Children to disable.\n * @property {boolean} [isDisabled=true] Whether to disable the children.\n */\n\n/**\n * @param {OwnProps & import('react').HTMLAttributes<HTMLDivElement>} props\n * @return {JSX.Element} Element wrapping the children to disable them when isDisabled is true.\n */\nfunction Disabled( { className, children, isDisabled = true, ...props } ) {\n\t/** @type {import('react').RefCallback<HTMLDivElement>} */\n\tconst ref = useDisabled();\n\n\tif ( ! isDisabled ) {\n\t\treturn <Provider value={ false }>{ children }</Provider>;\n\t}\n\n\treturn (\n\t\t<Provider value={ true }>\n\t\t\t<StyledWrapper\n\t\t\t\tref={ ref }\n\t\t\t\tclassName={ classnames( className, 'components-disabled' ) }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</StyledWrapper>\n\t\t</Provider>\n\t);\n}\n\nDisabled.Context = Context;\nDisabled.Consumer = Consumer;\n\nexport default Disabled;\n"]}
|
package/build/heading/hook.js
CHANGED
|
@@ -32,7 +32,7 @@ function useHeading(props) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const textProps = (0, _text.useText)({
|
|
35
|
-
color: _utils.COLORS.
|
|
35
|
+
color: _utils.COLORS.gray[900],
|
|
36
36
|
size: (0, _fontSize.getHeadingFontSize)(level),
|
|
37
37
|
isBlock: true,
|
|
38
38
|
weight: _utils.CONFIG.fontWeightHeading,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/heading/hook.ts"],"names":["useHeading","props","as","asProp","level","otherProps","a11yProps","role","parseInt","textProps","color","COLORS","
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/heading/hook.ts"],"names":["useHeading","props","as","asProp","level","otherProps","a11yProps","role","parseInt","textProps","color","COLORS","gray","size","isBlock","weight","CONFIG","fontWeightHeading"],"mappings":";;;;;;;AAGA;;AAEA;;AACA;;AACA;;AAPA;AACA;AACA;AAgDO,SAASA,UAAT,CACNC,KADM,EAEL;AACD,QAAM;AAAEC,IAAAA,EAAE,EAAEC,MAAN;AAAcC,IAAAA,KAAK,GAAG,CAAtB;AAAyB,OAAGC;AAA5B,MAA2C,+BAChDJ,KADgD,EAEhD,SAFgD,CAAjD;AAKA,QAAMC,EAAE,GAAKC,MAAM,IAAK,IAAIC,KAAO,EAAnC;AAEA,QAAME,SAGL,GAAG,EAHJ;;AAIA,MAAK,OAAOJ,EAAP,KAAc,QAAd,IAA0BA,EAAE,CAAE,CAAF,CAAF,KAAY,GAA3C,EAAiD;AAChD;AACAI,IAAAA,SAAS,CAACC,IAAV,GAAiB,SAAjB;AACAD,IAAAA,SAAS,CAAE,YAAF,CAAT,GACC,OAAOF,KAAP,KAAiB,QAAjB,GAA4BI,QAAQ,CAAEJ,KAAF,CAApC,GAAgDA,KADjD;AAEA;;AAED,QAAMK,SAAS,GAAG,mBAAS;AAC1BC,IAAAA,KAAK,EAAEC,cAAOC,IAAP,CAAa,GAAb,CADmB;AAE1BC,IAAAA,IAAI,EAAE,kCAAoBT,KAApB,CAFoB;AAG1BU,IAAAA,OAAO,EAAE,IAHiB;AAI1BC,IAAAA,MAAM,EAAEC,cAAOC,iBAJW;AAK1B,OAAGZ;AALuB,GAAT,CAAlB;AAQA,SAAO,EAAE,GAAGI,SAAL;AAAgB,OAAGH,SAAnB;AAA8BJ,IAAAA;AAA9B,GAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { useContextSystem, WordPressComponentProps } from '../ui/context';\nimport type { Props as TextProps } from '../text/types';\nimport { useText } from '../text';\nimport { getHeadingFontSize } from '../ui/utils/font-size';\nimport { CONFIG, COLORS } from '../utils';\n\nexport type HeadingSize =\n\t| 1\n\t| 2\n\t| 3\n\t| 4\n\t| 5\n\t| 6\n\t| '1'\n\t| '2'\n\t| '3'\n\t| '4'\n\t| '5'\n\t| '6';\n\nexport interface HeadingProps extends Omit< TextProps, 'size' > {\n\t/**\n\t * `Heading` will typically render the sizes `1`, `2`, `3`, `4`, `5`, or `6`, which map to `h1`-`h6`.\n\t *\n\t * @default 2\n\t *\n\t * @example\n\t * ```jsx\n\t * import { __experimentalHeading as Heading } from `@wordpress/components`\n\t *\n\t * function Example() {\n\t * return (\n\t * <div>\n\t * <Heading level=\"1\">Code is Poetry</Heading>\n\t * <Heading level=\"2\">Code is Poetry</Heading>\n\t * <Heading level=\"3\">Code is Poetry</Heading>\n\t * <Heading level=\"4\">Code is Poetry</Heading>\n\t * <Heading level=\"5\">Code is Poetry</Heading>\n\t * <Heading level=\"6\">Code is Poetry</Heading>\n\t * </div>\n\t * );\n\t * }\n\t * ```\n\t */\n\tlevel: HeadingSize;\n}\n\nexport function useHeading(\n\tprops: WordPressComponentProps< HeadingProps, 'h1' >\n) {\n\tconst { as: asProp, level = 2, ...otherProps } = useContextSystem(\n\t\tprops,\n\t\t'Heading'\n\t);\n\n\tconst as = ( asProp || `h${ level }` ) as keyof JSX.IntrinsicElements;\n\n\tconst a11yProps: {\n\t\trole?: string;\n\t\t'aria-level'?: number;\n\t} = {};\n\tif ( typeof as === 'string' && as[ 0 ] !== 'h' ) {\n\t\t// If not a semantic `h` element, add a11y props:\n\t\ta11yProps.role = 'heading';\n\t\ta11yProps[ 'aria-level' ] =\n\t\t\ttypeof level === 'string' ? parseInt( level ) : level;\n\t}\n\n\tconst textProps = useText( {\n\t\tcolor: COLORS.gray[ 900 ],\n\t\tsize: getHeadingFontSize( level ),\n\t\tisBlock: true,\n\t\tweight: CONFIG.fontWeightHeading as import('react').CSSProperties[ 'fontWeight' ],\n\t\t...otherProps,\n\t} );\n\n\treturn { ...textProps, ...a11yProps, as };\n}\n"]}
|
|
@@ -5,7 +5,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.InputControl =
|
|
8
|
+
exports.InputControl = void 0;
|
|
9
|
+
exports.UnforwardedInputControl = UnforwardedInputControl;
|
|
9
10
|
exports.default = void 0;
|
|
10
11
|
|
|
11
12
|
var _element = require("@wordpress/element");
|
|
@@ -39,7 +40,7 @@ function useUniqueId(idProp) {
|
|
|
39
40
|
return idProp || id;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
function
|
|
43
|
+
function UnforwardedInputControl(_ref, ref) {
|
|
43
44
|
let {
|
|
44
45
|
__unstableStateReducer: stateReducer = state => state,
|
|
45
46
|
__unstableInputWidth,
|
|
@@ -92,8 +93,30 @@ function InputControl(_ref, ref) {
|
|
|
92
93
|
value: value
|
|
93
94
|
})));
|
|
94
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* InputControl components let users enter and edit text. This is an experimental component
|
|
98
|
+
* intended to (in time) merge with or replace `TextControl`.
|
|
99
|
+
*
|
|
100
|
+
* ```jsx
|
|
101
|
+
* import { __experimentalInputControl as InputControl } from '@wordpress/components';
|
|
102
|
+
* import { useState } from '@wordpress/compose';
|
|
103
|
+
*
|
|
104
|
+
* const Example = () => {
|
|
105
|
+
* const [ value, setValue ] = useState( '' );
|
|
106
|
+
*
|
|
107
|
+
* return (
|
|
108
|
+
* <InputControl
|
|
109
|
+
* value={ value }
|
|
110
|
+
* onChange={ ( nextValue ) => setValue( nextValue ?? '' ) }
|
|
111
|
+
* />
|
|
112
|
+
* );
|
|
113
|
+
* };
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
95
116
|
|
|
96
|
-
|
|
97
|
-
|
|
117
|
+
|
|
118
|
+
const InputControl = (0, _element.forwardRef)(UnforwardedInputControl);
|
|
119
|
+
exports.InputControl = InputControl;
|
|
120
|
+
var _default = InputControl;
|
|
98
121
|
exports.default = _default;
|
|
99
122
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/input-control/index.tsx"],"names":["useUniqueId","idProp","instanceId","InputControl","id","ref","__unstableStateReducer","stateReducer","state","__unstableInputWidth","className","disabled","hideLabelFromVision","isPressEnterToChange","label","labelPosition","onChange","noop","onValidate","onKeyDown","prefix","size","suffix","value","props","isFocused","setIsFocused","classes"
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/input-control/index.tsx"],"names":["useUniqueId","idProp","instanceId","InputControl","id","UnforwardedInputControl","ref","__unstableStateReducer","stateReducer","state","__unstableInputWidth","className","disabled","hideLabelFromVision","isPressEnterToChange","label","labelPosition","onChange","noop","onValidate","onKeyDown","prefix","size","suffix","value","props","isFocused","setIsFocused","classes"],"mappings":";;;;;;;;;;;AAWA;;;;AARA;;AACA;;AAMA;;AAMA;;AACA;;AAjBA;AACA;AACA;;AAKA;AACA;AACA;;AAIA;AACA;AACA;AAKA,SAASA,WAAT,CAAsBC,MAAtB,EAAwC;AACvC,QAAMC,UAAU,GAAG,4BAAeC,YAAf,CAAnB;AACA,QAAMC,EAAE,GAAI,2BAA2BF,UAAY,EAAnD;AAEA,SAAOD,MAAM,IAAIG,EAAjB;AACA;;AAEM,SAASC,uBAAT,OAoBNC,GApBM,EAqBL;AAAA,MApBD;AACCC,IAAAA,sBAAsB,EAAEC,YAAY,GAAKC,KAAF,IAAaA,KADrD;AAECC,IAAAA,oBAFD;AAGCC,IAAAA,SAHD;AAICC,IAAAA,QAAQ,GAAG,KAJZ;AAKCC,IAAAA,mBAAmB,GAAG,KALvB;AAMCT,IAAAA,EAAE,EAAEH,MANL;AAOCa,IAAAA,oBAAoB,GAAG,KAPxB;AAQCC,IAAAA,KARD;AASCC,IAAAA,aAAa,GAAG,KATjB;AAUCC,IAAAA,QAAQ,GAAGC,YAVZ;AAWCC,IAAAA,UAAU,GAAGD,YAXd;AAYCE,IAAAA,SAAS,GAAGF,YAZb;AAaCG,IAAAA,MAbD;AAcCC,IAAAA,IAAI,GAAG,SAdR;AAeCC,IAAAA,MAfD;AAgBCC,IAAAA,KAhBD;AAiBC,OAAGC;AAjBJ,GAoBC;AACD,QAAM,CAAEC,SAAF,EAAaC,YAAb,IAA8B,uBAAU,KAAV,CAApC;AAEA,QAAMvB,EAAE,GAAGJ,WAAW,CAAEC,MAAF,CAAtB;AACA,QAAM2B,OAAO,GAAG,yBAAY,0BAAZ,EAAwCjB,SAAxC,CAAhB;AAEA,SACC,4BAAC,kBAAD;AACC,IAAA,oBAAoB,EAAGD,oBADxB;AAEC,IAAA,SAAS,EAAGkB,OAFb;AAGC,IAAA,QAAQ,EAAGhB,QAHZ;AAIC,IAAA,GAAG,EAAG,CAJP;AAKC,IAAA,mBAAmB,EAAGC,mBALvB;AAMC,IAAA,EAAE,EAAGT,EANN;AAOC,IAAA,SAAS,EAAGsB,SAPb;AAQC,IAAA,OAAO,EAAC,MART;AASC,IAAA,KAAK,EAAGX,KATT;AAUC,IAAA,aAAa,EAAGC,aAVjB;AAWC,IAAA,MAAM,EAAGK,MAXV;AAYC,IAAA,IAAI,EAAGC,IAZR;AAaC,IAAA,MAAM,EAAGC;AAbV,KAeC,4BAAC,mBAAD,6BACME,KADN;AAEC,IAAA,SAAS,EAAC,iCAFX;AAGC,IAAA,QAAQ,EAAGb,QAHZ;AAIC,IAAA,EAAE,EAAGR,EAJN;AAKC,IAAA,SAAS,EAAGsB,SALb;AAMC,IAAA,oBAAoB,EAAGZ,oBANxB;AAOC,IAAA,QAAQ,EAAGG,QAPZ;AAQC,IAAA,SAAS,EAAGG,SARb;AASC,IAAA,UAAU,EAAGD,UATd;AAUC,IAAA,GAAG,EAAGb,GAVP;AAWC,IAAA,YAAY,EAAGqB,YAXhB;AAYC,IAAA,IAAI,EAAGL,IAZR;AAaC,IAAA,YAAY,EAAGd,YAbhB;AAcC,IAAA,KAAK,EAAGgB;AAdT,KAfD,CADD;AAkCA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMrB,YAAY,GAAG,yBAAYE,uBAAZ,CAArB;;eAEQF,Y","sourcesContent":["/**\n * External dependencies\n */\nimport { noop } from 'lodash';\nimport classNames from 'classnames';\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { useState, forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport InputBase from './input-base';\nimport InputField from './input-field';\nimport type { InputControlProps } from './types';\n\nfunction useUniqueId( idProp?: string ) {\n\tconst instanceId = useInstanceId( InputControl );\n\tconst id = `inspector-input-control-${ instanceId }`;\n\n\treturn idProp || id;\n}\n\nexport function UnforwardedInputControl(\n\t{\n\t\t__unstableStateReducer: stateReducer = ( state ) => state,\n\t\t__unstableInputWidth,\n\t\tclassName,\n\t\tdisabled = false,\n\t\thideLabelFromVision = false,\n\t\tid: idProp,\n\t\tisPressEnterToChange = false,\n\t\tlabel,\n\t\tlabelPosition = 'top',\n\t\tonChange = noop,\n\t\tonValidate = noop,\n\t\tonKeyDown = noop,\n\t\tprefix,\n\t\tsize = 'default',\n\t\tsuffix,\n\t\tvalue,\n\t\t...props\n\t}: InputControlProps,\n\tref: ForwardedRef< HTMLInputElement >\n) {\n\tconst [ isFocused, setIsFocused ] = useState( false );\n\n\tconst id = useUniqueId( idProp );\n\tconst classes = classNames( 'components-input-control', className );\n\n\treturn (\n\t\t<InputBase\n\t\t\t__unstableInputWidth={ __unstableInputWidth }\n\t\t\tclassName={ classes }\n\t\t\tdisabled={ disabled }\n\t\t\tgap={ 3 }\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\tid={ id }\n\t\t\tisFocused={ isFocused }\n\t\t\tjustify=\"left\"\n\t\t\tlabel={ label }\n\t\t\tlabelPosition={ labelPosition }\n\t\t\tprefix={ prefix }\n\t\t\tsize={ size }\n\t\t\tsuffix={ suffix }\n\t\t>\n\t\t\t<InputField\n\t\t\t\t{ ...props }\n\t\t\t\tclassName=\"components-input-control__input\"\n\t\t\t\tdisabled={ disabled }\n\t\t\t\tid={ id }\n\t\t\t\tisFocused={ isFocused }\n\t\t\t\tisPressEnterToChange={ isPressEnterToChange }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\tonValidate={ onValidate }\n\t\t\t\tref={ ref }\n\t\t\t\tsetIsFocused={ setIsFocused }\n\t\t\t\tsize={ size }\n\t\t\t\tstateReducer={ stateReducer }\n\t\t\t\tvalue={ value }\n\t\t\t/>\n\t\t</InputBase>\n\t);\n}\n\n/**\n * InputControl components let users enter and edit text. This is an experimental component\n * intended to (in time) merge with or replace `TextControl`.\n *\n * ```jsx\n * import { __experimentalInputControl as InputControl } from '@wordpress/components';\n * import { useState } from '@wordpress/compose';\n *\n * const Example = () => {\n * const [ value, setValue ] = useState( '' );\n *\n * return (\n * \t<InputControl\n * \t\tvalue={ value }\n * \t\tonChange={ ( nextValue ) => setValue( nextValue ?? '' ) }\n * \t/>\n * );\n * };\n * ```\n */\nexport const InputControl = forwardRef( UnforwardedInputControl );\n\nexport default InputControl;\n"]}
|