@salutejs/plasma-new-hope 0.72.0-canary.1160.8612911363.0 → 0.72.0-canary.1160.8617165473.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. package/cjs/components/Cell/Cell.js +2 -0
  2. package/cjs/components/Cell/Cell.js.map +1 -1
  3. package/cjs/components/TextField/TextField.js +5 -5
  4. package/cjs/components/TextField/TextField.js.map +1 -1
  5. package/cjs/components/TextField/hooks/useKeyNavigation.js +5 -4
  6. package/cjs/components/TextField/hooks/useKeyNavigation.js.map +1 -1
  7. package/cjs/components/TextField/ui/TextFieldChip/TextFieldChip.js +3 -3
  8. package/cjs/components/TextField/ui/TextFieldChip/TextFieldChip.js.map +1 -1
  9. package/es/components/Cell/Cell.js +2 -0
  10. package/es/components/Cell/Cell.js.map +1 -1
  11. package/es/components/TextField/TextField.js +5 -5
  12. package/es/components/TextField/TextField.js.map +1 -1
  13. package/es/components/TextField/hooks/useKeyNavigation.js +5 -4
  14. package/es/components/TextField/hooks/useKeyNavigation.js.map +1 -1
  15. package/es/components/TextField/ui/TextFieldChip/TextFieldChip.js +3 -3
  16. package/es/components/TextField/ui/TextFieldChip/TextFieldChip.js.map +1 -1
  17. package/package.json +2 -2
  18. package/styled-components/cjs/components/Cell/Cell.js +2 -0
  19. package/styled-components/cjs/components/TextField/TextField.js +5 -5
  20. package/styled-components/cjs/components/TextField/hooks/useKeyNavigation.js +5 -4
  21. package/styled-components/cjs/components/TextField/ui/TextFieldChip/TextFieldChip.js +3 -3
  22. package/styled-components/cjs/examples/plasma_b2c/components/TextField/TextField.stories.tsx +60 -12
  23. package/styled-components/cjs/examples/plasma_web/components/TextField/TextField.stories.tsx +60 -12
  24. package/styled-components/cjs/examples/sds_engineer/components/TextField/TextField.stories.tsx +60 -12
  25. package/styled-components/es/components/Cell/Cell.js +2 -0
  26. package/styled-components/es/components/TextField/TextField.js +5 -5
  27. package/styled-components/es/components/TextField/hooks/useKeyNavigation.js +5 -4
  28. package/styled-components/es/components/TextField/ui/TextFieldChip/TextFieldChip.js +3 -3
  29. package/styled-components/es/examples/plasma_b2c/components/TextField/TextField.stories.tsx +60 -12
  30. package/styled-components/es/examples/plasma_web/components/TextField/TextField.stories.tsx +60 -12
  31. package/styled-components/es/examples/sds_engineer/components/TextField/TextField.stories.tsx +60 -12
  32. package/types/components/Cell/Cell.d.ts.map +1 -1
  33. package/types/components/TextField/TextField.types.d.ts +42 -19
  34. package/types/components/TextField/TextField.types.d.ts.map +1 -1
  35. package/types/components/TextField/hooks/useKeyNavigation.d.ts +2 -2
  36. package/types/components/TextField/hooks/useKeyNavigation.d.ts.map +1 -1
  37. package/types/components/TextField/ui/TextFieldChip/TextFieldChip.types.d.ts +1 -1
  38. package/types/components/TextField/ui/TextFieldChip/TextFieldChip.types.d.ts.map +1 -1
  39. package/types/examples/plasma_b2c/components/TextField/TextField.d.ts +35 -1
  40. package/types/examples/plasma_b2c/components/TextField/TextField.d.ts.map +1 -1
  41. package/types/examples/plasma_web/components/TextField/TextField.d.ts +35 -1
  42. package/types/examples/plasma_web/components/TextField/TextField.d.ts.map +1 -1
  43. package/types/examples/sds_engineer/components/TextField/TextField.d.ts +35 -1
  44. package/types/examples/sds_engineer/components/TextField/TextField.d.ts.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useKeyNavigation.js","sources":["../../../../src/components/TextField/hooks/useKeyNavigation.ts"],"sourcesContent":["import { useState } from 'react';\nimport type { ChangeEvent, KeyboardEvent } from 'react';\n\nimport type { UseKeyNavigationProps } from '../TextField.types';\n\nexport const Keys = {\n Enter: 'Enter',\n Tab: 'Tab',\n Escape: 'Escape',\n ArrowLeft: 'ArrowLeft',\n ArrowRight: 'ArrowRight',\n Backspace: 'Backspace',\n};\n\nexport const useKeyNavigation = ({\n controlledRefs: { chipsRefs, contentRef, inputRef },\n disabled,\n readOnly,\n chips,\n enumerationType,\n updateChips,\n onChange,\n onSearch,\n}: UseKeyNavigationProps) => {\n const [activeChipIndex, setActiveChipIndex] = useState(-1);\n\n const handleInputKeydown = (event: ChangeEvent<HTMLInputElement> & KeyboardEvent<HTMLInputElement>) => {\n const { value } = event.target as HTMLInputElement;\n\n if (disabled || readOnly) {\n return;\n }\n\n if (event.key === Keys.Enter && enumerationType === 'chip' && value) {\n const nextIndex = chips?.length || 0;\n\n const newChips = [...chips, { id: `${nextIndex}_${value}`, text: value }];\n const newValues = newChips.map(({ text }) => text);\n\n updateChips(newChips, newValues);\n event.target.value = '';\n onChange?.(event);\n }\n\n if (event.key === Keys.Enter && onSearch) {\n onSearch(value, event);\n }\n\n if (event.key === Keys.Backspace && chips.length && inputRef?.current?.selectionStart === 0) {\n const newChips = [...chips];\n newChips?.pop();\n chipsRefs?.current.pop();\n\n const newValues = newChips.map(({ text }) => text);\n\n updateChips(newChips, newValues);\n }\n };\n\n const onChipClear = (clearId: string) => {\n if (!chips.length) {\n return;\n }\n\n const newChips = chips?.filter(({ id: chipId }) => chipId !== clearId) || [];\n const newValues = newChips.map(({ text }) => text);\n\n updateChips(newChips, newValues);\n };\n\n const handleChipKeyDown = (event: KeyboardEvent<HTMLButtonElement>, chipId: string) => {\n if (event.key === Keys.Tab) {\n event.preventDefault();\n }\n\n if (event.key === Keys.Backspace) {\n onChipClear(chipId);\n }\n };\n\n const handleContentKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const chipsRefsCount = chips.length;\n const currentCaretPosition = inputRef?.current?.selectionStart || 0;\n\n let newActiveChipIndex = activeChipIndex;\n let focusedItem: HTMLButtonElement | HTMLInputElement | null = null;\n\n if (event.key === Keys.ArrowLeft && enumerationType === 'chip' && currentCaretPosition <= 0) {\n const index = activeChipIndex - 1 <= 0 ? 0 : activeChipIndex - 1;\n\n newActiveChipIndex = document.activeElement === inputRef?.current ? chipsRefsCount - 1 : index;\n\n focusedItem = chipsRefs.current?.[newActiveChipIndex];\n }\n\n if (\n event.key === Keys.ArrowRight &&\n enumerationType === 'chip' &&\n document.activeElement !== inputRef?.current\n ) {\n const index = activeChipIndex + 1 >= chipsRefsCount ? activeChipIndex : activeChipIndex + 1;\n\n newActiveChipIndex = document.activeElement === contentRef?.current ? 0 : index;\n focusedItem =\n index === activeChipIndex\n ? (inputRef?.current as HTMLInputElement)\n : chipsRefs.current?.[newActiveChipIndex];\n }\n\n if (event.key === Keys.Backspace && document.activeElement !== inputRef?.current) {\n const index = activeChipIndex - 1 <= 0 ? 0 : activeChipIndex - 1;\n\n newActiveChipIndex = chipsRefsCount === 0 ? -1 : index;\n focusedItem =\n chipsRefsCount === 0\n ? (inputRef?.current as HTMLInputElement)\n : chipsRefs?.current?.[newActiveChipIndex];\n }\n\n focusedItem?.focus();\n focusedItem?.scrollIntoView({\n behavior: 'smooth',\n block: 'center',\n inline: 'center',\n });\n\n setActiveChipIndex(newActiveChipIndex);\n };\n\n return { handleInputKeydown, handleChipKeyDown, onChipClear, handleContentKeyDown } as const;\n};\n"],"names":["Keys","Enter","Tab","Escape","ArrowLeft","ArrowRight","Backspace","useKeyNavigation","_ref","_ref$controlledRefs","controlledRefs","chipsRefs","contentRef","inputRef","disabled","readOnly","chips","enumerationType","updateChips","onChange","onSearch","_useState","useState","_useState2","_slicedToArray","activeChipIndex","setActiveChipIndex","handleInputKeydown","event","_inputRef$current","_ref2","target","value","key","nextIndex","length","newChips","concat","_toConsumableArray","id","text","newValues","map","_ref3","current","selectionStart","pop","_ref4","onChipClear","clearId","filter","_ref5","chipId","_ref6","handleChipKeyDown","preventDefault","handleContentKeyDown","_inputRef$current2","_focusedItem","_focusedItem2","chipsRefsCount","currentCaretPosition","newActiveChipIndex","focusedItem","_chipsRefs$current","index","document","activeElement","_chipsRefs$current2","_chipsRefs$current3","focus","scrollIntoView","behavior","block","inline"],"mappings":";;;AAKO,IAAMA,IAAI,GAAG;AAChBC,EAAAA,KAAK,EAAE,OAAO;AACdC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,SAAS,EAAE,WAAW;AACtBC,EAAAA,UAAU,EAAE,YA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AAkB,CAACoC,kBAAkB,CAAC,CAAA;GACzC,CAAA;EAED,OAAO;AAAEnC,IAAAA,kBAAkB,EAAlBA,kBAAkB;AAAE2B,IAAAA,iBAAiB,EAAjBA,iBAAiB;AAAEN,IAAAA,WAAW,EAAXA,WAAW;AAAEQ,IAAAA,oBAAoB,EAApBA,oBAAAA;GAAsB,CAAA;AACvF;;;;"}
1
+ {"version":3,"file":"useKeyNavigation.js","sources":["../../../../src/components/TextField/hooks/useKeyNavigation.ts"],"sourcesContent":["import { useState } from 'react';\nimport type { ChangeEvent, KeyboardEvent } from 'react';\n\nimport type { UseKeyNavigationProps } from '../TextField.types';\n\nexport const Keys = {\n Enter: 'Enter',\n Tab: 'Tab',\n Escape: 'Escape',\n ArrowLeft: 'ArrowLeft',\n ArrowRight: 'ArrowRight',\n Backspace: 'Backspace',\n};\n\nexport const useKeyNavigation = ({\n controlledRefs: { chipsRefs, contentRef, inputRef },\n disabled,\n readOnly,\n chips,\n enumerationType,\n updateChips,\n onChange,\n onSearch,\n}: UseKeyNavigationProps) => {\n const [activeChipIndex, setActiveChipIndex] = useState(-1);\n\n const handleInputKeydown = (event: ChangeEvent<HTMLInputElement> & KeyboardEvent<HTMLInputElement>) => {\n const { value } = event.target as HTMLInputElement;\n\n if (disabled || readOnly) {\n return;\n }\n\n if (event.key === Keys.Enter && enumerationType === 'chip' && value) {\n const nextIndex = chips?.length || 0;\n\n const newChips = [...chips, { id: `${nextIndex}_${value}`, text: value }];\n const newValues = newChips.map(({ text }) => text);\n\n updateChips(newChips, newValues);\n event.target.value = '';\n onChange?.(event);\n }\n\n if (event.key === Keys.Enter && onSearch) {\n onSearch(value, event);\n }\n\n if (event.key === Keys.Backspace && chips.length && inputRef?.current?.selectionStart === 0) {\n const newChips = [...chips];\n newChips?.pop();\n chipsRefs?.current.pop();\n\n const newValues = newChips.map(({ text }) => text);\n\n updateChips(newChips, newValues);\n }\n };\n\n const onChipClear = (clearId: string, index: number) => {\n if (!chips.length) {\n return;\n }\n\n const newChips = chips?.filter(({ id: chipId }) => chipId !== clearId) || [];\n const newValues = newChips.map(({ text }) => text);\n chipsRefs?.current.splice(index, 1);\n\n updateChips(newChips, newValues);\n };\n\n const handleChipKeyDown = (event: KeyboardEvent<HTMLButtonElement>, chipId: string, chipIndex: number) => {\n if (event.key === Keys.Tab) {\n event.preventDefault();\n }\n\n if (event.key === Keys.Backspace) {\n onChipClear(chipId, chipIndex);\n }\n };\n\n const handleContentKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const chipsRefsCount = chipsRefs.current.length;\n const currentCaretPosition = inputRef?.current?.selectionStart || 0;\n\n let newActiveChipIndex = activeChipIndex;\n let focusedItem: HTMLButtonElement | HTMLInputElement | null = null;\n\n if (event.key === Keys.ArrowLeft && enumerationType === 'chip' && currentCaretPosition <= 0) {\n const index = activeChipIndex - 1 <= 0 ? 0 : activeChipIndex - 1;\n\n newActiveChipIndex = document.activeElement === inputRef?.current ? chipsRefsCount - 1 : index;\n\n focusedItem = chipsRefs.current?.[newActiveChipIndex];\n }\n\n if (\n event.key === Keys.ArrowRight &&\n enumerationType === 'chip' &&\n document.activeElement !== inputRef?.current\n ) {\n const index = activeChipIndex + 1 >= chipsRefsCount ? activeChipIndex : activeChipIndex + 1;\n\n newActiveChipIndex = document.activeElement === contentRef?.current ? 0 : index;\n focusedItem =\n index === activeChipIndex\n ? (inputRef?.current as HTMLInputElement)\n : chipsRefs.current?.[newActiveChipIndex];\n }\n\n if (event.key === Keys.Backspace && document.activeElement !== inputRef?.current) {\n const index = activeChipIndex - 1 <= 0 ? 0 : activeChipIndex - 1;\n\n newActiveChipIndex = chipsRefsCount === 0 ? -1 : index;\n focusedItem =\n chipsRefsCount === 0\n ? (inputRef?.current as HTMLInputElement)\n : chipsRefs?.current?.[newActiveChipIndex];\n }\n\n focusedItem?.focus();\n focusedItem?.scrollIntoView({\n behavior: 'smooth',\n block: 'center',\n inline: 'center',\n });\n\n setActiveChipIndex(newActiveChipIndex);\n };\n\n return { handleInputKeydown, handleChipKeyDown, onChipClear, handleContentKeyDown } as const;\n};\n"],"names":["Keys","Enter","Tab","Escape","ArrowLeft","ArrowRight","Backspace","useKeyNavigation","_ref","_ref$controlledRefs","controlledRefs","chipsRefs","contentRef","inputRef","disabled","readOnly","chips","enumerationType","updateChips","onChange","onSearch","_useState","useState","_useState2","_slicedToArray","activeChipIndex","setActiveChipIndex","handleInputKeydown","event","_inputRef$current","_ref2","target","value","key","nextIndex","length","newChips","concat","_toConsumableArray","id","text","newValues","map","_ref3","current","selectionStart","pop","_ref4","onChipClear","clearId","index","filter","_ref5","chipId","_ref6","splice","handleChipKeyDown","chipIndex","preventDefault","handleContentKeyDown","_inputRef$current2","_focusedItem","_focusedItem2","chipsRefsCount","currentCaretPosition","newActiveChipIndex","focusedItem","_chipsRefs$current","document","activeElement","_chipsRefs$current2","_chipsRefs$current3","focus","scrollIntoView","behavior","block","inline"],"mappings":";;;AAKO,IAAMA,IAAI,GAAG;AAChBC,EAAAA,KAAK,EAAE,OAAO;AACdC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,SAAS,EAAE,WAAW;AACtBC,EAAAA,UAAU,EAAE,YAAY;AACxBC,EAAAA,SAAS,EAAE,WAAA;AACf,EAAC;IAEYC,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAAC,IAAA,EASA;AAAA,EAAA,IAAAC,mBAAA,GAAAD,IAAA,CARzBE,cAAc;IAAIC,SAAS,GAAAF,mBAAA,CAATE,SAAS;IAAEC,UAAU,GAAAH,mBAAA,CAAVG,UAAU;IAAEC,QAAQ,GAAAJ,mBAAA,CAARI,QAAQ;IACjDC,QAAQ,GAAAN,IAAA,CAARM,QAAQ;IACRC,QAAQ,GAAAP,IAAA,CAARO,QAAQ;IACRC,KAAK,GAAAR,IAAA,CAALQ,KAAK;IACLC,eAAe,GAAAT,IAAA,CAAfS,eAAe;IACfC,WAAW,GAAAV,IAAA,CAAX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7 +5,7 @@ import { StyledChip } from './TextFieldChip.styles.js';
5
5
  * Чип, отображающий выбранный элемент
6
6
  */
7
7
  var TextFieldChip = /*#__PURE__*/forwardRef(function (_ref, ref) {
8
- var chipId = _ref.chipId,
8
+ var id = _ref.id,
9
9
  text = _ref.text,
10
10
  disabled = _ref.disabled,
11
11
  readOnly = _ref.readOnly,
@@ -13,10 +13,10 @@ var TextFieldChip = /*#__PURE__*/forwardRef(function (_ref, ref) {
13
13
  onClear = _ref.onClear,
14
14
  onKeyDown = _ref.onKeyDown;
15
15
  var onClearHandle = function onClearHandle() {
16
- return onClear(chipId);
16
+ return onClear(id);
17
17
  };
18
18
  var onKeyDownHandle = function onKeyDownHandle(event) {
19
- onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event, chipId);
19
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event, id);
20
20
  };
21
21
  return /*#__PURE__*/React.createElement(StyledChip, {
22
22
  ref: ref,
@@ -1 +1 @@
1
- {"version":3,"file":"TextFieldChip.js","sources":["../../../../../src/components/TextField/ui/TextFieldChip/TextFieldChip.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { StyledChip } from './TextFieldChip.styles';\nimport type { TextFieldChipProps } from './TextFieldChip.types';\n\n/**\n * Чип, отображающий выбранный элемент\n */\nexport const TextFieldChip = forwardRef<HTMLButtonElement, TextFieldChipProps>(\n ({ chipId, text, disabled, readOnly, onClick, onClear, onKeyDown }, ref) => {\n const onClearHandle = () => onClear(chipId);\n\n const onKeyDownHandle = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event, chipId);\n };\n\n return (\n <StyledChip\n ref={ref}\n tabIndex={-1}\n disabled={disabled}\n readOnly={readOnly}\n onClick={onClick}\n onClear={onClearHandle}\n onKeyDown={onKeyDownHandle}\n text={`${text}`}\n />\n );\n },\n);\n"],"names":["TextFieldChip","forwardRef","_ref","ref","chipId","text","disabled","readOnly","onClick","onClear","onKeyDown","onClearHandle","onKeyDownHandle","event","React","createElement","StyledChip","tabIndex","concat"],"mappings":";;;AAKA;AACA;AACA;AACO,IAAMA,aAAa,gBAAGC,UAAU,CACnC,UAAAC,IAAA,EAAoEC,GAAG,EAAK;AAAA,EAAA,IAAzEC,MAAM,GAAAF,IAAA,CAANE,MAAM;IAAEC,IAAI,GAAAH,IAAA,CAAJG,IAAI;IAAEC,QAAQ,GAAAJ,IAAA,CAARI,QAAQ;IAAEC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IAAEC,OAAO,GAAAN,IAAA,CAAPM,OAAO;IAAEC,OAAO,GAAAP,IAAA,CAAPO,OAAO;IAAEC,SAAS,GAAAR,IAAA,CAATQ,SAAS,CAAA;AAC5D,EAAA,IAAMC,aAAa,GAAG,SAAhBA,aAAaA,GAAA;IAAA,OAASF,OAAO,CAACL,MAAM,CAAC,CAAA;AAAA,GAAA,CAAA;AAE3C,EAAA,IAAMQ,eAAe,GAAG,SAAlBA,eAAeA,CAAIC,KAA6C,EAAK;IACvEH,SAAS,KAAA,IAAA,IAATA,SAAS,KAATA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,SAAS,CAAGG,KAAK,EAAET,MAAM,CAAC,CAAA;GAC7B,CAAA;AAED,EAAA,oBACIU,KAAA,CAAAC,aAAA,CAACC,UAAU,EAAA;AACPb,IAAAA,GAAG,EAAEA,GAAI;IACTc,QAAQ,EAAE,CAAC,CAAE;AACbX,IAAAA,QAAQ,EAAEA,QAAS;AACnBC,IAAAA,QAAQ,EAAEA,QAAS;AACnBC,IAAAA,OAAO,EAAEA,OAAQ;AACjBC,IAAAA,OAAO,EAAEE,aAAc;AACvBD,IAAAA,SAAS,EAAEE,eAAgB;IAC3BP,IAAI,EAAA,EAAA,CAAAa,MAAA,CAAKb,IAAI,CAAA;AAAG,GACnB,CAAC,CAAA;AAEV,CACJ;;;;"}
1
+ {"version":3,"file":"TextFieldChip.js","sources":["../../../../../src/components/TextField/ui/TextFieldChip/TextFieldChip.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { StyledChip } from './TextFieldChip.styles';\nimport type { TextFieldChipProps } from './TextFieldChip.types';\n\n/**\n * Чип, отображающий выбранный элемент\n */\nexport const TextFieldChip = forwardRef<HTMLButtonElement, TextFieldChipProps>(\n ({ id, text, disabled, readOnly, onClick, onClear, onKeyDown }, ref) => {\n const onClearHandle = () => onClear(id);\n\n const onKeyDownHandle = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event, id);\n };\n\n return (\n <StyledChip\n ref={ref}\n tabIndex={-1}\n disabled={disabled}\n readOnly={readOnly}\n onClick={onClick}\n onClear={onClearHandle}\n onKeyDown={onKeyDownHandle}\n text={`${text}`}\n />\n );\n },\n);\n"],"names":["TextFieldChip","forwardRef","_ref","ref","id","text","disabled","readOnly","onClick","onClear","onKeyDown","onClearHandle","onKeyDownHandle","event","React","createElement","StyledChip","tabIndex","concat"],"mappings":";;;AAKA;AACA;AACA;AACO,IAAMA,aAAa,gBAAGC,UAAU,CACnC,UAAAC,IAAA,EAAgEC,GAAG,EAAK;AAAA,EAAA,IAArEC,EAAE,GAAAF,IAAA,CAAFE,EAAE;IAAEC,IAAI,GAAAH,IAAA,CAAJG,IAAI;IAAEC,QAAQ,GAAAJ,IAAA,CAARI,QAAQ;IAAEC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IAAEC,OAAO,GAAAN,IAAA,CAAPM,OAAO;IAAEC,OAAO,GAAAP,IAAA,CAAPO,OAAO;IAAEC,SAAS,GAAAR,IAAA,CAATQ,SAAS,CAAA;AACxD,EAAA,IAAMC,aAAa,GAAG,SAAhBA,aAAaA,GAAA;IAAA,OAASF,OAAO,CAACL,EAAE,CAAC,CAAA;AAAA,GAAA,CAAA;AAEvC,EAAA,IAAMQ,eAAe,GAAG,SAAlBA,eAAeA,CAAIC,KAA6C,EAAK;IACvEH,SAAS,KAAA,IAAA,IAATA,SAAS,KAATA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,SAAS,CAAGG,KAAK,EAAET,EAAE,CAAC,CAAA;GACzB,CAAA;AAED,EAAA,oBACIU,KAAA,CAAAC,aAAA,CAACC,UAAU,EAAA;AACPb,IAAAA,GAAG,EAAEA,GAAI;IACTc,QAAQ,EAAE,CAAC,CAAE;AACbX,IAAAA,QAAQ,EAAEA,QAAS;AACnBC,IAAAA,QAAQ,EAAEA,QAAS;AACnBC,IAAAA,OAAO,EAAEA,OAAQ;AACjBC,IAAAA,OAAO,EAAEE,aAAc;AACvBD,IAAAA,SAAS,EAAEE,eAAgB;IAC3BP,IAAI,EAAA,EAAA,CAAAa,MAAA,CAAKb,IAAI,CAAA;AAAG,GACnB,CAAC,CAAA;AAEV,CACJ;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salutejs/plasma-new-hope",
3
- "version": "0.72.0-canary.1160.8612911363.0",
3
+ "version": "0.72.0-canary.1160.8617165473.0",
4
4
  "description": "Salute Design System blueprint",
5
5
  "main": "cjs/index.js",
6
6
  "module": "es/index.js",
@@ -102,5 +102,5 @@
102
102
  "react-popper": "2.3.0",
103
103
  "storeon": "3.1.5"
104
104
  },
105
- "gitHead": "2c219b5bc21124b0c826daf43a79feef2c7e90bd"
105
+ "gitHead": "0f6737ab306b99e594de14d4206547354d7295f6"
106
106
  }
@@ -33,6 +33,8 @@ var cellRoot = exports.cellRoot = function cellRoot(Root) {
33
33
  _ref$stretching = _ref.stretching,
34
34
  stretching = _ref$stretching === void 0 ? 'filled' : _ref$stretching;
35
35
  var stretchingClass = _Cell2.classes["".concat(stretching, "Stretching")];
36
+
37
+ // Импорт старых свойств
36
38
  var titleText = title || description;
37
39
  var contentLeftDeprecated = contentLeft || content;
38
40
  return /*#__PURE__*/_react["default"].createElement(Root, {
@@ -18,7 +18,7 @@ var _TextField = /*#__PURE__*/require("./TextField.styles");
18
18
  var _TextField2 = /*#__PURE__*/require("./TextField.tokens");
19
19
  var _ui = /*#__PURE__*/require("./ui");
20
20
  var _useKeyNavigation2 = /*#__PURE__*/require("./hooks/useKeyNavigation");
21
- var _excluded = ["id", "contentLeft", "contentRight", "label", "labelPlacement", "placeholder", "leftHelper", "enumerationType", "view", "size", "readOnly", "disabled", "values", "onChange", "onChangeChips", "onSearch"];
21
+ var _excluded = ["id", "contentLeft", "contentRight", "label", "labelPlacement", "placeholder", "leftHelper", "enumerationType", "view", "size", "readOnly", "disabled", "chips", "onChange", "onChangeChips", "onSearch"];
22
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); }
23
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; }
24
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); }
@@ -48,7 +48,7 @@ var textFieldRoot = exports.textFieldRoot = function textFieldRoot(Root) {
48
48
  readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
49
49
  _ref$disabled = _ref.disabled,
50
50
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
51
- values = _ref.values,
51
+ values = _ref.chips,
52
52
  onChange = _ref.onChange,
53
53
  onChangeChips = _ref.onChangeChips,
54
54
  onSearch = _ref.onSearch,
@@ -164,20 +164,20 @@ var textFieldRoot = exports.textFieldRoot = function textFieldRoot(Root) {
164
164
  var chipId = _ref2.id,
165
165
  text = _ref2.text;
166
166
  return /*#__PURE__*/_react["default"].createElement(_ui.TextFieldChip, {
167
+ id: chipId,
167
168
  ref: function ref(element) {
168
169
  return getRef(element, index);
169
170
  },
170
- chipId: chipId,
171
171
  key: "".concat(chipId, "_").concat(index),
172
172
  disabled: disabled,
173
173
  readOnly: readOnly,
174
174
  value: text,
175
175
  text: text,
176
176
  onKeyDown: function onKeyDown(event) {
177
- return handleChipKeyDown(event, chipId);
177
+ return handleChipKeyDown(event, chipId, index);
178
178
  },
179
179
  onClear: function onClear() {
180
- return onChipClear(chipId);
180
+ return onChipClear(chipId, index);
181
181
  },
182
182
  onClick: onChipClick
183
183
  });
@@ -74,7 +74,7 @@ var useKeyNavigation = exports.useKeyNavigation = function useKeyNavigation(_ref
74
74
  updateChips(_newChips, _newValues);
75
75
  }
76
76
  };
77
- var onChipClear = function onChipClear(clearId) {
77
+ var onChipClear = function onChipClear(clearId, index) {
78
78
  if (!chips.length) {
79
79
  return;
80
80
  }
@@ -86,19 +86,20 @@ var useKeyNavigation = exports.useKeyNavigation = function useKeyNavigation(_ref
86
86
  var text = _ref6.text;
87
87
  return text;
88
88
  });
89
+ chipsRefs === null || chipsRefs === void 0 ? void 0 : chipsRefs.current.splice(index, 1);
89
90
  updateChips(newChips, newValues);
90
91
  };
91
- var handleChipKeyDown = function handleChipKeyDown(event, chipId) {
92
+ var handleChipKeyDown = function handleChipKeyDown(event, chipId, chipIndex) {
92
93
  if (event.key === Keys.Tab) {
93
94
  event.preventDefault();
94
95
  }
95
96
  if (event.key === Keys.Backspace) {
96
- onChipClear(chipId);
97
+ onChipClear(chipId, chipIndex);
97
98
  }
98
99
  };
99
100
  var handleContentKeyDown = function handleContentKeyDown(event) {
100
101
  var _inputRef$current2, _focusedItem, _focusedItem2;
101
- var chipsRefsCount = chips.length;
102
+ var chipsRefsCount = chipsRefs.current.length;
102
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;
103
104
  var newActiveChipIndex = activeChipIndex;
104
105
  var focusedItem = null;
@@ -13,7 +13,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
13
13
  * Чип, отображающий выбранный элемент
14
14
  */
15
15
  var TextFieldChip = exports.TextFieldChip = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
16
- var chipId = _ref.chipId,
16
+ var id = _ref.id,
17
17
  text = _ref.text,
18
18
  disabled = _ref.disabled,
19
19
  readOnly = _ref.readOnly,
@@ -21,10 +21,10 @@ var TextFieldChip = exports.TextFieldChip = /*#__PURE__*/(0, _react.forwardRef)(
21
21
  onClear = _ref.onClear,
22
22
  onKeyDown = _ref.onKeyDown;
23
23
  var onClearHandle = function onClearHandle() {
24
- return onClear(chipId);
24
+ return onClear(id);
25
25
  };
26
26
  var onKeyDownHandle = function onKeyDownHandle(event) {
27
- onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event, chipId);
27
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event, id);
28
28
  };
29
29
  return /*#__PURE__*/_react["default"].createElement(_TextFieldChip.StyledChip, {
30
30
  ref: ref,
@@ -11,10 +11,10 @@ const onChange = action('onChange');
11
11
  const onFocus = action('onFocus');
12
12
  const onBlur = action('onBlur');
13
13
  const onSearch = action('onSearch');
14
+ const onChipsChange = action('onChipsChange');
14
15
 
15
16
  const sizes = ['l', 'm', 's', 'xs'];
16
17
  const views = ['default', 'positive', 'warning', 'negative'];
17
- const enumerationTypes = ['plain', 'chip'];
18
18
  const labelPlacements = ['outer', 'inner'];
19
19
 
20
20
  const meta: Meta<typeof TextField> = {
@@ -39,12 +39,6 @@ const meta: Meta<typeof TextField> = {
39
39
  type: 'inline-radio',
40
40
  },
41
41
  },
42
- enumerationType: {
43
- options: enumerationTypes,
44
- control: {
45
- type: 'select',
46
- },
47
- },
48
42
  size: {
49
43
  options: sizes,
50
44
  control: {
@@ -72,6 +66,9 @@ type StoryPropsDefault = Omit<
72
66
  | 'maxLength'
73
67
  | 'minLength'
74
68
  | 'required'
69
+ | 'enumerationType'
70
+ | 'chips'
71
+ | 'onChangeChips'
75
72
  > & {
76
73
  'storybook:contentLeft': boolean;
77
74
  'storybook:contentRight': boolean;
@@ -90,6 +87,7 @@ const StoryDemo = ({
90
87
  return (
91
88
  <TextField
92
89
  {...rest}
90
+ enumerationType="plain"
93
91
  value={text}
94
92
  contentLeft={enableContentLeft ? <IconPlaceholder size={iconSize} /> : undefined}
95
93
  contentRight={enableContentRight ? <IconPlaceholder size={iconSize} /> : undefined}
@@ -114,7 +112,6 @@ export const Default: StoryObj<StoryPropsDefault> = {
114
112
  labelPlacement: 'outer',
115
113
  placeholder: 'Заполните поле',
116
114
  leftHelper: 'Подсказка к полю',
117
- enumerationType: 'plain',
118
115
  disabled: false,
119
116
  readOnly: false,
120
117
  'storybook:contentLeft': true,
@@ -123,11 +120,62 @@ export const Default: StoryObj<StoryPropsDefault> = {
123
120
  render: (args) => <StoryDemo {...args} />,
124
121
  };
125
122
 
126
- export const Chips: StoryObj<StoryPropsDefault> = {
123
+ type StoryPropsChips = Omit<
124
+ ComponentProps<typeof TextField>,
125
+ | 'helperBlock'
126
+ | 'contentLeft'
127
+ | 'htmlSize'
128
+ | 'contentRight'
129
+ | 'type'
130
+ | 'name'
131
+ | 'onFocus'
132
+ | 'onBlur'
133
+ | 'onChange'
134
+ | 'onSearch'
135
+ | 'value'
136
+ | 'checked'
137
+ | 'maxLength'
138
+ | 'minLength'
139
+ | 'required'
140
+ | 'enumerationType'
141
+ > & {
142
+ 'storybook:contentLeft': boolean;
143
+ 'storybook:contentRight': boolean;
144
+ };
145
+
146
+ const StoryChips = ({
147
+ 'storybook:contentLeft': enableContentLeft,
148
+ 'storybook:contentRight': enableContentRight,
149
+ view,
150
+ ...rest
151
+ }: StoryPropsChips) => {
152
+ const [text, setText] = useState('Значение поля');
153
+
154
+ const iconSize = rest.size === 'xs' ? 'xs' : 's';
155
+
156
+ return (
157
+ <TextField
158
+ {...rest}
159
+ enumerationType="chip"
160
+ value={text}
161
+ contentLeft={enableContentLeft ? <IconPlaceholder size={iconSize} /> : undefined}
162
+ contentRight={enableContentRight ? <IconPlaceholder size={iconSize} /> : undefined}
163
+ view={view}
164
+ onChange={(e) => {
165
+ setText(e.target.value);
166
+ onChange(e.target.value);
167
+ }}
168
+ onFocus={onFocus}
169
+ onBlur={onBlur}
170
+ onChangeChips={onChipsChange}
171
+ />
172
+ );
173
+ };
174
+
175
+ export const Chips: StoryObj<StoryPropsChips> = {
127
176
  args: {
128
177
  ...Default.args,
129
- enumerationType: 'chip',
130
- values: ['1 value', '2 value', '3 value', '4 value'],
178
+ chips: ['1 value', '2 value', '3 value', '4 value'],
131
179
  },
132
- render: (args) => <StoryDemo {...args} />,
180
+ render: (args) => <StoryChips {...args} />,
133
181
  };
@@ -11,10 +11,10 @@ const onChange = action('onChange');
11
11
  const onFocus = action('onFocus');
12
12
  const onBlur = action('onBlur');
13
13
  const onSearch = action('onSearch');
14
+ const onChipsChange = action('onChipsChange');
14
15
 
15
16
  const sizes = ['l', 'm', 's', 'xs'];
16
17
  const views = ['default', 'positive', 'warning', 'negative'];
17
- const enumerationTypes = ['plain', 'chip'];
18
18
  const labelPlacements = ['outer', 'inner'];
19
19
 
20
20
  const meta: Meta<typeof TextField> = {
@@ -39,12 +39,6 @@ const meta: Meta<typeof TextField> = {
39
39
  type: 'inline-radio',
40
40
  },
41
41
  },
42
- enumerationType: {
43
- options: enumerationTypes,
44
- control: {
45
- type: 'select',
46
- },
47
- },
48
42
  size: {
49
43
  options: sizes,
50
44
  control: {
@@ -72,6 +66,9 @@ type StoryPropsDefault = Omit<
72
66
  | 'maxLength'
73
67
  | 'minLength'
74
68
  | 'required'
69
+ | 'enumerationType'
70
+ | 'chips'
71
+ | 'onChangeChips'
75
72
  > & {
76
73
  'storybook:contentLeft': boolean;
77
74
  'storybook:contentRight': boolean;
@@ -90,6 +87,7 @@ const StoryDemo = ({
90
87
  return (
91
88
  <TextField
92
89
  {...rest}
90
+ enumerationType="plain"
93
91
  value={text}
94
92
  contentLeft={enableContentLeft ? <IconPlaceholder size={iconSize} /> : undefined}
95
93
  contentRight={enableContentRight ? <IconPlaceholder size={iconSize} /> : undefined}
@@ -114,7 +112,6 @@ export const Default: StoryObj<StoryPropsDefault> = {
114
112
  labelPlacement: 'outer',
115
113
  placeholder: 'Заполните поле',
116
114
  leftHelper: 'Подсказка к полю',
117
- enumerationType: 'plain',
118
115
  disabled: false,
119
116
  readOnly: false,
120
117
  'storybook:contentLeft': true,
@@ -123,11 +120,62 @@ export const Default: StoryObj<StoryPropsDefault> = {
123
120
  render: (args) => <StoryDemo {...args} />,
124
121
  };
125
122
 
126
- export const Chips: StoryObj<StoryPropsDefault> = {
123
+ type StoryPropsChips = Omit<
124
+ ComponentProps<typeof TextField>,
125
+ | 'helperBlock'
126
+ | 'contentLeft'
127
+ | 'htmlSize'
128
+ | 'contentRight'
129
+ | 'type'
130
+ | 'name'
131
+ | 'onFocus'
132
+ | 'onBlur'
133
+ | 'onChange'
134
+ | 'onSearch'
135
+ | 'value'
136
+ | 'checked'
137
+ | 'maxLength'
138
+ | 'minLength'
139
+ | 'required'
140
+ | 'enumerationType'
141
+ > & {
142
+ 'storybook:contentLeft': boolean;
143
+ 'storybook:contentRight': boolean;
144
+ };
145
+
146
+ const StoryChips = ({
147
+ 'storybook:contentLeft': enableContentLeft,
148
+ 'storybook:contentRight': enableContentRight,
149
+ view,
150
+ ...rest
151
+ }: StoryPropsChips) => {
152
+ const [text, setText] = useState('Значение поля');
153
+
154
+ const iconSize = rest.size === 'xs' ? 'xs' : 's';
155
+
156
+ return (
157
+ <TextField
158
+ {...rest}
159
+ enumerationType="chip"
160
+ value={text}
161
+ contentLeft={enableContentLeft ? <IconPlaceholder size={iconSize} /> : undefined}
162
+ contentRight={enableContentRight ? <IconPlaceholder size={iconSize} /> : undefined}
163
+ view={view}
164
+ onChange={(e) => {
165
+ setText(e.target.value);
166
+ onChange(e.target.value);
167
+ }}
168
+ onFocus={onFocus}
169
+ onBlur={onBlur}
170
+ onChangeChips={onChipsChange}
171
+ />
172
+ );
173
+ };
174
+
175
+ export const Chips: StoryObj<StoryPropsChips> = {
127
176
  args: {
128
177
  ...Default.args,
129
- enumerationType: 'chip',
130
- values: ['1 value', '2 value', '3 value', '4 value'],
178
+ chips: ['1 value', '2 value', '3 value', '4 value'],
131
179
  },
132
- render: (args) => <StoryDemo {...args} />,
180
+ render: (args) => <StoryChips {...args} />,
133
181
  };
@@ -11,10 +11,10 @@ const onChange = action('onChange');
11
11
  const onFocus = action('onFocus');
12
12
  const onBlur = action('onBlur');
13
13
  const onSearch = action('onSearch');
14
+ const onChipsChange = action('onChipsChange');
14
15
 
15
16
  const sizes = ['l', 'm', 's', 'xs'];
16
17
  const views = ['default', 'positive', 'warning', 'negative'];
17
- const enumerationTypes = ['plain', 'chip'];
18
18
  const labelPlacements = ['outer', 'inner'];
19
19
 
20
20
  const meta: Meta<typeof TextField> = {
@@ -39,12 +39,6 @@ const meta: Meta<typeof TextField> = {
39
39
  type: 'inline-radio',
40
40
  },
41
41
  },
42
- enumerationType: {
43
- options: enumerationTypes,
44
- control: {
45
- type: 'select',
46
- },
47
- },
48
42
  size: {
49
43
  options: sizes,
50
44
  control: {
@@ -72,6 +66,9 @@ type StoryPropsDefault = Omit<
72
66
  | 'maxLength'
73
67
  | 'minLength'
74
68
  | 'required'
69
+ | 'enumerationType'
70
+ | 'chips'
71
+ | 'onChangeChips'
75
72
  > & {
76
73
  'storybook:contentLeft': boolean;
77
74
  'storybook:contentRight': boolean;
@@ -90,6 +87,7 @@ const StoryDemo = ({
90
87
  return (
91
88
  <TextField
92
89
  {...rest}
90
+ enumerationType="plain"
93
91
  value={text}
94
92
  contentLeft={enableContentLeft ? <IconPlaceholder size={iconSize} /> : undefined}
95
93
  contentRight={enableContentRight ? <IconPlaceholder size={iconSize} /> : undefined}
@@ -114,7 +112,6 @@ export const Default: StoryObj<StoryPropsDefault> = {
114
112
  labelPlacement: 'outer',
115
113
  placeholder: 'Заполните поле',
116
114
  leftHelper: 'Подсказка к полю',
117
- enumerationType: 'plain',
118
115
  disabled: false,
119
116
  readOnly: false,
120
117
  'storybook:contentLeft': true,
@@ -123,11 +120,62 @@ export const Default: StoryObj<StoryPropsDefault> = {
123
120
  render: (args) => <StoryDemo {...args} />,
124
121
  };
125
122
 
126
- export const Chips: StoryObj<StoryPropsDefault> = {
123
+ type StoryPropsChips = Omit<
124
+ ComponentProps<typeof TextField>,
125
+ | 'helperBlock'
126
+ | 'contentLeft'
127
+ | 'htmlSize'
128
+ | 'contentRight'
129
+ | 'type'
130
+ | 'name'
131
+ | 'onFocus'
132
+ | 'onBlur'
133
+ | 'onChange'
134
+ | 'onSearch'
135
+ | 'value'
136
+ | 'checked'
137
+ | 'maxLength'
138
+ | 'minLength'
139
+ | 'required'
140
+ | 'enumerationType'
141
+ > & {
142
+ 'storybook:contentLeft': boolean;
143
+ 'storybook:contentRight': boolean;
144
+ };
145
+
146
+ const StoryChips = ({
147
+ 'storybook:contentLeft': enableContentLeft,
148
+ 'storybook:contentRight': enableContentRight,
149
+ view,
150
+ ...rest
151
+ }: StoryPropsChips) => {
152
+ const [text, setText] = useState('Значение поля');
153
+
154
+ const iconSize = rest.size === 'xs' ? 'xs' : 's';
155
+
156
+ return (
157
+ <TextField
158
+ {...rest}
159
+ enumerationType="chip"
160
+ value={text}
161
+ contentLeft={enableContentLeft ? <IconPlaceholder size={iconSize} /> : undefined}
162
+ contentRight={enableContentRight ? <IconPlaceholder size={iconSize} /> : undefined}
163
+ view={view}
164
+ onChange={(e) => {
165
+ setText(e.target.value);
166
+ onChange(e.target.value);
167
+ }}
168
+ onFocus={onFocus}
169
+ onBlur={onBlur}
170
+ onChangeChips={onChipsChange}
171
+ />
172
+ );
173
+ };
174
+
175
+ export const Chips: StoryObj<StoryPropsChips> = {
127
176
  args: {
128
177
  ...Default.args,
129
- enumerationType: 'chip',
130
- values: ['1 value', '2 value', '3 value', '4 value'],
178
+ chips: ['1 value', '2 value', '3 value', '4 value'],
131
179
  },
132
- render: (args) => <StoryDemo {...args} />,
180
+ render: (args) => <StoryChips {...args} />,
133
181
  };
@@ -24,6 +24,8 @@ export var cellRoot = function cellRoot(Root) {
24
24
  _ref$stretching = _ref.stretching,
25
25
  stretching = _ref$stretching === void 0 ? 'filled' : _ref$stretching;
26
26
  var stretchingClass = classes["".concat(stretching, "Stretching")];
27
+
28
+ // Импорт старых свойств
27
29
  var titleText = title || description;
28
30
  var contentLeftDeprecated = contentLeft || content;
29
31
  return /*#__PURE__*/React.createElement(Root, {
@@ -1,4 +1,4 @@
1
- var _excluded = ["id", "contentLeft", "contentRight", "label", "labelPlacement", "placeholder", "leftHelper", "enumerationType", "view", "size", "readOnly", "disabled", "values", "onChange", "onChangeChips", "onSearch"];
1
+ var _excluded = ["id", "contentLeft", "contentRight", "label", "labelPlacement", "placeholder", "leftHelper", "enumerationType", "view", "size", "readOnly", "disabled", "chips", "onChange", "onChangeChips", "onSearch"];
2
2
  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); }
3
3
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
4
  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."); }
@@ -39,7 +39,7 @@ export var textFieldRoot = function textFieldRoot(Root) {
39
39
  readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
40
40
  _ref$disabled = _ref.disabled,
41
41
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
42
- values = _ref.values,
42
+ values = _ref.chips,
43
43
  onChange = _ref.onChange,
44
44
  onChangeChips = _ref.onChangeChips,
45
45
  onSearch = _ref.onSearch,
@@ -155,20 +155,20 @@ export var textFieldRoot = function textFieldRoot(Root) {
155
155
  var chipId = _ref2.id,
156
156
  text = _ref2.text;
157
157
  return /*#__PURE__*/React.createElement(TextFieldChip, {
158
+ id: chipId,
158
159
  ref: function ref(element) {
159
160
  return getRef(element, index);
160
161
  },
161
- chipId: chipId,
162
162
  key: "".concat(chipId, "_").concat(index),
163
163
  disabled: disabled,
164
164
  readOnly: readOnly,
165
165
  value: text,
166
166
  text: text,
167
167
  onKeyDown: function onKeyDown(event) {
168
- return handleChipKeyDown(event, chipId);
168
+ return handleChipKeyDown(event, chipId, index);
169
169
  },
170
170
  onClear: function onClear() {
171
- return onChipClear(chipId);
171
+ return onChipClear(chipId, index);
172
172
  },
173
173
  onClick: onChipClick
174
174
  });