@salutejs/plasma-new-hope 0.72.0-dev.0 → 0.73.0-dev.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/TextField/TextField.js +166 -40
- package/cjs/components/TextField/TextField.js.map +1 -1
- package/cjs/components/TextField/TextField.styles.js +27 -11
- package/cjs/components/TextField/TextField.styles.js.map +1 -1
- package/cjs/components/TextField/TextField.styles_1b1mddp.css +8 -0
- package/cjs/components/TextField/TextField.tokens.js +68 -20
- package/cjs/components/TextField/TextField.tokens.js.map +1 -1
- package/cjs/components/TextField/TextField_wctd2m.css +1 -0
- package/cjs/components/TextField/hooks/useKeyNavigation.js +132 -0
- package/cjs/components/TextField/hooks/useKeyNavigation.js.map +1 -0
- package/cjs/components/TextField/ui/TextFieldChip/TextFieldChip.css +19 -0
- package/cjs/components/TextField/ui/TextFieldChip/TextFieldChip.js +38 -0
- package/cjs/components/TextField/ui/TextFieldChip/TextFieldChip.js.map +1 -0
- package/cjs/components/TextField/ui/TextFieldChip/TextFieldChip.styles.js +26 -0
- package/cjs/components/TextField/ui/TextFieldChip/TextFieldChip.styles.js.map +1 -0
- package/cjs/components/TextField/ui/TextFieldChip/TextFieldChip.styles_1y8n7la.css +1 -0
- package/cjs/components/TextField/{_disabled → variations/_disabled}/base.js +2 -2
- package/cjs/components/TextField/variations/_disabled/base.js.map +1 -0
- package/cjs/components/TextField/variations/_disabled/base_1tnjoy9.css +1 -0
- package/cjs/components/TextField/{_label-placement → variations/_label-placement}/base.js +1 -1
- package/cjs/components/TextField/variations/_label-placement/base.js.map +1 -0
- package/cjs/components/TextField/{_label-placement → variations/_label-placement}/inner.js +2 -2
- package/cjs/components/TextField/variations/_label-placement/inner.js.map +1 -0
- package/cjs/components/TextField/variations/_label-placement/inner_gqlcj2.css +1 -0
- package/cjs/components/TextField/{_label-placement → variations/_label-placement}/outer.js +2 -2
- package/cjs/components/TextField/variations/_label-placement/outer.js.map +1 -0
- package/cjs/components/TextField/variations/_label-placement/outer_is41nj.css +1 -0
- package/cjs/components/TextField/{_view → variations/_read-only}/base.js +2 -2
- package/cjs/components/TextField/variations/_read-only/base.js.map +1 -0
- package/cjs/components/TextField/variations/_read-only/base_134hshp.css +1 -0
- package/cjs/components/TextField/variations/_size/base.js +9 -0
- package/cjs/components/TextField/variations/_size/base.js.map +1 -0
- package/cjs/components/TextField/variations/_size/base_1khzr9t.css +1 -0
- package/cjs/components/TextField/{_size → variations/_view}/base.js +2 -2
- package/cjs/components/TextField/variations/_view/base.js.map +1 -0
- package/cjs/components/TextField/variations/_view/base_1qd77x6.css +1 -0
- package/cjs/index.css +16 -9
- package/cjs/index.js +2 -2
- package/es/components/TextField/TextField.js +169 -44
- package/es/components/TextField/TextField.js.map +1 -1
- package/es/components/TextField/TextField.styles.js +25 -12
- package/es/components/TextField/TextField.styles.js.map +1 -1
- package/es/components/TextField/TextField.styles_1b1mddp.css +8 -0
- package/es/components/TextField/TextField.tokens.js +68 -21
- package/es/components/TextField/TextField.tokens.js.map +1 -1
- package/es/components/TextField/TextField_wctd2m.css +1 -0
- package/es/components/TextField/hooks/useKeyNavigation.js +127 -0
- package/es/components/TextField/hooks/useKeyNavigation.js.map +1 -0
- package/es/components/TextField/ui/TextFieldChip/TextFieldChip.css +19 -0
- package/es/components/TextField/ui/TextFieldChip/TextFieldChip.js +34 -0
- package/es/components/TextField/ui/TextFieldChip/TextFieldChip.js.map +1 -0
- package/es/components/TextField/ui/TextFieldChip/TextFieldChip.styles.js +22 -0
- package/es/components/TextField/ui/TextFieldChip/TextFieldChip.styles.js.map +1 -0
- package/es/components/TextField/ui/TextFieldChip/TextFieldChip.styles_1y8n7la.css +1 -0
- package/es/components/TextField/variations/_disabled/base.js +5 -0
- package/es/components/TextField/variations/_disabled/base.js.map +1 -0
- package/es/components/TextField/variations/_disabled/base_1tnjoy9.css +1 -0
- package/es/components/TextField/{_label-placement → variations/_label-placement}/base.js +1 -1
- package/es/components/TextField/variations/_label-placement/base.js.map +1 -0
- package/es/components/TextField/variations/_label-placement/inner.js +5 -0
- package/es/components/TextField/variations/_label-placement/inner.js.map +1 -0
- package/es/components/TextField/variations/_label-placement/inner_gqlcj2.css +1 -0
- package/es/components/TextField/variations/_label-placement/outer.js +5 -0
- package/es/components/TextField/variations/_label-placement/outer.js.map +1 -0
- package/es/components/TextField/variations/_label-placement/outer_is41nj.css +1 -0
- package/es/components/TextField/variations/_read-only/base.js +5 -0
- package/es/components/TextField/variations/_read-only/base.js.map +1 -0
- package/es/components/TextField/variations/_read-only/base_134hshp.css +1 -0
- package/es/components/TextField/variations/_size/base.js +5 -0
- package/es/components/TextField/variations/_size/base.js.map +1 -0
- package/es/components/TextField/variations/_size/base_1khzr9t.css +1 -0
- package/es/components/TextField/{_disabled → variations/_view}/base.js +2 -2
- package/es/components/TextField/variations/_view/base.js.map +1 -0
- package/es/components/TextField/variations/_view/base_1qd77x6.css +1 -0
- package/es/index.css +16 -9
- package/es/index.js +2 -2
- package/package.json +2 -2
- package/styled-components/cjs/components/TextField/TextField.js +173 -43
- package/styled-components/cjs/components/TextField/TextField.styles.js +18 -10
- package/styled-components/cjs/components/TextField/TextField.template-doc.mdx +24 -0
- package/styled-components/cjs/components/TextField/TextField.tokens.js +68 -21
- package/styled-components/cjs/components/TextField/hooks/index.js +12 -0
- package/styled-components/cjs/components/TextField/hooks/useKeyNavigation.js +138 -0
- package/styled-components/cjs/components/TextField/index.js +2 -2
- package/styled-components/cjs/components/TextField/ui/TextFieldChip/TextFieldChip.js +39 -0
- package/styled-components/cjs/components/TextField/ui/TextFieldChip/TextFieldChip.styles.js +25 -0
- package/styled-components/cjs/components/TextField/ui/TextFieldChip/TextFieldChip.types.js +5 -0
- package/styled-components/cjs/components/TextField/ui/index.js +12 -0
- package/styled-components/cjs/components/TextField/variations/_disabled/base.js +10 -0
- package/styled-components/cjs/components/TextField/variations/_label-placement/inner.js +10 -0
- package/styled-components/cjs/components/TextField/{_label-placement → variations/_label-placement}/outer.js +3 -3
- package/styled-components/cjs/components/TextField/variations/_read-only/base.js +10 -0
- package/styled-components/cjs/components/TextField/variations/_read-only/tokens.json +1 -0
- package/styled-components/cjs/components/TextField/variations/_size/base.js +10 -0
- package/styled-components/cjs/components/TextField/variations/_view/base.js +10 -0
- package/styled-components/cjs/examples/plasma_b2c/components/TextField/TextField.config.js +43 -0
- package/styled-components/cjs/examples/plasma_b2c/components/TextField/TextField.js +11 -0
- package/styled-components/cjs/examples/plasma_b2c/components/TextField/TextField.stories.tsx +181 -0
- package/styled-components/cjs/examples/plasma_web/components/TextField/TextField.config.js +40 -0
- package/styled-components/cjs/examples/plasma_web/components/TextField/TextField.js +11 -0
- package/styled-components/cjs/examples/plasma_web/components/TextField/TextField.stories.tsx +181 -0
- package/styled-components/cjs/examples/sds_engineer/components/TextField/TextField.config.js +43 -0
- package/styled-components/cjs/examples/sds_engineer/components/TextField/TextField.js +11 -0
- package/styled-components/cjs/examples/sds_engineer/components/TextField/TextField.stories.tsx +181 -0
- package/styled-components/es/components/TextField/TextField.js +177 -47
- package/styled-components/es/components/TextField/TextField.styles.js +17 -9
- package/styled-components/es/components/TextField/TextField.template-doc.mdx +24 -0
- package/styled-components/es/components/TextField/TextField.tokens.js +67 -20
- package/styled-components/es/components/TextField/hooks/index.js +1 -0
- package/styled-components/es/components/TextField/hooks/useKeyNavigation.js +132 -0
- package/styled-components/es/components/TextField/index.js +2 -2
- package/styled-components/es/components/TextField/ui/TextFieldChip/TextFieldChip.js +30 -0
- package/styled-components/es/components/TextField/ui/TextFieldChip/TextFieldChip.styles.js +19 -0
- package/styled-components/es/components/TextField/ui/TextFieldChip/TextFieldChip.types.js +1 -0
- package/styled-components/es/components/TextField/ui/index.js +1 -0
- package/styled-components/es/components/TextField/variations/_disabled/base.js +4 -0
- package/styled-components/es/components/TextField/variations/_label-placement/inner.js +4 -0
- package/styled-components/es/components/TextField/variations/_label-placement/outer.js +4 -0
- package/styled-components/es/components/TextField/variations/_read-only/base.js +4 -0
- package/styled-components/es/components/TextField/variations/_read-only/tokens.json +1 -0
- package/styled-components/es/components/TextField/variations/_size/base.js +4 -0
- package/styled-components/es/components/TextField/variations/_view/base.js +4 -0
- package/styled-components/es/examples/plasma_b2c/components/TextField/TextField.config.js +37 -0
- package/styled-components/es/examples/plasma_b2c/components/TextField/TextField.js +5 -0
- package/styled-components/es/examples/plasma_b2c/components/TextField/TextField.stories.tsx +181 -0
- package/styled-components/es/examples/plasma_web/components/TextField/TextField.config.js +34 -0
- package/styled-components/es/examples/plasma_web/components/TextField/TextField.js +5 -0
- package/styled-components/es/examples/plasma_web/components/TextField/TextField.stories.tsx +181 -0
- package/styled-components/es/examples/sds_engineer/components/TextField/TextField.config.js +37 -0
- package/styled-components/es/examples/sds_engineer/components/TextField/TextField.js +5 -0
- package/styled-components/es/examples/sds_engineer/components/TextField/TextField.stories.tsx +181 -0
- package/types/components/TextField/TextField.d.ts +8 -3
- package/types/components/TextField/TextField.d.ts.map +1 -1
- package/types/components/TextField/TextField.styles.d.ts +6 -3
- package/types/components/TextField/TextField.styles.d.ts.map +1 -1
- package/types/components/TextField/TextField.tokens.d.ts +57 -8
- package/types/components/TextField/TextField.tokens.d.ts.map +1 -1
- package/types/components/TextField/TextField.types.d.ts +71 -6
- package/types/components/TextField/TextField.types.d.ts.map +1 -1
- package/types/components/TextField/hooks/index.d.ts +2 -0
- package/types/components/TextField/hooks/index.d.ts.map +1 -0
- package/types/components/TextField/hooks/useKeyNavigation.d.ts +17 -0
- package/types/components/TextField/hooks/useKeyNavigation.d.ts.map +1 -0
- package/types/components/TextField/index.d.ts +3 -2
- package/types/components/TextField/index.d.ts.map +1 -1
- package/types/components/TextField/ui/TextFieldChip/TextFieldChip.d.ts +7 -0
- package/types/components/TextField/ui/TextFieldChip/TextFieldChip.d.ts.map +1 -0
- package/types/components/TextField/ui/TextFieldChip/TextFieldChip.styles.d.ts +3 -0
- package/types/components/TextField/ui/TextFieldChip/TextFieldChip.styles.d.ts.map +1 -0
- package/types/components/TextField/ui/TextFieldChip/TextFieldChip.types.d.ts +37 -0
- package/types/components/TextField/ui/TextFieldChip/TextFieldChip.types.d.ts.map +1 -0
- package/types/components/TextField/ui/index.d.ts +2 -0
- package/types/components/TextField/ui/index.d.ts.map +1 -0
- package/types/components/TextField/variations/_disabled/base.d.ts.map +1 -0
- package/types/components/TextField/variations/_label-placement/base.d.ts.map +1 -0
- package/types/components/TextField/variations/_label-placement/index.d.ts.map +1 -0
- package/types/components/TextField/variations/_label-placement/inner.d.ts.map +1 -0
- package/types/components/TextField/variations/_label-placement/outer.d.ts.map +1 -0
- package/types/components/TextField/variations/_read-only/base.d.ts.map +1 -0
- package/types/components/TextField/variations/_size/base.d.ts.map +1 -0
- package/types/components/TextField/variations/_view/base.d.ts +2 -0
- package/types/components/TextField/variations/_view/base.d.ts.map +1 -0
- package/types/examples/plasma_b2c/components/TextField/TextField.config.d.ts +32 -0
- package/types/examples/plasma_b2c/components/TextField/TextField.config.d.ts.map +1 -0
- package/types/examples/plasma_b2c/components/TextField/TextField.d.ts +60 -0
- package/types/examples/plasma_b2c/components/TextField/TextField.d.ts.map +1 -0
- package/types/examples/plasma_web/components/TextField/TextField.config.d.ts +32 -0
- package/types/examples/plasma_web/components/TextField/TextField.config.d.ts.map +1 -0
- package/types/examples/plasma_web/components/TextField/TextField.d.ts +60 -0
- package/types/examples/plasma_web/components/TextField/TextField.d.ts.map +1 -0
- package/types/examples/sds_engineer/components/TextField/TextField.config.d.ts +32 -0
- package/types/examples/sds_engineer/components/TextField/TextField.config.d.ts.map +1 -0
- package/types/examples/sds_engineer/components/TextField/TextField.d.ts +60 -0
- package/types/examples/sds_engineer/components/TextField/TextField.d.ts.map +1 -0
- package/cjs/components/TextField/TextField.styles_2qw1n8.css +0 -5
- package/cjs/components/TextField/TextField_1lzb2r1.css +0 -1
- package/cjs/components/TextField/_disabled/base.js.map +0 -1
- package/cjs/components/TextField/_disabled/base_so3w81.css +0 -1
- package/cjs/components/TextField/_label-placement/base.js.map +0 -1
- package/cjs/components/TextField/_label-placement/inner.js.map +0 -1
- package/cjs/components/TextField/_label-placement/inner_1tyuicp.css +0 -1
- package/cjs/components/TextField/_label-placement/outer.js.map +0 -1
- package/cjs/components/TextField/_label-placement/outer_19ekaek.css +0 -1
- package/cjs/components/TextField/_size/base.js.map +0 -1
- package/cjs/components/TextField/_size/base_b5smyu.css +0 -1
- package/cjs/components/TextField/_view/base.js.map +0 -1
- package/cjs/components/TextField/_view/base_5bqzed.css +0 -1
- package/es/components/TextField/TextField.styles_2qw1n8.css +0 -5
- package/es/components/TextField/TextField_1lzb2r1.css +0 -1
- package/es/components/TextField/_disabled/base.js.map +0 -1
- package/es/components/TextField/_disabled/base_so3w81.css +0 -1
- package/es/components/TextField/_label-placement/base.js.map +0 -1
- package/es/components/TextField/_label-placement/inner.js +0 -5
- package/es/components/TextField/_label-placement/inner.js.map +0 -1
- package/es/components/TextField/_label-placement/inner_1tyuicp.css +0 -1
- package/es/components/TextField/_label-placement/outer.js +0 -5
- package/es/components/TextField/_label-placement/outer.js.map +0 -1
- package/es/components/TextField/_label-placement/outer_19ekaek.css +0 -1
- package/es/components/TextField/_size/base.js +0 -5
- package/es/components/TextField/_size/base.js.map +0 -1
- package/es/components/TextField/_size/base_b5smyu.css +0 -1
- package/es/components/TextField/_view/base.js +0 -5
- package/es/components/TextField/_view/base.js.map +0 -1
- package/es/components/TextField/_view/base_5bqzed.css +0 -1
- package/styled-components/cjs/components/TextField/_disabled/base.js +0 -9
- package/styled-components/cjs/components/TextField/_label-placement/inner.js +0 -10
- package/styled-components/cjs/components/TextField/_size/base.js +0 -10
- package/styled-components/cjs/components/TextField/_view/base.js +0 -10
- package/styled-components/es/components/TextField/_disabled/base.js +0 -3
- package/styled-components/es/components/TextField/_label-placement/inner.js +0 -4
- package/styled-components/es/components/TextField/_label-placement/outer.js +0 -4
- package/styled-components/es/components/TextField/_size/base.js +0 -4
- package/styled-components/es/components/TextField/_view/base.js +0 -4
- package/types/components/TextField/_disabled/base.d.ts.map +0 -1
- package/types/components/TextField/_label-placement/base.d.ts.map +0 -1
- package/types/components/TextField/_label-placement/index.d.ts.map +0 -1
- package/types/components/TextField/_label-placement/inner.d.ts.map +0 -1
- package/types/components/TextField/_label-placement/outer.d.ts.map +0 -1
- package/types/components/TextField/_size/base.d.ts.map +0 -1
- package/types/components/TextField/_view/base.d.ts.map +0 -1
- /package/cjs/components/TextField/{_label-placement → variations/_label-placement}/base_x642ct.css +0 -0
- /package/es/components/TextField/{_label-placement → variations/_label-placement}/base_x642ct.css +0 -0
- /package/styled-components/cjs/components/TextField/{_disabled → variations/_disabled}/tokens.json +0 -0
- /package/styled-components/cjs/components/TextField/{_label-placement → variations/_label-placement}/base.js +0 -0
- /package/styled-components/cjs/components/TextField/{_label-placement → variations/_label-placement}/index.js +0 -0
- /package/styled-components/cjs/components/TextField/{_size → variations/_size}/tokens.json +0 -0
- /package/styled-components/cjs/components/TextField/{_view → variations/_view}/tokens.json +0 -0
- /package/styled-components/es/components/TextField/{_disabled → variations/_disabled}/tokens.json +0 -0
- /package/styled-components/es/components/TextField/{_label-placement → variations/_label-placement}/base.js +0 -0
- /package/styled-components/es/components/TextField/{_label-placement → variations/_label-placement}/index.js +0 -0
- /package/styled-components/es/components/TextField/{_size → variations/_size}/tokens.json +0 -0
- /package/styled-components/es/components/TextField/{_view → variations/_view}/tokens.json +0 -0
- /package/types/components/TextField/{_disabled → variations/_disabled}/base.d.ts +0 -0
- /package/types/components/TextField/{_label-placement → variations/_label-placement}/base.d.ts +0 -0
- /package/types/components/TextField/{_label-placement → variations/_label-placement}/index.d.ts +0 -0
- /package/types/components/TextField/{_label-placement → variations/_label-placement}/inner.d.ts +0 -0
- /package/types/components/TextField/{_label-placement → variations/_label-placement}/outer.d.ts +0 -0
- /package/types/components/TextField/{_size → variations/_read-only}/base.d.ts +0 -0
- /package/types/components/TextField/{_view → variations/_size}/base.d.ts +0 -0
@@ -4,79 +4,204 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
5
5
|
value: true
|
6
6
|
});
|
7
|
-
exports.textFieldRoot = exports.textFieldConfig = void 0;
|
7
|
+
exports.textFieldRoot = exports.textFieldConfig = exports.base = void 0;
|
8
8
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
9
|
-
var _styledComponents = /*#__PURE__*/require("styled-components");
|
10
9
|
var _plasmaCore = /*#__PURE__*/require("@salutejs/plasma-core");
|
11
|
-
var
|
12
|
-
var
|
13
|
-
var
|
14
|
-
var
|
10
|
+
var _styledComponents = /*#__PURE__*/require("styled-components");
|
11
|
+
var _utils = /*#__PURE__*/require("../../utils");
|
12
|
+
var _base = /*#__PURE__*/require("./variations/_size/base");
|
13
|
+
var _base2 = /*#__PURE__*/require("./variations/_view/base");
|
14
|
+
var _base3 = /*#__PURE__*/require("./variations/_disabled/base");
|
15
|
+
var _base4 = /*#__PURE__*/require("./variations/_read-only/base");
|
16
|
+
var _base5 = /*#__PURE__*/require("./variations/_label-placement/base");
|
15
17
|
var _TextField = /*#__PURE__*/require("./TextField.styles");
|
16
|
-
var
|
18
|
+
var _TextField2 = /*#__PURE__*/require("./TextField.tokens");
|
19
|
+
var _ui = /*#__PURE__*/require("./ui");
|
20
|
+
var _useKeyNavigation2 = /*#__PURE__*/require("./hooks/useKeyNavigation");
|
21
|
+
var _excluded = ["id", "contentLeft", "contentRight", "label", "labelPlacement", "placeholder", "leftHelper", "enumerationType", "view", "size", "readOnly", "disabled", "chips", "onChange", "onChangeChips", "onSearch"];
|
17
22
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
18
23
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
19
24
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
25
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
26
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
27
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
28
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
29
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
30
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
20
31
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
21
32
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
22
|
-
var base = /*#__PURE__*/(0, _styledComponents.css)(["display:block;"]);
|
33
|
+
var base = exports.base = /*#__PURE__*/(0, _styledComponents.css)(["display:block;overflow:hidden;"]);
|
23
34
|
var textFieldRoot = exports.textFieldRoot = function textFieldRoot(Root) {
|
24
|
-
return /*#__PURE__*/(0, _react.forwardRef)(function (
|
25
|
-
var
|
26
|
-
|
27
|
-
|
28
|
-
label =
|
29
|
-
labelPlacement =
|
30
|
-
placeholder =
|
31
|
-
leftHelper =
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
return /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
36
|
+
var id = _ref.id,
|
37
|
+
contentLeft = _ref.contentLeft,
|
38
|
+
contentRight = _ref.contentRight,
|
39
|
+
label = _ref.label,
|
40
|
+
labelPlacement = _ref.labelPlacement,
|
41
|
+
placeholder = _ref.placeholder,
|
42
|
+
leftHelper = _ref.leftHelper,
|
43
|
+
_ref$enumerationType = _ref.enumerationType,
|
44
|
+
enumerationType = _ref$enumerationType === void 0 ? 'plain' : _ref$enumerationType,
|
45
|
+
view = _ref.view,
|
46
|
+
size = _ref.size,
|
47
|
+
_ref$readOnly = _ref.readOnly,
|
48
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
49
|
+
_ref$disabled = _ref.disabled,
|
50
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
51
|
+
values = _ref.chips,
|
52
|
+
onChange = _ref.onChange,
|
53
|
+
onChangeChips = _ref.onChangeChips,
|
54
|
+
onSearch = _ref.onSearch,
|
55
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
56
|
+
var contentRef = (0, _react.useRef)(null);
|
57
|
+
var inputRef = (0, _react.useRef)(null);
|
58
|
+
var chipsRefs = (0, _react.useRef)([]);
|
59
|
+
var controlledRefs = {
|
60
|
+
contentRef: contentRef,
|
61
|
+
inputRef: inputRef,
|
62
|
+
chipsRefs: chipsRefs
|
63
|
+
};
|
64
|
+
var _useState = (0, _react.useState)([]),
|
65
|
+
_useState2 = _slicedToArray(_useState, 2),
|
66
|
+
chips = _useState2[0],
|
67
|
+
setChips = _useState2[1];
|
68
|
+
var uniqId = (0, _plasmaCore.safeUseId)();
|
69
|
+
var innerId = id || uniqId;
|
70
|
+
var labelId = (0, _plasmaCore.safeUseId)();
|
71
|
+
var helperTextId = (0, _plasmaCore.safeUseId)();
|
72
|
+
var isChipEnumeration = enumerationType === 'chip';
|
73
|
+
var hideLabel = (size === 'xs' || isChipEnumeration) && labelPlacement === 'inner';
|
74
|
+
var labelInside = size !== 'xs' && labelPlacement === 'inner';
|
75
|
+
var innerLabelPlacementValue = hideLabel ? 'outer' : labelPlacement;
|
76
|
+
var innerPlaceholderValue = hideLabel ? label : placeholder;
|
77
|
+
var innerLabelValue = hideLabel ? undefined : label;
|
78
|
+
var isChipsVisible = isChipEnumeration && (chips === null || chips === void 0 ? void 0 : chips.length);
|
79
|
+
var withHasChips = isChipsVisible ? _TextField2.classes.hasChips : undefined;
|
80
|
+
var wrapperWithoutLeftContent = !contentLeft && isChipsVisible ? _TextField2.classes.hasEmptyContentLeft : undefined;
|
81
|
+
var wrapperWithoutRightContent = !contentRight && isChipsVisible ? _TextField2.classes.hasEmptyContentRight : undefined;
|
38
82
|
var handleChange = function handleChange(event) {
|
83
|
+
if (disabled || readOnly) {
|
84
|
+
return;
|
85
|
+
}
|
39
86
|
var _event$target = event.target,
|
40
87
|
maxLength = _event$target.maxLength,
|
41
88
|
value = _event$target.value;
|
42
|
-
if (
|
89
|
+
if (maxLength !== -1 && value.length > maxLength) {
|
90
|
+
return;
|
91
|
+
}
|
92
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
93
|
+
};
|
94
|
+
var updateChips = function updateChips(newChips, newValues) {
|
95
|
+
setChips(newChips);
|
96
|
+
onChangeChips === null || onChangeChips === void 0 ? void 0 : onChangeChips(newValues);
|
97
|
+
};
|
98
|
+
var _useKeyNavigation = (0, _useKeyNavigation2.useKeyNavigation)({
|
99
|
+
controlledRefs: controlledRefs,
|
100
|
+
disabled: disabled,
|
101
|
+
readOnly: readOnly,
|
102
|
+
chips: chips,
|
103
|
+
enumerationType: enumerationType,
|
104
|
+
updateChips: updateChips,
|
105
|
+
onSearch: onSearch,
|
106
|
+
onChange: onChange
|
107
|
+
}),
|
108
|
+
handleInputKeydown = _useKeyNavigation.handleInputKeydown,
|
109
|
+
handleChipKeyDown = _useKeyNavigation.handleChipKeyDown,
|
110
|
+
onChipClear = _useKeyNavigation.onChipClear,
|
111
|
+
handleContentKeyDown = _useKeyNavigation.handleContentKeyDown;
|
112
|
+
var onChipClick = function onChipClick(event) {
|
113
|
+
return event.stopPropagation();
|
114
|
+
};
|
115
|
+
var handleInputFocus = function handleInputFocus() {
|
116
|
+
if (readOnly || disabled || !(inputRef !== null && inputRef !== void 0 && inputRef.current)) {
|
43
117
|
return;
|
44
118
|
}
|
45
|
-
|
119
|
+
inputRef.current.scrollIntoView({
|
120
|
+
behavior: 'smooth',
|
121
|
+
block: 'center',
|
122
|
+
inline: 'center'
|
123
|
+
});
|
124
|
+
inputRef.current.focus({
|
125
|
+
preventScroll: true
|
126
|
+
});
|
46
127
|
};
|
47
|
-
var
|
48
|
-
if (
|
49
|
-
|
128
|
+
var getRef = function getRef(element, index) {
|
129
|
+
if (element && chipsRefs !== null && chipsRefs !== void 0 && chipsRefs.current) {
|
130
|
+
chipsRefs.current[index] = element;
|
50
131
|
}
|
51
132
|
};
|
52
|
-
|
53
|
-
|
54
|
-
|
133
|
+
(0, _react.useEffect)(function () {
|
134
|
+
if (!isChipEnumeration && !(values !== null && values !== void 0 && values.length)) {
|
135
|
+
return;
|
136
|
+
}
|
137
|
+
var newChips = (values === null || values === void 0 ? void 0 : values.map(function (value, index) {
|
138
|
+
return {
|
139
|
+
id: "".concat(index, "_").concat(value),
|
140
|
+
text: value
|
141
|
+
};
|
142
|
+
})) || [];
|
143
|
+
setChips(newChips);
|
144
|
+
}, [isChipEnumeration, values]);
|
55
145
|
return /*#__PURE__*/_react["default"].createElement(Root, {
|
146
|
+
ref: ref,
|
56
147
|
view: view,
|
57
148
|
size: size,
|
58
149
|
disabled: disabled,
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
},
|
63
|
-
|
64
|
-
|
150
|
+
readOnly: !disabled && readOnly,
|
151
|
+
labelPlacement: innerLabelPlacementValue,
|
152
|
+
onClick: handleInputFocus
|
153
|
+
}, labelInside || innerLabelValue && /*#__PURE__*/_react["default"].createElement(_TextField.Label, {
|
154
|
+
id: labelId,
|
155
|
+
htmlFor: id
|
156
|
+
}, innerLabelValue), /*#__PURE__*/_react["default"].createElement(_TextField.InputWrapper, {
|
157
|
+
className: (0, _utils.cx)(withHasChips, wrapperWithoutLeftContent, wrapperWithoutRightContent)
|
158
|
+
}, contentLeft && /*#__PURE__*/_react["default"].createElement(_TextField.StyledContentLeft, null, contentLeft), /*#__PURE__*/_react["default"].createElement(_TextField.InputLabelWrapper, {
|
159
|
+
tabIndex: -1,
|
160
|
+
ref: contentRef,
|
161
|
+
onKeyDown: handleContentKeyDown,
|
162
|
+
className: withHasChips
|
163
|
+
}, isChipEnumeration && Boolean(chips === null || chips === void 0 ? void 0 : chips.length) && /*#__PURE__*/_react["default"].createElement(_TextField.StyledChips, null, chips === null || chips === void 0 ? void 0 : chips.map(function (_ref2, index) {
|
164
|
+
var chipId = _ref2.id,
|
165
|
+
text = _ref2.text;
|
166
|
+
return /*#__PURE__*/_react["default"].createElement(_ui.TextFieldChip, {
|
167
|
+
id: chipId,
|
168
|
+
ref: function ref(element) {
|
169
|
+
return getRef(element, index);
|
170
|
+
},
|
171
|
+
key: "".concat(chipId, "_").concat(index),
|
172
|
+
disabled: disabled,
|
173
|
+
readOnly: readOnly,
|
174
|
+
value: text,
|
175
|
+
text: text,
|
176
|
+
onKeyDown: function onKeyDown(event) {
|
177
|
+
return handleChipKeyDown(event, chipId, index);
|
178
|
+
},
|
179
|
+
onClear: function onClear() {
|
180
|
+
return onChipClear(chipId, index);
|
181
|
+
},
|
182
|
+
onClick: onChipClick
|
183
|
+
});
|
184
|
+
})), /*#__PURE__*/_react["default"].createElement(_TextField.Input, _extends({}, rest, {
|
185
|
+
ref: inputRef,
|
186
|
+
id: innerId,
|
187
|
+
"aria-labelledby": labelId,
|
65
188
|
"aria-describedby": helperTextId,
|
66
|
-
placeholder:
|
189
|
+
placeholder: innerPlaceholderValue,
|
67
190
|
disabled: disabled,
|
191
|
+
readOnly: !disabled && readOnly,
|
68
192
|
onChange: handleChange,
|
69
|
-
|
193
|
+
onKeyDown: handleInputKeydown
|
70
194
|
})), labelInside && /*#__PURE__*/_react["default"].createElement(_TextField.Label, {
|
71
|
-
id:
|
72
|
-
|
195
|
+
id: labelId,
|
196
|
+
htmlFor: innerId
|
197
|
+
}, innerLabelValue)), contentRight && /*#__PURE__*/_react["default"].createElement(_TextField.StyledContentRight, null, contentRight)), leftHelper && /*#__PURE__*/_react["default"].createElement(_TextField.LeftHelper, {
|
73
198
|
id: helperTextId
|
74
199
|
}, leftHelper));
|
75
200
|
});
|
76
201
|
};
|
77
202
|
var textFieldConfig = exports.textFieldConfig = {
|
78
203
|
name: 'TextField',
|
79
|
-
tag: '
|
204
|
+
tag: 'div',
|
80
205
|
layout: textFieldRoot,
|
81
206
|
base: base,
|
82
207
|
variations: {
|
@@ -90,11 +215,16 @@ var textFieldConfig = exports.textFieldConfig = {
|
|
90
215
|
css: _base3.base,
|
91
216
|
attrs: true
|
92
217
|
},
|
218
|
+
readOnly: {
|
219
|
+
css: _base4.base,
|
220
|
+
attrs: true
|
221
|
+
},
|
93
222
|
labelPlacement: {
|
94
|
-
css:
|
223
|
+
css: _base5.base
|
95
224
|
}
|
96
225
|
},
|
97
226
|
defaults: {
|
98
|
-
size: 'm'
|
227
|
+
size: 'm',
|
228
|
+
view: 'default'
|
99
229
|
}
|
100
230
|
};
|
@@ -3,23 +3,31 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.LeftHelper = exports.Label = exports.InputWrapper = exports.InputLabelWrapper = exports.Input = void 0;
|
6
|
+
exports.StyledContentRight = exports.StyledContentLeft = exports.StyledChips = exports.LeftHelper = exports.Label = exports.InputWrapper = exports.InputLabelWrapper = exports.Input = void 0;
|
7
7
|
var _styledComponents = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("styled-components"));
|
8
|
+
var _TextField = /*#__PURE__*/require("./TextField.tokens");
|
8
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
9
|
-
var
|
10
|
+
var InputWrapper = exports.InputWrapper = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
10
11
|
componentId: "plasma-new-hope__sc-g4vxbb-0"
|
11
|
-
})(["
|
12
|
+
})(["position:relative;display:flex;align-items:center;box-sizing:border-box;"]);
|
12
13
|
var InputLabelWrapper = exports.InputLabelWrapper = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
13
14
|
componentId: "plasma-new-hope__sc-g4vxbb-1"
|
14
|
-
})(["", "{
|
15
|
-
|
16
|
-
// NOTE: border-width is used in size border-color is used in view
|
17
|
-
var InputWrapper = exports.InputWrapper = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
15
|
+
})(["flex:1;overflow:scroll;position:relative;width:100%;display:inline-flex;align-items:center;::-webkit-scrollbar{display:none;}scrollbar-width:none;overscroll-behavior:contain;&.", "{height:var(", ");border-radius:var(", ");}"], /*#__PURE__*/String(_TextField.classes.hasChips), _TextField.tokens.chipHeight, _TextField.tokens.chipBorderRadius);
|
16
|
+
var StyledChips = exports.StyledChips = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
18
17
|
componentId: "plasma-new-hope__sc-g4vxbb-2"
|
19
|
-
})(["
|
20
|
-
var
|
18
|
+
})(["display:flex;gap:var(", ");margin-right:var(", ");user-select:none;"], _TextField.tokens.chipGap, _TextField.tokens.chipGap);
|
19
|
+
var Input = exports.Input = /*#__PURE__*/_styledComponents["default"].input.withConfig({
|
21
20
|
componentId: "plasma-new-hope__sc-g4vxbb-3"
|
21
|
+
})(["box-sizing:border-box;appearance:none;border:0;padding:0;background-color:transparent;outline:none;flex:1;min-width:60%;"]);
|
22
|
+
var Label = exports.Label = /*#__PURE__*/_styledComponents["default"].label.withConfig({
|
23
|
+
componentId: "plasma-new-hope__sc-g4vxbb-4"
|
22
24
|
})([""]);
|
25
|
+
var StyledContentLeft = exports.StyledContentLeft = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
26
|
+
componentId: "plasma-new-hope__sc-g4vxbb-5"
|
27
|
+
})(["margin:var(", ");"], _TextField.tokens.leftContentMargin);
|
28
|
+
var StyledContentRight = exports.StyledContentRight = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
29
|
+
componentId: "plasma-new-hope__sc-g4vxbb-6"
|
30
|
+
})(["margin:var(", ");"], _TextField.tokens.rightContentMargin);
|
23
31
|
var LeftHelper = exports.LeftHelper = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
24
|
-
componentId: "plasma-new-hope__sc-g4vxbb-
|
32
|
+
componentId: "plasma-new-hope__sc-g4vxbb-7"
|
25
33
|
})([""]);
|
@@ -110,3 +110,27 @@ export function App() {
|
|
110
110
|
);
|
111
111
|
}
|
112
112
|
```
|
113
|
+
|
114
|
+
### Режим ввода
|
115
|
+
С помощью свойства `enumarationType` можно вводить элементы как теги.
|
116
|
+
По нажатию Enter, после ввода нужного текста, он преобразуется в Chip:
|
117
|
+
|
118
|
+
```tsx live
|
119
|
+
import React from 'react';
|
120
|
+
import { TextField } from '@salutejs/{{ package }};
|
121
|
+
|
122
|
+
export function App() {
|
123
|
+
return (
|
124
|
+
<div>
|
125
|
+
<TextField
|
126
|
+
placeholder="Введите значение"
|
127
|
+
defaultValue="Значение"
|
128
|
+
size="l"
|
129
|
+
enumerationType="chip"
|
130
|
+
helperText="Подсказка снизу"
|
131
|
+
values={["Значение 1"]}
|
132
|
+
/>
|
133
|
+
</div>
|
134
|
+
);
|
135
|
+
}
|
136
|
+
```
|
@@ -3,35 +3,46 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.tokens = void 0;
|
6
|
+
exports.tokens = exports.classes = void 0;
|
7
|
+
var classes = exports.classes = {
|
8
|
+
hasChips: 'has-chips',
|
9
|
+
hasEmptyContentLeft: 'has-empty-content-left',
|
10
|
+
hasEmptyContentRight: 'has-empty-content-right'
|
11
|
+
};
|
7
12
|
var tokens = exports.tokens = {
|
8
13
|
color: '--plasma-textfield-color',
|
9
14
|
backgroundColor: '--plasma-textfield-bg-color',
|
10
15
|
backgroundColorHover: '--plasma-textfield-bg-color-hover',
|
11
16
|
backgroundColorFocus: '--plasma-textfield-bg-color-focus',
|
12
|
-
/** Цвет каретки */
|
13
|
-
caretColor: '--plasma-textfield__caret-color',
|
14
|
-
placeholderColor: '--plasma-textfield__placeholder-color',
|
15
17
|
borderColor: '--plasma-textfield-border-color',
|
16
18
|
borderColorHover: '--plasma-textfield-border-color-hover',
|
17
19
|
borderColorFocus: '--plasma-textfield-border-color-focus',
|
20
|
+
/** Цвета для read-only состояния */
|
21
|
+
colorReadOnly: '--plasma-textfield-color-readonly',
|
22
|
+
backgroundColorReadOnly: '--plasma-textfield-bg-color-readonly',
|
23
|
+
borderColorReadOnly: '--plasma-textfield-border-color-readonly',
|
24
|
+
placeholderColorReadOnly: '--plasma-textfield__placeholder-color-readonly',
|
25
|
+
/** Цвет каретки */
|
26
|
+
caretColor: '--plasma-textfield__caret-color',
|
27
|
+
placeholderColor: '--plasma-textfield__placeholder-color',
|
18
28
|
height: '--plasma-textfield-height',
|
19
29
|
borderWidth: '--plasmas-textfield-border-width',
|
20
30
|
borderRadius: '--plasma-textfield-border-radius',
|
21
|
-
/**
|
31
|
+
/** Отступ от границы ТextField */
|
22
32
|
padding: '--plasma-textfield-padding',
|
23
|
-
|
24
|
-
/*
|
25
|
-
|
26
|
-
|
33
|
+
paddingWithChips: '--plasma-textfield-padding-with-chips',
|
34
|
+
/* Токены для инпута */
|
35
|
+
leftContentMargin: '--plasma-textfield__left-content-margin',
|
36
|
+
rightContentMargin: '--plasma-textfield__right-content-margin',
|
27
37
|
fontFamily: '--plasma-textfield-font-family',
|
28
38
|
fontStyle: '--plasma-textfield-font-style',
|
29
39
|
fontSize: '--plasma-textfield-font-size',
|
30
40
|
fontWeight: '--plasma-textfield-font-weight',
|
31
41
|
letterSpacing: '--plasma-textfield-letter-spacing',
|
32
42
|
lineHeight: '--plasma-textfield-line-height',
|
33
|
-
/**
|
43
|
+
/** Токены лейбла */
|
34
44
|
labelColor: '--plasma-textfield__label-color',
|
45
|
+
labelColorReadOnly: '--plasma-textfield__label-color-readonly',
|
35
46
|
labelOffset: '--plasma-textfield__label-offset',
|
36
47
|
labelFontFamily: '--plasma-textfield__label-font-family',
|
37
48
|
labelFontStyle: '--plasma-textfield__label-font-style',
|
@@ -46,16 +57,52 @@ var tokens = exports.tokens = {
|
|
46
57
|
labelInnerFontWeight: '--plasma-textfield-placement_inner__label-font-weight',
|
47
58
|
labelInnerLetterSpacing: '--plasma-textfield-placement_inner__label-letter-spacing',
|
48
59
|
labelInnerLineHeight: '--plasma-textfield-placement_inner__label-line-height',
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
60
|
+
labelInnerPadding: '--plasma-textfield-placement_inner__label-padding',
|
61
|
+
contentLabelInnerPadding: '--plasma-textfield-placement_inner__content-padding',
|
62
|
+
leftHelperColor: '--plasma-textfield__left-helper-color',
|
63
|
+
leftHelperColorReadOnly: '--plasma-textfield__left-helper-color-readonly',
|
64
|
+
leftHelperOffset: '--plasma-textfield__left-helper-offset',
|
65
|
+
leftHelperFontFamily: '--plasma-textfield__left-helper-font-family',
|
66
|
+
leftHelperFontStyle: '--plasma-textfield__left-helper-font-style',
|
67
|
+
leftHelperFontSize: '--plasma-textfield__left-helper-font-size',
|
68
|
+
leftHelperFontWeight: '--plasma-textfield__left-helper-font-weight',
|
69
|
+
leftHelperLetterSpacing: '--plasma-textfield__left-helper-letter-spacing',
|
70
|
+
leftHelperLineHeight: '--plasma-textfield__left-helper-line-height',
|
59
71
|
/** Прозрачность для всего компонента в состоянии disabled */
|
60
|
-
disabledOpacity: '--plasma-textfield-disabled-opacity'
|
72
|
+
disabledOpacity: '--plasma-textfield-disabled-opacity',
|
73
|
+
/** Токены чипа */
|
74
|
+
chipHeight: '--plasma-textfield__chip-height',
|
75
|
+
chipBorderRadius: '--plasma-textfield__chip-border-radius',
|
76
|
+
chipGap: '--plasma-textfield__chip-gap',
|
77
|
+
chipBackground: '--plasma-textfield__chip-background',
|
78
|
+
chipColor: '--plasma-textfield__chip-color',
|
79
|
+
chipBackgroundHover: '--plasma-textfield__chip-background-hover',
|
80
|
+
chipColorHover: '--plasma-textfield__chip-color-hover',
|
81
|
+
chipScaleHover: '--plasma-textfield__chip-scale-hover',
|
82
|
+
chipBackgroundReadOnly: '--plasma-textfield__chip-background-readonly',
|
83
|
+
chipColorReadOnly: '--plasma-textfield__chip-color-readonly',
|
84
|
+
chipBackgroundReadOnlyHover: '--plasma-textfield__chip-background-readonly-hover',
|
85
|
+
chipColorReadOnlyHover: '--plasma-textfield__chip-color-readonly-hover',
|
86
|
+
chipBackgroundActive: '--plasma-textfield__chip-background-active',
|
87
|
+
chipColorActive: '--plasma-textfield__chip-color-active',
|
88
|
+
chipScaleActive: '--plasma-textfield__chip-scale-active',
|
89
|
+
chipFocusColor: '--plasma-textfield__chip-focus-color',
|
90
|
+
chipCloseIconColor: '--plasma-textfield__chip-close-icon-color',
|
91
|
+
chipOutlineSize: '--plasma-textfield__chip-outline-size',
|
92
|
+
chipWidth: '--plasma-textfield__chip-width',
|
93
|
+
chipPaddingTop: '--plasma-textfield__chip-padding-top',
|
94
|
+
chipPaddingRight: '--plasma-textfield__chip-padding-right',
|
95
|
+
chipPaddingBottom: '--plasma-textfield__chip-padding-bottom',
|
96
|
+
chipPaddingLeft: '--plasma-textfield__chip-padding-left',
|
97
|
+
chipCloseIconSize: '--plasma-textfield__chip-close-icon-size',
|
98
|
+
chipFontFamily: '--plasma-textfield__chip-font-family',
|
99
|
+
chipFontSize: '--plasma-textfield__chip-font-size',
|
100
|
+
chipFontStyle: '--plasma-textfield__chip-font-style',
|
101
|
+
chipFontWeight: '--plasma-textfield__chip-font-weight',
|
102
|
+
chipLetterSpacing: '--plasma-textfield__chip-letter-spacing',
|
103
|
+
chipLineHeight: '--plasma-textfield__chip-line-height',
|
104
|
+
chipClearContentMarginLeft: '--plasma-textfield__chip-clear-content-margin-left',
|
105
|
+
chipClearContentMarginRight: '--plasma-textfield__chip-clear-content-margin-right',
|
106
|
+
chipOpacityReadonly: '--plasma-textfield__chip-opacity-readonly',
|
107
|
+
focusColor: '--plasma-textfield-focus-color'
|
61
108
|
};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
Object.defineProperty(exports, "useKeyNavigation", {
|
7
|
+
enumerable: true,
|
8
|
+
get: function get() {
|
9
|
+
return _useKeyNavigation.useKeyNavigation;
|
10
|
+
}
|
11
|
+
});
|
12
|
+
var _useKeyNavigation = /*#__PURE__*/require("./useKeyNavigation");
|
@@ -0,0 +1,138 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.useKeyNavigation = exports.Keys = void 0;
|
7
|
+
var _react = /*#__PURE__*/require("react");
|
8
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
9
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
10
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
11
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
12
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
13
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
14
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
15
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
16
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
17
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
18
|
+
var Keys = exports.Keys = {
|
19
|
+
Enter: 'Enter',
|
20
|
+
Tab: 'Tab',
|
21
|
+
Escape: 'Escape',
|
22
|
+
ArrowLeft: 'ArrowLeft',
|
23
|
+
ArrowRight: 'ArrowRight',
|
24
|
+
Backspace: 'Backspace'
|
25
|
+
};
|
26
|
+
var useKeyNavigation = exports.useKeyNavigation = function useKeyNavigation(_ref) {
|
27
|
+
var _ref$controlledRefs = _ref.controlledRefs,
|
28
|
+
chipsRefs = _ref$controlledRefs.chipsRefs,
|
29
|
+
contentRef = _ref$controlledRefs.contentRef,
|
30
|
+
inputRef = _ref$controlledRefs.inputRef,
|
31
|
+
disabled = _ref.disabled,
|
32
|
+
readOnly = _ref.readOnly,
|
33
|
+
chips = _ref.chips,
|
34
|
+
enumerationType = _ref.enumerationType,
|
35
|
+
updateChips = _ref.updateChips,
|
36
|
+
onChange = _ref.onChange,
|
37
|
+
onSearch = _ref.onSearch;
|
38
|
+
var _useState = (0, _react.useState)(-1),
|
39
|
+
_useState2 = _slicedToArray(_useState, 2),
|
40
|
+
activeChipIndex = _useState2[0],
|
41
|
+
setActiveChipIndex = _useState2[1];
|
42
|
+
var handleInputKeydown = function handleInputKeydown(event) {
|
43
|
+
var _inputRef$current;
|
44
|
+
var _ref2 = event.target,
|
45
|
+
value = _ref2.value;
|
46
|
+
if (disabled || readOnly) {
|
47
|
+
return;
|
48
|
+
}
|
49
|
+
if (event.key === Keys.Enter && enumerationType === 'chip' && value) {
|
50
|
+
var nextIndex = (chips === null || chips === void 0 ? void 0 : chips.length) || 0;
|
51
|
+
var newChips = [].concat(_toConsumableArray(chips), [{
|
52
|
+
id: "".concat(nextIndex, "_").concat(value),
|
53
|
+
text: value
|
54
|
+
}]);
|
55
|
+
var newValues = newChips.map(function (_ref3) {
|
56
|
+
var text = _ref3.text;
|
57
|
+
return text;
|
58
|
+
});
|
59
|
+
updateChips(newChips, newValues);
|
60
|
+
event.target.value = '';
|
61
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
62
|
+
}
|
63
|
+
if (event.key === Keys.Enter && onSearch) {
|
64
|
+
onSearch(value, event);
|
65
|
+
}
|
66
|
+
if (event.key === Keys.Backspace && chips.length && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.selectionStart) === 0) {
|
67
|
+
var _newChips = _toConsumableArray(chips);
|
68
|
+
_newChips === null || _newChips === void 0 ? void 0 : _newChips.pop();
|
69
|
+
chipsRefs === null || chipsRefs === void 0 ? void 0 : chipsRefs.current.pop();
|
70
|
+
var _newValues = _newChips.map(function (_ref4) {
|
71
|
+
var text = _ref4.text;
|
72
|
+
return text;
|
73
|
+
});
|
74
|
+
updateChips(_newChips, _newValues);
|
75
|
+
}
|
76
|
+
};
|
77
|
+
var onChipClear = function onChipClear(clearId, index) {
|
78
|
+
if (!chips.length) {
|
79
|
+
return;
|
80
|
+
}
|
81
|
+
var newChips = (chips === null || chips === void 0 ? void 0 : chips.filter(function (_ref5) {
|
82
|
+
var chipId = _ref5.id;
|
83
|
+
return chipId !== clearId;
|
84
|
+
})) || [];
|
85
|
+
var newValues = newChips.map(function (_ref6) {
|
86
|
+
var text = _ref6.text;
|
87
|
+
return text;
|
88
|
+
});
|
89
|
+
chipsRefs === null || chipsRefs === void 0 ? void 0 : chipsRefs.current.splice(index, 1);
|
90
|
+
updateChips(newChips, newValues);
|
91
|
+
};
|
92
|
+
var handleChipKeyDown = function handleChipKeyDown(event, chipId, chipIndex) {
|
93
|
+
if (event.key === Keys.Tab) {
|
94
|
+
event.preventDefault();
|
95
|
+
}
|
96
|
+
if (event.key === Keys.Backspace) {
|
97
|
+
onChipClear(chipId, chipIndex);
|
98
|
+
}
|
99
|
+
};
|
100
|
+
var handleContentKeyDown = function handleContentKeyDown(event) {
|
101
|
+
var _inputRef$current2, _focusedItem, _focusedItem2;
|
102
|
+
var chipsRefsCount = chipsRefs.current.length;
|
103
|
+
var currentCaretPosition = (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.selectionStart) || 0;
|
104
|
+
var newActiveChipIndex = activeChipIndex;
|
105
|
+
var focusedItem = null;
|
106
|
+
if (event.key === Keys.ArrowLeft && enumerationType === 'chip' && currentCaretPosition <= 0) {
|
107
|
+
var _chipsRefs$current;
|
108
|
+
var index = activeChipIndex - 1 <= 0 ? 0 : activeChipIndex - 1;
|
109
|
+
newActiveChipIndex = document.activeElement === (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) ? chipsRefsCount - 1 : index;
|
110
|
+
focusedItem = (_chipsRefs$current = chipsRefs.current) === null || _chipsRefs$current === void 0 ? void 0 : _chipsRefs$current[newActiveChipIndex];
|
111
|
+
}
|
112
|
+
if (event.key === Keys.ArrowRight && enumerationType === 'chip' && document.activeElement !== (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current)) {
|
113
|
+
var _chipsRefs$current2;
|
114
|
+
var _index = activeChipIndex + 1 >= chipsRefsCount ? activeChipIndex : activeChipIndex + 1;
|
115
|
+
newActiveChipIndex = document.activeElement === (contentRef === null || contentRef === void 0 ? void 0 : contentRef.current) ? 0 : _index;
|
116
|
+
focusedItem = _index === activeChipIndex ? inputRef === null || inputRef === void 0 ? void 0 : inputRef.current : (_chipsRefs$current2 = chipsRefs.current) === null || _chipsRefs$current2 === void 0 ? void 0 : _chipsRefs$current2[newActiveChipIndex];
|
117
|
+
}
|
118
|
+
if (event.key === Keys.Backspace && document.activeElement !== (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current)) {
|
119
|
+
var _chipsRefs$current3;
|
120
|
+
var _index2 = activeChipIndex - 1 <= 0 ? 0 : activeChipIndex - 1;
|
121
|
+
newActiveChipIndex = chipsRefsCount === 0 ? -1 : _index2;
|
122
|
+
focusedItem = chipsRefsCount === 0 ? inputRef === null || inputRef === void 0 ? void 0 : inputRef.current : chipsRefs === null || chipsRefs === void 0 ? void 0 : (_chipsRefs$current3 = chipsRefs.current) === null || _chipsRefs$current3 === void 0 ? void 0 : _chipsRefs$current3[newActiveChipIndex];
|
123
|
+
}
|
124
|
+
(_focusedItem = focusedItem) === null || _focusedItem === void 0 ? void 0 : _focusedItem.focus();
|
125
|
+
(_focusedItem2 = focusedItem) === null || _focusedItem2 === void 0 ? void 0 : _focusedItem2.scrollIntoView({
|
126
|
+
behavior: 'smooth',
|
127
|
+
block: 'center',
|
128
|
+
inline: 'center'
|
129
|
+
});
|
130
|
+
setActiveChipIndex(newActiveChipIndex);
|
131
|
+
};
|
132
|
+
return {
|
133
|
+
handleInputKeydown: handleInputKeydown,
|
134
|
+
handleChipKeyDown: handleChipKeyDown,
|
135
|
+
onChipClear: onChipClear,
|
136
|
+
handleContentKeyDown: handleContentKeyDown
|
137
|
+
};
|
138
|
+
};
|
@@ -33,7 +33,7 @@ Object.defineProperty(exports, "textField_labelPlacement_outer", {
|
|
33
33
|
return _outer.labelPlacement_outer;
|
34
34
|
}
|
35
35
|
});
|
36
|
-
var _inner = /*#__PURE__*/require("./_label-placement/inner");
|
37
|
-
var _outer = /*#__PURE__*/require("./_label-placement/outer");
|
36
|
+
var _inner = /*#__PURE__*/require("./variations/_label-placement/inner");
|
37
|
+
var _outer = /*#__PURE__*/require("./variations/_label-placement/outer");
|
38
38
|
var _TextField = /*#__PURE__*/require("./TextField");
|
39
39
|
var _TextField2 = /*#__PURE__*/require("./TextField.tokens");
|