@wordpress/components 30.3.2-next.6870dfe5b.0 → 30.3.2-next.6f42e1382.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 +3 -1
- package/build/private-apis.js +1 -0
- package/build/private-apis.js.map +1 -1
- package/build/validated-form-controls/components/form-token-field.js +64 -0
- package/build/validated-form-controls/components/form-token-field.js.map +1 -0
- package/build/validated-form-controls/components/index.js +11 -0
- package/build/validated-form-controls/components/index.js.map +1 -1
- package/build-module/private-apis.js +2 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/validated-form-controls/components/form-token-field.js +57 -0
- package/build-module/validated-form-controls/components/form-token-field.js.map +1 -0
- package/build-module/validated-form-controls/components/index.js +1 -0
- package/build-module/validated-form-controls/components/index.js.map +1 -1
- package/build-style/style-rtl.css +4 -0
- package/build-style/style.css +4 -0
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/form-token-field.d.ts +4 -0
- package/build-types/validated-form-controls/components/form-token-field.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/index.d.ts +1 -0
- package/build-types/validated-form-controls/components/index.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/form-token-field.story.d.ts +15 -0
- package/build-types/validated-form-controls/components/stories/form-token-field.story.d.ts.map +1 -0
- package/package.json +19 -19
- package/src/private-apis.ts +2 -0
- package/src/validated-form-controls/components/form-token-field.tsx +84 -0
- package/src/validated-form-controls/components/index.ts +1 -0
- package/src/validated-form-controls/components/stories/form-token-field.story.tsx +83 -0
- package/src/validated-form-controls/style.scss +6 -0
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
-
## 30.3.1-next.0 (2025-09-
|
|
5
|
+
## 30.3.1-next.0 (2025-09-12)
|
|
6
6
|
|
|
7
7
|
### Bug Fixes
|
|
8
8
|
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
### Internal
|
|
12
12
|
|
|
13
13
|
- `ValidatedCheckboxControl`: Expose the component under private API's ([#71505](https://github.com/WordPress/gutenberg/pull/71505/)).
|
|
14
|
+
- Expose `ValidatedTextareaControl` via Private APIs ([#71495](https://github.com/WordPress/gutenberg/pull/71495))
|
|
15
|
+
- Add support for ValidatedFormTokenField [#71350](https://github.com/WordPress/gutenberg/pull/71350).
|
|
14
16
|
|
|
15
17
|
## 30.3.0 (2025-09-03)
|
|
16
18
|
|
package/build/private-apis.js
CHANGED
|
@@ -40,6 +40,7 @@ const privateApis = exports.privateApis = {};
|
|
|
40
40
|
ValidatedCheckboxControl: _validatedFormControls.ValidatedCheckboxControl,
|
|
41
41
|
ValidatedNumberControl: _validatedFormControls.ValidatedNumberControl,
|
|
42
42
|
ValidatedTextControl: _validatedFormControls.ValidatedTextControl,
|
|
43
|
+
ValidatedTextareaControl: _validatedFormControls.ValidatedTextareaControl,
|
|
43
44
|
ValidatedToggleControl: _validatedFormControls.ValidatedToggleControl
|
|
44
45
|
});
|
|
45
46
|
//# sourceMappingURL=private-apis.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_utils","require","_menu","_contextSystemProvider","_theme","_interopRequireDefault","_tabs","_strings","_withIgnoreImeEvents","_lockUnlock","_badge","_calendar","_validatedFormControls","_picker","privateApis","exports","lock","__experimentalPopoverLegacyPositionToPlacement","ComponentsContext","Tabs","Theme","Menu","kebabCase","withIgnoreIMEEvents","Badge","normalizeTextString","DateCalendar","DateRangeCalendar","TZDate","Picker","ValidatedInputControl","ValidatedCheckboxControl","ValidatedNumberControl","ValidatedTextControl","ValidatedToggleControl"],"sources":["@wordpress/components/src/private-apis.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { positionToPlacement as __experimentalPopoverLegacyPositionToPlacement } from './popover/utils';\nimport { Menu } from './menu';\nimport { ComponentsContext } from './context/context-system-provider';\nimport Theme from './theme';\nimport { Tabs } from './tabs';\nimport { kebabCase, normalizeTextString } from './utils/strings';\nimport { withIgnoreIMEEvents } from './utils/with-ignore-ime-events';\nimport { lock } from './lock-unlock';\nimport Badge from './badge';\n\nimport { DateCalendar, DateRangeCalendar, TZDate } from './calendar';\nimport {\n\tValidatedCheckboxControl,\n\tValidatedInputControl,\n\tValidatedNumberControl,\n\tValidatedTextControl,\n\tValidatedToggleControl,\n} from './validated-form-controls';\nimport { Picker } from './color-picker/picker';\n\nexport const privateApis = {};\nlock( privateApis, {\n\t__experimentalPopoverLegacyPositionToPlacement,\n\tComponentsContext,\n\tTabs,\n\tTheme,\n\tMenu,\n\tkebabCase,\n\twithIgnoreIMEEvents,\n\tBadge,\n\tnormalizeTextString,\n\tDateCalendar,\n\tDateRangeCalendar,\n\tTZDate,\n\tPicker,\n\tValidatedInputControl,\n\tValidatedCheckboxControl,\n\tValidatedNumberControl,\n\tValidatedTextControl,\n\tValidatedToggleControl,\n} );\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,oBAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAL,sBAAA,CAAAJ,OAAA;AAEA,IAAAU,SAAA,GAAAV,OAAA;AACA,IAAAW,sBAAA,GAAAX,OAAA;
|
|
1
|
+
{"version":3,"names":["_utils","require","_menu","_contextSystemProvider","_theme","_interopRequireDefault","_tabs","_strings","_withIgnoreImeEvents","_lockUnlock","_badge","_calendar","_validatedFormControls","_picker","privateApis","exports","lock","__experimentalPopoverLegacyPositionToPlacement","ComponentsContext","Tabs","Theme","Menu","kebabCase","withIgnoreIMEEvents","Badge","normalizeTextString","DateCalendar","DateRangeCalendar","TZDate","Picker","ValidatedInputControl","ValidatedCheckboxControl","ValidatedNumberControl","ValidatedTextControl","ValidatedTextareaControl","ValidatedToggleControl"],"sources":["@wordpress/components/src/private-apis.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { positionToPlacement as __experimentalPopoverLegacyPositionToPlacement } from './popover/utils';\nimport { Menu } from './menu';\nimport { ComponentsContext } from './context/context-system-provider';\nimport Theme from './theme';\nimport { Tabs } from './tabs';\nimport { kebabCase, normalizeTextString } from './utils/strings';\nimport { withIgnoreIMEEvents } from './utils/with-ignore-ime-events';\nimport { lock } from './lock-unlock';\nimport Badge from './badge';\n\nimport { DateCalendar, DateRangeCalendar, TZDate } from './calendar';\nimport {\n\tValidatedCheckboxControl,\n\tValidatedInputControl,\n\tValidatedNumberControl,\n\tValidatedTextControl,\n\tValidatedTextareaControl,\n\tValidatedToggleControl,\n} from './validated-form-controls';\nimport { Picker } from './color-picker/picker';\n\nexport const privateApis = {};\nlock( privateApis, {\n\t__experimentalPopoverLegacyPositionToPlacement,\n\tComponentsContext,\n\tTabs,\n\tTheme,\n\tMenu,\n\tkebabCase,\n\twithIgnoreIMEEvents,\n\tBadge,\n\tnormalizeTextString,\n\tDateCalendar,\n\tDateRangeCalendar,\n\tTZDate,\n\tPicker,\n\tValidatedInputControl,\n\tValidatedCheckboxControl,\n\tValidatedNumberControl,\n\tValidatedTextControl,\n\tValidatedTextareaControl,\n\tValidatedToggleControl,\n} );\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,oBAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAL,sBAAA,CAAAJ,OAAA;AAEA,IAAAU,SAAA,GAAAV,OAAA;AACA,IAAAW,sBAAA,GAAAX,OAAA;AAQA,IAAAY,OAAA,GAAAZ,OAAA;AAtBA;AACA;AACA;;AAsBO,MAAMa,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,CAAC,CAAC;AAC7B,IAAAE,gBAAI,EAAEF,WAAW,EAAE;EAClBG,8CAA8C,EAA9CA,0BAA8C;EAC9CC,iBAAiB,EAAjBA,wCAAiB;EACjBC,IAAI,EAAJA,UAAI;EACJC,KAAK,EAALA,cAAK;EACLC,IAAI,EAAJA,UAAI;EACJC,SAAS,EAATA,kBAAS;EACTC,mBAAmB,EAAnBA,wCAAmB;EACnBC,KAAK,EAALA,cAAK;EACLC,mBAAmB,EAAnBA,4BAAmB;EACnBC,YAAY,EAAZA,sBAAY;EACZC,iBAAiB,EAAjBA,2BAAiB;EACjBC,MAAM,EAANA,gBAAM;EACNC,MAAM,EAANA,cAAM;EACNC,qBAAqB,EAArBA,4CAAqB;EACrBC,wBAAwB,EAAxBA,+CAAwB;EACxBC,sBAAsB,EAAtBA,6CAAsB;EACtBC,oBAAoB,EAApBA,2CAAoB;EACpBC,wBAAwB,EAAxBA,+CAAwB;EACxBC,sBAAsB,EAAtBA;AACD,CAAE,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ValidatedFormTokenField = void 0;
|
|
7
|
+
var _element = require("@wordpress/element");
|
|
8
|
+
var _controlWithError = require("../control-with-error");
|
|
9
|
+
var _formTokenField = require("../../form-token-field");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
/**
|
|
12
|
+
* WordPress dependencies
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const UnforwardedValidatedFormTokenField = ({
|
|
20
|
+
required,
|
|
21
|
+
onValidate,
|
|
22
|
+
customValidity,
|
|
23
|
+
onChange,
|
|
24
|
+
markWhenOptional,
|
|
25
|
+
...restProps
|
|
26
|
+
}, forwardedRef) => {
|
|
27
|
+
const validityTargetRef = (0, _element.useRef)(null);
|
|
28
|
+
const valueRef = (0, _element.useRef)(restProps.value);
|
|
29
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
30
|
+
className: "components-validated-control__wrapper-with-error-delegate",
|
|
31
|
+
ref: forwardedRef,
|
|
32
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_controlWithError.ControlWithError, {
|
|
33
|
+
required: required,
|
|
34
|
+
markWhenOptional: markWhenOptional,
|
|
35
|
+
onValidate: () => {
|
|
36
|
+
return onValidate?.(valueRef.current);
|
|
37
|
+
},
|
|
38
|
+
customValidity: customValidity,
|
|
39
|
+
getValidityTarget: () => validityTargetRef.current,
|
|
40
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_formTokenField.FormTokenField, {
|
|
41
|
+
__next40pxDefaultSize: true,
|
|
42
|
+
__nextHasNoMarginBottom: true,
|
|
43
|
+
...restProps,
|
|
44
|
+
onChange: (value, ...args) => {
|
|
45
|
+
valueRef.current = value;
|
|
46
|
+
onChange?.(value, ...args);
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
50
|
+
className: "components-validated-control__error-delegate",
|
|
51
|
+
type: "text",
|
|
52
|
+
ref: validityTargetRef,
|
|
53
|
+
required: required,
|
|
54
|
+
value: valueRef.current && valueRef.current.length > 0 ? 'hasvalue' : '',
|
|
55
|
+
tabIndex: -1,
|
|
56
|
+
onChange: () => {},
|
|
57
|
+
onFocus: e => {
|
|
58
|
+
e.target.previousElementSibling?.querySelector('input[type="text"]')?.focus();
|
|
59
|
+
}
|
|
60
|
+
})]
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
const ValidatedFormTokenField = exports.ValidatedFormTokenField = (0, _element.forwardRef)(UnforwardedValidatedFormTokenField);
|
|
64
|
+
//# sourceMappingURL=form-token-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_element","require","_controlWithError","_formTokenField","_jsxRuntime","UnforwardedValidatedFormTokenField","required","onValidate","customValidity","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","useRef","valueRef","value","jsxs","className","ref","children","jsx","ControlWithError","current","getValidityTarget","FormTokenField","__next40pxDefaultSize","__nextHasNoMarginBottom","args","type","length","tabIndex","onFocus","e","target","previousElementSibling","querySelector","focus","ValidatedFormTokenField","exports","forwardRef"],"sources":["@wordpress/components/src/validated-form-controls/components/form-token-field.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport type { ValidatedControlProps } from './types';\nimport { FormTokenField } from '../../form-token-field';\nimport type { FormTokenFieldProps } from '../../form-token-field/types';\n\ntype Value = FormTokenFieldProps[ 'value' ];\n\nconst UnforwardedValidatedFormTokenField = (\n\t{\n\t\trequired,\n\t\tonValidate,\n\t\tcustomValidity,\n\t\tonChange,\n\t\tmarkWhenOptional,\n\t\t...restProps\n\t}: Omit<\n\t\tReact.ComponentProps< typeof FormTokenField >,\n\t\t'__next40pxDefaultSize' | '__nextHasNoMarginBottom'\n\t> &\n\t\tValidatedControlProps< FormTokenFieldProps[ 'value' ] >,\n\tforwardedRef: React.ForwardedRef< HTMLDivElement >\n) => {\n\tconst validityTargetRef = useRef< HTMLInputElement >( null );\n\tconst valueRef = useRef< Value >( restProps.value );\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"components-validated-control__wrapper-with-error-delegate\"\n\t\t\tref={ forwardedRef }\n\t\t>\n\t\t\t<ControlWithError\n\t\t\t\trequired={ required }\n\t\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\t\tonValidate={ () => {\n\t\t\t\t\treturn onValidate?.( valueRef.current );\n\t\t\t\t} }\n\t\t\t\tcustomValidity={ customValidity }\n\t\t\t\tgetValidityTarget={ () => validityTargetRef.current }\n\t\t\t>\n\t\t\t\t<FormTokenField\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t{ ...restProps }\n\t\t\t\t\tonChange={ ( value, ...args ) => {\n\t\t\t\t\t\tvalueRef.current = value;\n\t\t\t\t\t\tonChange?.( value, ...args );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</ControlWithError>\n\t\t\t<input\n\t\t\t\tclassName=\"components-validated-control__error-delegate\"\n\t\t\t\ttype=\"text\"\n\t\t\t\tref={ validityTargetRef }\n\t\t\t\trequired={ required }\n\t\t\t\tvalue={\n\t\t\t\t\tvalueRef.current && valueRef.current.length > 0\n\t\t\t\t\t\t? 'hasvalue'\n\t\t\t\t\t\t: ''\n\t\t\t\t}\n\t\t\t\ttabIndex={ -1 }\n\t\t\t\tonChange={ () => {} }\n\t\t\t\tonFocus={ ( e ) => {\n\t\t\t\t\te.target.previousElementSibling\n\t\t\t\t\t\t?.querySelector< HTMLInputElement >(\n\t\t\t\t\t\t\t'input[type=\"text\"]'\n\t\t\t\t\t\t)\n\t\t\t\t\t\t?.focus();\n\t\t\t\t} }\n\t\t\t/>\n\t\t</div>\n\t);\n};\n\nexport const ValidatedFormTokenField = forwardRef(\n\tUnforwardedValidatedFormTokenField\n);\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,eAAA,GAAAF,OAAA;AAAwD,IAAAG,WAAA,GAAAH,OAAA;AAVxD;AACA;AACA;;AAGA;AACA;AACA;;AAQA,MAAMI,kCAAkC,GAAGA,CA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GACV,EACH;MACDC,QAAQ,EAAG,CAAC,CAAG;MACftB,QAAQ,EAAGA,CAAA,KAAM,CAAC,CAAG;MACrBuB,OAAO,EAAKC,CAAC,IAAM;QAClBA,CAAC,CAACC,MAAM,CAACC,sBAAsB,EAC5BC,aAAa,CACd,oBACD,CAAC,EACCC,KAAK,CAAC,CAAC;MACX;IAAG,CACH,CAAC;EAAA,CACE,CAAC;AAER,CAAC;AAEM,MAAMC,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,IAAAE,mBAAU,EAChDnC,kCACD,CAAC","ignoreList":[]}
|
|
@@ -36,6 +36,17 @@ Object.keys(_customSelectControl).forEach(function (key) {
|
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
|
+
var _formTokenField = require("./form-token-field");
|
|
40
|
+
Object.keys(_formTokenField).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _formTokenField[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _formTokenField[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
39
50
|
var _inputControl = require("./input-control");
|
|
40
51
|
Object.keys(_inputControl).forEach(function (key) {
|
|
41
52
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_checkboxControl","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_comboboxControl","_customSelectControl","_inputControl","_numberControl","_radioControl","_rangeControl","_selectControl","_textControl","_textareaControl","_toggleControl","_toggleGroupControl"],"sources":["@wordpress/components/src/validated-form-controls/components/index.ts"],"sourcesContent":["export * from './checkbox-control';\nexport * from './combobox-control';\nexport * from './custom-select-control';\nexport * from './input-control';\nexport * from './number-control';\nexport * from './radio-control';\nexport * from './range-control';\nexport * from './select-control';\nexport * from './text-control';\nexport * from './textarea-control';\nexport * from './toggle-control';\nexport * from './toggle-group-control';\n"],"mappings":";;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,gBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,gBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,gBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,gBAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,gBAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,gBAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,gBAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,oBAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,oBAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,oBAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,oBAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,
|
|
1
|
+
{"version":3,"names":["_checkboxControl","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_comboboxControl","_customSelectControl","_formTokenField","_inputControl","_numberControl","_radioControl","_rangeControl","_selectControl","_textControl","_textareaControl","_toggleControl","_toggleGroupControl"],"sources":["@wordpress/components/src/validated-form-controls/components/index.ts"],"sourcesContent":["export * from './checkbox-control';\nexport * from './combobox-control';\nexport * from './custom-select-control';\nexport * from './form-token-field';\nexport * from './input-control';\nexport * from './number-control';\nexport * from './radio-control';\nexport * from './range-control';\nexport * from './select-control';\nexport * from './text-control';\nexport * from './textarea-control';\nexport * from './toggle-control';\nexport * from './toggle-group-control';\n"],"mappings":";;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,gBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,gBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,gBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,gBAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,gBAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,gBAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,gBAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,oBAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,oBAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAA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AhB,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAY,mBAAA,CAAAhB,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -11,7 +11,7 @@ import { withIgnoreIMEEvents } from './utils/with-ignore-ime-events';
|
|
|
11
11
|
import { lock } from './lock-unlock';
|
|
12
12
|
import Badge from './badge';
|
|
13
13
|
import { DateCalendar, DateRangeCalendar, TZDate } from './calendar';
|
|
14
|
-
import { ValidatedCheckboxControl, ValidatedInputControl, ValidatedNumberControl, ValidatedTextControl, ValidatedToggleControl } from './validated-form-controls';
|
|
14
|
+
import { ValidatedCheckboxControl, ValidatedInputControl, ValidatedNumberControl, ValidatedTextControl, ValidatedTextareaControl, ValidatedToggleControl } from './validated-form-controls';
|
|
15
15
|
import { Picker } from './color-picker/picker';
|
|
16
16
|
export const privateApis = {};
|
|
17
17
|
lock(privateApis, {
|
|
@@ -32,6 +32,7 @@ lock(privateApis, {
|
|
|
32
32
|
ValidatedCheckboxControl,
|
|
33
33
|
ValidatedNumberControl,
|
|
34
34
|
ValidatedTextControl,
|
|
35
|
+
ValidatedTextareaControl,
|
|
35
36
|
ValidatedToggleControl
|
|
36
37
|
});
|
|
37
38
|
//# sourceMappingURL=private-apis.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["positionToPlacement","__experimentalPopoverLegacyPositionToPlacement","Menu","ComponentsContext","Theme","Tabs","kebabCase","normalizeTextString","withIgnoreIMEEvents","lock","Badge","DateCalendar","DateRangeCalendar","TZDate","ValidatedCheckboxControl","ValidatedInputControl","ValidatedNumberControl","ValidatedTextControl","ValidatedToggleControl","Picker","privateApis"],"sources":["@wordpress/components/src/private-apis.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { positionToPlacement as __experimentalPopoverLegacyPositionToPlacement } from './popover/utils';\nimport { Menu } from './menu';\nimport { ComponentsContext } from './context/context-system-provider';\nimport Theme from './theme';\nimport { Tabs } from './tabs';\nimport { kebabCase, normalizeTextString } from './utils/strings';\nimport { withIgnoreIMEEvents } from './utils/with-ignore-ime-events';\nimport { lock } from './lock-unlock';\nimport Badge from './badge';\n\nimport { DateCalendar, DateRangeCalendar, TZDate } from './calendar';\nimport {\n\tValidatedCheckboxControl,\n\tValidatedInputControl,\n\tValidatedNumberControl,\n\tValidatedTextControl,\n\tValidatedToggleControl,\n} from './validated-form-controls';\nimport { Picker } from './color-picker/picker';\n\nexport const privateApis = {};\nlock( privateApis, {\n\t__experimentalPopoverLegacyPositionToPlacement,\n\tComponentsContext,\n\tTabs,\n\tTheme,\n\tMenu,\n\tkebabCase,\n\twithIgnoreIMEEvents,\n\tBadge,\n\tnormalizeTextString,\n\tDateCalendar,\n\tDateRangeCalendar,\n\tTZDate,\n\tPicker,\n\tValidatedInputControl,\n\tValidatedCheckboxControl,\n\tValidatedNumberControl,\n\tValidatedTextControl,\n\tValidatedToggleControl,\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,mBAAmB,IAAIC,8CAA8C,QAAQ,iBAAiB;AACvG,SAASC,IAAI,QAAQ,QAAQ;AAC7B,SAASC,iBAAiB,QAAQ,mCAAmC;AACrE,OAAOC,KAAK,MAAM,SAAS;AAC3B,SAASC,IAAI,QAAQ,QAAQ;AAC7B,SAASC,SAAS,EAAEC,mBAAmB,QAAQ,iBAAiB;AAChE,SAASC,mBAAmB,QAAQ,gCAAgC;AACpE,SAASC,IAAI,QAAQ,eAAe;AACpC,OAAOC,KAAK,MAAM,SAAS;AAE3B,SAASC,YAAY,EAAEC,iBAAiB,EAAEC,MAAM,QAAQ,YAAY;AACpE,SACCC,wBAAwB,EACxBC,qBAAqB,EACrBC,sBAAsB,EACtBC,oBAAoB,EACpBC,sBAAsB,QAChB,2BAA2B;AAClC,SAASC,MAAM,QAAQ,uBAAuB;AAE9C,OAAO,MAAMC,WAAW,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"names":["positionToPlacement","__experimentalPopoverLegacyPositionToPlacement","Menu","ComponentsContext","Theme","Tabs","kebabCase","normalizeTextString","withIgnoreIMEEvents","lock","Badge","DateCalendar","DateRangeCalendar","TZDate","ValidatedCheckboxControl","ValidatedInputControl","ValidatedNumberControl","ValidatedTextControl","ValidatedTextareaControl","ValidatedToggleControl","Picker","privateApis"],"sources":["@wordpress/components/src/private-apis.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { positionToPlacement as __experimentalPopoverLegacyPositionToPlacement } from './popover/utils';\nimport { Menu } from './menu';\nimport { ComponentsContext } from './context/context-system-provider';\nimport Theme from './theme';\nimport { Tabs } from './tabs';\nimport { kebabCase, normalizeTextString } from './utils/strings';\nimport { withIgnoreIMEEvents } from './utils/with-ignore-ime-events';\nimport { lock } from './lock-unlock';\nimport Badge from './badge';\n\nimport { DateCalendar, DateRangeCalendar, TZDate } from './calendar';\nimport {\n\tValidatedCheckboxControl,\n\tValidatedInputControl,\n\tValidatedNumberControl,\n\tValidatedTextControl,\n\tValidatedTextareaControl,\n\tValidatedToggleControl,\n} from './validated-form-controls';\nimport { Picker } from './color-picker/picker';\n\nexport const privateApis = {};\nlock( privateApis, {\n\t__experimentalPopoverLegacyPositionToPlacement,\n\tComponentsContext,\n\tTabs,\n\tTheme,\n\tMenu,\n\tkebabCase,\n\twithIgnoreIMEEvents,\n\tBadge,\n\tnormalizeTextString,\n\tDateCalendar,\n\tDateRangeCalendar,\n\tTZDate,\n\tPicker,\n\tValidatedInputControl,\n\tValidatedCheckboxControl,\n\tValidatedNumberControl,\n\tValidatedTextControl,\n\tValidatedTextareaControl,\n\tValidatedToggleControl,\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,mBAAmB,IAAIC,8CAA8C,QAAQ,iBAAiB;AACvG,SAASC,IAAI,QAAQ,QAAQ;AAC7B,SAASC,iBAAiB,QAAQ,mCAAmC;AACrE,OAAOC,KAAK,MAAM,SAAS;AAC3B,SAASC,IAAI,QAAQ,QAAQ;AAC7B,SAASC,SAAS,EAAEC,mBAAmB,QAAQ,iBAAiB;AAChE,SAASC,mBAAmB,QAAQ,gCAAgC;AACpE,SAASC,IAAI,QAAQ,eAAe;AACpC,OAAOC,KAAK,MAAM,SAAS;AAE3B,SAASC,YAAY,EAAEC,iBAAiB,EAAEC,MAAM,QAAQ,YAAY;AACpE,SACCC,wBAAwB,EACxBC,qBAAqB,EACrBC,sBAAsB,EACtBC,oBAAoB,EACpBC,wBAAwB,EACxBC,sBAAsB,QAChB,2BAA2B;AAClC,SAASC,MAAM,QAAQ,uBAAuB;AAE9C,OAAO,MAAMC,WAAW,GAAG,CAAC,CAAC;AAC7BZ,IAAI,CAAEY,WAAW,EAAE;EAClBpB,8CAA8C;EAC9CE,iBAAiB;EACjBE,IAAI;EACJD,KAAK;EACLF,IAAI;EACJI,SAAS;EACTE,mBAAmB;EACnBE,KAAK;EACLH,mBAAmB;EACnBI,YAAY;EACZC,iBAAiB;EACjBC,MAAM;EACNO,MAAM;EACNL,qBAAqB;EACrBD,wBAAwB;EACxBE,sBAAsB;EACtBC,oBAAoB;EACpBC,wBAAwB;EACxBC;AACD,CAAE,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { forwardRef, useRef } from '@wordpress/element';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { ControlWithError } from '../control-with-error';
|
|
10
|
+
import { FormTokenField } from '../../form-token-field';
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
const UnforwardedValidatedFormTokenField = ({
|
|
13
|
+
required,
|
|
14
|
+
onValidate,
|
|
15
|
+
customValidity,
|
|
16
|
+
onChange,
|
|
17
|
+
markWhenOptional,
|
|
18
|
+
...restProps
|
|
19
|
+
}, forwardedRef) => {
|
|
20
|
+
const validityTargetRef = useRef(null);
|
|
21
|
+
const valueRef = useRef(restProps.value);
|
|
22
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
23
|
+
className: "components-validated-control__wrapper-with-error-delegate",
|
|
24
|
+
ref: forwardedRef,
|
|
25
|
+
children: [/*#__PURE__*/_jsx(ControlWithError, {
|
|
26
|
+
required: required,
|
|
27
|
+
markWhenOptional: markWhenOptional,
|
|
28
|
+
onValidate: () => {
|
|
29
|
+
return onValidate?.(valueRef.current);
|
|
30
|
+
},
|
|
31
|
+
customValidity: customValidity,
|
|
32
|
+
getValidityTarget: () => validityTargetRef.current,
|
|
33
|
+
children: /*#__PURE__*/_jsx(FormTokenField, {
|
|
34
|
+
__next40pxDefaultSize: true,
|
|
35
|
+
__nextHasNoMarginBottom: true,
|
|
36
|
+
...restProps,
|
|
37
|
+
onChange: (value, ...args) => {
|
|
38
|
+
valueRef.current = value;
|
|
39
|
+
onChange?.(value, ...args);
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
}), /*#__PURE__*/_jsx("input", {
|
|
43
|
+
className: "components-validated-control__error-delegate",
|
|
44
|
+
type: "text",
|
|
45
|
+
ref: validityTargetRef,
|
|
46
|
+
required: required,
|
|
47
|
+
value: valueRef.current && valueRef.current.length > 0 ? 'hasvalue' : '',
|
|
48
|
+
tabIndex: -1,
|
|
49
|
+
onChange: () => {},
|
|
50
|
+
onFocus: e => {
|
|
51
|
+
e.target.previousElementSibling?.querySelector('input[type="text"]')?.focus();
|
|
52
|
+
}
|
|
53
|
+
})]
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
export const ValidatedFormTokenField = forwardRef(UnforwardedValidatedFormTokenField);
|
|
57
|
+
//# sourceMappingURL=form-token-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","useRef","ControlWithError","FormTokenField","jsx","_jsx","jsxs","_jsxs","UnforwardedValidatedFormTokenField","required","onValidate","customValidity","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","valueRef","value","className","ref","children","current","getValidityTarget","__next40pxDefaultSize","__nextHasNoMarginBottom","args","type","length","tabIndex","onFocus","e","target","previousElementSibling","querySelector","focus","ValidatedFormTokenField"],"sources":["@wordpress/components/src/validated-form-controls/components/form-token-field.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport type { ValidatedControlProps } from './types';\nimport { FormTokenField } from '../../form-token-field';\nimport type { FormTokenFieldProps } from '../../form-token-field/types';\n\ntype Value = FormTokenFieldProps[ 'value' ];\n\nconst UnforwardedValidatedFormTokenField = (\n\t{\n\t\trequired,\n\t\tonValidate,\n\t\tcustomValidity,\n\t\tonChange,\n\t\tmarkWhenOptional,\n\t\t...restProps\n\t}: Omit<\n\t\tReact.ComponentProps< typeof FormTokenField >,\n\t\t'__next40pxDefaultSize' | '__nextHasNoMarginBottom'\n\t> &\n\t\tValidatedControlProps< FormTokenFieldProps[ 'value' ] >,\n\tforwardedRef: React.ForwardedRef< HTMLDivElement >\n) => {\n\tconst validityTargetRef = useRef< HTMLInputElement >( null );\n\tconst valueRef = useRef< Value >( restProps.value );\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"components-validated-control__wrapper-with-error-delegate\"\n\t\t\tref={ forwardedRef }\n\t\t>\n\t\t\t<ControlWithError\n\t\t\t\trequired={ required }\n\t\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\t\tonValidate={ () => {\n\t\t\t\t\treturn onValidate?.( valueRef.current );\n\t\t\t\t} }\n\t\t\t\tcustomValidity={ customValidity }\n\t\t\t\tgetValidityTarget={ () => validityTargetRef.current }\n\t\t\t>\n\t\t\t\t<FormTokenField\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t{ ...restProps }\n\t\t\t\t\tonChange={ ( value, ...args ) => {\n\t\t\t\t\t\tvalueRef.current = value;\n\t\t\t\t\t\tonChange?.( value, ...args );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</ControlWithError>\n\t\t\t<input\n\t\t\t\tclassName=\"components-validated-control__error-delegate\"\n\t\t\t\ttype=\"text\"\n\t\t\t\tref={ validityTargetRef }\n\t\t\t\trequired={ required }\n\t\t\t\tvalue={\n\t\t\t\t\tvalueRef.current && valueRef.current.length > 0\n\t\t\t\t\t\t? 'hasvalue'\n\t\t\t\t\t\t: ''\n\t\t\t\t}\n\t\t\t\ttabIndex={ -1 }\n\t\t\t\tonChange={ () => {} }\n\t\t\t\tonFocus={ ( e ) => {\n\t\t\t\t\te.target.previousElementSibling\n\t\t\t\t\t\t?.querySelector< HTMLInputElement >(\n\t\t\t\t\t\t\t'input[type=\"text\"]'\n\t\t\t\t\t\t)\n\t\t\t\t\t\t?.focus();\n\t\t\t\t} }\n\t\t\t/>\n\t\t</div>\n\t);\n};\n\nexport const ValidatedFormTokenField = forwardRef(\n\tUnforwardedValidatedFormTokenField\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,MAAM,QAAQ,oBAAoB;;AAEvD;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,uBAAuB;AAExD,SAASC,cAAc,QAAQ,wBAAwB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAKxD,MAAMC,kCAAkC,GAAGA,CAC1C;EACCC,QAAQ;EACRC,UAAU;EACVC,cAAc;EACdC,QAAQ;EACRC,gBAAgB;EAChB,GAAGC;AAKmD,CAAC,EACxDC,YAAkD,KAC9C;EACJ,MAAMC,iBAAiB,GAAGf,MAAM,CAAsB,IAAK,CAAC;EAC5D,MAAMgB,QAAQ,GAAGhB,MAAM,CAAWa,SAAS,CAACI,KAAM,CAAC;EAEnD,oBACCX,KAAA;IACCY,SAAS,EAAC,2DAA2D;IACrEC,GAAG,EAAGL,YAAc;IAAAM,QAAA,gBAEpBhB,IAAA,CAACH,gBAAgB;MAChBO,QAAQ,EAAGA,QAAU;MACrBI,gBAAgB,EAAGA,gBAAkB;MACrCH,UAAU,EAAGA,CAAA,KAAM;QAClB,OAAOA,UAAU,GAAIO,QAAQ,CAACK,OAAQ,CAAC;MACxC,CAAG;MACHX,cAAc,EAAGA,cAAgB;MACjCY,iBAAiB,EAAGA,CAAA,KAAMP,iBAAiB,CAACM,OAAS;MAAAD,QAAA,eAErDhB,IAAA,CAACF,cAAc;QACdqB,qBAAqB;QACrBC,uBAAuB;QAAA,GAClBX,SAAS;QACdF,QAAQ,EAAGA,CAAEM,KAAK,EAAE,GAAGQ,IAAI,KAAM;UAChCT,QAAQ,CAACK,OAAO,GAAGJ,KAAK;UACxBN,QAAQ,GAAIM,KAAK,EAAE,GAAGQ,IAAK,CAAC;QAC7B;MAAG,CACH;IAAC,CACe,CAAC,eACnBrB,IAAA;MACCc,SAAS,EAAC,8CAA8C;MACxDQ,IAAI,EAAC,MAAM;MACXP,GAAG,EAAGJ,iBAAmB;MACzBP,QAAQ,EAAGA,QAAU;MACrBS,KAAK,EACJD,QAAQ,CAACK,OAAO,IAAIL,QAAQ,CAACK,OAAO,CAACM,MAAM,GAAG,CAAC,GAC5C,UAAU,GACV,EACH;MACDC,QAAQ,EAAG,CAAC,CAAG;MACfjB,QAAQ,EAAGA,CAAA,KAAM,CAAC,CAAG;MACrBkB,OAAO,EAAKC,CAAC,IAAM;QAClBA,CAAC,CAACC,MAAM,CAACC,sBAAsB,EAC5BC,aAAa,CACd,oBACD,CAAC,EACCC,KAAK,CAAC,CAAC;MACX;IAAG,CACH,CAAC;EAAA,CACE,CAAC;AAER,CAAC;AAED,OAAO,MAAMC,uBAAuB,GAAGpC,UAAU,CAChDQ,kCACD,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/components/src/validated-form-controls/components/index.ts"],"sourcesContent":["export * from './checkbox-control';\nexport * from './combobox-control';\nexport * from './custom-select-control';\nexport * from './input-control';\nexport * from './number-control';\nexport * from './radio-control';\nexport * from './range-control';\nexport * from './select-control';\nexport * from './text-control';\nexport * from './textarea-control';\nexport * from './toggle-control';\nexport * from './toggle-group-control';\n"],"mappings":"AAAA,cAAc,oBAAoB;AAClC,cAAc,oBAAoB;AAClC,cAAc,yBAAyB;AACvC,cAAc,iBAAiB;AAC/B,cAAc,kBAAkB;AAChC,cAAc,iBAAiB;AAC/B,cAAc,iBAAiB;AAC/B,cAAc,kBAAkB;AAChC,cAAc,gBAAgB;AAC9B,cAAc,oBAAoB;AAClC,cAAc,kBAAkB;AAChC,cAAc,wBAAwB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/components/src/validated-form-controls/components/index.ts"],"sourcesContent":["export * from './checkbox-control';\nexport * from './combobox-control';\nexport * from './custom-select-control';\nexport * from './form-token-field';\nexport * from './input-control';\nexport * from './number-control';\nexport * from './radio-control';\nexport * from './range-control';\nexport * from './select-control';\nexport * from './text-control';\nexport * from './textarea-control';\nexport * from './toggle-control';\nexport * from './toggle-group-control';\n"],"mappings":"AAAA,cAAc,oBAAoB;AAClC,cAAc,oBAAoB;AAClC,cAAc,yBAAyB;AACvC,cAAc,oBAAoB;AAClC,cAAc,iBAAiB;AAC/B,cAAc,kBAAkB;AAChC,cAAc,iBAAiB;AAC/B,cAAc,iBAAiB;AAC/B,cAAc,kBAAkB;AAChC,cAAc,gBAAgB;AAC9B,cAAc,oBAAoB;AAClC,cAAc,kBAAkB;AAChC,cAAc,wBAAwB","ignoreList":[]}
|
|
@@ -3847,6 +3847,10 @@ div.components-toolbar > div + div.has-left-divider::before {
|
|
|
3847
3847
|
.components-validated-control__wrapper-with-error-delegate:has(input[type=radio]:invalid) {
|
|
3848
3848
|
--wp-components-color-accent: #cc1818;
|
|
3849
3849
|
}
|
|
3850
|
+
.components-validated-control__wrapper-with-error-delegate:has(input:user-invalid) .components-form-token-field__input-container:not(:has([aria-expanded=true])) {
|
|
3851
|
+
--wp-components-color-accent: #cc1818;
|
|
3852
|
+
border-color: #cc1818;
|
|
3853
|
+
}
|
|
3850
3854
|
|
|
3851
3855
|
.components-validated-control__error-delegate {
|
|
3852
3856
|
position: absolute;
|
package/build-style/style.css
CHANGED
|
@@ -3860,6 +3860,10 @@ div.components-toolbar > div + div.has-left-divider::before {
|
|
|
3860
3860
|
.components-validated-control__wrapper-with-error-delegate:has(input[type=radio]:invalid) {
|
|
3861
3861
|
--wp-components-color-accent: #cc1818;
|
|
3862
3862
|
}
|
|
3863
|
+
.components-validated-control__wrapper-with-error-delegate:has(input:user-invalid) .components-form-token-field__input-container:not(:has([aria-expanded=true])) {
|
|
3864
|
+
--wp-components-color-accent: #cc1818;
|
|
3865
|
+
border-color: #cc1818;
|
|
3866
|
+
}
|
|
3863
3867
|
|
|
3864
3868
|
.components-validated-control__error-delegate {
|
|
3865
3869
|
position: absolute;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private-apis.d.ts","sourceRoot":"","sources":["../src/private-apis.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"private-apis.d.ts","sourceRoot":"","sources":["../src/private-apis.ts"],"names":[],"mappings":"AAwBA,eAAO,MAAM,WAAW,IAAK,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ValidatedControlProps } from './types';
|
|
2
|
+
import type { FormTokenFieldProps } from '../../form-token-field/types';
|
|
3
|
+
export declare const ValidatedFormTokenField: import("react").ForwardRefExoticComponent<Omit<FormTokenFieldProps, "__next40pxDefaultSize" | "__nextHasNoMarginBottom"> & ValidatedControlProps<(string | import("../../form-token-field/types").TokenItem)[] | undefined> & import("react").RefAttributes<HTMLDivElement>>;
|
|
4
|
+
//# sourceMappingURL=form-token-field.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-token-field.d.ts","sourceRoot":"","sources":["../../../src/validated-form-controls/components/form-token-field.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAsExE,eAAO,MAAM,uBAAuB,8QAEnC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/validated-form-controls/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/validated-form-controls/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
5
|
+
/**
|
|
6
|
+
* Internal dependencies
|
|
7
|
+
*/
|
|
8
|
+
import { ValidatedFormTokenField } from '../form-token-field';
|
|
9
|
+
declare const meta: Meta<typeof ValidatedFormTokenField>;
|
|
10
|
+
export default meta;
|
|
11
|
+
/**
|
|
12
|
+
* This demonstrates how array validation would work with the ValidatedFormTokenField component.
|
|
13
|
+
*/
|
|
14
|
+
export declare const Default: StoryObj<typeof ValidatedFormTokenField>;
|
|
15
|
+
//# sourceMappingURL=form-token-field.story.d.ts.map
|
package/build-types/validated-form-controls/components/stories/form-token-field.story.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-token-field.story.d.ts","sourceRoot":"","sources":["../../../../src/validated-form-controls/components/stories/form-token-field.story.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;GAEG;AACH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAI9D,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,uBAAuB,CAY/C,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAE,OAAO,uBAAuB,CAuC7D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/components",
|
|
3
|
-
"version": "30.3.2-next.
|
|
3
|
+
"version": "30.3.2-next.6f42e1382.0",
|
|
4
4
|
"description": "UI components for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -44,23 +44,23 @@
|
|
|
44
44
|
"@types/gradient-parser": "1.1.0",
|
|
45
45
|
"@types/highlight-words-core": "1.2.1",
|
|
46
46
|
"@use-gesture/react": "^10.3.1",
|
|
47
|
-
"@wordpress/a11y": "^4.30.1-next.
|
|
48
|
-
"@wordpress/compose": "^7.30.1-next.
|
|
49
|
-
"@wordpress/date": "^5.30.1-next.
|
|
50
|
-
"@wordpress/deprecated": "^4.30.1-next.
|
|
51
|
-
"@wordpress/dom": "^4.30.1-next.
|
|
52
|
-
"@wordpress/element": "^6.30.1-next.
|
|
53
|
-
"@wordpress/escape-html": "^3.30.1-next.
|
|
54
|
-
"@wordpress/hooks": "^4.30.1-next.
|
|
55
|
-
"@wordpress/html-entities": "^4.30.1-next.
|
|
56
|
-
"@wordpress/i18n": "^6.3.1-next.
|
|
57
|
-
"@wordpress/icons": "^10.30.1-next.
|
|
58
|
-
"@wordpress/is-shallow-equal": "^5.30.1-next.
|
|
59
|
-
"@wordpress/keycodes": "^4.30.1-next.
|
|
60
|
-
"@wordpress/primitives": "^4.30.1-next.
|
|
61
|
-
"@wordpress/private-apis": "^1.30.1-next.
|
|
62
|
-
"@wordpress/rich-text": "^7.30.1-next.
|
|
63
|
-
"@wordpress/warning": "^3.30.1-next.
|
|
47
|
+
"@wordpress/a11y": "^4.30.1-next.6f42e1382.0",
|
|
48
|
+
"@wordpress/compose": "^7.30.1-next.6f42e1382.0",
|
|
49
|
+
"@wordpress/date": "^5.30.1-next.6f42e1382.0",
|
|
50
|
+
"@wordpress/deprecated": "^4.30.1-next.6f42e1382.0",
|
|
51
|
+
"@wordpress/dom": "^4.30.1-next.6f42e1382.0",
|
|
52
|
+
"@wordpress/element": "^6.30.1-next.6f42e1382.0",
|
|
53
|
+
"@wordpress/escape-html": "^3.30.1-next.6f42e1382.0",
|
|
54
|
+
"@wordpress/hooks": "^4.30.1-next.6f42e1382.0",
|
|
55
|
+
"@wordpress/html-entities": "^4.30.1-next.6f42e1382.0",
|
|
56
|
+
"@wordpress/i18n": "^6.3.1-next.6f42e1382.0",
|
|
57
|
+
"@wordpress/icons": "^10.30.1-next.6f42e1382.0",
|
|
58
|
+
"@wordpress/is-shallow-equal": "^5.30.1-next.6f42e1382.0",
|
|
59
|
+
"@wordpress/keycodes": "^4.30.1-next.6f42e1382.0",
|
|
60
|
+
"@wordpress/primitives": "^4.30.1-next.6f42e1382.0",
|
|
61
|
+
"@wordpress/private-apis": "^1.30.1-next.6f42e1382.0",
|
|
62
|
+
"@wordpress/rich-text": "^7.30.1-next.6f42e1382.0",
|
|
63
|
+
"@wordpress/warning": "^3.30.1-next.6f42e1382.0",
|
|
64
64
|
"change-case": "^4.1.2",
|
|
65
65
|
"clsx": "^2.1.1",
|
|
66
66
|
"colord": "^2.7.0",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"publishConfig": {
|
|
87
87
|
"access": "public"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "8806899f598577a3c90a55d9aa79fbc372fe1e75"
|
|
90
90
|
}
|
package/src/private-apis.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
ValidatedInputControl,
|
|
18
18
|
ValidatedNumberControl,
|
|
19
19
|
ValidatedTextControl,
|
|
20
|
+
ValidatedTextareaControl,
|
|
20
21
|
ValidatedToggleControl,
|
|
21
22
|
} from './validated-form-controls';
|
|
22
23
|
import { Picker } from './color-picker/picker';
|
|
@@ -40,5 +41,6 @@ lock( privateApis, {
|
|
|
40
41
|
ValidatedCheckboxControl,
|
|
41
42
|
ValidatedNumberControl,
|
|
42
43
|
ValidatedTextControl,
|
|
44
|
+
ValidatedTextareaControl,
|
|
43
45
|
ValidatedToggleControl,
|
|
44
46
|
} );
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { forwardRef, useRef } from '@wordpress/element';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { ControlWithError } from '../control-with-error';
|
|
10
|
+
import type { ValidatedControlProps } from './types';
|
|
11
|
+
import { FormTokenField } from '../../form-token-field';
|
|
12
|
+
import type { FormTokenFieldProps } from '../../form-token-field/types';
|
|
13
|
+
|
|
14
|
+
type Value = FormTokenFieldProps[ 'value' ];
|
|
15
|
+
|
|
16
|
+
const UnforwardedValidatedFormTokenField = (
|
|
17
|
+
{
|
|
18
|
+
required,
|
|
19
|
+
onValidate,
|
|
20
|
+
customValidity,
|
|
21
|
+
onChange,
|
|
22
|
+
markWhenOptional,
|
|
23
|
+
...restProps
|
|
24
|
+
}: Omit<
|
|
25
|
+
React.ComponentProps< typeof FormTokenField >,
|
|
26
|
+
'__next40pxDefaultSize' | '__nextHasNoMarginBottom'
|
|
27
|
+
> &
|
|
28
|
+
ValidatedControlProps< FormTokenFieldProps[ 'value' ] >,
|
|
29
|
+
forwardedRef: React.ForwardedRef< HTMLDivElement >
|
|
30
|
+
) => {
|
|
31
|
+
const validityTargetRef = useRef< HTMLInputElement >( null );
|
|
32
|
+
const valueRef = useRef< Value >( restProps.value );
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div
|
|
36
|
+
className="components-validated-control__wrapper-with-error-delegate"
|
|
37
|
+
ref={ forwardedRef }
|
|
38
|
+
>
|
|
39
|
+
<ControlWithError
|
|
40
|
+
required={ required }
|
|
41
|
+
markWhenOptional={ markWhenOptional }
|
|
42
|
+
onValidate={ () => {
|
|
43
|
+
return onValidate?.( valueRef.current );
|
|
44
|
+
} }
|
|
45
|
+
customValidity={ customValidity }
|
|
46
|
+
getValidityTarget={ () => validityTargetRef.current }
|
|
47
|
+
>
|
|
48
|
+
<FormTokenField
|
|
49
|
+
__next40pxDefaultSize
|
|
50
|
+
__nextHasNoMarginBottom
|
|
51
|
+
{ ...restProps }
|
|
52
|
+
onChange={ ( value, ...args ) => {
|
|
53
|
+
valueRef.current = value;
|
|
54
|
+
onChange?.( value, ...args );
|
|
55
|
+
} }
|
|
56
|
+
/>
|
|
57
|
+
</ControlWithError>
|
|
58
|
+
<input
|
|
59
|
+
className="components-validated-control__error-delegate"
|
|
60
|
+
type="text"
|
|
61
|
+
ref={ validityTargetRef }
|
|
62
|
+
required={ required }
|
|
63
|
+
value={
|
|
64
|
+
valueRef.current && valueRef.current.length > 0
|
|
65
|
+
? 'hasvalue'
|
|
66
|
+
: ''
|
|
67
|
+
}
|
|
68
|
+
tabIndex={ -1 }
|
|
69
|
+
onChange={ () => {} }
|
|
70
|
+
onFocus={ ( e ) => {
|
|
71
|
+
e.target.previousElementSibling
|
|
72
|
+
?.querySelector< HTMLInputElement >(
|
|
73
|
+
'input[type="text"]'
|
|
74
|
+
)
|
|
75
|
+
?.focus();
|
|
76
|
+
} }
|
|
77
|
+
/>
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const ValidatedFormTokenField = forwardRef(
|
|
83
|
+
UnforwardedValidatedFormTokenField
|
|
84
|
+
);
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useState } from '@wordpress/element';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* External dependencies
|
|
8
|
+
*/
|
|
9
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import { ValidatedFormTokenField } from '../form-token-field';
|
|
15
|
+
import { formDecorator } from './story-utils';
|
|
16
|
+
import type { TokenItem } from '../../../form-token-field/types';
|
|
17
|
+
|
|
18
|
+
const meta: Meta< typeof ValidatedFormTokenField > = {
|
|
19
|
+
title: 'Components/Selection & Input/Validated Form Controls/ValidatedFormTokenField',
|
|
20
|
+
id: 'components-validatedformtokenfield',
|
|
21
|
+
component: ValidatedFormTokenField,
|
|
22
|
+
tags: [ 'status-private' ],
|
|
23
|
+
decorators: formDecorator,
|
|
24
|
+
args: { onChange: () => {} },
|
|
25
|
+
argTypes: {
|
|
26
|
+
onChange: { control: false },
|
|
27
|
+
value: { control: false },
|
|
28
|
+
customValidity: { control: false },
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
export default meta;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* This demonstrates how array validation would work with the ValidatedFormTokenField component.
|
|
35
|
+
*/
|
|
36
|
+
export const Default: StoryObj< typeof ValidatedFormTokenField > = {
|
|
37
|
+
render: function Template( { onChange, ...args } ) {
|
|
38
|
+
const [ value, setValue ] = useState< ( string | TokenItem )[] >( [] );
|
|
39
|
+
const [ customValidity, setCustomValidity ] =
|
|
40
|
+
useState<
|
|
41
|
+
React.ComponentProps<
|
|
42
|
+
typeof ValidatedFormTokenField
|
|
43
|
+
>[ 'customValidity' ]
|
|
44
|
+
>( undefined );
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<ValidatedFormTokenField
|
|
48
|
+
{ ...args }
|
|
49
|
+
value={ value }
|
|
50
|
+
onChange={ ( newValue, ...rest ) => {
|
|
51
|
+
setValue( newValue );
|
|
52
|
+
onChange?.( newValue, ...rest );
|
|
53
|
+
} }
|
|
54
|
+
onValidate={ ( v ) => {
|
|
55
|
+
if (
|
|
56
|
+
v?.some( ( token ) => {
|
|
57
|
+
const tokenValue =
|
|
58
|
+
typeof token === 'string' ? token : token.value;
|
|
59
|
+
return tokenValue.toLowerCase() === 'error';
|
|
60
|
+
} )
|
|
61
|
+
) {
|
|
62
|
+
setCustomValidity( {
|
|
63
|
+
type: 'invalid',
|
|
64
|
+
message: 'The tag "error" is not allowed.',
|
|
65
|
+
} );
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
setCustomValidity( undefined );
|
|
70
|
+
} }
|
|
71
|
+
customValidity={ customValidity }
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
Default.args = {
|
|
78
|
+
required: true,
|
|
79
|
+
label: 'Tags',
|
|
80
|
+
placeholder: 'Add tags...',
|
|
81
|
+
suggestions: [ 'Posts', 'Pages', 'Media', 'Error' ],
|
|
82
|
+
__experimentalExpandOnFocus: true,
|
|
83
|
+
};
|
|
@@ -34,6 +34,12 @@
|
|
|
34
34
|
&:has(input[type="radio"]:invalid) {
|
|
35
35
|
--wp-components-color-accent: #{$alert-red};
|
|
36
36
|
}
|
|
37
|
+
|
|
38
|
+
// For FormTokenField
|
|
39
|
+
&:has(input:user-invalid) .components-form-token-field__input-container:not(:has([aria-expanded="true"])) {
|
|
40
|
+
--wp-components-color-accent: #{$alert-red};
|
|
41
|
+
border-color: $alert-red;
|
|
42
|
+
}
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
.components-validated-control__error-delegate {
|