@consta/uikit 5.1.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__internal__/src/components/Chips/Chips.js +1 -1
- package/__internal__/src/components/Chips/Chips.js.map +1 -1
- package/__internal__/src/components/Chips/ChipsChoice/ChipsChoice.js +1 -1
- package/__internal__/src/components/Chips/ChipsChoice/ChipsChoice.js.map +1 -1
- package/__internal__/src/components/Chips/ChipsChoice/types.d.ts +1 -0
- package/__internal__/src/components/Chips/ChipsChoice/types.js.map +1 -1
- package/__internal__/src/components/Chips/ChipsItem/ChipsItem.css +2 -2
- package/__internal__/src/components/Chips/ChipsItem/ChipsItem.js +1 -1
- package/__internal__/src/components/Chips/ChipsItem/ChipsItem.js.map +1 -1
- package/__internal__/src/components/Chips/helpers.d.ts +6 -2
- package/__internal__/src/components/Chips/helpers.js +1 -1
- package/__internal__/src/components/Chips/helpers.js.map +1 -1
- package/__internal__/src/components/Chips/types.d.ts +4 -0
- package/__internal__/src/components/Chips/types.js.map +1 -1
- package/__internal__/src/components/ChoiceGroup/ChoiceGroup.js +1 -1
- package/__internal__/src/components/ChoiceGroup/ChoiceGroup.js.map +1 -1
- package/__internal__/src/components/ChoiceGroup/Item/ChoiceGroup-Item.js +1 -1
- package/__internal__/src/components/ChoiceGroup/Item/ChoiceGroup-Item.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDate/DatePickerFieldTypeDate.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDate/DatePickerFieldTypeDate.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDate/helpers.d.ts +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDate/helpers.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDate/helpers.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTime/DatePickerFieldTypeDateTime.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTime/DatePickerFieldTypeDateTime.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTime/helpers.d.ts +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTime/helpers.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTime/helpers.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonth/DatePickerFieldTypeMonth.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonth/DatePickerFieldTypeMonth.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonth/helpers.d.ts +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonth/helpers.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonth/helpers.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeTime/DatePickerFieldTypeTime.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeTime/DatePickerFieldTypeTime.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeTime/helpers.d.ts +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeTime/helpers.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeTime/helpers.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeYear/DatePickerFieldTypeYear.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeYear/DatePickerFieldTypeYear.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeYear/helpers.d.ts +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeYear/helpers.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeYear/helpers.js.map +1 -1
- package/__internal__/src/components/DatePicker/helpers.d.ts +7 -1
- package/__internal__/src/components/DatePicker/helpers.js +1 -1
- package/__internal__/src/components/DatePicker/helpers.js.map +1 -1
- package/__internal__/src/components/Slider/useSlider/helper.d.ts +1 -0
- package/__internal__/src/components/Slider/useSlider/helper.js +1 -1
- package/__internal__/src/components/Slider/useSlider/helper.js.map +1 -1
- package/__internal__/src/components/Slider/useSlider/useSlider.js +1 -1
- package/__internal__/src/components/Slider/useSlider/useSlider.js.map +1 -1
- package/__internal__/src/components/Spoiler/Spoiler.js +1 -1
- package/__internal__/src/components/Spoiler/Spoiler.js.map +1 -1
- package/__internal__/src/components/Spoiler/types.d.ts +2 -0
- package/__internal__/src/components/Spoiler/types.js.map +1 -1
- package/__internal__/src/components/Switch/Switch.css +1 -1
- package/__internal__/src/components/TextField/TextField.js +1 -1
- package/__internal__/src/components/TextField/TextField.js.map +1 -1
- package/__internal__/src/components/TextField/types.d.ts +1 -0
- package/__internal__/src/components/TextField/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["items","getItemActive","getItemAs","getItemAttributes","getItemIconLeft","getItemIconRight","getItemLabel","getItemRef","getItemStatus","className","interactive","onItemClick","onItemRightIconClick","activeView","size"];import"./Chips.css";import React,{forwardRef}from"react";import{cn}from"../../utils/bem";import{ChipsItem}from"./ChipsItem";import{withDefaultGetters}from"./helpers";var cnChips=cn("Chips"),ChipsRender=function(a,b){var c=withDefaultGetters(a),d=c.items,e=c.getItemActive,f=c.
|
|
1
|
+
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["items","getItemActive","getItemDisabled","getItemAs","getItemAttributes","getItemIconLeft","getItemIconRight","getItemLabel","getItemRef","getItemStatus","className","interactive","onItemClick","onItemRightIconClick","activeView","size","disabled"];import"./Chips.css";import React,{forwardRef}from"react";import{cn}from"../../utils/bem";import{ChipsItem}from"./ChipsItem";import{withDefaultGetters}from"./helpers";var cnChips=cn("Chips"),ChipsRender=function(a,b){var c=withDefaultGetters(a),d=c.items,e=c.getItemActive,f=c.getItemDisabled,g=c.getItemAs,h=c.getItemAttributes,i=c.getItemIconLeft,j=c.getItemIconRight,k=c.getItemLabel,l=c.getItemRef,m=c.getItemStatus,n=c.className,o=c.interactive,p=c.onItemClick,q=c.onItemRightIconClick,r=c.activeView,s=c.size,t=c.disabled,u=_objectWithoutProperties(c,_excluded);return React.createElement("div",Object.assign({},u,{ref:b,className:cnChips(null,[n])}),d.map(function(a,b){var c=f(a)||void 0!==t&&t;return React.createElement(ChipsItem,Object.assign({},h(a),{key:b,size:s,activeView:r,onClick:p&&!c?function(b){return p(a,{e:b})}:void 0,onRightIconClick:q&&c?function(b){return q(a,{e:b})}:void 0,label:k(a),as:g(a),active:e(a),iconLeft:i(a),iconRight:j(a),ref:l(a),status:m(a),interactive:!c&&o,disabled:c}))}))};export var Chips=forwardRef(ChipsRender);
|
|
2
2
|
//# sourceMappingURL=Chips.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chips.js","names":["React","forwardRef","cn","ChipsItem","withDefaultGetters","cnChips","ChipsRender","props","ref","items","getItemActive","getItemAs","getItemAttributes","getItemIconLeft","getItemIconRight","getItemLabel","getItemRef","getItemStatus","className","interactive","onItemClick","onItemRightIconClick","activeView","size","otherProps","map","item","index","e","Chips"],"sources":["../../../../../src/components/Chips/Chips.tsx"],"sourcesContent":["import './Chips.css';\n\nimport React, { forwardRef } from 'react';\n\nimport { cn } from '##/utils/bem';\n\nimport { ChipsItem } from './ChipsItem';\nimport { withDefaultGetters } from './helpers';\nimport { ChipsComponent, ChipsProps } from './types';\n\nconst cnChips = cn('Chips');\n\nconst ChipsRender = (props: ChipsProps, ref: React.Ref<HTMLDivElement>) => {\n const {\n items,\n getItemActive,\n getItemAs,\n getItemAttributes,\n getItemIconLeft,\n getItemIconRight,\n getItemLabel,\n getItemRef,\n getItemStatus,\n className,\n interactive,\n onItemClick,\n onItemRightIconClick,\n activeView,\n size,\n ...otherProps\n } = withDefaultGetters(props);\n\n return (\n <div {...otherProps} ref={ref} className={cnChips(null, [className])}>\n {items.map((item, index) => {\n return (\n <ChipsItem\n {...getItemAttributes(item)}\n key={index}\n size={size}\n activeView={activeView}\n onClick={\n onItemClick\n ? (e: React.MouseEvent) => onItemClick(item, { e })\n : undefined\n }\n onRightIconClick={\n onItemRightIconClick\n ? (e: React.MouseEvent) => onItemRightIconClick(item, { e })\n : undefined\n }\n label={getItemLabel(item)}\n as={getItemAs(item)}\n active={getItemActive(item)}\n iconLeft={getItemIconLeft(item)}\n iconRight={getItemIconRight(item)}\n ref={getItemRef(item)}\n status={getItemStatus(item)}\n interactive={interactive}\n />\n );\n })}\n </div>\n );\n};\n\nexport const Chips = forwardRef(ChipsRender) as ChipsComponent;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Chips.js","names":["React","forwardRef","cn","ChipsItem","withDefaultGetters","cnChips","ChipsRender","props","ref","items","getItemActive","getItemDisabled","getItemAs","getItemAttributes","getItemIconLeft","getItemIconRight","getItemLabel","getItemRef","getItemStatus","className","interactive","onItemClick","onItemRightIconClick","activeView","size","disabled","otherProps","map","item","index","itemDisabled","e","Chips"],"sources":["../../../../../src/components/Chips/Chips.tsx"],"sourcesContent":["import './Chips.css';\n\nimport React, { forwardRef } from 'react';\n\nimport { cn } from '##/utils/bem';\n\nimport { ChipsItem } from './ChipsItem';\nimport { withDefaultGetters } from './helpers';\nimport { ChipsComponent, ChipsProps } from './types';\n\nconst cnChips = cn('Chips');\n\nconst ChipsRender = (props: ChipsProps, ref: React.Ref<HTMLDivElement>) => {\n const {\n items,\n getItemActive,\n getItemDisabled,\n getItemAs,\n getItemAttributes,\n getItemIconLeft,\n getItemIconRight,\n getItemLabel,\n getItemRef,\n getItemStatus,\n className,\n interactive,\n onItemClick,\n onItemRightIconClick,\n activeView,\n size,\n disabled = false,\n ...otherProps\n } = withDefaultGetters(props);\n\n return (\n <div {...otherProps} ref={ref} className={cnChips(null, [className])}>\n {items.map((item, index) => {\n const itemDisabled = getItemDisabled(item) || disabled;\n return (\n <ChipsItem\n {...getItemAttributes(item)}\n key={index}\n size={size}\n activeView={activeView}\n onClick={\n onItemClick && !itemDisabled\n ? (e: React.MouseEvent) => onItemClick(item, { e })\n : undefined\n }\n onRightIconClick={\n onItemRightIconClick && itemDisabled\n ? (e: React.MouseEvent) => onItemRightIconClick(item, { e })\n : undefined\n }\n label={getItemLabel(item)}\n as={getItemAs(item)}\n active={getItemActive(item)}\n iconLeft={getItemIconLeft(item)}\n iconRight={getItemIconRight(item)}\n ref={getItemRef(item)}\n status={getItemStatus(item)}\n interactive={!itemDisabled && interactive}\n disabled={itemDisabled}\n />\n );\n })}\n </div>\n );\n};\n\nexport const Chips = forwardRef(ChipsRender) as ChipsComponent;\n"],"mappings":"8VAAA,oBAEA,MAAOA,MAAP,EAAgBC,UAAhB,KAAkC,OAAlC,CAEA,OAASC,EAAT,uBAEA,OAASC,SAAT,mBACA,OAASC,kBAAT,iB,GAGMC,QAAO,CAAGH,EAAE,CAAC,OAAD,C,CAEZI,WAAW,CAAG,SAACC,CAAD,CAAoBC,CAApB,CAAuD,CACzE,MAmBIJ,kBAAkB,CAACG,CAAD,CAnBtB,CACEE,CADF,GACEA,KADF,CAEEC,CAFF,GAEEA,aAFF,CAGEC,CAHF,GAGEA,eAHF,CAIEC,CAJF,GAIEA,SAJF,CAKEC,CALF,GAKEA,iBALF,CAMEC,CANF,GAMEA,eANF,CAOEC,CAPF,GAOEA,gBAPF,CAQEC,CARF,GAQEA,YARF,CASEC,CATF,GASEA,UATF,CAUEC,CAVF,GAUEA,aAVF,CAWEC,CAXF,GAWEA,SAXF,CAYEC,CAZF,GAYEA,WAZF,CAaEC,CAbF,GAaEA,WAbF,CAcEC,CAdF,GAcEA,oBAdF,CAeEC,CAfF,GAeEA,UAfF,CAgBEC,CAhBF,GAgBEA,IAhBF,KAiBEC,QAjBF,CAkBKC,CAlBL,uCAqBA,MACE,4CAASA,CAAT,EAAqB,GAAG,CAAElB,CAA1B,CAA+B,SAAS,CAAEH,OAAO,CAAC,IAAD,CAAO,CAACc,CAAD,CAAP,CAAjD,GACGV,CAAK,CAACkB,GAAN,CAAU,SAACC,CAAD,CAAOC,CAAP,CAAiB,CAC1B,GAAMC,EAAY,CAAGnB,CAAe,CAACiB,CAAD,CAAf,eAArB,CACA,MACE,qBAAC,SAAD,kBACMf,CAAiB,CAACe,CAAD,CADvB,EAEE,GAAG,CAAEC,CAFP,CAGE,IAAI,CAAEL,CAHR,CAIE,UAAU,CAAED,CAJd,CAKE,OAAO,CACLF,CAAW,EAAI,CAACS,CAAhB,CACI,SAACC,CAAD,QAAyBV,EAAW,CAACO,CAAD,CAAO,CAAEG,CAAC,CAADA,CAAF,CAAP,CAApC,CADJ,OANJ,CAUE,gBAAgB,CACdT,CAAoB,EAAIQ,CAAxB,CACI,SAACC,CAAD,QAAyBT,EAAoB,CAACM,CAAD,CAAO,CAAEG,CAAC,CAADA,CAAF,CAAP,CAA7C,CADJ,OAXJ,CAeE,KAAK,CAAEf,CAAY,CAACY,CAAD,CAfrB,CAgBE,EAAE,CAAEhB,CAAS,CAACgB,CAAD,CAhBf,CAiBE,MAAM,CAAElB,CAAa,CAACkB,CAAD,CAjBvB,CAkBE,QAAQ,CAAEd,CAAe,CAACc,CAAD,CAlB3B,CAmBE,SAAS,CAAEb,CAAgB,CAACa,CAAD,CAnB7B,CAoBE,GAAG,CAAEX,CAAU,CAACW,CAAD,CApBjB,CAqBE,MAAM,CAAEV,CAAa,CAACU,CAAD,CArBvB,CAsBE,WAAW,CAAE,CAACE,CAAD,EAAiBV,CAtBhC,CAuBE,QAAQ,CAAEU,CAvBZ,GA0BH,CA7BA,CADH,CAiCH,C,CAED,MAAO,IAAME,MAAK,CAAG/B,UAAU,CAACK,WAAD,CAAxB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["value","onChange","multiple","getItemKey","getItemLabel"];import React,{forwardRef}from"react";import{Chips}from"./..";import{useChoiceGroup}from"../../../hooks/useChoiceGroup";import{defaultGetItemLabel}from"../helpers";export var getUndefined=function(){};export var getItemKeyDefault=function(a){return a.key};var ChipsChoiceRender=function(a,b){var c=a.value,d=a.onChange,e=a.multiple,f=a.getItemKey,g=void 0===f?getItemKeyDefault:f,h=a.getItemLabel,i=void 0===h?defaultGetItemLabel:h,j=_objectWithoutProperties(a,_excluded),
|
|
1
|
+
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["value","onChange","multiple","getItemKey","getItemLabel","disabled"];import React,{forwardRef}from"react";import{Chips}from"./..";import{useChoiceGroup}from"../../../hooks/useChoiceGroup";import{defaultGetItemLabel}from"../helpers";export var getUndefined=function(){};export var getItemKeyDefault=function(a){return a.key};var ChipsChoiceRender=function(a,b){var c=a.value,d=a.onChange,e=a.multiple,f=a.getItemKey,g=void 0===f?getItemKeyDefault:f,h=a.getItemLabel,i=void 0===h?defaultGetItemLabel:h,j=a.disabled,k=void 0!==j&&j,l=_objectWithoutProperties(a,_excluded),m=useChoiceGroup({getKey:function getKey(a){var b=g(a);return typeof b!==void 0&&b?b:i(a)},value:c,callBack:d,multiple:e}),n=m.getOnChange,o=m.getChecked;return React.createElement(Chips,Object.assign({},l,{ref:b,onItemRightIconClick:getUndefined,onItemClick:function onItemClick(a,b){var c=b.e;return!k&&n(a)(c)},getItemIconRight:getUndefined,getItemAttributes:getUndefined,getItemActive:o,interactive:!k,disabled:k}))};export var ChipsChoice=forwardRef(ChipsChoiceRender);
|
|
2
2
|
//# sourceMappingURL=ChipsChoice.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChipsChoice.js","names":["React","forwardRef","Chips","useChoiceGroup","defaultGetItemLabel","getUndefined","getItemKeyDefault","item","key","ChipsChoiceRender","props","ref","value","onChange","multiple","getItemKey","getItemLabel","otherProps","getKey","callBack","getOnChange","getChecked","e","ChipsChoice"],"sources":["../../../../../../src/components/Chips/ChipsChoice/ChipsChoice.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { Chips } from '##/components/Chips';\nimport { useChoiceGroup } from '##/hooks/useChoiceGroup';\n\nimport { defaultGetItemLabel } from '../helpers';\nimport {\n ChipsChoiceComponent,\n ChipsChoiceDefaultItem,\n ChipsChoicePropGetItemKey,\n ChipsChoiceProps,\n} from './types';\n\nexport const getUndefined = () => undefined;\nexport const getItemKeyDefault: ChipsChoicePropGetItemKey<\n ChipsChoiceDefaultItem\n> = (item) => item.key;\n\nconst ChipsChoiceRender = (\n props: ChipsChoiceProps,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const {\n value,\n onChange,\n multiple,\n getItemKey = getItemKeyDefault,\n getItemLabel = defaultGetItemLabel,\n ...otherProps\n } = props;\n\n const { getOnChange, getChecked } = useChoiceGroup<\n ChipsChoiceDefaultItem,\n React.MouseEvent\n >({\n getKey: (item: ChipsChoiceDefaultItem) => {\n const key = getItemKey(item);\n return typeof key !== undefined && key ? key : getItemLabel(item);\n },\n value: value as ChipsChoiceDefaultItem,\n callBack: onChange,\n multiple: multiple as false,\n // привел к типам из-за того что\n // TS не понимает что параметры для не Multiple и Multiple не могут прийти одновременно\n });\n\n return (\n <Chips\n {...otherProps}\n ref={ref}\n onItemRightIconClick={getUndefined}\n onItemClick={(item, { e }) => getOnChange(item)(e)}\n getItemIconRight={getUndefined}\n getItemAttributes={getUndefined}\n getItemActive={getChecked}\n interactive\n />\n );\n};\n\nexport const ChipsChoice = forwardRef(\n ChipsChoiceRender,\n) as ChipsChoiceComponent;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChipsChoice.js","names":["React","forwardRef","Chips","useChoiceGroup","defaultGetItemLabel","getUndefined","getItemKeyDefault","item","key","ChipsChoiceRender","props","ref","value","onChange","multiple","getItemKey","getItemLabel","disabled","otherProps","getKey","callBack","getOnChange","getChecked","e","ChipsChoice"],"sources":["../../../../../../src/components/Chips/ChipsChoice/ChipsChoice.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { Chips } from '##/components/Chips';\nimport { useChoiceGroup } from '##/hooks/useChoiceGroup';\n\nimport { defaultGetItemLabel } from '../helpers';\nimport {\n ChipsChoiceComponent,\n ChipsChoiceDefaultItem,\n ChipsChoicePropGetItemKey,\n ChipsChoiceProps,\n} from './types';\n\nexport const getUndefined = () => undefined;\nexport const getItemKeyDefault: ChipsChoicePropGetItemKey<\n ChipsChoiceDefaultItem\n> = (item) => item.key;\n\nconst ChipsChoiceRender = (\n props: ChipsChoiceProps,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const {\n value,\n onChange,\n multiple,\n getItemKey = getItemKeyDefault,\n getItemLabel = defaultGetItemLabel,\n disabled = false,\n ...otherProps\n } = props;\n\n const { getOnChange, getChecked } = useChoiceGroup<\n ChipsChoiceDefaultItem,\n React.MouseEvent\n >({\n getKey: (item: ChipsChoiceDefaultItem) => {\n const key = getItemKey(item);\n return typeof key !== undefined && key ? key : getItemLabel(item);\n },\n value: value as ChipsChoiceDefaultItem,\n callBack: onChange,\n multiple: multiple as false,\n // привел к типам из-за того что\n // TS не понимает что параметры для не Multiple и Multiple не могут прийти одновременно\n });\n\n return (\n <Chips\n {...otherProps}\n ref={ref}\n onItemRightIconClick={getUndefined}\n onItemClick={(item, { e }) => !disabled && getOnChange(item)(e)}\n getItemIconRight={getUndefined}\n getItemAttributes={getUndefined}\n getItemActive={getChecked}\n interactive={!disabled}\n disabled={disabled}\n />\n );\n};\n\nexport const ChipsChoice = forwardRef(\n ChipsChoiceRender,\n) as ChipsChoiceComponent;\n"],"mappings":"0KAAA,MAAOA,MAAP,EAAgBC,UAAhB,KAAkC,OAAlC,CAEA,OAASC,KAAT,YACA,OAASC,cAAT,qCAEA,OAASC,mBAAT,kBAQA,MAAO,IAAMC,aAAY,CAAG,YAArB,CACP,MAAO,IAAMC,kBAEZ,CAAG,SAACC,CAAD,QAAUA,EAAI,CAACC,GAAf,CAFG,CAIP,GAAMC,kBAAiB,CAAG,SACxBC,CADwB,CAExB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ePropValue<ITEM, MULTIPLE>;
|
|
23
23
|
getItemKey?: ChipsChoicePropGetItemKey<ITEM>;
|
|
24
|
+
disabled?: boolean;
|
|
24
25
|
}, HTMLDivElement> & (ITEM extends {
|
|
25
26
|
label: string;
|
|
26
27
|
} ? {} : {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../../../src/components/Chips/ChipsChoice/types.ts"],"sourcesContent":["import {\n ChipsItemProps,\n ChipsPropActiveView,\n ChipsPropGetItemIconLeft,\n ChipsPropGetItemLabel,\n ChipsPropGetItemRef,\n ChipsPropGetItemStatus,\n ChipsPropSize,\n} from '##/components/Chips';\nimport { PropsWithHTMLAttributesAndRef } from '##/utils/types/PropsWithHTMLAttributes';\n\nexport type ChipsChoiceDefaultItem = Omit<\n ChipsItemProps,\n | 'size'\n | 'activeView'\n | 'interactive'\n | 'onRightIconClick'\n | 'iconRight'\n | 'as'\n> & {\n key: string;\n};\n\nexport type ChipsChoicePropGetItemKey<ITEM> = (\n item: ITEM,\n) => string | number | undefined;\n\nexport type ChipsChoicePropOnChange<ITEM, MULTIPLE extends boolean> = (\n value: MULTIPLE extends true ? ITEM[] | null : ITEM,\n props: {\n e: React.MouseEvent;\n },\n) => void;\n\nexport type ChipsChoicePropValue<ITEM, MULTIPLE extends boolean> =\n | (MULTIPLE extends true ? ITEM[] : ITEM)\n | null;\n\nexport type ChipsChoiceProps<\n ITEM = ChipsChoiceDefaultItem,\n MULTIPLE extends boolean = false,\n> = PropsWithHTMLAttributesAndRef<\n {\n size?: ChipsPropSize;\n activeView?: ChipsPropActiveView;\n items: ITEM[];\n getItemStatus?: ChipsPropGetItemStatus<ITEM>;\n getItemLabel?: ChipsPropGetItemLabel<ITEM>;\n getItemIconLeft?: ChipsPropGetItemIconLeft<ITEM>;\n getItemRef?: ChipsPropGetItemRef<ITEM>;\n onChange: ChipsChoicePropOnChange<ITEM, MULTIPLE>;\n multiple?: MULTIPLE;\n value?: ChipsChoicePropValue<ITEM, MULTIPLE>;\n getItemKey?: ChipsChoicePropGetItemKey<ITEM>;\n },\n HTMLDivElement\n> &\n (ITEM extends { label: string }\n ? {}\n : {\n getItemLabel?: ChipsPropGetItemLabel<ITEM>;\n });\n\nexport type ChipsChoiceComponent = <\n ITEM = ChipsChoiceDefaultItem,\n MULTIPLE extends boolean = false,\n>(\n props: ChipsChoiceProps<ITEM, MULTIPLE>,\n) => React.ReactElement | null;\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../../src/components/Chips/ChipsChoice/types.ts"],"sourcesContent":["import {\n ChipsItemProps,\n ChipsPropActiveView,\n ChipsPropGetItemIconLeft,\n ChipsPropGetItemLabel,\n ChipsPropGetItemRef,\n ChipsPropGetItemStatus,\n ChipsPropSize,\n} from '##/components/Chips';\nimport { PropsWithHTMLAttributesAndRef } from '##/utils/types/PropsWithHTMLAttributes';\n\nexport type ChipsChoiceDefaultItem = Omit<\n ChipsItemProps,\n | 'size'\n | 'activeView'\n | 'interactive'\n | 'onRightIconClick'\n | 'iconRight'\n | 'as'\n> & {\n key: string;\n};\n\nexport type ChipsChoicePropGetItemKey<ITEM> = (\n item: ITEM,\n) => string | number | undefined;\n\nexport type ChipsChoicePropOnChange<ITEM, MULTIPLE extends boolean> = (\n value: MULTIPLE extends true ? ITEM[] | null : ITEM,\n props: {\n e: React.MouseEvent;\n },\n) => void;\n\nexport type ChipsChoicePropValue<ITEM, MULTIPLE extends boolean> =\n | (MULTIPLE extends true ? ITEM[] : ITEM)\n | null;\n\nexport type ChipsChoiceProps<\n ITEM = ChipsChoiceDefaultItem,\n MULTIPLE extends boolean = false,\n> = PropsWithHTMLAttributesAndRef<\n {\n size?: ChipsPropSize;\n activeView?: ChipsPropActiveView;\n items: ITEM[];\n getItemStatus?: ChipsPropGetItemStatus<ITEM>;\n getItemLabel?: ChipsPropGetItemLabel<ITEM>;\n getItemIconLeft?: ChipsPropGetItemIconLeft<ITEM>;\n getItemRef?: ChipsPropGetItemRef<ITEM>;\n onChange: ChipsChoicePropOnChange<ITEM, MULTIPLE>;\n multiple?: MULTIPLE;\n value?: ChipsChoicePropValue<ITEM, MULTIPLE>;\n getItemKey?: ChipsChoicePropGetItemKey<ITEM>;\n disabled?: boolean;\n },\n HTMLDivElement\n> &\n (ITEM extends { label: string }\n ? {}\n : {\n getItemLabel?: ChipsPropGetItemLabel<ITEM>;\n });\n\nexport type ChipsChoiceComponent = <\n ITEM = ChipsChoiceDefaultItem,\n MULTIPLE extends boolean = false,\n>(\n props: ChipsChoiceProps<ITEM, MULTIPLE>,\n) => React.ReactElement | null;\n"],"mappings":""}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
.ChipsItem{--chip-bg-color:var(--color-control-bg-ghost);--chip-bg-color-hover:var(--color-control-bg-ghost-hover);--chip-color:var(--color-control-typo-ghost);--chip-color-hover:var(--color-control-typo-ghost-hover);--chip-border:transparent;--chip-border-hover:transparent;align-items:center;background-color:var(--chip-bg-color);border:var(--control-border-width) solid var(--chip-border);border-radius:99rem;box-sizing:border-box;color:var(--chip-color);display:inline-flex;font-family:inherit;font-size:var(--chip-text-size);gap:calc(var(--chip-space)/2);height:var(--chip-height);justify-content:center;padding:0 var(--chip-space);text-decoration:none;transition:background-color .15s ease,border-color .15s ease,box-shadow .15s ease,color .15s ease,fill .15s ease;white-space:nowrap}.ChipsItem_status{padding:0 var(--chip-space) 0 calc(var(--chip-height)/2 - var(--chip-badge-size)/2)}.
|
|
1
|
+
.ChipsItem{--chip-bg-color:var(--color-control-bg-ghost);--chip-bg-color-hover:var(--color-control-bg-ghost-hover);--chip-color:var(--color-control-typo-ghost);--chip-color-hover:var(--color-control-typo-ghost-hover);--chip-border:transparent;--chip-border-hover:transparent;align-items:center;background-color:var(--chip-bg-color);border:var(--control-border-width) solid var(--chip-border);border-radius:99rem;box-sizing:border-box;color:var(--chip-color);display:inline-flex;font-family:inherit;font-size:var(--chip-text-size);gap:calc(var(--chip-space)/2);height:var(--chip-height);justify-content:center;padding:0 var(--chip-space);text-decoration:none;transition:background-color .15s ease,border-color .15s ease,box-shadow .15s ease,color .15s ease,fill .15s ease;white-space:nowrap}.ChipsItem_status{padding:0 var(--chip-space) 0 calc(var(--chip-height)/2 - var(--chip-badge-size)/2)}.ChipsItem_interactive{cursor:pointer}.ChipsItem_interactive:hover{background-color:var(--chip-bg-color-hover);border:var(--control-border-width) solid var(--chip-border-hover);color:var(--chip-color-hover)}.ChipsItem_size_xs{--chip-height:var(--control-height-xs);--chip-text-size:var(--control-text-size-xs);--chip-space:var(--space-xs);--chip-badge-size:10px}.ChipsItem_size_s{--chip-height:var(--control-height-s);--chip-text-size:var(--control-text-size-s);--chip-space:var(--space-s);--chip-badge-size:16px}.ChipsItem_size_m{--chip-height:var(--control-height-m);--chip-text-size:var(--control-text-size-m);--chip-space:var(--space-m);--chip-badge-size:16px}.ChipsItem_size_l{--chip-height:var(--control-height-l);--chip-text-size:var(--control-text-size-l);--chip-space:var(--space-l);--chip-badge-size:24px}.ChipsItem_activeView_primary{--chip-active-bg-color:var(--color-control-bg-primary);--chip-active-bg-color-hover:var(--color-control-bg-primary-hover);--chip-active-color:var(--color-control-typo-primary);--chip-active-color-hover:var(--color-control-typo-primary-hover);--chip-active-border:transparent;--chip-active-border-hover:transparent;--chip-active-disabled-bg-color:var(--color-control-bg-secondary);--chip-active-disabled-color:var(--color-control-typo-disable);--chip-active-disabled-border:var(--color-control-typo-disable)}.ChipsItem_activeView_secondary{--chip-active-bg-color:var(--color-control-bg-secondary);--chip-active-bg-color-hover:var(--color-control-bg-clear);--chip-active-color:var(--color-control-typo-secondary);--chip-active-color-hover:var(--color-control-typo-secondary-hover);--chip-active-border:var(--color-control-bg-border-secondary);--chip-active-border-hover:var(
|
|
2
2
|
--color-control-bg-border-secondary-hover
|
|
3
|
-
)}.ChipsItem-IconButton{background-color:transparent;border:transparent;border-radius:var(--control-radius);color:inherit;cursor:pointer;padding:0}
|
|
3
|
+
);--chip-active-disabled-bg-color:var(--color-control-bg-secondary);--chip-active-disabled-color:var(--color-control-typo-disable);--chip-active-disabled-border:var(--color-control-typo-disable)}.ChipsItem_disabled{--chip-bg-color:var(--color-control-bg-disable);--chip-bg-color-hover:none;--chip-color:var(--color-control-typo-disable);--chip-color-hover:none;--chip-border:transparent;--chip-border-hover:none}.ChipsItem_active{--chip-bg-color:var(--chip-active-bg-color);--chip-bg-color-hover:var(--chip-active-bg-color-hover);--chip-color:var(--chip-active-color);--chip-color-hover:var(--chip-active-color-hover);--chip-border:var(--chip-active-border);--chip-border-hover:var(--chip-active-border-hover)}.ChipsItem_disabled.ChipsItem_active{--chip-bg-color:var(--chip-active-disabled-bg-color);--chip-bg-color-hover:none;--chip-color:var(--chip-active-disabled-color);--chip-color-hover:none;--chip-border:var(--chip-active-disabled-border);--chip-border-hover:none}.ChipsItem-IconButton{background-color:transparent;border:transparent;border-radius:var(--control-radius);color:inherit;cursor:pointer;padding:0}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["as","label","size","status","activeView","className","interactive","style","active","iconLeft","iconRight","onRightIconClick","onKeyUp","tabIndex"];import"./ChipsItem.css";import React,{useRef}from"react";import{Badge}from"../../Badge";import{useForkRef}from"../../../hooks/useForkRef";import{useKeys}from"../../../hooks/useKeys";import{cnMixFocus}from"../../../mixs/MixFocus";import{cn}from"../../../utils/bem";import{forwardRefWithAs}from"../../../utils/types/PropsWithAsAttributes";import{chipsPropActiveViewDefault,chipsPropSizeDefault}from"../types";var cnChip=cn("ChipsItem"),iconSizeMap={l:"m",m:"s",s:"s",xs:"xs"};export var ChipsItem=forwardRefWithAs(function(a,b){var c=a.as,d=void 0===c?"span":c,e=a.label,f=a.size,g=void 0===f?chipsPropSizeDefault:f,h=a.status,i=a.activeView,j=void 0===i?chipsPropActiveViewDefault:i,k=a.className,l=a.interactive,m=a.style,n=a.active,o=a.iconLeft,p=a.iconRight,q=a.onRightIconClick,r=a.onKeyUp,s=a.tabIndex,t=_objectWithoutProperties(a,_excluded),
|
|
1
|
+
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["as","label","size","status","activeView","className","interactive","style","active","iconLeft","iconRight","onRightIconClick","onKeyUp","tabIndex","disabled"];import"./ChipsItem.css";import React,{useRef}from"react";import{Badge}from"../../Badge";import{useForkRef}from"../../../hooks/useForkRef";import{useKeys}from"../../../hooks/useKeys";import{cnMixFocus}from"../../../mixs/MixFocus";import{cn}from"../../../utils/bem";import{forwardRefWithAs}from"../../../utils/types/PropsWithAsAttributes";import{chipsPropActiveViewDefault,chipsPropSizeDefault}from"../types";var cnChip=cn("ChipsItem"),iconSizeMap={l:"m",m:"s",s:"s",xs:"xs"};export var ChipsItem=forwardRefWithAs(function(a,b){var c=a.as,d=void 0===c?"span":c,e=a.label,f=a.size,g=void 0===f?chipsPropSizeDefault:f,h=a.status,i=a.activeView,j=void 0===i?chipsPropActiveViewDefault:i,k=a.className,l=a.interactive,m=a.style,n=a.active,o=a.iconLeft,p=a.iconRight,q=a.onRightIconClick,r=a.onKeyUp,s=a.tabIndex,t=a.disabled,u=void 0!==t&&t,v=_objectWithoutProperties(a,_excluded),w=useRef(null),x=useRef(null),y=!u&&l,z=useKeys({keys:{Enter:function Enter(){if(x&&q){var a;null===(a=x.current)||void 0===a?void 0:a.focus()}else{var b;null===(b=w.current)||void 0===b?void 0:b.click()}},Escape:function Escape(){if(x&&q){var a;null===(a=w.current)||void 0===a?void 0:a.focus()}},Space:function Space(){var a;null===(a=w.current)||void 0===a?void 0:a.click()}},onEvent:r,isActive:!!y});return React.createElement(d,Object.assign({},v,{disabled:u,className:cnChip({size:g,interactive:y,activeView:j,active:n,disabled:u,status:!!h},[y?cnMixFocus():void 0,k]),ref:useForkRef([w,b]),onKeyUp:z,tabIndex:y?s||0:void 0,role:y?"button":void 0}),h&&React.createElement(Badge,{status:h,size:iconSizeMap[g],minified:!0}),!h&&o&&React.createElement(o,{size:iconSizeMap[g]}),e,p&&React.createElement(p,Object.assign({size:iconSizeMap[g]},q&&!u?{as:"button",role:"button",type:"button",onClick:q,className:cnChip("IconButton",[cnMixFocus()]),ref:x,tabIndex:-1}:{})))});
|
|
2
2
|
//# sourceMappingURL=ChipsItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChipsItem.js","names":["React","useRef","Badge","useForkRef","useKeys","cnMixFocus","cn","forwardRefWithAs","chipsPropActiveViewDefault","chipsPropSizeDefault","cnChip","iconSizeMap","l","m","s","xs","ChipsItem","props","ref","as","label","size","status","activeView","className","interactive","style","active","IconLeft","iconLeft","IconRight","iconRight","onRightIconClick","onKeyUpProp","onKeyUp","tabIndex","otherProps","componentRef","iconButtonRef","keys","Enter","current","focus","click","Escape","Space","onEvent","isActive","role","type","onClick"],"sources":["../../../../../../src/components/Chips/ChipsItem/ChipsItem.tsx"],"sourcesContent":["import './ChipsItem.css';\n\nimport { IconPropSize } from '@consta/icons/Icon';\nimport React, { useRef } from 'react';\n\nimport { Badge } from '##/components/Badge';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { useKeys } from '##/hooks/useKeys';\nimport { cnMixFocus } from '##/mixs/MixFocus';\nimport { cn } from '##/utils/bem';\nimport { forwardRefWithAs } from '##/utils/types/PropsWithAsAttributes';\n\nimport {\n ChipsItemProps,\n chipsPropActiveViewDefault,\n ChipsPropSize,\n chipsPropSizeDefault,\n} from '../types';\n\nconst cnChip = cn('ChipsItem');\n\nconst iconSizeMap: Record<ChipsPropSize, IconPropSize> = {\n l: 'm',\n m: 's',\n s: 's',\n xs: 'xs',\n};\n\nexport const ChipsItem = forwardRefWithAs<ChipsItemProps, 'span'>(\n (props, ref) => {\n const {\n as = 'span',\n label,\n size = chipsPropSizeDefault,\n status,\n activeView = chipsPropActiveViewDefault,\n className,\n interactive,\n style,\n active,\n iconLeft: IconLeft,\n iconRight: IconRight,\n onRightIconClick,\n onKeyUp: onKeyUpProp,\n tabIndex,\n ...otherProps\n } = props;\n\n const componentRef = useRef<HTMLElement>(null);\n const iconButtonRef = useRef<HTMLButtonElement>(null);\n\n const onKeyUp = useKeys({\n keys: {\n Enter: () => {\n if (iconButtonRef && onRightIconClick) {\n iconButtonRef.current?.focus();\n } else {\n componentRef.current?.click();\n }\n },\n Escape: () => {\n if (iconButtonRef && onRightIconClick) {\n componentRef.current?.focus();\n }\n },\n Space: () => {\n componentRef.current?.click();\n },\n },\n onEvent: onKeyUpProp,\n isActive: !!interactive,\n });\n\n const Tag = as as string;\n\n return (\n <Tag\n {...otherProps}\n className={cnChip(\n {
|
|
1
|
+
{"version":3,"file":"ChipsItem.js","names":["React","useRef","Badge","useForkRef","useKeys","cnMixFocus","cn","forwardRefWithAs","chipsPropActiveViewDefault","chipsPropSizeDefault","cnChip","iconSizeMap","l","m","s","xs","ChipsItem","props","ref","as","label","size","status","activeView","className","interactiveProp","interactive","style","active","IconLeft","iconLeft","IconRight","iconRight","onRightIconClick","onKeyUpProp","onKeyUp","tabIndex","disabled","otherProps","componentRef","iconButtonRef","keys","Enter","current","focus","click","Escape","Space","onEvent","isActive","role","type","onClick"],"sources":["../../../../../../src/components/Chips/ChipsItem/ChipsItem.tsx"],"sourcesContent":["import './ChipsItem.css';\n\nimport { IconPropSize } from '@consta/icons/Icon';\nimport React, { useRef } from 'react';\n\nimport { Badge } from '##/components/Badge';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { useKeys } from '##/hooks/useKeys';\nimport { cnMixFocus } from '##/mixs/MixFocus';\nimport { cn } from '##/utils/bem';\nimport { forwardRefWithAs } from '##/utils/types/PropsWithAsAttributes';\n\nimport {\n ChipsItemProps,\n chipsPropActiveViewDefault,\n ChipsPropSize,\n chipsPropSizeDefault,\n} from '../types';\n\nconst cnChip = cn('ChipsItem');\n\nconst iconSizeMap: Record<ChipsPropSize, IconPropSize> = {\n l: 'm',\n m: 's',\n s: 's',\n xs: 'xs',\n};\n\nexport const ChipsItem = forwardRefWithAs<ChipsItemProps, 'span'>(\n (props, ref) => {\n const {\n as = 'span',\n label,\n size = chipsPropSizeDefault,\n status,\n activeView = chipsPropActiveViewDefault,\n className,\n interactive: interactiveProp,\n style,\n active,\n iconLeft: IconLeft,\n iconRight: IconRight,\n onRightIconClick,\n onKeyUp: onKeyUpProp,\n tabIndex,\n disabled = false,\n ...otherProps\n } = props;\n\n const componentRef = useRef<HTMLElement>(null);\n const iconButtonRef = useRef<HTMLButtonElement>(null);\n const interactive = disabled ? false : interactiveProp;\n\n const onKeyUp = useKeys({\n keys: {\n Enter: () => {\n if (iconButtonRef && onRightIconClick) {\n iconButtonRef.current?.focus();\n } else {\n componentRef.current?.click();\n }\n },\n Escape: () => {\n if (iconButtonRef && onRightIconClick) {\n componentRef.current?.focus();\n }\n },\n Space: () => {\n componentRef.current?.click();\n },\n },\n onEvent: onKeyUpProp,\n isActive: !!interactive,\n });\n\n const Tag = as as string;\n\n return (\n <Tag\n {...otherProps}\n disabled={disabled}\n className={cnChip(\n {\n size,\n interactive,\n activeView,\n active,\n disabled,\n status: Boolean(status),\n },\n [interactive ? cnMixFocus() : undefined, className],\n )}\n ref={useForkRef([componentRef, ref])}\n onKeyUp={onKeyUp}\n tabIndex={interactive ? tabIndex || 0 : undefined}\n role={interactive ? 'button' : undefined}\n >\n {status && <Badge status={status} size={iconSizeMap[size]} minified />}\n {!status && IconLeft && <IconLeft size={iconSizeMap[size]} />}\n {label}\n {IconRight && (\n <IconRight\n size={iconSizeMap[size]}\n {...(onRightIconClick && !disabled\n ? {\n as: 'button',\n role: 'button',\n type: 'button',\n onClick: onRightIconClick,\n className: cnChip('IconButton', [cnMixFocus()]),\n ref: iconButtonRef,\n tabIndex: -1,\n }\n : {})}\n />\n )}\n </Tag>\n );\n },\n);\n"],"mappings":"oQAAA,wBAGA,MAAOA,MAAP,EAAgBC,MAAhB,KAA8B,OAA9B,CAEA,OAASC,KAAT,mBACA,OAASC,UAAT,iCACA,OAASC,OAAT,8BACA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AAC,CAAD,EAAU,IAAI,CAAElB,WAAW,CAACU,CAAD,CAA3B,EApB1B,CAqBGD,CArBH,CAsBGW,CAAS,EACR,oBAAC,CAAD,gBACE,IAAI,CAAEpB,WAAW,CAACU,CAAD,CADnB,EAEOY,CAAgB,EAAI,CAACI,CAArB,CACD,CACElB,EAAE,CAAE,QADN,CAEE+B,IAAI,CAAE,QAFR,CAGEC,IAAI,CAAE,QAHR,CAIEC,OAAO,CAAEnB,CAJX,CAKET,SAAS,CAAEd,MAAM,CAAC,YAAD,CAAe,CAACL,UAAU,EAAX,CAAf,CALnB,CAMEa,GAAG,CAAEsB,CANP,CAOEJ,QAAQ,CAAE,CAAC,CAPb,CADC,CAUD,EAZN,EAvBJ,CAwCH,CA1FsC,CAAlC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ChipsDefaultItem, ChipsPropGetItemActive, ChipsPropGetItemAs, ChipsPropGetItemAttributes, ChipsPropGetItemIconLeft, ChipsPropGetItemIconRight, ChipsPropGetItemLabel, ChipsPropGetItemRef, ChipsPropGetItemStatus, ChipsProps } from './types';
|
|
2
|
+
import { ChipsDefaultItem, ChipsPropGetItemActive, ChipsPropGetItemAs, ChipsPropGetItemAttributes, ChipsPropGetItemDisabled, ChipsPropGetItemIconLeft, ChipsPropGetItemIconRight, ChipsPropGetItemLabel, ChipsPropGetItemRef, ChipsPropGetItemStatus, ChipsProps } from './types';
|
|
3
3
|
export declare const defaultGetItemIconRight: ChipsPropGetItemIconRight<ChipsDefaultItem>;
|
|
4
4
|
export declare const defaultGetItemActive: ChipsPropGetItemActive<ChipsDefaultItem>;
|
|
5
|
+
export declare const defaultGetItemDisabled: ChipsPropGetItemDisabled<ChipsDefaultItem>;
|
|
5
6
|
export declare const defaultGetItemIconLeft: ChipsPropGetItemIconLeft<ChipsDefaultItem>;
|
|
6
7
|
export declare const defaultGetItemStatus: ChipsPropGetItemStatus<ChipsDefaultItem>;
|
|
7
8
|
export declare const defaultGetItemLabel: ChipsPropGetItemLabel<ChipsDefaultItem>;
|
|
@@ -13,6 +14,7 @@ export declare function withDefaultGetters<ITEM>(props: ChipsProps<ITEM>): {
|
|
|
13
14
|
activeView?: "primary" | "secondary" | undefined;
|
|
14
15
|
items: ITEM[];
|
|
15
16
|
interactive?: boolean | undefined;
|
|
17
|
+
disabled?: boolean | undefined;
|
|
16
18
|
getItemStatus?: ChipsPropGetItemStatus<ITEM> | undefined;
|
|
17
19
|
getItemLabel?: ChipsPropGetItemLabel<ITEM> | undefined;
|
|
18
20
|
getItemIconLeft?: ChipsPropGetItemIconLeft<ITEM> | undefined;
|
|
@@ -21,9 +23,10 @@ export declare function withDefaultGetters<ITEM>(props: ChipsProps<ITEM>): {
|
|
|
21
23
|
getItemAs?: ChipsPropGetItemAs<ITEM> | undefined;
|
|
22
24
|
getItemAttributes?: ChipsPropGetItemAttributes<ITEM> | undefined;
|
|
23
25
|
getItemActive?: ChipsPropGetItemActive<ITEM> | undefined;
|
|
26
|
+
getItemDisabled?: ChipsPropGetItemDisabled<ITEM> | undefined;
|
|
24
27
|
onItemClick?: import("./types").ChipsPropOnItemClick<ITEM> | undefined;
|
|
25
28
|
onItemRightIconClick?: import("./types").ChipsPropItemOnRightIconClick<ITEM> | undefined;
|
|
26
|
-
} & Omit<import("react").HTMLAttributes<HTMLDivElement>, "size" | "css" | "items" | "getItemLabel" | "getItemStatus" | "onItemClick" | "getItemActive" | "getItemAs" | "getItemAttributes" | "getItemRef" | "interactive" | "getItemIconLeft" | "getItemIconRight" | "activeView" | "onItemRightIconClick"> & import("react").RefAttributes<HTMLDivElement> & (ITEM extends {
|
|
29
|
+
} & Omit<import("react").HTMLAttributes<HTMLDivElement>, "disabled" | "size" | "css" | "items" | "getItemLabel" | "getItemDisabled" | "getItemStatus" | "onItemClick" | "getItemActive" | "getItemAs" | "getItemAttributes" | "getItemRef" | "interactive" | "getItemIconLeft" | "getItemIconRight" | "activeView" | "onItemRightIconClick"> & import("react").RefAttributes<HTMLDivElement> & (ITEM extends {
|
|
27
30
|
label: string;
|
|
28
31
|
} ? {} : {
|
|
29
32
|
getItemLabel: ChipsPropGetItemLabel<ITEM>;
|
|
@@ -36,4 +39,5 @@ export declare function withDefaultGetters<ITEM>(props: ChipsProps<ITEM>): {
|
|
|
36
39
|
getItemAs: ChipsPropGetItemAs<ChipsDefaultItem> | ChipsPropGetItemAs<ITEM>;
|
|
37
40
|
getItemAttributes: ChipsPropGetItemAttributes<ChipsDefaultItem> | ChipsPropGetItemAttributes<ITEM>;
|
|
38
41
|
getItemActive: ChipsPropGetItemActive<ChipsDefaultItem> | ChipsPropGetItemActive<ITEM>;
|
|
42
|
+
getItemDisabled: ChipsPropGetItemDisabled<ChipsDefaultItem> | ChipsPropGetItemDisabled<ITEM>;
|
|
39
43
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _defineProperty from"@babel/runtime/helpers/defineProperty";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}export var defaultGetItemIconRight=function(a){return a.iconRight};export var defaultGetItemActive=function(a){return a.active};export var defaultGetItemIconLeft=function(a){return a.iconLeft};export var defaultGetItemStatus=function(a){return a.status};export var defaultGetItemLabel=function(a){return a.label};export var defaultGetItemAs=function(a){return a.as};export var defaultGetItemAttributes=function(a){return a.attributes};export var defaultGetItemRef=function(a){return a.ref};export function withDefaultGetters(a){return _objectSpread(_objectSpread({},a),{},{getItemLabel:a.getItemLabel||defaultGetItemLabel,getItemIconRight:a.getItemIconRight||defaultGetItemIconRight,getItemIconLeft:a.getItemIconLeft||defaultGetItemIconLeft,getItemStatus:a.getItemStatus||defaultGetItemStatus,getItemRef:a.getItemRef||defaultGetItemRef,getItemAs:a.getItemAs||defaultGetItemAs,getItemAttributes:a.getItemAttributes||defaultGetItemAttributes,getItemActive:a.getItemActive||defaultGetItemActive})}
|
|
1
|
+
import _defineProperty from"@babel/runtime/helpers/defineProperty";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}export var defaultGetItemIconRight=function(a){return a.iconRight};export var defaultGetItemActive=function(a){return a.active};export var defaultGetItemDisabled=function(a){return a.disabled};export var defaultGetItemIconLeft=function(a){return a.iconLeft};export var defaultGetItemStatus=function(a){return a.status};export var defaultGetItemLabel=function(a){return a.label};export var defaultGetItemAs=function(a){return a.as};export var defaultGetItemAttributes=function(a){return a.attributes};export var defaultGetItemRef=function(a){return a.ref};export function withDefaultGetters(a){return _objectSpread(_objectSpread({},a),{},{getItemLabel:a.getItemLabel||defaultGetItemLabel,getItemIconRight:a.getItemIconRight||defaultGetItemIconRight,getItemIconLeft:a.getItemIconLeft||defaultGetItemIconLeft,getItemStatus:a.getItemStatus||defaultGetItemStatus,getItemRef:a.getItemRef||defaultGetItemRef,getItemAs:a.getItemAs||defaultGetItemAs,getItemAttributes:a.getItemAttributes||defaultGetItemAttributes,getItemActive:a.getItemActive||defaultGetItemActive,getItemDisabled:a.getItemDisabled||defaultGetItemDisabled})}
|
|
2
2
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":["defaultGetItemIconRight","item","iconRight","defaultGetItemActive","active","defaultGetItemIconLeft","iconLeft","defaultGetItemStatus","status","defaultGetItemLabel","label","defaultGetItemAs","as","defaultGetItemAttributes","attributes","defaultGetItemRef","ref","withDefaultGetters","props","getItemLabel","getItemIconRight","getItemIconLeft","getItemStatus","getItemRef","getItemAs","getItemAttributes","getItemActive"],"sources":["../../../../../src/components/Chips/helpers.ts"],"sourcesContent":["import {\n ChipsDefaultItem,\n ChipsPropGetItemActive,\n ChipsPropGetItemAs,\n ChipsPropGetItemAttributes,\n ChipsPropGetItemIconLeft,\n ChipsPropGetItemIconRight,\n ChipsPropGetItemLabel,\n ChipsPropGetItemRef,\n ChipsPropGetItemStatus,\n ChipsProps,\n} from './types';\n\nexport const defaultGetItemIconRight: ChipsPropGetItemIconRight<\n ChipsDefaultItem\n> = (item) => item.iconRight;\nexport const defaultGetItemActive: ChipsPropGetItemActive<ChipsDefaultItem> = (\n item,\n) => item.active;\nexport const defaultGetItemIconLeft: ChipsPropGetItemIconLeft<\n ChipsDefaultItem\n> = (item) => item.iconLeft;\nexport const defaultGetItemStatus: ChipsPropGetItemStatus<ChipsDefaultItem> = (\n item,\n) => item.status;\nexport const defaultGetItemLabel: ChipsPropGetItemLabel<ChipsDefaultItem> = (\n item,\n) => item.label;\nexport const defaultGetItemAs: ChipsPropGetItemAs<ChipsDefaultItem> = (item) =>\n item.as;\nexport const defaultGetItemAttributes: ChipsPropGetItemAttributes<\n ChipsDefaultItem\n> = (item) => item.attributes;\nexport const defaultGetItemRef: ChipsPropGetItemRef<ChipsDefaultItem> = (\n item,\n) => item.ref;\n\nexport function withDefaultGetters<ITEM>(props: ChipsProps<ITEM>) {\n return {\n ...props,\n getItemLabel: props.getItemLabel || defaultGetItemLabel,\n getItemIconRight: props.getItemIconRight || defaultGetItemIconRight,\n getItemIconLeft: props.getItemIconLeft || defaultGetItemIconLeft,\n getItemStatus: props.getItemStatus || defaultGetItemStatus,\n getItemRef: props.getItemRef || defaultGetItemRef,\n getItemAs: props.getItemAs || defaultGetItemAs,\n getItemAttributes: props.getItemAttributes || defaultGetItemAttributes,\n getItemActive: props.getItemActive || defaultGetItemActive,\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.js","names":["defaultGetItemIconRight","item","iconRight","defaultGetItemActive","active","defaultGetItemDisabled","disabled","defaultGetItemIconLeft","iconLeft","defaultGetItemStatus","status","defaultGetItemLabel","label","defaultGetItemAs","as","defaultGetItemAttributes","attributes","defaultGetItemRef","ref","withDefaultGetters","props","getItemLabel","getItemIconRight","getItemIconLeft","getItemStatus","getItemRef","getItemAs","getItemAttributes","getItemActive","getItemDisabled"],"sources":["../../../../../src/components/Chips/helpers.ts"],"sourcesContent":["import {\n ChipsDefaultItem,\n ChipsPropGetItemActive,\n ChipsPropGetItemAs,\n ChipsPropGetItemAttributes,\n ChipsPropGetItemDisabled,\n ChipsPropGetItemIconLeft,\n ChipsPropGetItemIconRight,\n ChipsPropGetItemLabel,\n ChipsPropGetItemRef,\n ChipsPropGetItemStatus,\n ChipsProps,\n} from './types';\n\nexport const defaultGetItemIconRight: ChipsPropGetItemIconRight<\n ChipsDefaultItem\n> = (item) => item.iconRight;\nexport const defaultGetItemActive: ChipsPropGetItemActive<ChipsDefaultItem> = (\n item,\n) => item.active;\nexport const defaultGetItemDisabled: ChipsPropGetItemDisabled<\n ChipsDefaultItem\n> = (item) => item.disabled;\nexport const defaultGetItemIconLeft: ChipsPropGetItemIconLeft<\n ChipsDefaultItem\n> = (item) => item.iconLeft;\nexport const defaultGetItemStatus: ChipsPropGetItemStatus<ChipsDefaultItem> = (\n item,\n) => item.status;\nexport const defaultGetItemLabel: ChipsPropGetItemLabel<ChipsDefaultItem> = (\n item,\n) => item.label;\nexport const defaultGetItemAs: ChipsPropGetItemAs<ChipsDefaultItem> = (item) =>\n item.as;\nexport const defaultGetItemAttributes: ChipsPropGetItemAttributes<\n ChipsDefaultItem\n> = (item) => item.attributes;\nexport const defaultGetItemRef: ChipsPropGetItemRef<ChipsDefaultItem> = (\n item,\n) => item.ref;\n\nexport function withDefaultGetters<ITEM>(props: ChipsProps<ITEM>) {\n return {\n ...props,\n getItemLabel: props.getItemLabel || defaultGetItemLabel,\n getItemIconRight: props.getItemIconRight || defaultGetItemIconRight,\n getItemIconLeft: props.getItemIconLeft || defaultGetItemIconLeft,\n getItemStatus: props.getItemStatus || defaultGetItemStatus,\n getItemRef: props.getItemRef || defaultGetItemRef,\n getItemAs: props.getItemAs || defaultGetItemAs,\n getItemAttributes: props.getItemAttributes || defaultGetItemAttributes,\n getItemActive: props.getItemActive || defaultGetItemActive,\n getItemDisabled: props.getItemDisabled || defaultGetItemDisabled,\n };\n}\n"],"mappings":"qqBAcA,MAAO,IAAMA,wBAEZ,CAAG,SAACC,CAAD,QAAUA,EAAI,CAACC,SAAf,CAFG,CAGP,MAAO,IAAMC,qBAA8D,CAAG,SAC5EF,CAD4E,QAEzEA,EAAI,CAACG,MAFoE,CAAvE,CAGP,MAAO,IAAMC,uBAEZ,CAAG,SAACJ,CAAD,QAAUA,EAAI,CAACK,QAAf,CAFG,CAGP,MAAO,IAAMC,uBAEZ,CAAG,SAACN,CAAD,QAAUA,EAAI,CAACO,QAAf,CAFG,CAGP,MAAO,IAAMC,qBAA8D,CAAG,SAC5ER,CAD4E,QAEzEA,EAAI,CAACS,MAFoE,CAAvE,CAGP,MAAO,IAAMC,oBAA4D,CAAG,SAC1EV,CAD0E,QAEvEA,EAAI,CAACW,KAFkE,CAArE,CAGP,MAAO,IAAMC,iBAAsD,CAAG,SAACZ,CAAD,QACpEA,EAAI,CAACa,EAD+D,CAA/D,CAEP,MAAO,IAAMC,yBAEZ,CAAG,SAACd,CAAD,QAAUA,EAAI,CAACe,UAAf,CAFG,CAGP,MAAO,IAAMC,kBAAwD,CAAG,SACtEhB,CADsE,QAEnEA,EAAI,CAACiB,GAF8D,CAAjE,CAIP,MAAO,SAASC,mBAAT,CAAkCC,CAAlC,CAA2D,CAChE,sCACKA,CADL,MAEEC,YAAY,CAAED,CAAK,CAACC,YAAN,EAAsBV,mBAFtC,CAGEW,gBAAgB,CAAEF,CAAK,CAACE,gBAAN,EAA0BtB,uBAH9C,CAIEuB,eAAe,CAAEH,CAAK,CAACG,eAAN,EAAyBhB,sBAJ5C,CAKEiB,aAAa,CAAEJ,CAAK,CAACI,aAAN,EAAuBf,oBALxC,CAMEgB,UAAU,CAAEL,CAAK,CAACK,UAAN,EAAoBR,iBANlC,CAOES,SAAS,CAAEN,CAAK,CAACM,SAAN,EAAmBb,gBAPhC,CAQEc,iBAAiB,CAAEP,CAAK,CAACO,iBAAN,EAA2BZ,wBARhD,CASEa,aAAa,CAAER,CAAK,CAACQ,aAAN,EAAuBzB,oBATxC,CAUE0B,eAAe,CAAET,CAAK,CAACS,eAAN,EAAyBxB,sBAV5C,EAYD"}
|
|
@@ -20,6 +20,7 @@ export declare type ChipsItemProps = {
|
|
|
20
20
|
status?: ChipsPropStatus;
|
|
21
21
|
label: string;
|
|
22
22
|
active?: boolean;
|
|
23
|
+
disabled?: boolean;
|
|
23
24
|
};
|
|
24
25
|
export declare type ChipsDefaultItem = Omit<ChipsItemProps, 'size' | 'activeView' | 'interactive' | 'onRightIconClick'> & {
|
|
25
26
|
attributes?: Omit<AsAttributes, 'children' | 'ref'>;
|
|
@@ -34,6 +35,7 @@ export declare type ChipsPropGetItemRef<ITEM> = (item: ITEM) => ChipsDefaultItem
|
|
|
34
35
|
export declare type ChipsPropGetItemAs<ITEM> = (item: ITEM) => ChipsDefaultItem['as'];
|
|
35
36
|
export declare type ChipsPropGetItemAttributes<ITEM> = (item: ITEM) => ChipsDefaultItem['attributes'];
|
|
36
37
|
export declare type ChipsPropGetItemActive<ITEM> = (item: ITEM) => ChipsDefaultItem['active'];
|
|
38
|
+
export declare type ChipsPropGetItemDisabled<ITEM> = (item: ITEM) => ChipsDefaultItem['disabled'];
|
|
37
39
|
export declare type ChipsPropOnItemClick<ITEM> = (item: ITEM, props: {
|
|
38
40
|
e: React.MouseEvent;
|
|
39
41
|
}) => void;
|
|
@@ -45,6 +47,7 @@ export declare type ChipsProps<ITEM = ChipsDefaultItem> = PropsWithHTMLAttribute
|
|
|
45
47
|
activeView?: ChipsPropActiveView;
|
|
46
48
|
items: ITEM[];
|
|
47
49
|
interactive?: boolean;
|
|
50
|
+
disabled?: boolean;
|
|
48
51
|
getItemStatus?: ChipsPropGetItemStatus<ITEM>;
|
|
49
52
|
getItemLabel?: ChipsPropGetItemLabel<ITEM>;
|
|
50
53
|
getItemIconLeft?: ChipsPropGetItemIconLeft<ITEM>;
|
|
@@ -53,6 +56,7 @@ export declare type ChipsProps<ITEM = ChipsDefaultItem> = PropsWithHTMLAttribute
|
|
|
53
56
|
getItemAs?: ChipsPropGetItemAs<ITEM>;
|
|
54
57
|
getItemAttributes?: ChipsPropGetItemAttributes<ITEM>;
|
|
55
58
|
getItemActive?: ChipsPropGetItemActive<ITEM>;
|
|
59
|
+
getItemDisabled?: ChipsPropGetItemDisabled<ITEM>;
|
|
56
60
|
onItemClick?: ChipsPropOnItemClick<ITEM>;
|
|
57
61
|
onItemRightIconClick?: ChipsPropItemOnRightIconClick<ITEM>;
|
|
58
62
|
}, HTMLDivElement> & (ITEM extends {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["chipsPropSize","chipsPropSizeDefault","chipsPropActiveView","chipsPropActiveViewDefault"],"sources":["../../../../../src/components/Chips/types.ts"],"sourcesContent":["import { IconComponent } from '@consta/icons/Icon';\n\nimport { badgePropStatus } from '##/components/Badge';\nimport { AsAttributes, AsTags } from '##/utils/types/AsTags';\nimport { PropsWithHTMLAttributesAndRef } from '##/utils/types/PropsWithHTMLAttributes';\n\nexport const chipsPropSize = ['xs', 's', 'm', 'l'] as const;\nexport type ChipsPropSize = typeof chipsPropSize[number];\nexport const chipsPropSizeDefault: ChipsPropSize = 'm';\n\nexport const chipsPropActiveView = ['primary', 'secondary'] as const;\nexport type ChipsPropActiveView = typeof chipsPropActiveView[number];\nexport const chipsPropActiveViewDefault: ChipsPropActiveView = 'primary';\n\nexport type ChipsPropStatus = typeof badgePropStatus[number];\n\nexport type ChipsItemProps = {\n size?: ChipsPropSize;\n activeView?: ChipsPropActiveView;\n interactive?: boolean;\n onRightIconClick?: React.MouseEventHandler<HTMLButtonElement>;\n iconLeft?: IconComponent;\n iconRight?: IconComponent;\n status?: ChipsPropStatus;\n label: string;\n active?: boolean;\n};\n\nexport type ChipsDefaultItem = Omit<\n ChipsItemProps,\n 'size' | 'activeView' | 'interactive' | 'onRightIconClick'\n> & {\n attributes?: Omit<AsAttributes, 'children' | 'ref'>;\n as?: AsTags;\n ref?: React.RefObject<HTMLElement>;\n};\n\n// export type ChipsPropGetItemKey<ITEM> = (item: ITEM) => ChipsDefaultItem['key'];\nexport type ChipsPropGetItemStatus<ITEM> = (\n item: ITEM,\n) => ChipsDefaultItem['status'];\nexport type ChipsPropGetItemLabel<ITEM> = (\n item: ITEM,\n) => ChipsDefaultItem['label'];\nexport type ChipsPropGetItemIconLeft<ITEM> = (\n item: ITEM,\n) => ChipsDefaultItem['iconLeft'];\nexport type ChipsPropGetItemIconRight<ITEM> = (\n item: ITEM,\n) => ChipsDefaultItem['iconRight'];\nexport type ChipsPropGetItemRef<ITEM> = (item: ITEM) => ChipsDefaultItem['ref'];\nexport type ChipsPropGetItemAs<ITEM> = (item: ITEM) => ChipsDefaultItem['as'];\nexport type ChipsPropGetItemAttributes<ITEM> = (\n item: ITEM,\n) => ChipsDefaultItem['attributes'];\nexport type ChipsPropGetItemActive<ITEM> = (\n item: ITEM,\n) => ChipsDefaultItem['active'];\nexport type ChipsPropOnItemClick<ITEM> = (\n item: ITEM,\n props: { e: React.MouseEvent },\n) => void;\nexport type ChipsPropItemOnRightIconClick<ITEM> = (\n item: ITEM,\n props: { e: React.MouseEvent },\n) => void;\n\nexport type ChipsProps<ITEM = ChipsDefaultItem> = PropsWithHTMLAttributesAndRef<\n {\n size?: ChipsPropSize;\n activeView?: ChipsPropActiveView;\n items: ITEM[];\n interactive?: boolean;\n getItemStatus?: ChipsPropGetItemStatus<ITEM>;\n getItemLabel?: ChipsPropGetItemLabel<ITEM>;\n getItemIconLeft?: ChipsPropGetItemIconLeft<ITEM>;\n getItemIconRight?: ChipsPropGetItemIconRight<ITEM>;\n getItemRef?: ChipsPropGetItemRef<ITEM>;\n getItemAs?: ChipsPropGetItemAs<ITEM>;\n getItemAttributes?: ChipsPropGetItemAttributes<ITEM>;\n getItemActive?: ChipsPropGetItemActive<ITEM>;\n onItemClick?: ChipsPropOnItemClick<ITEM>;\n onItemRightIconClick?: ChipsPropItemOnRightIconClick<ITEM>;\n },\n HTMLDivElement\n> &\n (ITEM extends { label: string }\n ? {}\n : {\n getItemLabel: ChipsPropGetItemLabel<ITEM>;\n });\n\nexport type ChipsComponent = <ITEM = ChipsDefaultItem>(\n props: ChipsProps<ITEM>,\n) => React.ReactElement | null;\n"],"mappings":"AAMA,MAAO,IAAMA,cAAa,CAAG,CAAC,IAAD,CAAO,GAAP,CAAY,GAAZ,CAAiB,GAAjB,CAAtB,CAEP,MAAO,IAAMC,qBAAmC,CAAG,GAA5C,CAEP,MAAO,IAAMC,oBAAmB,CAAG,CAAC,SAAD,CAAY,WAAZ,CAA5B,CAEP,MAAO,IAAMC,2BAA+C,CAAG,SAAxD"}
|
|
1
|
+
{"version":3,"file":"types.js","names":["chipsPropSize","chipsPropSizeDefault","chipsPropActiveView","chipsPropActiveViewDefault"],"sources":["../../../../../src/components/Chips/types.ts"],"sourcesContent":["import { IconComponent } from '@consta/icons/Icon';\n\nimport { badgePropStatus } from '##/components/Badge';\nimport { AsAttributes, AsTags } from '##/utils/types/AsTags';\nimport { PropsWithHTMLAttributesAndRef } from '##/utils/types/PropsWithHTMLAttributes';\n\nexport const chipsPropSize = ['xs', 's', 'm', 'l'] as const;\nexport type ChipsPropSize = typeof chipsPropSize[number];\nexport const chipsPropSizeDefault: ChipsPropSize = 'm';\n\nexport const chipsPropActiveView = ['primary', 'secondary'] as const;\nexport type ChipsPropActiveView = typeof chipsPropActiveView[number];\nexport const chipsPropActiveViewDefault: ChipsPropActiveView = 'primary';\n\nexport type ChipsPropStatus = typeof badgePropStatus[number];\n\nexport type ChipsItemProps = {\n size?: ChipsPropSize;\n activeView?: ChipsPropActiveView;\n interactive?: boolean;\n onRightIconClick?: React.MouseEventHandler<HTMLButtonElement>;\n iconLeft?: IconComponent;\n iconRight?: IconComponent;\n status?: ChipsPropStatus;\n label: string;\n active?: boolean;\n disabled?: boolean;\n};\n\nexport type ChipsDefaultItem = Omit<\n ChipsItemProps,\n 'size' | 'activeView' | 'interactive' | 'onRightIconClick'\n> & {\n attributes?: Omit<AsAttributes, 'children' | 'ref'>;\n as?: AsTags;\n ref?: React.RefObject<HTMLElement>;\n};\n\n// export type ChipsPropGetItemKey<ITEM> = (item: ITEM) => ChipsDefaultItem['key'];\nexport type ChipsPropGetItemStatus<ITEM> = (\n item: ITEM,\n) => ChipsDefaultItem['status'];\nexport type ChipsPropGetItemLabel<ITEM> = (\n item: ITEM,\n) => ChipsDefaultItem['label'];\nexport type ChipsPropGetItemIconLeft<ITEM> = (\n item: ITEM,\n) => ChipsDefaultItem['iconLeft'];\nexport type ChipsPropGetItemIconRight<ITEM> = (\n item: ITEM,\n) => ChipsDefaultItem['iconRight'];\nexport type ChipsPropGetItemRef<ITEM> = (item: ITEM) => ChipsDefaultItem['ref'];\nexport type ChipsPropGetItemAs<ITEM> = (item: ITEM) => ChipsDefaultItem['as'];\nexport type ChipsPropGetItemAttributes<ITEM> = (\n item: ITEM,\n) => ChipsDefaultItem['attributes'];\nexport type ChipsPropGetItemActive<ITEM> = (\n item: ITEM,\n) => ChipsDefaultItem['active'];\nexport type ChipsPropGetItemDisabled<ITEM> = (\n item: ITEM,\n) => ChipsDefaultItem['disabled'];\nexport type ChipsPropOnItemClick<ITEM> = (\n item: ITEM,\n props: { e: React.MouseEvent },\n) => void;\nexport type ChipsPropItemOnRightIconClick<ITEM> = (\n item: ITEM,\n props: { e: React.MouseEvent },\n) => void;\n\nexport type ChipsProps<ITEM = ChipsDefaultItem> = PropsWithHTMLAttributesAndRef<\n {\n size?: ChipsPropSize;\n activeView?: ChipsPropActiveView;\n items: ITEM[];\n interactive?: boolean;\n disabled?: boolean;\n getItemStatus?: ChipsPropGetItemStatus<ITEM>;\n getItemLabel?: ChipsPropGetItemLabel<ITEM>;\n getItemIconLeft?: ChipsPropGetItemIconLeft<ITEM>;\n getItemIconRight?: ChipsPropGetItemIconRight<ITEM>;\n getItemRef?: ChipsPropGetItemRef<ITEM>;\n getItemAs?: ChipsPropGetItemAs<ITEM>;\n getItemAttributes?: ChipsPropGetItemAttributes<ITEM>;\n getItemActive?: ChipsPropGetItemActive<ITEM>;\n getItemDisabled?: ChipsPropGetItemDisabled<ITEM>;\n onItemClick?: ChipsPropOnItemClick<ITEM>;\n onItemRightIconClick?: ChipsPropItemOnRightIconClick<ITEM>;\n },\n HTMLDivElement\n> &\n (ITEM extends { label: string }\n ? {}\n : {\n getItemLabel: ChipsPropGetItemLabel<ITEM>;\n });\n\nexport type ChipsComponent = <ITEM = ChipsDefaultItem>(\n props: ChipsProps<ITEM>,\n) => React.ReactElement | null;\n"],"mappings":"AAMA,MAAO,IAAMA,cAAa,CAAG,CAAC,IAAD,CAAO,GAAP,CAAY,GAAZ,CAAiB,GAAjB,CAAtB,CAEP,MAAO,IAAMC,qBAAmC,CAAG,GAA5C,CAEP,MAAO,IAAMC,oBAAmB,CAAG,CAAC,SAAD,CAAY,WAAZ,CAA5B,CAEP,MAAO,IAAMC,2BAA+C,CAAG,SAAxD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["size","form","view","width","onlyIcon","iconSize","value","multiple","items","getItemLabel","onChange","getItemIcon","getItemAttributes","getItemRef","getItemDisabled","name","className","disabled","truncate"];import"./ChoiceGroup.css";import React,{forwardRef}from"react";import{useChoiceGroup}from"../../hooks/useChoiceGroup
|
|
1
|
+
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["size","form","view","width","onlyIcon","iconSize","value","multiple","items","getItemLabel","onChange","getItemIcon","getItemAttributes","getItemRef","getItemDisabled","name","className","disabled","truncate"];import"./ChoiceGroup.css";import React,{forwardRef}from"react";import{useChoiceGroup}from"../../hooks/useChoiceGroup";import{cn}from"../../utils/bem";import{getByMap}from"../../utils/getByMap";import{withDefaultGetters}from"./helper";import{ChoiceGroupItem}from"./Item/ChoiceGroup-Item";import{choiceGroupDefaultForm,choiceGroupDefaultSize,choiceGroupDefaultView,choiceGroupWidthDefault}from"./types";var sizeMap={xs:"xs",s:"xs",m:"s",l:"m"};export var cnChoiceGroup=cn("ChoiceGroup");var ChoiceGroupRender=function(a,b){var c=withDefaultGetters(a),d=c.size,e=void 0===d?choiceGroupDefaultSize:d,f=c.form,g=void 0===f?choiceGroupDefaultForm:f,h=c.view,i=void 0===h?choiceGroupDefaultView:h,j=c.width,k=void 0===j?choiceGroupWidthDefault:j,l=c.onlyIcon,m=c.iconSize,n=c.value,o=void 0===n?null:n,p=c.multiple,q=void 0!==p&&p,r=c.items,s=c.getItemLabel,t=c.onChange,u=c.getItemIcon,v=c.getItemAttributes,w=c.getItemRef,x=c.getItemDisabled,y=c.name,z=c.className,A=c.disabled,B=void 0!==A&&A,C=c.truncate,D=_objectWithoutProperties(c,_excluded),E=useChoiceGroup({value:o,getKey:s,callBack:t,multiple:q}),F=E.getOnChange,G=E.getChecked,H=getByMap(sizeMap,e,m);return React.createElement("div",Object.assign({},D,{ref:b,className:cnChoiceGroup({size:e,form:g,view:i,width:k,onlyIcon:l,disabled:B,truncate:C},[z])}),r.map(function(a,b){var c,d=G(a),e=!!x&&x(a),f=null!==(c=v(a))&&void 0!==c?c:{},g=s(a).toString();return React.createElement(React.Fragment,{key:g},0<b&&React.createElement("div",{className:cnChoiceGroup("Divider",{checked:d,disabled:e})}),React.createElement(ChoiceGroupItem,Object.assign({onChange:F(a),checked:d,label:g,icon:u&&u(a),iconSize:H,multiple:q,onlyIcon:l,ref:w(a),name:y,disabled:B||e,title:l||C?g:void 0},f)))}))};export var ChoiceGroup=forwardRef(ChoiceGroupRender);export*from"./types";
|
|
2
2
|
//# sourceMappingURL=ChoiceGroup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChoiceGroup.js","names":["React","forwardRef","useChoiceGroup","cn","getByMap","withDefaultGetters","ChoiceGroupItem","choiceGroupDefaultForm","choiceGroupDefaultSize","choiceGroupDefaultView","choiceGroupWidthDefault","sizeMap","xs","s","m","l","cnChoiceGroup","ChoiceGroupRender","props","ref","size","form","view","width","onlyIcon","iconSizeProp","iconSize","value","multiple","items","getItemLabel","onChange","getItemIcon","getItemAttributes","getItemRef","getItemDisabled","name","className","disabled","truncate","otherProps","getKey","callBack","getOnChange","getChecked","map","item","
|
|
1
|
+
{"version":3,"file":"ChoiceGroup.js","names":["React","forwardRef","useChoiceGroup","cn","getByMap","withDefaultGetters","ChoiceGroupItem","choiceGroupDefaultForm","choiceGroupDefaultSize","choiceGroupDefaultView","choiceGroupWidthDefault","sizeMap","xs","s","m","l","cnChoiceGroup","ChoiceGroupRender","props","ref","size","form","view","width","onlyIcon","iconSizeProp","iconSize","value","multiple","items","getItemLabel","onChange","getItemIcon","getItemAttributes","getItemRef","getItemDisabled","name","className","disabled","truncate","otherProps","getKey","callBack","getOnChange","getChecked","map","item","index","itemChecked","itemDisabled","attributes","label","toString","checked","ChoiceGroup"],"sources":["../../../../../src/components/ChoiceGroup/ChoiceGroup.tsx"],"sourcesContent":["import './ChoiceGroup.css';\n\nimport { IconPropSize } from '@consta/icons/Icon';\nimport React, { forwardRef } from 'react';\n\nimport { useChoiceGroup } from '##/hooks/useChoiceGroup';\nimport { cn } from '##/utils/bem';\nimport { getByMap } from '##/utils/getByMap';\n\nimport { withDefaultGetters } from './helper';\nimport { ChoiceGroupItem } from './Item/ChoiceGroup-Item';\nimport {\n ChoiceGroupComponent,\n choiceGroupDefaultForm,\n choiceGroupDefaultSize,\n choiceGroupDefaultView,\n ChoiceGroupPropOnChange,\n ChoiceGroupProps,\n ChoiceGroupPropSize,\n choiceGroupWidthDefault,\n} from './types';\n\nconst sizeMap: Record<ChoiceGroupPropSize, IconPropSize> = {\n xs: 'xs',\n s: 'xs',\n m: 's',\n l: 'm',\n};\n\nexport const cnChoiceGroup = cn('ChoiceGroup');\n\nconst ChoiceGroupRender = (\n props: ChoiceGroupProps,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const {\n size = choiceGroupDefaultSize,\n form = choiceGroupDefaultForm,\n view = choiceGroupDefaultView,\n width = choiceGroupWidthDefault,\n onlyIcon,\n iconSize: iconSizeProp,\n value = null,\n multiple = false,\n items,\n getItemLabel,\n onChange,\n getItemIcon,\n getItemAttributes,\n getItemRef,\n getItemDisabled,\n name,\n className,\n disabled = false,\n truncate,\n ...otherProps\n } = withDefaultGetters(props);\n\n type Item = typeof items[number];\n\n const { getOnChange, getChecked } = useChoiceGroup<\n Item,\n React.ChangeEvent<HTMLInputElement>\n >({\n value: value as Item,\n getKey: getItemLabel,\n callBack: onChange as ChoiceGroupPropOnChange<Item, false>,\n multiple: multiple as false,\n // привел к типам из-за того что\n // TS не понимает что параметры для не Multiple и Multiple не могут прийти одновременно\n });\n\n const iconSize = getByMap(sizeMap, size, iconSizeProp);\n\n return (\n <div\n {...otherProps}\n ref={ref}\n className={cnChoiceGroup(\n { size, form, view, width, onlyIcon, disabled, truncate },\n [className],\n )}\n >\n {items.map((item, index) => {\n const itemChecked = getChecked(item);\n const itemDisabled = !!getItemDisabled && getItemDisabled(item);\n const attributes = getItemAttributes(item) ?? {};\n const label = getItemLabel(item).toString();\n\n return (\n <React.Fragment key={label}>\n {index > 0 && (\n <div\n className={cnChoiceGroup('Divider', {\n checked: itemChecked,\n disabled: itemDisabled,\n })}\n />\n )}\n <ChoiceGroupItem\n onChange={getOnChange(item)}\n checked={itemChecked}\n label={label}\n icon={getItemIcon && getItemIcon(item)}\n iconSize={iconSize}\n multiple={multiple}\n onlyIcon={onlyIcon}\n ref={getItemRef(item)}\n name={name}\n disabled={disabled || itemDisabled}\n title={onlyIcon || truncate ? label : undefined}\n {...attributes}\n />\n </React.Fragment>\n );\n })}\n </div>\n );\n};\n\nexport const ChoiceGroup = forwardRef(\n ChoiceGroupRender,\n) as ChoiceGroupComponent;\n\nexport * from './types';\n"],"mappings":"uTAAA,0BAGA,MAAOA,MAAP,EAAgBC,UAAhB,KAAkC,OAAlC,CAEA,OAASC,cAAT,kCACA,OAASC,EAAT,uBACA,OAASC,QAAT,4BAEA,OAASC,kBAAT,gBACA,OAASC,eAAT,+BACA,OAEEC,sBAFF,CAGEC,sBAHF,CAIEC,sBAJF,CAQEC,uBARF,eAWA,GAAMC,QAAkD,CAAG,CACzDC,EAAE,CAAE,IADqD,CAEzDC,CAAC,CAAE,IAFsD,CAGzDC,CAAC,CAAE,GAHsD,CAIzDC,CAAC,CAAE,GAJsD,CAA3D,CAOA,MAAO,IAAMC,cAAa,CAAGb,EAAE,CAAC,aAAD,CAAxB,CAEP,GAAMc,kBAAiB,CAAG,SACxBC,CADwB,CAExBC,CAFwB,CAGrB,OAsBCd,kBAAkB,CAACa,CAAD,CAtBnB,KAEDE,IAFC,CAEDA,CAFC,YAEMZ,sBAFN,OAGDa,IAHC,CAGDA,CAHC,YAGMd,sBAHN,OAIDe,IAJC,CAIDA,CAJC,YAIMb,sBAJN,OAKDc,KALC,CAKDA,CALC,YAKOb,uBALP,GAMDc,CANC,GAMDA,QANC,CAOSC,CAPT,GAODC,QAPC,KAQDC,KARC,CAQDA,CARC,YAQO,IARP,OASDC,QATC,CASDA,CATC,eAUDC,CA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QAAnB,EAJY,CAM1B,MACE,qBAAC,KAAD,CAAO,QAAP,EAAgB,GAAG,CAAED,CAArB,EACW,CAAR,CAAAJ,CAAK,EACJ,2BACE,SAAS,CAAE/B,aAAa,CAAC,SAAD,CAAY,CAClCqC,OAAO,CAAEL,CADyB,CAElCV,QAAQ,CAAEW,CAFwB,CAAZ,CAD1B,EAFJ,CASE,oBAAC,eAAD,gBACE,QAAQ,CAAEN,CAAW,CAACG,CAAD,CADvB,CAEE,OAAO,CAAEE,CAFX,CAGE,KAAK,CAAEG,CAHT,CAIE,IAAI,CAAEnB,CAAW,EAAIA,CAAW,CAACc,CAAD,CAJlC,CAKE,QAAQ,CAAEpB,CALZ,CAME,QAAQ,CAAEE,CANZ,CAOE,QAAQ,CAAEJ,CAPZ,CAQE,GAAG,CAAEU,CAAU,CAACY,CAAD,CARjB,CASE,IAAI,CAAEV,CATR,CAUE,QAAQ,CAAEE,CAAQ,EAAIW,CAVxB,CAWE,KAAK,CAAEzB,CAAQ,EAAIe,CAAZ,CAAuBY,CAAvB,OAXT,EAYMD,CAZN,EATF,CAyBH,CAhCA,CARH,CA2CH,CAvFD,CAyFA,MAAO,IAAMI,YAAW,CAAGrD,UAAU,CACnCgB,iBADmC,CAA9B,CAIP"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["label","onChange","checked","multiple","icon","onlyIcon","name","iconSize","disabled","className"];import React,{forwardRef}from"react";import{useFlag}from"../../../hooks/useFlag";import{cnMixFocus}from"../../../mixs/MixFocus/MixFocus";import{cnChoiceGroup}from"../ChoiceGroup";export var ChoiceGroupItem=forwardRef(function(a,b){var c=a.label,d=a.onChange,e=a.checked,f=a.multiple,g=a.icon,h=a.onlyIcon,i=a.name,j=a.iconSize,k=a.disabled,l=void 0!==k&&k,m=a.className,n=_objectWithoutProperties(a,_excluded),o=useFlag(),p=_slicedToArray(o,2),q=p[0],r=p[1];return React.createElement("label",Object.assign({className:cnChoiceGroup("Label",{focus:q,checked:e,disabled:l},[cnMixFocus(),m]),
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["label","onChange","checked","multiple","icon","onlyIcon","name","iconSize","disabled","className"];import React,{forwardRef}from"react";import{useFlag}from"../../../hooks/useFlag";import{cnMixFocus}from"../../../mixs/MixFocus/MixFocus";import{cnChoiceGroup}from"../ChoiceGroup";export var ChoiceGroupItem=forwardRef(function(a,b){var c=a.label,d=a.onChange,e=a.checked,f=a.multiple,g=a.icon,h=a.onlyIcon,i=a.name,j=a.iconSize,k=a.disabled,l=void 0!==k&&k,m=a.className,n=_objectWithoutProperties(a,_excluded),o=useFlag(),p=_slicedToArray(o,2),q=p[0],r=p[1];return React.createElement("label",Object.assign({},n,{className:cnChoiceGroup("Label",{focus:q,checked:e,disabled:l},[cnMixFocus(),m]),ref:b}),React.createElement("input",{type:f?"checkbox":"radio",className:cnChoiceGroup("Input"),checked:e,onFocus:r.on,onBlur:r.off,value:"".concat(i,"-").concat(c),onChange:d,name:i,disabled:l}),g&&React.createElement(g,{className:cnChoiceGroup("Icon"),size:j}),!h&&React.createElement("span",{className:cnChoiceGroup("Text")},c))});
|
|
2
2
|
//# sourceMappingURL=ChoiceGroup-Item.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChoiceGroup-Item.js","names":["React","forwardRef","useFlag","cnMixFocus","cnChoiceGroup","ChoiceGroupItem","props","ref","label","onChange","checked","multiple","Icon","icon","onlyIcon","name","iconSize","disabled","className","otherProps","focus","setFocus","on","off"],"sources":["../../../../../../src/components/ChoiceGroup/Item/ChoiceGroup-Item.tsx"],"sourcesContent":["import { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport React, { forwardRef } from 'react';\n\nimport { useFlag } from '##/hooks/useFlag';\nimport { PropsWithHTMLAttributes } from '##/utils/types/PropsWithHTMLAttributes';\n\nimport { cnMixFocus } from '../../../mixs/MixFocus/MixFocus';\nimport { cnChoiceGroup } from '../ChoiceGroup';\n\ntype Props = PropsWithHTMLAttributes<\n {\n icon?: IconComponent;\n onlyIcon?: boolean;\n iconSize?: IconPropSize;\n label: string;\n name: string;\n onChange: React.ChangeEventHandler<HTMLInputElement>;\n checked: boolean;\n multiple: boolean;\n disabled?: boolean;\n },\n HTMLLabelElement\n>;\n\nexport const ChoiceGroupItem = forwardRef<HTMLLabelElement, Props>(\n (props, ref) => {\n const {\n label,\n onChange,\n checked,\n multiple,\n icon: Icon,\n onlyIcon,\n name,\n iconSize,\n disabled = false,\n className,\n ...otherProps\n } = props;\n const [focus, setFocus] = useFlag();\n\n return (\n <label\n className={cnChoiceGroup('Label', { focus, checked, disabled }, [\n cnMixFocus(),\n className,\n ])}\n
|
|
1
|
+
{"version":3,"file":"ChoiceGroup-Item.js","names":["React","forwardRef","useFlag","cnMixFocus","cnChoiceGroup","ChoiceGroupItem","props","ref","label","onChange","checked","multiple","Icon","icon","onlyIcon","name","iconSize","disabled","className","otherProps","focus","setFocus","on","off"],"sources":["../../../../../../src/components/ChoiceGroup/Item/ChoiceGroup-Item.tsx"],"sourcesContent":["import { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport React, { forwardRef } from 'react';\n\nimport { useFlag } from '##/hooks/useFlag';\nimport { PropsWithHTMLAttributes } from '##/utils/types/PropsWithHTMLAttributes';\n\nimport { cnMixFocus } from '../../../mixs/MixFocus/MixFocus';\nimport { cnChoiceGroup } from '../ChoiceGroup';\n\ntype Props = PropsWithHTMLAttributes<\n {\n icon?: IconComponent;\n onlyIcon?: boolean;\n iconSize?: IconPropSize;\n label: string;\n name: string;\n onChange: React.ChangeEventHandler<HTMLInputElement>;\n checked: boolean;\n multiple: boolean;\n disabled?: boolean;\n },\n HTMLLabelElement\n>;\n\nexport const ChoiceGroupItem = forwardRef<HTMLLabelElement, Props>(\n (props, ref) => {\n const {\n label,\n onChange,\n checked,\n multiple,\n icon: Icon,\n onlyIcon,\n name,\n iconSize,\n disabled = false,\n className,\n ...otherProps\n } = props;\n const [focus, setFocus] = useFlag();\n\n return (\n <label\n {...otherProps}\n className={cnChoiceGroup('Label', { focus, checked, disabled }, [\n cnMixFocus(),\n className,\n ])}\n ref={ref}\n >\n <input\n type={multiple ? 'checkbox' : 'radio'}\n className={cnChoiceGroup('Input')}\n checked={checked}\n onFocus={setFocus.on}\n onBlur={setFocus.off}\n value={`${name}-${label}`}\n onChange={onChange}\n name={name}\n disabled={disabled}\n />\n {Icon && <Icon className={cnChoiceGroup('Icon')} size={iconSize} />}\n {!onlyIcon && <span className={cnChoiceGroup('Text')}>{label}</span>}\n </label>\n );\n },\n);\n"],"mappings":"yQACA,MAAOA,MAAP,EAAgBC,UAAhB,KAAkC,OAAlC,CAEA,OAASC,OAAT,8BAGA,OAASC,UAAT,uCACA,OAASC,aAAT,sBAiBA,MAAO,IAAMC,gBAAe,CAAGJ,UAAU,CACvC,SAACK,CAAD,CAAQC,CAAR,CAAgB,IAEZC,EAFY,CAaVF,CAbU,CAEZE,KAFY,CAGZC,CAHY,CAaVH,CAbU,CAGZG,QAHY,CAIZC,CAJY,CAaVJ,CAbU,CAIZI,OAJY,CAKZC,CALY,CAaVL,CAbU,CAKZK,QALY,CAMNC,CANM,CAaVN,CAbU,CAMZO,IANY,CAOZC,CAPY,CAaVR,CAbU,CAOZQ,QAPY,CAQZC,CARY,CAaVT,CAbU,CAQZS,IARY,CASZC,CATY,CAaVV,CAbU,CASZU,QATY,GAaVV,CAbU,CAUZW,QAVY,CAUZA,CAVY,eAWZC,CAXY,CAaVZ,CAbU,CAWZY,SAXY,CAYTC,CAZS,0BAaVb,CAbU,cAcYJ,OAAO,EAdnB,uBAcPkB,CAdO,MAcAC,CAdA,MAgBd,MACE,8CACMF,CADN,EAEE,SAAS,CAAEf,aAAa,CAAC,OAAD,CAAU,CAAEgB,KAAK,CAALA,CAAF,CAASV,OAAO,CAAPA,CAAT,CAAkBO,QAAQ,CAARA,CAAlB,CAAV,CAAwC,CAC9Dd,UAAU,EADoD,CAE9De,CAF8D,CAAxC,CAF1B,CAME,GAAG,CAAEX,CANP,GAQE,6BACE,IAAI,CAAEI,CAAQ,CAAG,UAAH,CAAgB,OADhC,CAEE,SAAS,CAAEP,aAAa,CAAC,OAAD,CAF1B,CAGE,OAAO,CAAEM,CAHX,CAIE,OAAO,CAAEW,CAAQ,CAACC,EAJpB,CAKE,MAAM,CAAED,CAAQ,CAACE,GALnB,CAME,KAAK,WAAKR,CAAL,aAAaP,CAAb,CANP,CAOE,QAAQ,CAAEC,CAPZ,CAQE,IAAI,CAAEM,CARR,CASE,QAAQ,CAAEE,CATZ,EARF,CAmBGL,CAAI,EAAI,oBAAC,CAAD,EAAM,SAAS,CAAER,aAAa,CAAC,MAAD,CAA9B,CAAwC,IAAI,CAAEY,CAA9C,EAnBX,CAoBG,CAACF,CAAD,EAAa,4BAAM,SAAS,CAAEV,aAAa,CAAC,MAAD,CAA9B,EAAyCI,CAAzC,CApBhB,CAuBH,CAzCsC,CAAlC"}
|
package/__internal__/src/components/DatePicker/DatePickerFieldTypeDate/DatePickerFieldTypeDate.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["format","separator","placeholder","onChange","onError","minDate","maxDate","value","inputRef","defaultValue"];import React from"react";import{TextField}from"../../TextField";import{useForkRef}from"../../../hooks/useForkRef";import{maxDateDefault,minDateDefault}from"../../../utils/date";import{datePickerPropFormatTypeDate,datePickerPropPlaceholderTypeDate,datePickerPropSeparatorDefault}from"../helpers";import{usePicker}from"./helpers";export var DatePickerFieldTypeDate=React.forwardRef(function(a,b){var c=a.format,d=void 0===c?datePickerPropFormatTypeDate:c,e=a.separator,f=void 0===e?datePickerPropSeparatorDefault:e,g=a.placeholder,h=void 0===g?datePickerPropPlaceholderTypeDate:g,i=a.onChange,j=a.onError,k=a.minDate,l=void 0===k?minDateDefault:k,m=a.maxDate,n=void 0===m?maxDateDefault:m,o=a.value,p=a.inputRef,q=a.defaultValue,r=_objectWithoutProperties(a,_excluded),s=usePicker({format:d,separator:f,onChange:i,onError:j,value:o,minDate:l,maxDate:n});return React.createElement(TextField,Object.assign({},r,{type:"text",inputContainerRef:b,inputRef:useForkRef([
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["format","separator","placeholder","onChange","onError","minDate","maxDate","value","inputRef","defaultValue"];import React from"react";import{TextField}from"../../TextField";import{useForkRef}from"../../../hooks/useForkRef";import{maxDateDefault,minDateDefault}from"../../../utils/date";import{datePickerPropFormatTypeDate,datePickerPropPlaceholderTypeDate,datePickerPropSeparatorDefault}from"../helpers";import{usePicker}from"./helpers";export var DatePickerFieldTypeDate=React.forwardRef(function(a,b){var c=a.format,d=void 0===c?datePickerPropFormatTypeDate:c,e=a.separator,f=void 0===e?datePickerPropSeparatorDefault:e,g=a.placeholder,h=void 0===g?datePickerPropPlaceholderTypeDate:g,i=a.onChange,j=a.onError,k=a.minDate,l=void 0===k?minDateDefault:k,m=a.maxDate,n=void 0===m?maxDateDefault:m,o=a.value,p=a.inputRef,q=a.defaultValue,r=_objectWithoutProperties(a,_excluded),s=usePicker({format:d,separator:f,onChange:i,onError:j,value:o,minDate:l,maxDate:n}),t=_slicedToArray(s,2),u=t[0],v=t[1];return React.createElement(TextField,Object.assign({},r,{type:"text",inputContainerRef:b,inputRef:useForkRef([u,p]),placeholder:h,onClear:v}))});
|
|
2
2
|
//# sourceMappingURL=DatePickerFieldTypeDate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePickerFieldTypeDate.js","names":["React","TextField","useForkRef","maxDateDefault","minDateDefault","datePickerPropFormatTypeDate","datePickerPropPlaceholderTypeDate","datePickerPropSeparatorDefault","usePicker","DatePickerFieldTypeDate","forwardRef","props","ref","format","separator","placeholder","onChange","onError","minDate","maxDate","value","inputRefProp","inputRef","defaultValue","otherProps"],"sources":["../../../../../../src/components/DatePicker/DatePickerFieldTypeDate/DatePickerFieldTypeDate.tsx"],"sourcesContent":["import React from 'react';\n\nimport { TextField } from '##/components/TextField';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { maxDateDefault, minDateDefault } from '##/utils/date';\n\nimport {\n datePickerPropFormatTypeDate,\n datePickerPropPlaceholderTypeDate,\n datePickerPropSeparatorDefault,\n} from '../helpers';\nimport { DatePickerFieldTypeDateProps, usePicker } from './helpers';\n\nexport const DatePickerFieldTypeDate = React.forwardRef<\n HTMLDivElement,\n DatePickerFieldTypeDateProps\n>((props, ref) => {\n const {\n format = datePickerPropFormatTypeDate,\n separator = datePickerPropSeparatorDefault,\n placeholder = datePickerPropPlaceholderTypeDate,\n onChange,\n onError,\n minDate = minDateDefault,\n maxDate = maxDateDefault,\n value,\n inputRef: inputRefProp,\n defaultValue,\n ...otherProps\n } = props;\n\n const inputRef = usePicker({\n format,\n separator,\n onChange,\n onError,\n value,\n minDate,\n maxDate,\n });\n\n return (\n <TextField\n {...otherProps}\n type=\"text\"\n inputContainerRef={ref}\n inputRef={useForkRef([inputRef, inputRefProp])}\n placeholder={placeholder}\n />\n );\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"DatePickerFieldTypeDate.js","names":["React","TextField","useForkRef","maxDateDefault","minDateDefault","datePickerPropFormatTypeDate","datePickerPropPlaceholderTypeDate","datePickerPropSeparatorDefault","usePicker","DatePickerFieldTypeDate","forwardRef","props","ref","format","separator","placeholder","onChange","onError","minDate","maxDate","value","inputRefProp","inputRef","defaultValue","otherProps","onClear"],"sources":["../../../../../../src/components/DatePicker/DatePickerFieldTypeDate/DatePickerFieldTypeDate.tsx"],"sourcesContent":["import React from 'react';\n\nimport { TextField } from '##/components/TextField';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { maxDateDefault, minDateDefault } from '##/utils/date';\n\nimport {\n datePickerPropFormatTypeDate,\n datePickerPropPlaceholderTypeDate,\n datePickerPropSeparatorDefault,\n} from '../helpers';\nimport { DatePickerFieldTypeDateProps, usePicker } from './helpers';\n\nexport const DatePickerFieldTypeDate = React.forwardRef<\n HTMLDivElement,\n DatePickerFieldTypeDateProps\n>((props, ref) => {\n const {\n format = datePickerPropFormatTypeDate,\n separator = datePickerPropSeparatorDefault,\n placeholder = datePickerPropPlaceholderTypeDate,\n onChange,\n onError,\n minDate = minDateDefault,\n maxDate = maxDateDefault,\n value,\n inputRef: inputRefProp,\n defaultValue,\n ...otherProps\n } = props;\n\n const [inputRef, onClear] = usePicker({\n format,\n separator,\n onChange,\n onError,\n value,\n minDate,\n maxDate,\n });\n\n return (\n <TextField\n {...otherProps}\n type=\"text\"\n inputContainerRef={ref}\n inputRef={useForkRef([inputRef, inputRefProp])}\n placeholder={placeholder}\n onClear={onClear}\n />\n );\n});\n"],"mappings":"oRAAA,MAAOA,MAAP,KAAkB,OAAlB,CAEA,OAASC,SAAT,uBACA,OAASC,UAAT,iCACA,OAASC,cAAT,CAAyBC,cAAzB,2BAEA,OACEC,4BADF,CAEEC,iCAFF,CAGEC,8BAHF,kBAKA,OAAuCC,SAAvC,iBAEA,MAAO,IAAMC,wBAAuB,CAAGT,KAAK,CAACU,UAAN,CAGrC,SAACC,CAAD,CAAQC,CAAR,CAAgB,OAaZD,CAbY,CAEdE,MAFc,CAEdA,CAFc,YAELR,4BAFK,KAaZM,CAbY,CAGdG,SAHc,CAGdA,CAHc,YAGFP,8BAHE,KAaZI,CAbY,CAIdI,WAJc,CAIdA,CAJc,YAIAT,iCAJA,GAKdU,CALc,CAaZL,CAbY,CAKdK,QALc,CAMdC,CANc,CAaZN,CAbY,CAMdM,OANc,GAaZN,CAbY,CAOdO,OAPc,CAOdA,CAPc,YAOJd,cAPI,KAaZO,CAbY,CAQdQ,OARc,CAQdA,CARc,YAQJhB,cARI,GASdiB,CATc,CAaZT,CAbY,CASdS,KATc,CAUJC,CAVI,CAaZV,CAbY,CAUdW,QAVc,CAWdC,CAXc,CAaZZ,CAbY,CAWdY,YAXc,CAYXC,CAZW,0BAaZb,CAbY,cAeYH,SAAS,CAAC,CACpCK,MAAM,CAANA,CADoC,CAEpCC,SAAS,CAATA,CAFoC,CAGpCE,QAAQ,CAARA,CAHoC,CAIpCC,OAAO,CAAPA,CAJoC,CAKpCG,KAAK,CAALA,CALoC,CAMpCF,OAAO,CAAPA,CANoC,CAOpCC,OAAO,CAAPA,CAPoC,CAAD,CAfrB,uBAeTG,CAfS,MAeCG,CAfD,MAyBhB,MACE,qBAAC,SAAD,kBACMD,CADN,EAEE,IAAI,CAAC,MAFP,CAGE,iBAAiB,CAAEZ,CAHrB,CAIE,QAAQ,CAAEV,UAAU,CAAC,CAACoB,CAAD,CAAWD,CAAX,CAAD,CAJtB,CAKE,WAAW,CAAEN,CALf,CAME,OAAO,CAAEU,CANX,GASH,CAtCsC,CAAhC"}
|
|
@@ -51,5 +51,5 @@ declare type UsePickerProps = {
|
|
|
51
51
|
minDate: Date;
|
|
52
52
|
maxDate: Date;
|
|
53
53
|
};
|
|
54
|
-
export declare const usePicker: (props: UsePickerProps) => import("react").MutableRefObject<HTMLInputElement | null
|
|
54
|
+
export declare const usePicker: (props: UsePickerProps) => readonly [import("react").MutableRefObject<HTMLInputElement | null>, import("react").MouseEventHandler<HTMLButtonElement>];
|
|
55
55
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{format as _format,isValid,isWithinInterval,parse as _parse}from"date-fns";import{useCallback}from"react";import{IMask,useIMask}from"react-imask";import{useMutableRef}from"../../../hooks/useMutableRef/useMutableRef";import{datePickerPropSeparatorDefault,getPartDate,getParts,getPartsDate,useStringValue}from"../helpers";import{datePickerErrorTypes}from"../types";export var usePicker=function(a){var b=a.value,c=a.onChange,d=a.onError,f=a.format,g=a.separator,h=a.maxDate,i=a.minDate,j=useMutableRef(c),k=useMutableRef(b),l=useMutableRef(d),m=useCallback(function(a,b,c){var d=j.current,e=k.current;if(!(e&&isValid(e)&&_format(e,f)===a)){if((null===a||void 0===a?void 0:a.length)!==f.length&&e&&c&&d)return void d(null,{e:c});if(d&&c){if(!a)return void(e&&d(null,{e:c}));var m=getParts(f,g,!1),n=getParts(a,g,!1),o=m.map(function(a){return getPartDate(m,n,a)}).filter(function(a){return!!a});if(m.length===o.length){var v=_parse(n.join(datePickerPropSeparatorDefault),m.join(datePickerPropSeparatorDefault),new Date);if(!isWithinInterval(v,{start:i,end:h})){var p,q=getPartsDate(a,f,g,!1,["dd","MM","yyyy"]),r=_slicedToArray(q,3),s=r[0],t=r[1],u=r[2];return null===(p=l.current)||void 0===p?void 0:p.call(l,{type:datePickerErrorTypes[0],stringValue:a,dd:s,MM:t,yyyy:u,date:v}),void(e&&d(null,{e:c}))}d(v,{e:c})}else e&&d(null,{e:c})}}},[null===i||void 0===i?void 0:i.getTime(),null===h||void 0===h?void 0:h.getTime(),f,g]),n=useIMask({mask:Date,pattern:f,blocks:{yyyy:{mask:IMask.MaskedRange,from:1,to:9999},MM:{mask:IMask.MaskedRange,from:1,to:12},dd:{mask:IMask.MaskedRange,from:1,to:31}},lazy:!0,autofix:!0,format:function format(a){return _format(a,f)},parse:function parse(a){return _parse(a,f,new Date)},validate:function validate(a){var b=getParts(f,g,!1),c=getParts(a,g,!1),d=b.map(function(a){return getPartDate(b,c,a)}).filter(function(a){return!!a});if(b.length===d.length&&!isValid(_parse(c.join(datePickerPropSeparatorDefault),b.join(datePickerPropSeparatorDefault),new Date))){var e,h=getPartsDate(a,f,g,!1,["dd","MM","yyyy"]),i=_slicedToArray(h,3),j=i[0],k=i[1],m=i[2];return null===(e=l.current)||void 0===e?void 0:e.call(l,{type:datePickerErrorTypes[1],stringValue:a,dd:j,MM:k,yyyy:m}),!1}return!0}},{onAccept:m}),o=
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{format as _format,isValid,isWithinInterval,parse as _parse}from"date-fns";import{useCallback}from"react";import{IMask,useIMask}from"react-imask";import{useMutableRef}from"../../../hooks/useMutableRef/useMutableRef";import{datePickerPropSeparatorDefault,getPartDate,getParts,getPartsDate,useStringValue}from"../helpers";import{datePickerErrorTypes}from"../types";export var usePicker=function(a){var b=a.value,c=a.onChange,d=a.onError,f=a.format,g=a.separator,h=a.maxDate,i=a.minDate,j=useMutableRef(c),k=useMutableRef(b),l=useMutableRef(d),m=useCallback(function(a,b,c){var d=j.current,e=k.current;if(!(e&&isValid(e)&&_format(e,f)===a)){if((null===a||void 0===a?void 0:a.length)!==f.length&&e&&c&&d)return void d(null,{e:c});if(d&&c){if(!a)return void(e&&d(null,{e:c}));var m=getParts(f,g,!1),n=getParts(a,g,!1),o=m.map(function(a){return getPartDate(m,n,a)}).filter(function(a){return!!a});if(m.length===o.length){var v=_parse(n.join(datePickerPropSeparatorDefault),m.join(datePickerPropSeparatorDefault),new Date);if(!isWithinInterval(v,{start:i,end:h})){var p,q=getPartsDate(a,f,g,!1,["dd","MM","yyyy"]),r=_slicedToArray(q,3),s=r[0],t=r[1],u=r[2];return null===(p=l.current)||void 0===p?void 0:p.call(l,{type:datePickerErrorTypes[0],stringValue:a,dd:s,MM:t,yyyy:u,date:v}),void(e&&d(null,{e:c}))}d(v,{e:c})}else e&&d(null,{e:c})}}},[null===i||void 0===i?void 0:i.getTime(),null===h||void 0===h?void 0:h.getTime(),f,g]),n=useIMask({mask:Date,pattern:f,blocks:{yyyy:{mask:IMask.MaskedRange,from:1,to:9999},MM:{mask:IMask.MaskedRange,from:1,to:12},dd:{mask:IMask.MaskedRange,from:1,to:31}},lazy:!0,autofix:!0,format:function format(a){return _format(a,f)},parse:function parse(a){return _parse(a,f,new Date)},validate:function validate(a){var b=getParts(f,g,!1),c=getParts(a,g,!1),d=b.map(function(a){return getPartDate(b,c,a)}).filter(function(a){return!!a});if(b.length===d.length&&!isValid(_parse(c.join(datePickerPropSeparatorDefault),b.join(datePickerPropSeparatorDefault),new Date))){var e,h=getPartsDate(a,f,g,!1,["dd","MM","yyyy"]),i=_slicedToArray(h,3),j=i[0],k=i[1],m=i[2];return null===(e=l.current)||void 0===e?void 0:e.call(l,{type:datePickerErrorTypes[1],stringValue:a,dd:j,MM:k,yyyy:m}),!1}return!0}},{onAccept:m}),o=useStringValue(b,f,g,j,n);return[n.ref,o]};
|
|
2
2
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":["format","isValid","isWithinInterval","parse","useCallback","IMask","useIMask","useMutableRef","datePickerPropSeparatorDefault","getPartDate","getParts","getPartsDate","useStringValue","datePickerErrorTypes","usePicker","props","value","onChange","onError","formatProp","separator","maxDate","minDate","onChangeRef","valueRef","onErrorRef","onAccept","stringValue","maskRef","e","current","length","formatArray","valueArray","validArray","map","marker","filter","item","date","join","Date","start","end","dd","MM","yyyy","type","getTime","mask","pattern","blocks","MaskedRange","from","to","lazy","autofix","string","validate","ref","setStringValue","setValue"],"sources":["../../../../../../src/components/DatePicker/DatePickerFieldTypeDate/helpers.ts"],"sourcesContent":["import { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport { format, isValid, isWithinInterval, parse } from 'date-fns';\nimport { MaskedDate } from 'imask';\nimport { useCallback } from 'react';\nimport { IMask, ReactMaskOpts, useIMask } from 'react-imask';\n\nimport {\n TextFieldPropForm,\n TextFieldPropSize,\n TextFieldPropStatus,\n TextFieldPropView,\n} from '##/components/TextField';\nimport { useMutableRef } from '##/hooks/useMutableRef/useMutableRef';\nimport { PropsWithHTMLAttributes } from '##/utils/types/PropsWithHTMLAttributes';\n\nimport {\n datePickerPropSeparatorDefault,\n getPartDate,\n getParts,\n getPartsDate,\n useStringValue,\n} from '../helpers';\nimport { datePickerErrorTypes, DatePickerPropOnError } from '../types';\n\ntype DatePickerFieldTypeDatePropOnChange = (\n value: Date | null,\n props: {\n e: Event;\n },\n) => void;\n\nexport type DatePickerFieldTypeDateProps = PropsWithHTMLAttributes<\n {\n className?: string;\n value?: Date | null;\n onChange?: DatePickerFieldTypeDatePropOnChange;\n onError?: DatePickerPropOnError;\n id?: string;\n name?: string;\n disabled?: boolean;\n size?: TextFieldPropSize;\n view?: TextFieldPropView;\n form?: TextFieldPropForm;\n status?: TextFieldPropStatus;\n onFocus?: React.FocusEventHandler<HTMLElement>;\n onBlur?: React.FocusEventHandler<HTMLElement>;\n autoFocus?: boolean;\n placeholder?: string;\n leftSide?: string | IconComponent;\n rightSide?: string | IconComponent;\n readOnly?: boolean;\n required?: boolean;\n tabIndex?: number;\n inputRef?: React.Ref<HTMLTextAreaElement | HTMLInputElement>;\n ariaLabel?: string;\n iconSize?: IconPropSize;\n children?: never;\n format?: string;\n separator?: string;\n minDate?: Date;\n maxDate?: Date;\n focused?: boolean;\n label?: string;\n labelIcon?: IconComponent;\n caption?: string;\n labelPosition?: 'top' | 'left';\n withClearButton?: boolean;\n },\n HTMLDivElement\n>;\n\ntype UsePickerProps = {\n value?: Date | null;\n onChange?: DatePickerFieldTypeDatePropOnChange;\n onError?: DatePickerPropOnError;\n format: string;\n separator: string;\n minDate: Date;\n maxDate: Date;\n};\n\nexport const usePicker = (props: UsePickerProps) => {\n const {\n value,\n onChange,\n onError,\n format: formatProp,\n separator,\n maxDate,\n minDate,\n } = props;\n const onChangeRef = useMutableRef(onChange);\n const valueRef = useMutableRef(value);\n const onErrorRef = useMutableRef(onError);\n\n const onAccept = useCallback(\n (stringValue: string, maskRef: unknown, e: InputEvent | undefined) => {\n const onChange = onChangeRef.current;\n const value = valueRef.current;\n\n if (\n value &&\n isValid(value) &&\n format(value, formatProp) === stringValue\n ) {\n return;\n }\n\n if (stringValue?.length !== formatProp.length && value && e && onChange) {\n onChange(null, { e });\n return;\n }\n\n if (onChange && e) {\n if (!stringValue) {\n if (value) {\n onChange(null, { e });\n }\n return;\n }\n\n const formatArray = getParts(formatProp, separator, false);\n const valueArray = getParts(stringValue, separator, false);\n const validArray = formatArray\n .map((marker) => getPartDate(formatArray, valueArray, marker))\n .filter((item) => Boolean(item));\n\n if (formatArray.length === validArray.length) {\n const date = parse(\n valueArray.join(datePickerPropSeparatorDefault),\n formatArray.join(datePickerPropSeparatorDefault),\n new Date(),\n );\n\n if (!isWithinInterval(date, { start: minDate, end: maxDate })) {\n const [dd, MM, yyyy] = getPartsDate(\n stringValue,\n formatProp,\n separator,\n false,\n ['dd', 'MM', 'yyyy'],\n );\n\n onErrorRef.current?.({\n type: datePickerErrorTypes[0],\n stringValue,\n dd,\n MM,\n yyyy,\n date,\n });\n if (value) {\n onChange(null, { e });\n }\n\n return;\n }\n onChange(date, { e });\n } else if (value) {\n onChange(null, { e });\n }\n }\n },\n [minDate?.getTime(), maxDate?.getTime(), formatProp, separator],\n );\n\n const {\n ref,\n setValue: setStringValue,\n value: stringValue,\n } = useIMask<HTMLInputElement, ReactMaskOpts>(\n {\n mask: Date as unknown as MaskedDate,\n pattern: formatProp,\n blocks: {\n // @ts-ignore\n yyyy: {\n mask: IMask.MaskedRange,\n from: 1,\n to: 9999,\n },\n // @ts-ignore\n MM: {\n mask: IMask.MaskedRange,\n from: 1,\n to: 12,\n },\n // @ts-ignore\n dd: {\n mask: IMask.MaskedRange,\n from: 1,\n to: 31,\n },\n },\n lazy: true,\n autofix: true,\n format: (date: Date) => format(date, formatProp),\n parse: (string: string) => parse(string, formatProp, new Date()),\n validate: (string: string) => {\n const formatArray = getParts(formatProp, separator, false);\n const valueArray = getParts(string, separator, false);\n const validArray = formatArray\n .map((marker) => getPartDate(formatArray, valueArray, marker))\n .filter((item) => Boolean(item));\n\n if (\n formatArray.length === validArray.length &&\n !isValid(\n parse(\n valueArray.join(datePickerPropSeparatorDefault),\n formatArray.join(datePickerPropSeparatorDefault),\n new Date(),\n ),\n )\n ) {\n const [dd, MM, yyyy] = getPartsDate(\n string,\n formatProp,\n separator,\n false,\n ['dd', 'MM', 'yyyy'],\n );\n\n onErrorRef.current?.({\n type: datePickerErrorTypes[1],\n stringValue: string,\n dd,\n MM,\n yyyy,\n });\n return false;\n }\n\n return true;\n },\n },\n { onAccept },\n );\n\n useStringValue(value, stringValue, formatProp, separator, setStringValue);\n\n return ref;\n};\n"],"mappings":"iEACA,OAASA,MAAM,GAANA,QAAT,CAAiBC,OAAjB,CAA0BC,gBAA1B,CAA4CC,KAAK,GAALA,OAA5C,KAAyD,UAAzD,CAEA,OAASC,WAAT,KAA4B,OAA5B,CACA,OAASC,KAAT,CAA+BC,QAA/B,KAA+C,aAA/C,CAQA,OAASC,aAAT,kDAGA,OACEC,8BADF,CAEEC,WAFF,CAGEC,QAHF,CAIEC,YAJF,CAKEC,cALF,kBAOA,OAASC,oBAAT,gBA2DA,MAAO,IAAMC,UAAS,CAAG,SAACC,CAAD,CAA2B,IAEhDC,EAFgD,CAS9CD,CAT8C,CAEhDC,KAFgD,CAGhDC,CAHgD,CAS9CF,CAT8C,CAGhDE,QAHgD,CAIhDC,CAJgD,CAS9CH,CAT8C,CAIhDG,OAJgD,CAKxCC,CALwC,CAS9CJ,CAT8C,CAKhDf,MALgD,CAMhDoB,CANgD,CAS9CL,CAT8C,CAMhDK,SANgD,CAOhDC,CAPgD,CAS9CN,CAT8C,CAOhDM,OAPgD,CAQhDC,CARgD,CAS9CP,CAT8C,CAQhDO,OARgD,CAU5CC,CAAW,CAAGhB,aAAa,CAACU,CAAD,CAViB,CAW5CO,CAAQ,CAAGjB,aAAa,CAACS,CAAD,CAXoB,CAY5CS,CAAU,CAAGlB,aAAa,CAACW,CAAD,CAZkB,CAc5CQ,CAAQ,CAAGtB,WAAW,CAC1B,SAACuB,CAAD,CAAsBC,CAAtB,CAAwCC,CAAxC,CAAsE,IAC9DZ,EAAQ,CAAGM,CAAW,CAACO,OADuC,CAE9Dd,CAAK,CAAGQ,CAAQ,CAACM,OAF6C,CAIpE,KACEd,CAAK,EACLf,OAAO,CAACe,CAAD,CADP,EAEAhB,OAAM,CAACgB,CA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,CAzFsC,CAsFhDiC,CAtFgD,GAsFhDA,GAtFgD,CAuFtCC,CAvFsC,GAuFhDC,QAvFgD,CAwFzClC,CAxFyC,GAwFhDX,KAxFgD,CAgKlD,MAFAJ,eAAc,CAACI,CAAD,CAAQW,CAAR,CAAqBR,CAArB,CAAiCC,CAAjC,CAA4CwC,CAA5C,CAEd,CAAOD,CACR,CAjKM"}
|
|
1
|
+
{"version":3,"file":"helpers.js","names":["format","isValid","isWithinInterval","parse","useCallback","IMask","useIMask","useMutableRef","datePickerPropSeparatorDefault","getPartDate","getParts","getPartsDate","useStringValue","datePickerErrorTypes","usePicker","props","value","onChange","onError","formatProp","separator","maxDate","minDate","onChangeRef","valueRef","onErrorRef","onAccept","stringValue","maskRef","e","current","length","formatArray","valueArray","validArray","map","marker","filter","item","date","join","Date","start","end","dd","MM","yyyy","type","getTime","imaskProps","mask","pattern","blocks","MaskedRange","from","to","lazy","autofix","string","validate","handleClear","ref"],"sources":["../../../../../../src/components/DatePicker/DatePickerFieldTypeDate/helpers.ts"],"sourcesContent":["import { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport { format, isValid, isWithinInterval, parse } from 'date-fns';\nimport { MaskedDate } from 'imask';\nimport { useCallback } from 'react';\nimport { IMask, ReactMaskOpts, useIMask } from 'react-imask';\n\nimport {\n TextFieldPropForm,\n TextFieldPropSize,\n TextFieldPropStatus,\n TextFieldPropView,\n} from '##/components/TextField';\nimport { useMutableRef } from '##/hooks/useMutableRef/useMutableRef';\nimport { PropsWithHTMLAttributes } from '##/utils/types/PropsWithHTMLAttributes';\n\nimport {\n datePickerPropSeparatorDefault,\n getPartDate,\n getParts,\n getPartsDate,\n useStringValue,\n} from '../helpers';\nimport { datePickerErrorTypes, DatePickerPropOnError } from '../types';\n\ntype DatePickerFieldTypeDatePropOnChange = (\n value: Date | null,\n props: {\n e: Event;\n },\n) => void;\n\nexport type DatePickerFieldTypeDateProps = PropsWithHTMLAttributes<\n {\n className?: string;\n value?: Date | null;\n onChange?: DatePickerFieldTypeDatePropOnChange;\n onError?: DatePickerPropOnError;\n id?: string;\n name?: string;\n disabled?: boolean;\n size?: TextFieldPropSize;\n view?: TextFieldPropView;\n form?: TextFieldPropForm;\n status?: TextFieldPropStatus;\n onFocus?: React.FocusEventHandler<HTMLElement>;\n onBlur?: React.FocusEventHandler<HTMLElement>;\n autoFocus?: boolean;\n placeholder?: string;\n leftSide?: string | IconComponent;\n rightSide?: string | IconComponent;\n readOnly?: boolean;\n required?: boolean;\n tabIndex?: number;\n inputRef?: React.Ref<HTMLTextAreaElement | HTMLInputElement>;\n ariaLabel?: string;\n iconSize?: IconPropSize;\n children?: never;\n format?: string;\n separator?: string;\n minDate?: Date;\n maxDate?: Date;\n focused?: boolean;\n label?: string;\n labelIcon?: IconComponent;\n caption?: string;\n labelPosition?: 'top' | 'left';\n withClearButton?: boolean;\n },\n HTMLDivElement\n>;\n\ntype UsePickerProps = {\n value?: Date | null;\n onChange?: DatePickerFieldTypeDatePropOnChange;\n onError?: DatePickerPropOnError;\n format: string;\n separator: string;\n minDate: Date;\n maxDate: Date;\n};\n\nexport const usePicker = (props: UsePickerProps) => {\n const {\n value,\n onChange,\n onError,\n format: formatProp,\n separator,\n maxDate,\n minDate,\n } = props;\n const onChangeRef = useMutableRef(onChange);\n const valueRef = useMutableRef(value);\n const onErrorRef = useMutableRef(onError);\n\n const onAccept = useCallback(\n (stringValue: string, maskRef: unknown, e: InputEvent | undefined) => {\n const onChange = onChangeRef.current;\n const value = valueRef.current;\n\n if (\n value &&\n isValid(value) &&\n format(value, formatProp) === stringValue\n ) {\n return;\n }\n\n if (stringValue?.length !== formatProp.length && value && e && onChange) {\n onChange(null, { e });\n return;\n }\n\n if (onChange && e) {\n if (!stringValue) {\n if (value) {\n onChange(null, { e });\n }\n return;\n }\n\n const formatArray = getParts(formatProp, separator, false);\n const valueArray = getParts(stringValue, separator, false);\n const validArray = formatArray\n .map((marker) => getPartDate(formatArray, valueArray, marker))\n .filter((item) => Boolean(item));\n\n if (formatArray.length === validArray.length) {\n const date = parse(\n valueArray.join(datePickerPropSeparatorDefault),\n formatArray.join(datePickerPropSeparatorDefault),\n new Date(),\n );\n\n if (!isWithinInterval(date, { start: minDate, end: maxDate })) {\n const [dd, MM, yyyy] = getPartsDate(\n stringValue,\n formatProp,\n separator,\n false,\n ['dd', 'MM', 'yyyy'],\n );\n\n onErrorRef.current?.({\n type: datePickerErrorTypes[0],\n stringValue,\n dd,\n MM,\n yyyy,\n date,\n });\n if (value) {\n onChange(null, { e });\n }\n\n return;\n }\n onChange(date, { e });\n } else if (value) {\n onChange(null, { e });\n }\n }\n },\n [minDate?.getTime(), maxDate?.getTime(), formatProp, separator],\n );\n\n const imaskProps = useIMask<HTMLInputElement, ReactMaskOpts>(\n {\n mask: Date as unknown as MaskedDate,\n pattern: formatProp,\n blocks: {\n // @ts-ignore\n yyyy: {\n mask: IMask.MaskedRange,\n from: 1,\n to: 9999,\n },\n // @ts-ignore\n MM: {\n mask: IMask.MaskedRange,\n from: 1,\n to: 12,\n },\n // @ts-ignore\n dd: {\n mask: IMask.MaskedRange,\n from: 1,\n to: 31,\n },\n },\n lazy: true,\n autofix: true,\n format: (date: Date) => format(date, formatProp),\n parse: (string: string) => parse(string, formatProp, new Date()),\n validate: (string: string) => {\n const formatArray = getParts(formatProp, separator, false);\n const valueArray = getParts(string, separator, false);\n const validArray = formatArray\n .map((marker) => getPartDate(formatArray, valueArray, marker))\n .filter((item) => Boolean(item));\n\n if (\n formatArray.length === validArray.length &&\n !isValid(\n parse(\n valueArray.join(datePickerPropSeparatorDefault),\n formatArray.join(datePickerPropSeparatorDefault),\n new Date(),\n ),\n )\n ) {\n const [dd, MM, yyyy] = getPartsDate(\n string,\n formatProp,\n separator,\n false,\n ['dd', 'MM', 'yyyy'],\n );\n\n onErrorRef.current?.({\n type: datePickerErrorTypes[1],\n stringValue: string,\n dd,\n MM,\n yyyy,\n });\n return false;\n }\n\n return true;\n },\n },\n { onAccept },\n );\n\n const handleClear = useStringValue(\n value,\n formatProp,\n separator,\n onChangeRef,\n imaskProps,\n );\n\n return [imaskProps.ref, handleClear] as const;\n};\n"],"mappings":"iEACA,OAASA,MAAM,GAANA,QAAT,CAAiBC,OAAjB,CAA0BC,gBAA1B,CAA4CC,KAAK,GAALA,OAA5C,KAAyD,UAAzD,CAEA,OAASC,WAAT,KAA4B,OAA5B,CACA,OAASC,KAAT,CAA+BC,QAA/B,KAA+C,aAA/C,CAQA,OAASC,aAAT,kDAGA,OACEC,8BADF,CAEEC,WAFF,CAGEC,QAHF,CAIEC,YAJF,CAKEC,cALF,kBAOA,OAASC,oBAAT,gBA2DA,MAAO,IAAMC,UAAS,CAAG,SAACC,CAAD,CAA2B,IAEhDC,EAFgD,CAS9CD,CAT8C,CAEhDC,KAFgD,CAGhDC,CAHgD,CAS9CF,CAT8C,CAGhDE,QAHgD,CAIhDC,CAJgD,CAS9CH,CAT8C,CAIhDG,OAJgD,CAKxCC,CALwC,CAS9CJ,CAT8C,CAKhDf,MALgD,CAMhDoB,CANgD,CAS9CL,CAT8C,CAMhDK,SANgD,CAOhDC,CAPgD,CAS9CN,CAT8C,CAOhDM,OAPgD,CAQhDC,CARgD,CAS9CP,CAT8C,CAQhDO,OARgD,CAU5CC,CAAW,CAAGhB,aAAa,CAACU,CAAD,CAViB,CAW5CO,CAAQ,CAAGjB,aAAa,CAACS,CAAD,CAXoB,CAY5CS,CAAU,CAAGlB,aAAa,CAACW,CAAD,CAZkB,CAc5CQ,CAAQ,CAAGtB,WAAW,CAC1B,SAACuB,CAAD,CAAsBC,CAAtB,CAAwCC,CAAxC,CAAsE,IAC9DZ,EAAQ,CAAGM,CAAW,CAACO,OADuC,CAE9Dd,CAAK,CAAGQ,CAAQ,CAACM,OAF6C,CAIpE,KACEd,CAAK,EACLf,OAAO,CAACe,CAAD,CADP,EAEAhB,OAAM,CAACgB,CAAD,CAAQG,CAAR,CAAN,GAA8BQ,CAHhC,GAQA,GAAI,QAAAA,CAAW,WAA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,CAEhCG,CAFgC,CAGhCC,CAHgC,CAIhCG,CAJgC,CAKhC0B,CALgC,CA1JgB,CAkKlD,MAAO,CAACA,CAAU,CAACY,GAAZ,CAAiBD,CAAjB,CACR,CAnKM"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["format","separator","placeholder","onChange","onError","minDate","maxDate","value","inputRef","multiplicityHours","multiplicitySeconds","multiplicityMinutes","defaultValue"];import React from"react";import{TextField}from"../../TextField";import{useForkRef}from"../../../hooks/useForkRef";import{maxDateDefault,minDateDefault}from"../../../utils/date";import{datePickerPropFormatTypeDateTime,datePickerPropPlaceholderTypeDateTime,datePickerPropSeparatorDefault}from"../helpers";import{usePicker}from"./helpers";export var DatePickerFieldTypeDateTime=React.forwardRef(function(a,b){var c=a.format,d=void 0===c?datePickerPropFormatTypeDateTime:c,e=a.separator,f=void 0===e?datePickerPropSeparatorDefault:e,g=a.placeholder,h=void 0===g?datePickerPropPlaceholderTypeDateTime:g,i=a.onChange,j=a.onError,k=a.minDate,l=void 0===k?minDateDefault:k,m=a.maxDate,n=void 0===m?maxDateDefault:m,o=a.value,p=a.inputRef,q=a.multiplicityHours,r=a.multiplicitySeconds,s=a.multiplicityMinutes,t=a.defaultValue,u=_objectWithoutProperties(a,_excluded),v=usePicker({onChange:i,value:o,onError:j,maxDate:n,minDate:l,multiplicityHours:q,multiplicityMinutes:s,multiplicitySeconds:r,separator:f,format:d});return React.createElement(TextField,Object.assign({},u,{type:"text",inputContainerRef:b,inputRef:useForkRef([
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["format","separator","placeholder","onChange","onError","minDate","maxDate","value","inputRef","multiplicityHours","multiplicitySeconds","multiplicityMinutes","defaultValue"];import React from"react";import{TextField}from"../../TextField";import{useForkRef}from"../../../hooks/useForkRef";import{maxDateDefault,minDateDefault}from"../../../utils/date";import{datePickerPropFormatTypeDateTime,datePickerPropPlaceholderTypeDateTime,datePickerPropSeparatorDefault}from"../helpers";import{usePicker}from"./helpers";export var DatePickerFieldTypeDateTime=React.forwardRef(function(a,b){var c=a.format,d=void 0===c?datePickerPropFormatTypeDateTime:c,e=a.separator,f=void 0===e?datePickerPropSeparatorDefault:e,g=a.placeholder,h=void 0===g?datePickerPropPlaceholderTypeDateTime:g,i=a.onChange,j=a.onError,k=a.minDate,l=void 0===k?minDateDefault:k,m=a.maxDate,n=void 0===m?maxDateDefault:m,o=a.value,p=a.inputRef,q=a.multiplicityHours,r=a.multiplicitySeconds,s=a.multiplicityMinutes,t=a.defaultValue,u=_objectWithoutProperties(a,_excluded),v=usePicker({onChange:i,value:o,onError:j,maxDate:n,minDate:l,multiplicityHours:q,multiplicityMinutes:s,multiplicitySeconds:r,separator:f,format:d}),w=_slicedToArray(v,2),x=w[0],y=w[1];return React.createElement(TextField,Object.assign({},u,{type:"text",inputContainerRef:b,inputRef:useForkRef([x,p]),placeholder:h,onClear:y}))});
|
|
2
2
|
//# sourceMappingURL=DatePickerFieldTypeDateTime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePickerFieldTypeDateTime.js","names":["React","TextField","useForkRef","maxDateDefault","minDateDefault","datePickerPropFormatTypeDateTime","datePickerPropPlaceholderTypeDateTime","datePickerPropSeparatorDefault","usePicker","DatePickerFieldTypeDateTime","forwardRef","props","ref","format","separator","placeholder","onChange","onError","minDate","maxDate","value","inputRefProp","inputRef","multiplicityHours","multiplicitySeconds","multiplicityMinutes","defaultValue","otherProps"],"sources":["../../../../../../src/components/DatePicker/DatePickerFieldTypeDateTime/DatePickerFieldTypeDateTime.tsx"],"sourcesContent":["import React from 'react';\n\nimport { TextField } from '##/components/TextField';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { maxDateDefault, minDateDefault } from '##/utils/date';\n\nimport {\n datePickerPropFormatTypeDateTime,\n datePickerPropPlaceholderTypeDateTime,\n datePickerPropSeparatorDefault,\n} from '../helpers';\nimport { DatePickerFieldTypeDateTimeProps, usePicker } from './helpers';\n\nexport const DatePickerFieldTypeDateTime = React.forwardRef<\n HTMLDivElement,\n DatePickerFieldTypeDateTimeProps\n>((props, ref) => {\n const {\n format = datePickerPropFormatTypeDateTime,\n separator = datePickerPropSeparatorDefault,\n placeholder = datePickerPropPlaceholderTypeDateTime,\n onChange,\n onError,\n minDate = minDateDefault,\n maxDate = maxDateDefault,\n value,\n inputRef: inputRefProp,\n multiplicityHours,\n multiplicitySeconds,\n multiplicityMinutes,\n defaultValue,\n ...otherProps\n } = props;\n\n const inputRef = usePicker({\n onChange,\n value,\n onError,\n maxDate,\n minDate,\n multiplicityHours,\n multiplicityMinutes,\n multiplicitySeconds,\n separator,\n format,\n });\n\n return (\n <TextField\n {...otherProps}\n type=\"text\"\n inputContainerRef={ref}\n inputRef={useForkRef([inputRef, inputRefProp])}\n placeholder={placeholder}\n />\n );\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"DatePickerFieldTypeDateTime.js","names":["React","TextField","useForkRef","maxDateDefault","minDateDefault","datePickerPropFormatTypeDateTime","datePickerPropPlaceholderTypeDateTime","datePickerPropSeparatorDefault","usePicker","DatePickerFieldTypeDateTime","forwardRef","props","ref","format","separator","placeholder","onChange","onError","minDate","maxDate","value","inputRefProp","inputRef","multiplicityHours","multiplicitySeconds","multiplicityMinutes","defaultValue","otherProps","onClear"],"sources":["../../../../../../src/components/DatePicker/DatePickerFieldTypeDateTime/DatePickerFieldTypeDateTime.tsx"],"sourcesContent":["import React from 'react';\n\nimport { TextField } from '##/components/TextField';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { maxDateDefault, minDateDefault } from '##/utils/date';\n\nimport {\n datePickerPropFormatTypeDateTime,\n datePickerPropPlaceholderTypeDateTime,\n datePickerPropSeparatorDefault,\n} from '../helpers';\nimport { DatePickerFieldTypeDateTimeProps, usePicker } from './helpers';\n\nexport const DatePickerFieldTypeDateTime = React.forwardRef<\n HTMLDivElement,\n DatePickerFieldTypeDateTimeProps\n>((props, ref) => {\n const {\n format = datePickerPropFormatTypeDateTime,\n separator = datePickerPropSeparatorDefault,\n placeholder = datePickerPropPlaceholderTypeDateTime,\n onChange,\n onError,\n minDate = minDateDefault,\n maxDate = maxDateDefault,\n value,\n inputRef: inputRefProp,\n multiplicityHours,\n multiplicitySeconds,\n multiplicityMinutes,\n defaultValue,\n ...otherProps\n } = props;\n\n const [inputRef, onClear] = usePicker({\n onChange,\n value,\n onError,\n maxDate,\n minDate,\n multiplicityHours,\n multiplicityMinutes,\n multiplicitySeconds,\n separator,\n format,\n });\n\n return (\n <TextField\n {...otherProps}\n type=\"text\"\n inputContainerRef={ref}\n inputRef={useForkRef([inputRef, inputRefProp])}\n placeholder={placeholder}\n onClear={onClear}\n />\n );\n});\n"],"mappings":"oVAAA,MAAOA,MAAP,KAAkB,OAAlB,CAEA,OAASC,SAAT,uBACA,OAASC,UAAT,iCACA,OAASC,cAAT,CAAyBC,cAAzB,2BAEA,OACEC,gCADF,CAEEC,qCAFF,CAGEC,8BAHF,kBAKA,OAA2CC,SAA3C,iBAEA,MAAO,IAAMC,4BAA2B,CAAGT,KAAK,CAACU,UAAN,CAGzC,SAACC,CAAD,CAAQC,CAAR,CAAgB,OAgBZD,CAhBY,CAEdE,MAFc,CAEdA,CAFc,YAELR,gCAFK,KAgBZM,CAhBY,CAGdG,SAHc,CAGdA,CAHc,YAGFP,8BAHE,KAgBZI,CAhBY,CAIdI,WAJc,CAIdA,CAJc,YAIAT,qCAJA,GAKdU,CALc,CAgBZL,CAhBY,CAKdK,QALc,CAMdC,CANc,CAgBZN,CAhBY,CAMdM,OANc,GAgBZN,CAhBY,CAOdO,OAPc,CAOdA,CAPc,YAOJd,cAPI,KAgBZO,CAhBY,CAQdQ,OARc,CAQdA,CARc,YAQJhB,cARI,GASdiB,CATc,CAgBZT,CAhBY,CASdS,KATc,CAUJC,CAVI,CAgBZV,CAhBY,CAUdW,QAVc,CAWdC,CAXc,CAgBZZ,CAhBY,CAWdY,iBAXc,CAYdC,CAZc,CAgBZb,CAhBY,CAYda,mBAZc,CAadC,CAbc,CAgBZd,CAhBY,CAadc,mBAbc,CAcdC,CAdc,CAgBZf,CAhBY,CAcde,YAdc,CAeXC,CAfW,0BAgBZhB,CAhBY,cAkBYH,SAAS,CAAC,CACpCQ,QAAQ,CAARA,CADoC,CAEpCI,KAAK,CAALA,CAFoC,CAGpCH,OAAO,CAAPA,CAHoC,CAIpCE,OAAO,CAAPA,CAJoC,CAKpCD,OAAO,CAAPA,CALoC,CAMpCK,iBAAiB,CAAjBA,CANoC,CAOpCE,mBAAmB,CAAnBA,CAPoC,CAQpCD,mBAAmB,CAAnBA,CARoC,CASpCV,SAAS,CAATA,CAToC,CAUpCD,MAAM,CAANA,CAVoC,CAAD,CAlBrB,uBAkBTS,CAlBS,MAkBCM,CAlBD,MA+BhB,MACE,qBAAC,SAAD,kBACMD,CADN,EAEE,IAAI,CAAC,MAFP,CAGE,iBAAiB,CAAEf,CAHrB,CAIE,QAAQ,CAAEV,UAAU,CAAC,CAACoB,CAAD,CAAWD,CAAX,CAAD,CAJtB,CAKE,WAAW,CAAEN,CALf,CAME,OAAO,CAAEa,CANX,GASH,CA5C0C,CAApC"}
|
|
@@ -57,5 +57,5 @@ declare type UsePickerProps = {
|
|
|
57
57
|
multiplicitySeconds: number | undefined;
|
|
58
58
|
multiplicityMinutes: number | undefined;
|
|
59
59
|
};
|
|
60
|
-
export declare const usePicker: (props: UsePickerProps) => React.MutableRefObject<HTMLInputElement | null
|
|
60
|
+
export declare const usePicker: (props: UsePickerProps) => readonly [React.MutableRefObject<HTMLInputElement | null>, React.MouseEventHandler<HTMLButtonElement>];
|
|
61
61
|
export {};
|