@scbt-ecom/ui 0.123.0 → 0.124.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.
@@ -1,2 +1,2 @@
1
- import{jsxs as x,jsx as p}from"react/jsx-runtime";import{useState as C,useRef as s}from"react";import{useClickOutside as y}from"../../../../hooks/useClickOutside.js";import"../../../../../../node_modules/classnames/index.js";import{Button as N}from"../../../button/Button.js";import"../../../buttonIcon/ButtonIcon.js";import"../../../calendar/Calendar.js";import"../../../calendar/model/utils.js";import"../../../accordion/Accordion.js";import"react-dom";import"../../../modal/ui/IframeModalContent.js";import"../../../../../../node_modules/react-hot-toast/dist/index.js";import{Icon as j}from"../../../icon/Icon.js";import"../primitives/Primitives.js";import"../../../carousel/ui/CarouselContent.js";import"../../../slot/Slot.js";import"../../../formElements/uncontrolled/autocomplete/Autocomplete.js";import"../../../formElements/uncontrolled/checkbox/Checkbox.js";import"../../../formElements/uncontrolled/combobox/combobox.js";import"../../../formElements/uncontrolled/dayPicker/DayPicker.js";import"../../../formElements/uncontrolled/input/Input.js";import"../../../formElements/uncontrolled/inputOtp/InputOtpBase.js";import"../../../formElements/uncontrolled/maskInput/MaskInput.js";import"../../../formElements/uncontrolled/radio/RadioGroup.js";import"../../../formElements/uncontrolled/radio/ui/RadioItem.js";import"../../../formElements/uncontrolled/slider/SliderBase.js";import"../../../formElements/uncontrolled/switch/Switch.js";import"../../../formElements/uncontrolled/textarea/Textarea.js";import"../../../formElements/uncontrolled/uploader/UploaderBase.js";import"../../../formElements/uncontrolled/inputCurrency/InputCurrency.js";import"../../../../../../src/configs/api.js";import"../../../formElements/controlled/editor/ui/Editor.js";import"../../../formElements/controlled/input/MaskInputControl.js";import"../../../dropdownList/ui/dropdownItem/DropdownItem.js";const io=({row:l,getValue:u,update:f,target:c,rowIndex:d=-1,attachment:r})=>{const[i,g]=C(u()),t=s(!1),m=s(null),{original:a}=l,w=o=>{g(o.target.value),t.current=!0},e=()=>{if(t.current){const o={...a,[c]:i};f(d,o),t.current=!1}};return y(m,e),x("div",{className:"flex items-center justify-between pr-1",children:[p("input",{ref:m,className:"mr-2 w-full outline-none",type:"text",value:i,onChange:w,onBlur:e,onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),e())}}),r&&p(N,{intent:"ghost",onClick:o=>{var n;return(n=r==null?void 0:r.handler)==null?void 0:n.call(r,i,o)},className:"mr-1 h-6 w-6 p-0",children:p(j,{name:r.icon,className:"size-4"})})]})};export{io as EditableCell};
1
+ import{jsxs as C,jsx as p}from"react/jsx-runtime";import{useState as y,useRef as s}from"react";import{useClickOutside as N}from"../../../../hooks/useClickOutside.js";import"../../../../../../node_modules/classnames/index.js";import{Button as j}from"../../../button/Button.js";import"../../../buttonIcon/ButtonIcon.js";import"../../../calendar/Calendar.js";import"../../../calendar/model/utils.js";import"../../../accordion/Accordion.js";import"react-dom";import"../../../modal/ui/IframeModalContent.js";import"../../../../../../node_modules/react-hot-toast/dist/index.js";import{Icon as k}from"../../../icon/Icon.js";import"../primitives/Primitives.js";import"../../../carousel/ui/CarouselContent.js";import"../../../slot/Slot.js";import"../../../formElements/uncontrolled/autocomplete/Autocomplete.js";import"../../../formElements/uncontrolled/checkbox/Checkbox.js";import"../../../formElements/uncontrolled/combobox/combobox.js";import"../../../formElements/uncontrolled/dayPicker/DayPicker.js";import"../../../formElements/uncontrolled/input/Input.js";import"../../../formElements/uncontrolled/inputOtp/InputOtpBase.js";import"../../../formElements/uncontrolled/maskInput/MaskInput.js";import"../../../formElements/uncontrolled/radio/RadioGroup.js";import"../../../formElements/uncontrolled/radio/ui/RadioItem.js";import"../../../formElements/uncontrolled/slider/SliderBase.js";import"../../../formElements/uncontrolled/switch/Switch.js";import"../../../formElements/uncontrolled/textarea/Textarea.js";import"../../../formElements/uncontrolled/uploader/UploaderBase.js";import"../../../formElements/uncontrolled/inputCurrency/InputCurrency.js";import"../../../../../../src/configs/api.js";import"../../../formElements/controlled/editor/ui/Editor.js";import"../../../formElements/controlled/input/MaskInputControl.js";import"../../../dropdownList/ui/dropdownItem/DropdownItem.js";const eo=({row:l,getValue:u,update:f,target:c,rowIndex:d=-1,attachment:r,readOnly:a=!1})=>{const[i,g]=y(u()),e=s(!1),m=s(null),{original:w}=l,x=o=>{g(o.target.value),e.current=!0},t=()=>{if(e.current){const o={...w,[c]:i};f(d,o),e.current=!1}};return N(m,t),C("div",{className:"flex items-center justify-between pr-1",children:[p("input",{ref:m,className:"mr-2 w-full outline-none",type:"text",readOnly:a,value:i,onChange:x,onBlur:t,onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),t())}}),r&&p(j,{intent:"ghost",onClick:o=>{var n;return(n=r==null?void 0:r.handler)==null?void 0:n.call(r,i,o)},className:"mr-1 h-6 w-6 p-0",children:p(k,{name:r.icon,className:"size-4"})})]})};export{eo as EditableCell};
2
2
  //# sourceMappingURL=EditableCell.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EditableCell.js","sources":["../../../../../../../lib/shared/ui/table/ui/editableCell/EditableCell.tsx"],"sourcesContent":["import { useRef, useState } from 'react'\nimport { type CellContext } from '@tanstack/react-table'\nimport { useClickOutside } from '$/shared/hooks'\nimport { type AllowedIcons, Button, Icon } from '$/shared/ui'\n\ntype Cell<TData, TValue> = CellContext<TData, TValue> & { rowIndex?: number }\n\ninterface EditableCellProps<TData, TValue> extends Cell<TData, TValue> {\n target: keyof TData\n update: (target: number, values: TData) => void\n attachment?: {\n icon: AllowedIcons\n handler?: (value: TValue | string, event: React.MouseEvent<HTMLButtonElement>) => void\n }\n}\n\nexport const EditableCell = <TData, TValue extends string | undefined>({\n row,\n getValue,\n update,\n target,\n rowIndex = -1,\n attachment\n}: EditableCellProps<TData, TValue>) => {\n const [value, setValue] = useState<TValue | string>(getValue())\n const changed = useRef<boolean>(false)\n\n const inputRef = useRef<HTMLInputElement>(null)\n\n const { original } = row\n\n const onValueChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n setValue(event.target.value)\n\n changed.current = true\n }\n\n const onInputBlur = () => {\n if (changed.current) {\n const updatedRow = { ...original, [target]: value }\n update(rowIndex, updatedRow)\n\n changed.current = false\n }\n }\n\n useClickOutside(inputRef, onInputBlur)\n\n return (\n <div className='flex items-center justify-between pr-1'>\n <input\n ref={inputRef}\n className='mr-2 w-full outline-none'\n type='text'\n value={value}\n onChange={onValueChange}\n onBlur={onInputBlur}\n onKeyDown={(event) => {\n if (event.key === 'Enter') {\n event.preventDefault()\n\n onInputBlur()\n }\n }}\n />\n {attachment && (\n <Button intent='ghost' onClick={(event) => attachment?.handler?.(value, event)} className='mr-1 h-6 w-6 p-0'>\n <Icon name={attachment.icon} className='size-4' />\n </Button>\n )}\n </div>\n )\n}\n"],"names":["EditableCell","row","getValue","update","target","rowIndex","attachment","value","setValue","useState","changed","useRef","inputRef","original","onValueChange","event","onInputBlur","updatedRow","useClickOutside","jsxs","jsx","Button","_a","Icon"],"mappings":"01DAgBO,MAAMA,GAAe,CAA2C,CACrE,IAAAC,EACA,SAAAC,EACA,OAAAC,EACA,OAAAC,EACA,SAAAC,EAAW,GACX,WAAAC,CACF,IAAwC,CACtC,KAAM,CAACC,EAAOC,CAAQ,EAAIC,EAA0BP,GAAU,EACxDQ,EAAUC,EAAgB,EAAK,EAE/BC,EAAWD,EAAyB,IAAI,EAExC,CAAE,SAAAE,GAAaZ,EAEfa,EAAiBC,GAA+C,CACpEP,EAASO,EAAM,OAAO,KAAK,EAE3BL,EAAQ,QAAU,EACpB,EAEMM,EAAc,IAAM,CACxB,GAAIN,EAAQ,QAAS,CACnB,MAAMO,EAAa,CAAE,GAAGJ,EAAU,CAACT,CAAM,EAAGG,CAAA,EAC5CJ,EAAOE,EAAUY,CAAU,EAE3BP,EAAQ,QAAU,EACpB,CACF,EAEA,OAAAQ,EAAgBN,EAAUI,CAAW,EAGnCG,EAAC,MAAA,CAAI,UAAU,yCACb,SAAA,CAAAC,EAAC,QAAA,CACC,IAAKR,EACL,UAAU,2BACV,KAAK,OACL,MAAAL,EACA,SAAUO,EACV,OAAQE,EACR,UAAYD,GAAU,CAChBA,EAAM,MAAQ,UAChBA,EAAM,eAAA,EAENC,EAAA,EAEJ,CAAA,CAAA,EAEDV,KACEe,EAAA,CAAO,OAAO,QAAQ,QAAUN,GAAA,OAAU,OAAAO,EAAAhB,GAAA,YAAAA,EAAY,UAAZ,YAAAgB,EAAA,KAAAhB,EAAsBC,EAAOQ,IAAQ,UAAU,mBACxF,SAAAK,EAACG,EAAA,CAAK,KAAMjB,EAAW,KAAM,UAAU,QAAA,CAAS,CAAA,CAClD,CAAA,EAEJ,CAEJ"}
1
+ {"version":3,"file":"EditableCell.js","sources":["../../../../../../../lib/shared/ui/table/ui/editableCell/EditableCell.tsx"],"sourcesContent":["import { useRef, useState } from 'react'\nimport { type CellContext } from '@tanstack/react-table'\nimport { useClickOutside } from '$/shared/hooks'\nimport { type AllowedIcons, Button, Icon } from '$/shared/ui'\n\ntype Cell<TData, TValue> = CellContext<TData, TValue> & { rowIndex?: number; readOnly?: boolean }\n\ninterface EditableCellProps<TData, TValue> extends Cell<TData, TValue> {\n target: keyof TData\n update: (target: number, values: TData) => void\n attachment?: {\n icon: AllowedIcons\n handler?: (value: TValue | string, event: React.MouseEvent<HTMLButtonElement>) => void\n }\n}\n\nexport const EditableCell = <TData, TValue extends string | undefined>({\n row,\n getValue,\n update,\n target,\n rowIndex = -1,\n attachment,\n readOnly = false\n}: EditableCellProps<TData, TValue>) => {\n const [value, setValue] = useState<TValue | string>(getValue())\n const changed = useRef<boolean>(false)\n\n const inputRef = useRef<HTMLInputElement>(null)\n\n const { original } = row\n\n const onValueChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n setValue(event.target.value)\n\n changed.current = true\n }\n\n const onInputBlur = () => {\n if (changed.current) {\n const updatedRow = { ...original, [target]: value }\n update(rowIndex, updatedRow)\n\n changed.current = false\n }\n }\n\n useClickOutside(inputRef, onInputBlur)\n\n return (\n <div className='flex items-center justify-between pr-1'>\n <input\n ref={inputRef}\n className='mr-2 w-full outline-none'\n type='text'\n readOnly={readOnly}\n value={value}\n onChange={onValueChange}\n onBlur={onInputBlur}\n onKeyDown={(event) => {\n if (event.key === 'Enter') {\n event.preventDefault()\n\n onInputBlur()\n }\n }}\n />\n {attachment && (\n <Button intent='ghost' onClick={(event) => attachment?.handler?.(value, event)} className='mr-1 h-6 w-6 p-0'>\n <Icon name={attachment.icon} className='size-4' />\n </Button>\n )}\n </div>\n )\n}\n"],"names":["EditableCell","row","getValue","update","target","rowIndex","attachment","readOnly","value","setValue","useState","changed","useRef","inputRef","original","onValueChange","event","onInputBlur","updatedRow","useClickOutside","jsxs","jsx","Button","_a","Icon"],"mappings":"01DAgBO,MAAMA,GAAe,CAA2C,CACrE,IAAAC,EACA,SAAAC,EACA,OAAAC,EACA,OAAAC,EACA,SAAAC,EAAW,GACX,WAAAC,EACA,SAAAC,EAAW,EACb,IAAwC,CACtC,KAAM,CAACC,EAAOC,CAAQ,EAAIC,EAA0BR,GAAU,EACxDS,EAAUC,EAAgB,EAAK,EAE/BC,EAAWD,EAAyB,IAAI,EAExC,CAAE,SAAAE,GAAab,EAEfc,EAAiBC,GAA+C,CACpEP,EAASO,EAAM,OAAO,KAAK,EAE3BL,EAAQ,QAAU,EACpB,EAEMM,EAAc,IAAM,CACxB,GAAIN,EAAQ,QAAS,CACnB,MAAMO,EAAa,CAAE,GAAGJ,EAAU,CAACV,CAAM,EAAGI,CAAA,EAC5CL,EAAOE,EAAUa,CAAU,EAE3BP,EAAQ,QAAU,EACpB,CACF,EAEA,OAAAQ,EAAgBN,EAAUI,CAAW,EAGnCG,EAAC,MAAA,CAAI,UAAU,yCACb,SAAA,CAAAC,EAAC,QAAA,CACC,IAAKR,EACL,UAAU,2BACV,KAAK,OACL,SAAAN,EACA,MAAAC,EACA,SAAUO,EACV,OAAQE,EACR,UAAYD,GAAU,CAChBA,EAAM,MAAQ,UAChBA,EAAM,eAAA,EAENC,EAAA,EAEJ,CAAA,CAAA,EAEDX,KACEgB,EAAA,CAAO,OAAO,QAAQ,QAAUN,GAAA,OAAU,OAAAO,EAAAjB,GAAA,YAAAA,EAAY,UAAZ,YAAAiB,EAAA,KAAAjB,EAAsBE,EAAOQ,IAAQ,UAAU,mBACxF,SAAAK,EAACG,EAAA,CAAK,KAAMlB,EAAW,KAAM,UAAU,QAAA,CAAS,CAAA,CAClD,CAAA,EAEJ,CAEJ"}