@xanui/ui 1.1.26 → 1.1.28
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/Alert/index.js +2 -2
- package/Alert/index.mjs +2 -2
- package/Autocomplete/index.d.ts +40 -0
- package/Autocomplete/index.js +136 -0
- package/Autocomplete/index.js.map +1 -0
- package/Autocomplete/index.mjs +134 -0
- package/Autocomplete/index.mjs.map +1 -0
- package/Avatar/index.d.ts +5 -0
- package/Avatar/index.js +7 -2
- package/Avatar/index.js.map +1 -1
- package/Avatar/index.mjs +7 -2
- package/Avatar/index.mjs.map +1 -1
- package/Button/index.d.ts +3 -0
- package/Button/index.js +13 -9
- package/Button/index.js.map +1 -1
- package/Button/index.mjs +12 -8
- package/Button/index.mjs.map +1 -1
- package/Calendar/index.js +35 -20
- package/Calendar/index.js.map +1 -1
- package/Calendar/index.mjs +27 -12
- package/Calendar/index.mjs.map +1 -1
- package/CalendarInput/index.js +6 -2
- package/CalendarInput/index.js.map +1 -1
- package/CalendarInput/index.mjs +6 -2
- package/CalendarInput/index.mjs.map +1 -1
- package/DataFilter/index.d.ts +7 -0
- package/DataFilter/index.js +78 -0
- package/DataFilter/index.js.map +1 -0
- package/DataFilter/index.mjs +67 -0
- package/DataFilter/index.mjs.map +1 -0
- package/DataFilter/options/DateFilter.d.ts +11 -0
- package/DataFilter/options/DateFilter.js +32 -0
- package/DataFilter/options/DateFilter.js.map +1 -0
- package/DataFilter/options/DateFilter.mjs +30 -0
- package/DataFilter/options/DateFilter.mjs.map +1 -0
- package/DataFilter/options/DateRangeFilter.d.ts +11 -0
- package/DataFilter/options/DateRangeFilter.js +27 -0
- package/DataFilter/options/DateRangeFilter.js.map +1 -0
- package/DataFilter/options/DateRangeFilter.mjs +25 -0
- package/DataFilter/options/DateRangeFilter.mjs.map +1 -0
- package/DataFilter/options/MultiSelectFilter.d.ts +11 -0
- package/DataFilter/options/MultiSelectFilter.js +38 -0
- package/DataFilter/options/MultiSelectFilter.js.map +1 -0
- package/DataFilter/options/MultiSelectFilter.mjs +36 -0
- package/DataFilter/options/MultiSelectFilter.mjs.map +1 -0
- package/DataFilter/options/NumberFilter.d.ts +11 -0
- package/DataFilter/options/NumberFilter.js +24 -0
- package/DataFilter/options/NumberFilter.js.map +1 -0
- package/DataFilter/options/NumberFilter.mjs +22 -0
- package/DataFilter/options/NumberFilter.mjs.map +1 -0
- package/DataFilter/options/NumberRangeFilter.d.ts +11 -0
- package/DataFilter/options/NumberRangeFilter.js +29 -0
- package/DataFilter/options/NumberRangeFilter.js.map +1 -0
- package/DataFilter/options/NumberRangeFilter.mjs +27 -0
- package/DataFilter/options/NumberRangeFilter.mjs.map +1 -0
- package/DataFilter/options/SelectFilter.d.ts +11 -0
- package/DataFilter/options/SelectFilter.js +34 -0
- package/DataFilter/options/SelectFilter.js.map +1 -0
- package/DataFilter/options/SelectFilter.mjs +32 -0
- package/DataFilter/options/SelectFilter.mjs.map +1 -0
- package/DataFilter/options/TextFilter.d.ts +11 -0
- package/DataFilter/options/TextFilter.js +24 -0
- package/DataFilter/options/TextFilter.js.map +1 -0
- package/DataFilter/options/TextFilter.mjs +22 -0
- package/DataFilter/options/TextFilter.mjs.map +1 -0
- package/DataFilter/types.d.ts +58 -0
- package/Datatable/FilterBox.js +21 -13
- package/Datatable/FilterBox.js.map +1 -1
- package/Datatable/FilterBox.mjs +20 -12
- package/Datatable/FilterBox.mjs.map +1 -1
- package/Datatable/Row.js +15 -14
- package/Datatable/Row.js.map +1 -1
- package/Datatable/Row.mjs +16 -15
- package/Datatable/Row.mjs.map +1 -1
- package/Datatable/Table.js +3 -3
- package/Datatable/Table.js.map +1 -1
- package/Datatable/Table.mjs +3 -3
- package/Datatable/Table.mjs.map +1 -1
- package/Datatable/TableHead.js +5 -4
- package/Datatable/TableHead.js.map +1 -1
- package/Datatable/TableHead.mjs +5 -4
- package/Datatable/TableHead.mjs.map +1 -1
- package/Datatable/index.d.ts +1 -1
- package/Datatable/index.js +51 -11
- package/Datatable/index.js.map +1 -1
- package/Datatable/index.mjs +50 -10
- package/Datatable/index.mjs.map +1 -1
- package/Datatable/types.d.ts +13 -9
- package/Drawer/index.js +3 -3
- package/Drawer/index.js.map +1 -1
- package/Drawer/index.mjs +3 -3
- package/Drawer/index.mjs.map +1 -1
- package/IconButton/index.js +1 -7
- package/IconButton/index.js.map +1 -1
- package/IconButton/index.mjs +1 -7
- package/IconButton/index.mjs.map +1 -1
- package/Input/index.d.ts +7 -7
- package/Input/index.js +35 -66
- package/Input/index.js.map +1 -1
- package/Input/index.mjs +35 -66
- package/Input/index.mjs.map +1 -1
- package/InputNumber/index.js +32 -0
- package/InputNumber/index.js.map +1 -0
- package/InputNumber/index.mjs +30 -0
- package/InputNumber/index.mjs.map +1 -0
- package/List/ListContext.js +11 -0
- package/List/ListContext.js.map +1 -0
- package/List/ListContext.mjs +8 -0
- package/List/ListContext.mjs.map +1 -0
- package/List/index.d.ts +2 -1
- package/List/index.js +23 -19
- package/List/index.js.map +1 -1
- package/List/index.mjs +23 -19
- package/List/index.mjs.map +1 -1
- package/ListItem/index.d.ts +1 -0
- package/ListItem/index.js +30 -13
- package/ListItem/index.js.map +1 -1
- package/ListItem/index.mjs +30 -13
- package/ListItem/index.mjs.map +1 -1
- package/Menu/index.js +2 -0
- package/Menu/index.js.map +1 -1
- package/Menu/index.mjs +2 -0
- package/Menu/index.mjs.map +1 -1
- package/Paper/index.js +2 -2
- package/Paper/index.js.map +1 -1
- package/Paper/index.mjs +2 -2
- package/Paper/index.mjs.map +1 -1
- package/Select/index.d.ts +2 -10
- package/Select/index.js +3 -3
- package/Select/index.js.map +1 -1
- package/Select/index.mjs +3 -3
- package/Select/index.mjs.map +1 -1
- package/Skeleton/index.d.ts +8 -0
- package/Skeleton/index.js +60 -0
- package/Skeleton/index.js.map +1 -0
- package/Skeleton/index.mjs +58 -0
- package/Skeleton/index.mjs.map +1 -0
- package/Table/index.js +3 -3
- package/Table/index.js.map +1 -1
- package/Table/index.mjs +3 -3
- package/Table/index.mjs.map +1 -1
- package/TablePagination/index.d.ts +2 -2
- package/TablePagination/index.js +2 -7
- package/TablePagination/index.js.map +1 -1
- package/TablePagination/index.mjs +2 -7
- package/TablePagination/index.mjs.map +1 -1
- package/index.d.ts +65 -55
- package/index.js +126 -108
- package/index.js.map +1 -1
- package/index.mjs +9 -0
- package/index.mjs.map +1 -1
- package/package.json +2 -7
package/Drawer/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Drawer/index.tsx"],"sourcesContent":["\"use client\";\nimport { Renderar, Tag, TagProps, useBreakpointProps, useBreakpointPropsType } from '@xanui/core';\nimport Layer, { LayerProps } from '../Layer';\nimport ClickOutside, { ClickOutsideProps } from '../ClickOutside';\n\n\nexport type DrawerProps = Omit<LayerProps, \"transition\" | \"slotProps\"> & {\n placement?: useBreakpointPropsType<\"left\" | \"right\" | \"bottom\" | \"top\">;\n size?: useBreakpointPropsType<number | \"small\" | \"medium\" | \"large\">;\n onClickOutside?: () => void;\n slotProps?: {\n layer?: Partial<Omit<LayerProps, \"children\">>\n root?: TagProps<\"div\">;\n content?: TagProps<\"div\">;\n clickOutside?: Omit<ClickOutsideProps, \"children\" | \"onClickOutside\">;\n }\n}\n\nconst getVariant = (placement?: any) => {\n switch (placement) {\n case \"right\":\n return \"fadeLeft\"\n case \"top\":\n return \"fadeDown\"\n case \"bottom\":\n return \"fadeUp\"\n default:\n return \"fadeRight\"\n }\n}\n\nconst Drawer = ({ children, placement, size, slotProps, onClickOutside, ...layerProps }: DrawerProps) => {\n const _p: any = {}\n if (placement) _p.placement = placement\n if (size) _p.size = size\n const p: any = useBreakpointProps(_p)\n\n placement = p.placement ?? 'left'\n size = p.size || \"medium\"\n\n let isSide = placement === 'left' || placement === 'right'\n let sizes: any = {\n small:
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Drawer/index.tsx"],"sourcesContent":["\"use client\";\nimport { Renderar, Tag, TagProps, useBreakpointProps, useBreakpointPropsType } from '@xanui/core';\nimport Layer, { LayerProps } from '../Layer';\nimport ClickOutside, { ClickOutsideProps } from '../ClickOutside';\n\n\nexport type DrawerProps = Omit<LayerProps, \"transition\" | \"slotProps\"> & {\n placement?: useBreakpointPropsType<\"left\" | \"right\" | \"bottom\" | \"top\">;\n size?: useBreakpointPropsType<number | \"small\" | \"medium\" | \"large\">;\n onClickOutside?: () => void;\n slotProps?: {\n layer?: Partial<Omit<LayerProps, \"children\">>\n root?: TagProps<\"div\">;\n content?: TagProps<\"div\">;\n clickOutside?: Omit<ClickOutsideProps, \"children\" | \"onClickOutside\">;\n }\n}\n\nconst getVariant = (placement?: any) => {\n switch (placement) {\n case \"right\":\n return \"fadeLeft\"\n case \"top\":\n return \"fadeDown\"\n case \"bottom\":\n return \"fadeUp\"\n default:\n return \"fadeRight\"\n }\n}\n\nconst Drawer = ({ children, placement, size, slotProps, onClickOutside, ...layerProps }: DrawerProps) => {\n const _p: any = {}\n if (placement) _p.placement = placement\n if (size) _p.size = size\n const p: any = useBreakpointProps(_p)\n\n placement = p.placement ?? 'left'\n size = p.size || \"medium\"\n\n let isSide = placement === 'left' || placement === 'right'\n let sizes: any = {\n small: 220,\n medium: 330,\n large: 440\n }\n\n let _size = sizes[size as any] || size\n\n return (\n <Layer\n {...layerProps}\n {...slotProps?.layer}\n transition={getVariant(placement)}\n >\n <Tag\n {...slotProps?.root}\n baseClass='drawer'\n sxr={{\n width: \"100vw\",\n height: \"100vh\",\n display: \"flex\",\n direction: isSide ? \"row\" : \"column\" as any,\n justifyContent: placement === 'left' || placement === 'top' ? \"flex-start\" : \"flex-end\"\n }}\n >\n <ClickOutside\n {...slotProps?.clickOutside}\n onClickOutside={onClickOutside || (() => { })}\n >\n <Tag\n sxr={{\n width: isSide ? _size : \"100%\",\n height: isSide ? \"100%\" : _size,\n bgcolor: \"background.primary\",\n shadow: 20\n }}\n baseClass='drawer-content'\n >\n {children}\n </Tag>\n </ClickOutside>\n </Tag>\n </Layer>\n )\n}\n\n\nDrawer.open = (children: DrawerProps[\"children\"], props?: Omit<DrawerProps, \"children\" | \"open\">) => {\n const d = Renderar.render(Drawer as any, {\n open: true,\n ...props,\n children,\n onClosed: () => {\n d.unrender()\n },\n onClickOutside: () => {\n if (props?.onClickOutside) {\n props.onClickOutside()\n } else {\n d.updateProps({ open: false })\n }\n }\n })\n\n return {\n open: () => {\n d.updateProps({ open: true })\n },\n close: () => {\n d.updateProps({ open: false })\n },\n }\n}\n\nDrawer.close = () => {\n Renderar.unrender(Drawer as any)\n}\n\nexport default Drawer"],"names":[],"mappings":";;;;;;;;;AAkBA;;AAEQ;AACI;AACJ;AACI;AACJ;AACI;AACJ;AACI;;AAEZ;AAEA;;AAAgB;;AAEZ;AAAe;AACf;AAAU;AACV;AAEA;AACA;;AAGA;AACI;AACA;AACA;;;AAKJ;AAUgB;AACA;AACA;;AAEA;;;;AAWQ;AACA;;AAU5B;AAGA;AACI;;AAMI;;;;;;;AAOA;;;;;;;;;AAWR;AAEA;AACI;AACJ;;"}
|
package/Drawer/index.mjs
CHANGED
|
@@ -30,9 +30,9 @@ const Drawer = (_a) => {
|
|
|
30
30
|
size = p.size || "medium";
|
|
31
31
|
let isSide = placement === 'left' || placement === 'right';
|
|
32
32
|
let sizes = {
|
|
33
|
-
small:
|
|
34
|
-
medium:
|
|
35
|
-
large:
|
|
33
|
+
small: 220,
|
|
34
|
+
medium: 330,
|
|
35
|
+
large: 440
|
|
36
36
|
};
|
|
37
37
|
let _size = sizes[size] || size;
|
|
38
38
|
return (jsx(Layer, Object.assign({}, layerProps, slotProps === null || slotProps === void 0 ? void 0 : slotProps.layer, { transition: getVariant(placement), children: jsx(Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.root, { baseClass: 'drawer', sxr: {
|
package/Drawer/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/Drawer/index.tsx"],"sourcesContent":["\"use client\";\nimport { Renderar, Tag, TagProps, useBreakpointProps, useBreakpointPropsType } from '@xanui/core';\nimport Layer, { LayerProps } from '../Layer';\nimport ClickOutside, { ClickOutsideProps } from '../ClickOutside';\n\n\nexport type DrawerProps = Omit<LayerProps, \"transition\" | \"slotProps\"> & {\n placement?: useBreakpointPropsType<\"left\" | \"right\" | \"bottom\" | \"top\">;\n size?: useBreakpointPropsType<number | \"small\" | \"medium\" | \"large\">;\n onClickOutside?: () => void;\n slotProps?: {\n layer?: Partial<Omit<LayerProps, \"children\">>\n root?: TagProps<\"div\">;\n content?: TagProps<\"div\">;\n clickOutside?: Omit<ClickOutsideProps, \"children\" | \"onClickOutside\">;\n }\n}\n\nconst getVariant = (placement?: any) => {\n switch (placement) {\n case \"right\":\n return \"fadeLeft\"\n case \"top\":\n return \"fadeDown\"\n case \"bottom\":\n return \"fadeUp\"\n default:\n return \"fadeRight\"\n }\n}\n\nconst Drawer = ({ children, placement, size, slotProps, onClickOutside, ...layerProps }: DrawerProps) => {\n const _p: any = {}\n if (placement) _p.placement = placement\n if (size) _p.size = size\n const p: any = useBreakpointProps(_p)\n\n placement = p.placement ?? 'left'\n size = p.size || \"medium\"\n\n let isSide = placement === 'left' || placement === 'right'\n let sizes: any = {\n small:
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/Drawer/index.tsx"],"sourcesContent":["\"use client\";\nimport { Renderar, Tag, TagProps, useBreakpointProps, useBreakpointPropsType } from '@xanui/core';\nimport Layer, { LayerProps } from '../Layer';\nimport ClickOutside, { ClickOutsideProps } from '../ClickOutside';\n\n\nexport type DrawerProps = Omit<LayerProps, \"transition\" | \"slotProps\"> & {\n placement?: useBreakpointPropsType<\"left\" | \"right\" | \"bottom\" | \"top\">;\n size?: useBreakpointPropsType<number | \"small\" | \"medium\" | \"large\">;\n onClickOutside?: () => void;\n slotProps?: {\n layer?: Partial<Omit<LayerProps, \"children\">>\n root?: TagProps<\"div\">;\n content?: TagProps<\"div\">;\n clickOutside?: Omit<ClickOutsideProps, \"children\" | \"onClickOutside\">;\n }\n}\n\nconst getVariant = (placement?: any) => {\n switch (placement) {\n case \"right\":\n return \"fadeLeft\"\n case \"top\":\n return \"fadeDown\"\n case \"bottom\":\n return \"fadeUp\"\n default:\n return \"fadeRight\"\n }\n}\n\nconst Drawer = ({ children, placement, size, slotProps, onClickOutside, ...layerProps }: DrawerProps) => {\n const _p: any = {}\n if (placement) _p.placement = placement\n if (size) _p.size = size\n const p: any = useBreakpointProps(_p)\n\n placement = p.placement ?? 'left'\n size = p.size || \"medium\"\n\n let isSide = placement === 'left' || placement === 'right'\n let sizes: any = {\n small: 220,\n medium: 330,\n large: 440\n }\n\n let _size = sizes[size as any] || size\n\n return (\n <Layer\n {...layerProps}\n {...slotProps?.layer}\n transition={getVariant(placement)}\n >\n <Tag\n {...slotProps?.root}\n baseClass='drawer'\n sxr={{\n width: \"100vw\",\n height: \"100vh\",\n display: \"flex\",\n direction: isSide ? \"row\" : \"column\" as any,\n justifyContent: placement === 'left' || placement === 'top' ? \"flex-start\" : \"flex-end\"\n }}\n >\n <ClickOutside\n {...slotProps?.clickOutside}\n onClickOutside={onClickOutside || (() => { })}\n >\n <Tag\n sxr={{\n width: isSide ? _size : \"100%\",\n height: isSide ? \"100%\" : _size,\n bgcolor: \"background.primary\",\n shadow: 20\n }}\n baseClass='drawer-content'\n >\n {children}\n </Tag>\n </ClickOutside>\n </Tag>\n </Layer>\n )\n}\n\n\nDrawer.open = (children: DrawerProps[\"children\"], props?: Omit<DrawerProps, \"children\" | \"open\">) => {\n const d = Renderar.render(Drawer as any, {\n open: true,\n ...props,\n children,\n onClosed: () => {\n d.unrender()\n },\n onClickOutside: () => {\n if (props?.onClickOutside) {\n props.onClickOutside()\n } else {\n d.updateProps({ open: false })\n }\n }\n })\n\n return {\n open: () => {\n d.updateProps({ open: true })\n },\n close: () => {\n d.updateProps({ open: false })\n },\n }\n}\n\nDrawer.close = () => {\n Renderar.unrender(Drawer as any)\n}\n\nexport default Drawer"],"names":[],"mappings":";;;;;;;AAkBA;;AAEQ;AACI;AACJ;AACI;AACJ;AACI;AACJ;AACI;;AAEZ;AAEA;;AAAgB;;AAEZ;AAAe;AACf;AAAU;AACV;AAEA;AACA;;AAGA;AACI;AACA;AACA;;;AAKJ;AAUgB;AACA;AACA;;AAEA;;;;AAWQ;AACA;;AAU5B;AAGA;AACI;;AAMI;;;;;;;AAOA;;;;;;;;;AAWR;AAEA;AACI;AACJ;;"}
|
package/IconButton/index.js
CHANGED
|
@@ -48,7 +48,7 @@ const IconButton = React.forwardRef((_a, ref) => {
|
|
|
48
48
|
alignItems: "center",
|
|
49
49
|
justifyContent: "center",
|
|
50
50
|
lineHeight: 1,
|
|
51
|
-
fontSize:
|
|
51
|
+
fontSize: "button",
|
|
52
52
|
bgcolor: "transparent",
|
|
53
53
|
"& svg": {
|
|
54
54
|
fontSize: Math.round((size / 3) * 1.8),
|
|
@@ -57,12 +57,6 @@ const IconButton = React.forwardRef((_a, ref) => {
|
|
|
57
57
|
height: "1em",
|
|
58
58
|
flexShrink: 0,
|
|
59
59
|
},
|
|
60
|
-
"& > *": {
|
|
61
|
-
fontSize: Math.round((size / 3) * 2),
|
|
62
|
-
display: "flex",
|
|
63
|
-
alignItems: "center",
|
|
64
|
-
justifyContent: "center",
|
|
65
|
-
},
|
|
66
60
|
}, hover: Object.assign(Object.assign({}, template.secondary), ((_props === null || _props === void 0 ? void 0 : _props.hover) || {})), children: children })));
|
|
67
61
|
});
|
|
68
62
|
|
package/IconButton/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/IconButton/index.tsx"],"sourcesContent":["\"use client\";\nimport React from 'react';\nimport { Tag, TagProps, TagComponentType, useInterface, UseColorTemplateColor, UseColorTemplateType, useColorTemplate, useBreakpointProps, useBreakpointPropsType } from '@xanui/core';\nimport useCorner from '../useCorner'\n\n\nexport type IconButtonProps<T extends TagComponentType = 'button'> = Omit<TagProps<T>, \"color\" | \"size\"> & {\n size?: useBreakpointPropsType<number | \"small\" | \"medium\" | \"large\">;\n color?: useBreakpointPropsType<UseColorTemplateColor>;\n variant?: useBreakpointPropsType<UseColorTemplateType>;\n corner?: useBreakpointPropsType<\"square\" | \"rounded\" | \"circle\">;\n}\n\nconst IconButton = React.forwardRef(<T extends TagComponentType = 'button'>({ children, ...rest }: IconButtonProps<T>, ref: React.Ref<any>) => {\n rest.sx = (rest as any).sx || {};\n let [{ variant, corner, color, size, ..._props }] = useInterface<any>(\"IconButton\", rest, {})\n\n const _p: any = {}\n if (size) _p.size = size\n if (color) _p.color = color\n if (variant) _p.variant = variant\n if (corner) _p.corner = corner\n const p: any = useBreakpointProps(_p)\n\n size = p.size ?? \"medium\"\n color = p.color\n variant = p.variant\n corner = p.corner ?? \"circle\"\n\n let template = useColorTemplate(color || \"brand\", variant || \"fill\")\n const cornerCss = useCorner(corner)\n\n if (size === 'small') {\n size = 28\n } else if (size === 'medium') {\n size = 34\n } else if (size === 'large') {\n size = 52\n }\n\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/IconButton/index.tsx"],"sourcesContent":["\"use client\";\nimport React from 'react';\nimport { Tag, TagProps, TagComponentType, useInterface, UseColorTemplateColor, UseColorTemplateType, useColorTemplate, useBreakpointProps, useBreakpointPropsType } from '@xanui/core';\nimport useCorner from '../useCorner'\n\n\nexport type IconButtonProps<T extends TagComponentType = 'button'> = Omit<TagProps<T>, \"color\" | \"size\"> & {\n size?: useBreakpointPropsType<number | \"small\" | \"medium\" | \"large\">;\n color?: useBreakpointPropsType<UseColorTemplateColor>;\n variant?: useBreakpointPropsType<UseColorTemplateType>;\n corner?: useBreakpointPropsType<\"square\" | \"rounded\" | \"circle\">;\n}\n\nconst IconButton = React.forwardRef(<T extends TagComponentType = 'button'>({ children, ...rest }: IconButtonProps<T>, ref: React.Ref<any>) => {\n rest.sx = (rest as any).sx || {};\n let [{ variant, corner, color, size, ..._props }] = useInterface<any>(\"IconButton\", rest, {})\n\n const _p: any = {}\n if (size) _p.size = size\n if (color) _p.color = color\n if (variant) _p.variant = variant\n if (corner) _p.corner = corner\n const p: any = useBreakpointProps(_p)\n\n size = p.size ?? \"medium\"\n color = p.color\n variant = p.variant\n corner = p.corner ?? \"circle\"\n\n let template = useColorTemplate(color || \"brand\", variant || \"fill\")\n const cornerCss = useCorner(corner)\n\n if (size === 'small') {\n size = 28\n } else if (size === 'medium') {\n size = 34\n } else if (size === 'large') {\n size = 52\n }\n\n return (\n <Tag\n component='button'\n ref={ref}\n {...cornerCss}\n {..._props}\n {...template.primary}\n baseClass='icon-button'\n sxr={{\n border: 0,\n radius: size,\n height: size,\n width: size,\n cursor: \"pointer\",\n fontFamily: \"inherit\",\n\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n\n lineHeight: 1,\n fontSize: \"button\",\n\n bgcolor: \"transparent\",\n\n \"& svg\": {\n fontSize: Math.round((size / 3) * 1.8),\n display: \"block\",\n width: \"1em\",\n height: \"1em\",\n flexShrink: 0,\n },\n }}\n hover={{\n ...template.secondary,\n ...((_props as any)?.hover || {})\n }}\n >\n {children}\n </Tag>\n )\n})\n// const IconButton = forwardRef(_IconButton) as unknown as typeof _IconButton\nexport default IconButton\n"],"names":[],"mappings":";;;;;;;;;AAaA;;AAA4E;;;;AAKxE;AAAU;AACV;AAAW;AACX;AAAa;AACb;AAAY;AACZ;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;;;AAEO;;;AAEA;;;;AAaK;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AACI;AACA;AACA;AACA;AACA;AACH;;AAUjB;;"}
|
package/IconButton/index.mjs
CHANGED
|
@@ -46,7 +46,7 @@ const IconButton = React.forwardRef((_a, ref) => {
|
|
|
46
46
|
alignItems: "center",
|
|
47
47
|
justifyContent: "center",
|
|
48
48
|
lineHeight: 1,
|
|
49
|
-
fontSize:
|
|
49
|
+
fontSize: "button",
|
|
50
50
|
bgcolor: "transparent",
|
|
51
51
|
"& svg": {
|
|
52
52
|
fontSize: Math.round((size / 3) * 1.8),
|
|
@@ -55,12 +55,6 @@ const IconButton = React.forwardRef((_a, ref) => {
|
|
|
55
55
|
height: "1em",
|
|
56
56
|
flexShrink: 0,
|
|
57
57
|
},
|
|
58
|
-
"& > *": {
|
|
59
|
-
fontSize: Math.round((size / 3) * 2),
|
|
60
|
-
display: "flex",
|
|
61
|
-
alignItems: "center",
|
|
62
|
-
justifyContent: "center",
|
|
63
|
-
},
|
|
64
58
|
}, hover: Object.assign(Object.assign({}, template.secondary), ((_props === null || _props === void 0 ? void 0 : _props.hover) || {})), children: children })));
|
|
65
59
|
});
|
|
66
60
|
|
package/IconButton/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/IconButton/index.tsx"],"sourcesContent":["\"use client\";\nimport React from 'react';\nimport { Tag, TagProps, TagComponentType, useInterface, UseColorTemplateColor, UseColorTemplateType, useColorTemplate, useBreakpointProps, useBreakpointPropsType } from '@xanui/core';\nimport useCorner from '../useCorner'\n\n\nexport type IconButtonProps<T extends TagComponentType = 'button'> = Omit<TagProps<T>, \"color\" | \"size\"> & {\n size?: useBreakpointPropsType<number | \"small\" | \"medium\" | \"large\">;\n color?: useBreakpointPropsType<UseColorTemplateColor>;\n variant?: useBreakpointPropsType<UseColorTemplateType>;\n corner?: useBreakpointPropsType<\"square\" | \"rounded\" | \"circle\">;\n}\n\nconst IconButton = React.forwardRef(<T extends TagComponentType = 'button'>({ children, ...rest }: IconButtonProps<T>, ref: React.Ref<any>) => {\n rest.sx = (rest as any).sx || {};\n let [{ variant, corner, color, size, ..._props }] = useInterface<any>(\"IconButton\", rest, {})\n\n const _p: any = {}\n if (size) _p.size = size\n if (color) _p.color = color\n if (variant) _p.variant = variant\n if (corner) _p.corner = corner\n const p: any = useBreakpointProps(_p)\n\n size = p.size ?? \"medium\"\n color = p.color\n variant = p.variant\n corner = p.corner ?? \"circle\"\n\n let template = useColorTemplate(color || \"brand\", variant || \"fill\")\n const cornerCss = useCorner(corner)\n\n if (size === 'small') {\n size = 28\n } else if (size === 'medium') {\n size = 34\n } else if (size === 'large') {\n size = 52\n }\n\n
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/IconButton/index.tsx"],"sourcesContent":["\"use client\";\nimport React from 'react';\nimport { Tag, TagProps, TagComponentType, useInterface, UseColorTemplateColor, UseColorTemplateType, useColorTemplate, useBreakpointProps, useBreakpointPropsType } from '@xanui/core';\nimport useCorner from '../useCorner'\n\n\nexport type IconButtonProps<T extends TagComponentType = 'button'> = Omit<TagProps<T>, \"color\" | \"size\"> & {\n size?: useBreakpointPropsType<number | \"small\" | \"medium\" | \"large\">;\n color?: useBreakpointPropsType<UseColorTemplateColor>;\n variant?: useBreakpointPropsType<UseColorTemplateType>;\n corner?: useBreakpointPropsType<\"square\" | \"rounded\" | \"circle\">;\n}\n\nconst IconButton = React.forwardRef(<T extends TagComponentType = 'button'>({ children, ...rest }: IconButtonProps<T>, ref: React.Ref<any>) => {\n rest.sx = (rest as any).sx || {};\n let [{ variant, corner, color, size, ..._props }] = useInterface<any>(\"IconButton\", rest, {})\n\n const _p: any = {}\n if (size) _p.size = size\n if (color) _p.color = color\n if (variant) _p.variant = variant\n if (corner) _p.corner = corner\n const p: any = useBreakpointProps(_p)\n\n size = p.size ?? \"medium\"\n color = p.color\n variant = p.variant\n corner = p.corner ?? \"circle\"\n\n let template = useColorTemplate(color || \"brand\", variant || \"fill\")\n const cornerCss = useCorner(corner)\n\n if (size === 'small') {\n size = 28\n } else if (size === 'medium') {\n size = 34\n } else if (size === 'large') {\n size = 52\n }\n\n return (\n <Tag\n component='button'\n ref={ref}\n {...cornerCss}\n {..._props}\n {...template.primary}\n baseClass='icon-button'\n sxr={{\n border: 0,\n radius: size,\n height: size,\n width: size,\n cursor: \"pointer\",\n fontFamily: \"inherit\",\n\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n\n lineHeight: 1,\n fontSize: \"button\",\n\n bgcolor: \"transparent\",\n\n \"& svg\": {\n fontSize: Math.round((size / 3) * 1.8),\n display: \"block\",\n width: \"1em\",\n height: \"1em\",\n flexShrink: 0,\n },\n }}\n hover={{\n ...template.secondary,\n ...((_props as any)?.hover || {})\n }}\n >\n {children}\n </Tag>\n )\n})\n// const IconButton = forwardRef(_IconButton) as unknown as typeof _IconButton\nexport default IconButton\n"],"names":[],"mappings":";;;;;;;AAaA;;AAA4E;;;;AAKxE;AAAU;AACV;AAAW;AACX;AAAa;AACb;AAAY;AACZ;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;;;AAEO;;;AAEA;;;;AAaK;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AACI;AACA;AACA;AACA;AACA;AACH;;AAUjB;;"}
|
package/Input/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { ReactElement } from 'react';
|
|
2
2
|
import { TagComponentType, TagProps, useBreakpointPropsType, UseColorTemplateColor } from '@xanui/core';
|
|
3
|
+
import { LabelProps } from '../Label/index.js';
|
|
3
4
|
|
|
4
|
-
type InputProps<T extends TagComponentType = "div"> = Omit<TagProps<T>, "size" | "color"> & {
|
|
5
|
+
type InputProps<T extends TagComponentType = "div"> = Omit<TagProps<T>, "size" | "color" | "label"> & {
|
|
5
6
|
value?: string;
|
|
6
7
|
type?: TagProps<'input'>['type'];
|
|
7
8
|
name?: string;
|
|
@@ -9,6 +10,7 @@ type InputProps<T extends TagComponentType = "div"> = Omit<TagProps<T>, "size" |
|
|
|
9
10
|
readOnly?: boolean;
|
|
10
11
|
autoFocus?: boolean;
|
|
11
12
|
autoComplete?: string;
|
|
13
|
+
label?: useBreakpointPropsType<string>;
|
|
12
14
|
onFocus?: (e: React.FocusEvent<any>) => void;
|
|
13
15
|
onBlur?: (e: React.FocusEvent<any>) => void;
|
|
14
16
|
onChange?: (e: React.ChangeEvent<any>) => void;
|
|
@@ -30,18 +32,16 @@ type InputProps<T extends TagComponentType = "div"> = Omit<TagProps<T>, "size" |
|
|
|
30
32
|
multiline?: boolean;
|
|
31
33
|
size?: useBreakpointPropsType<"small" | "medium" | "large">;
|
|
32
34
|
refs?: {
|
|
35
|
+
inputRoot?: React.Ref<"div">;
|
|
36
|
+
label?: React.Ref<"label">;
|
|
33
37
|
rootContainer?: React.Ref<"div">;
|
|
34
|
-
startIcon?: React.Ref<ReactElement>;
|
|
35
|
-
endIcon?: React.Ref<ReactElement>;
|
|
36
|
-
inputContainer?: React.Ref<"div">;
|
|
37
38
|
input?: React.Ref<'input' | 'textarea'>;
|
|
38
39
|
helperText?: React.Ref<"div">;
|
|
39
40
|
};
|
|
40
41
|
slotProps?: {
|
|
42
|
+
inputRoot?: Omit<TagProps<"div">, "children">;
|
|
43
|
+
label?: Omit<LabelProps, "children">;
|
|
41
44
|
rootContainer?: Omit<TagProps<"div">, "children">;
|
|
42
|
-
startIcon?: Omit<TagProps<'div'>, "children">;
|
|
43
|
-
endIcon?: Omit<TagProps<'div'>, "children">;
|
|
44
|
-
inputContainer?: Omit<TagProps<"div">, "children">;
|
|
45
45
|
helperText?: Omit<TagProps<"div">, "children">;
|
|
46
46
|
input?: Partial<TagProps<T>>;
|
|
47
47
|
};
|
package/Input/index.js
CHANGED
|
@@ -5,11 +5,12 @@ var tslib = require('tslib');
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var core = require('@xanui/core');
|
|
8
|
+
var index = require('../Label/index.js');
|
|
8
9
|
|
|
9
10
|
const Input = React.forwardRef((_a, ref) => {
|
|
10
11
|
var _b, _c, _d;
|
|
11
12
|
var { value, refs } = _a, props = tslib.__rest(_a, ["value", "refs"]);
|
|
12
|
-
let [_e, theme] = core.useInterface("Input", props, {}), { startIcon, endIcon, iconPlacement, color, name, placeholder, type, readOnly, autoFocus, autoComplete, onFocus, onBlur, onChange, onKeyDown, onKeyUp, focused, disabled, variant, error, helperText, multiline, size, rows, minRows, maxRows, fullWidth, slotProps } = _e, rest = tslib.__rest(_e, ["startIcon", "endIcon", "iconPlacement", "color", "name", "placeholder", "type", "readOnly", "autoFocus", "autoComplete", "onFocus", "onBlur", "onChange", "onKeyDown", "onKeyUp", "focused", "disabled", "variant", "error", "helperText", "multiline", "size", "rows", "minRows", "maxRows", "fullWidth", "slotProps"]);
|
|
13
|
+
let [_e, theme] = core.useInterface("Input", props, {}), { startIcon, endIcon, iconPlacement, color, label, name, placeholder, type, readOnly, autoFocus, autoComplete, onFocus, onBlur, onChange, onKeyDown, onKeyUp, focused, disabled, variant, error, helperText, multiline, size, rows, minRows, maxRows, fullWidth, slotProps } = _e, rest = tslib.__rest(_e, ["startIcon", "endIcon", "iconPlacement", "color", "label", "name", "placeholder", "type", "readOnly", "autoFocus", "autoComplete", "onFocus", "onBlur", "onChange", "onKeyDown", "onKeyUp", "focused", "disabled", "variant", "error", "helperText", "multiline", "size", "rows", "minRows", "maxRows", "fullWidth", "slotProps"]);
|
|
13
14
|
const _p = {};
|
|
14
15
|
if (startIcon)
|
|
15
16
|
_p.startIcon = startIcon;
|
|
@@ -75,12 +76,12 @@ const Input = React.forwardRef((_a, ref) => {
|
|
|
75
76
|
}, [value]) || 1;
|
|
76
77
|
const sizes = {
|
|
77
78
|
small: {
|
|
78
|
-
height:
|
|
79
|
+
height: 38,
|
|
79
80
|
gap: .5,
|
|
80
81
|
fontSize: 'button',
|
|
81
82
|
},
|
|
82
83
|
medium: {
|
|
83
|
-
height:
|
|
84
|
+
height: 46,
|
|
84
85
|
gap: 1,
|
|
85
86
|
fontSize: "text"
|
|
86
87
|
},
|
|
@@ -102,73 +103,41 @@ const Input = React.forwardRef((_a, ref) => {
|
|
|
102
103
|
}
|
|
103
104
|
};
|
|
104
105
|
}
|
|
105
|
-
return (jsxRuntime.jsxs(core.Tag, Object.assign({ width: fullWidth ? "100%" :
|
|
106
|
-
'
|
|
107
|
-
'
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
[`input-size-${size}`]: true,
|
|
111
|
-
}, children: [jsxRuntime.jsxs(core.Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.rootContainer, { ref: refs === null || refs === void 0 ? void 0 : refs.rootContainer, baseClass: 'root-container', sxr: {
|
|
106
|
+
return (jsxRuntime.jsxs(core.Tag, Object.assign({ width: fullWidth ? "100%" : "auto" }, rest, { ref: ref, baseClass: "input-wrapper", sxr: {
|
|
107
|
+
display: 'flex',
|
|
108
|
+
flexDirection: 'column',
|
|
109
|
+
gap: .5,
|
|
110
|
+
}, children: [!!label && jsxRuntime.jsx(index, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.label, { ref: refs === null || refs === void 0 ? void 0 : refs.label, children: label })), jsxRuntime.jsxs(core.Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.inputRoot, { ref: refs === null || refs === void 0 ? void 0 : refs.inputRoot, baseClass: 'input-root', sxr: {
|
|
112
111
|
width: "100%",
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
alignItems: iconPlacement === 'center' ? iconPlacement : `flex-${iconPlacement}`,
|
|
116
|
-
flexWrap: "nowrap",
|
|
117
|
-
transitionProperty: "border, box-shadow, background",
|
|
118
|
-
bgcolor: error ? "danger.soft.primary" : variant === "fill" ? "background.secondary" : "background.primary",
|
|
119
|
-
border: variant === "text" ? 0 : "1px solid",
|
|
120
|
-
borderColor: borderColor,
|
|
121
|
-
borderRadius: 1,
|
|
122
|
-
px: 1,
|
|
123
|
-
py: .5,
|
|
124
|
-
}, disabled: disabled || false }, _size, { height: multiline ? "auto" : _size.height, minHeight: _size.height, children: [startIcon && jsxRuntime.jsx(core.Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.startIcon, { ref: refs === null || refs === void 0 ? void 0 : refs.startIcon, flex: "0 0 auto", sxr: {
|
|
125
|
-
height: "100%",
|
|
126
|
-
alignItems: 'center',
|
|
127
|
-
justifyContent: "center",
|
|
128
|
-
display: "flex",
|
|
129
|
-
color: error ? "danger.primary" : "text.secondary",
|
|
130
|
-
}, baseClass: "input-start-icon", children: startIcon })), jsxRuntime.jsx(core.Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.inputContainer, { ref: refs === null || refs === void 0 ? void 0 : refs.inputContainer, baseClass: 'input-container', flex: 1, sxr: {
|
|
131
|
-
width: "100%",
|
|
132
|
-
display: "flex",
|
|
133
|
-
alignItems: "center",
|
|
134
|
-
flex: 1,
|
|
135
|
-
minHeight: _size.height,
|
|
136
|
-
"& textarea": {
|
|
137
|
-
resize: "none"
|
|
138
|
-
},
|
|
139
|
-
"& input:-webkit-autofill,& input:-webkit-autofill:hover, & input:-webkit-autofill:focus,& input:-webkit-autofill:active": {
|
|
112
|
+
overflow: "hidden",
|
|
113
|
+
}, children: [jsxRuntime.jsxs(core.Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.rootContainer, { ref: refs === null || refs === void 0 ? void 0 : refs.rootContainer, baseClass: 'input-root-container', sxr: Object.assign(Object.assign({ width: "100%", display: "flex", flexDirection: "row", alignItems: iconPlacement === 'center' ? iconPlacement : `flex-${iconPlacement}`, flexWrap: "nowrap", transitionProperty: "border, box-shadow, background", bgcolor: error ? "danger.soft.primary" : variant === "fill" ? "background.secondary" : "background.primary", border: variant === "text" ? 0 : "1px solid", borderColor: borderColor, borderRadius: 1, px: 1 }, _size), { height: multiline ? "auto" : _size.height, minHeight: _size.height, "& input:-webkit-autofill,& input:-webkit-autofill:hover, & input:-webkit-autofill:focus,& input:-webkit-autofill:active": {
|
|
140
114
|
"-webkit-text-fill-color": "text.primary",
|
|
141
115
|
"box-shadow": `0 0 0px 1000px ${variant === "fill" ? theme.colors.background.secondary : theme.colors.background.primary} inset`,
|
|
142
116
|
transition: "background-color 5000s ease-in-out 0s"
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
fontSize: "small",
|
|
168
|
-
lineHeight: "text",
|
|
169
|
-
fontWeight: 'text',
|
|
170
|
-
pl: .5,
|
|
171
|
-
}, children: helperText }))] })));
|
|
117
|
+
}, "& textarea": {
|
|
118
|
+
resize: "none"
|
|
119
|
+
} }), disabled: disabled || false, children: [startIcon, jsxRuntime.jsx(core.Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.input, { ref: inputMergeRef, baseClass: 'input', component: multiline ? 'textarea' : 'input' }, multiprops, { sxr: {
|
|
120
|
+
border: 0,
|
|
121
|
+
outline: 0,
|
|
122
|
+
bgcolor: "transparent",
|
|
123
|
+
color: error ? "danger.primary" : "text.primary",
|
|
124
|
+
fontSize: _size.fontSize,
|
|
125
|
+
height: multiline ? "auto" : _size.height + "px!important",
|
|
126
|
+
width: "100%",
|
|
127
|
+
maxHeight: 200,
|
|
128
|
+
}, value: value, onChange: onChange, onFocus: (e) => {
|
|
129
|
+
focused !== null && focused !== void 0 ? focused : setFocused(true);
|
|
130
|
+
onFocus && onFocus(e);
|
|
131
|
+
}, onBlur: (e) => {
|
|
132
|
+
focused !== null && focused !== void 0 ? focused : setFocused(false);
|
|
133
|
+
onBlur && onBlur(e);
|
|
134
|
+
}, onKeyDown: onKeyDown, onKeyUp: onKeyUp, name: name, placeholder: placeholder, type: type, readOnly: readOnly, autoComplete: autoComplete })), endIcon] })), helperText && jsxRuntime.jsx(core.Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.helperText, { ref: refs === null || refs === void 0 ? void 0 : refs.helperText, baseClass: "input-helper-text", sxr: {
|
|
135
|
+
color: error ? "danger.primary" : "text.primary",
|
|
136
|
+
fontSize: "small",
|
|
137
|
+
lineHeight: "text",
|
|
138
|
+
fontWeight: 'text',
|
|
139
|
+
pl: .5,
|
|
140
|
+
}, children: helperText }))] }))] })));
|
|
172
141
|
});
|
|
173
142
|
|
|
174
143
|
module.exports = Input;
|
package/Input/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Input/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { ReactElement, useEffect, useMemo, useState } from 'react';\nimport { Tag, TagProps, TagComponentType, UseColorTemplateColor, useBreakpointPropsType, useInterface, useBreakpointProps, useMergeRefs } from '@xanui/core';\n\nexport type InputProps<T extends TagComponentType = \"div\"> = Omit<TagProps<T>, \"size\" | \"color\"> & {\n value?: string;\n type?: TagProps<'input'>['type'];\n name?: string;\n placeholder?: string;\n readOnly?: boolean;\n autoFocus?: boolean;\n autoComplete?: string;\n\n\n onFocus?: (e: React.FocusEvent<any>) => void;\n onBlur?: (e: React.FocusEvent<any>) => void;\n onChange?: (e: React.ChangeEvent<any>) => void;\n onInput?: (e: React.FormEvent<any>) => void;\n onKeyDown?: (e: React.KeyboardEvent<any>) => void;\n onKeyUp?: (e: React.KeyboardEvent<any>) => void;\n\n rows?: useBreakpointPropsType<number>;\n minRows?: useBreakpointPropsType<number>;\n maxRows?: useBreakpointPropsType<number>;\n fullWidth?: boolean;\n\n startIcon?: useBreakpointPropsType<ReactElement>;\n endIcon?: useBreakpointPropsType<ReactElement>;\n iconPlacement?: useBreakpointPropsType<\"start\" | \"center\" | \"end\">;\n focused?: boolean;\n color?: useBreakpointPropsType<Omit<UseColorTemplateColor, \"default\">>;\n variant?: useBreakpointPropsType<\"fill\" | \"outline\" | \"text\">;\n error?: boolean;\n helperText?: useBreakpointPropsType<string>;\n multiline?: boolean;\n size?: useBreakpointPropsType<\"small\" | \"medium\" | \"large\">;\n\n refs?: {\n rootContainer?: React.Ref<\"div\">;\n startIcon?: React.Ref<ReactElement>;\n endIcon?: React.Ref<ReactElement>;\n inputContainer?: React.Ref<\"div\">;\n input?: React.Ref<'input' | 'textarea'>;\n helperText?: React.Ref<\"div\">;\n };\n\n slotProps?: {\n rootContainer?: Omit<TagProps<\"div\">, \"children\">;\n startIcon?: Omit<TagProps<'div'>, \"children\">;\n endIcon?: Omit<TagProps<'div'>, \"children\">;\n inputContainer?: Omit<TagProps<\"div\">, \"children\">;\n helperText?: Omit<TagProps<\"div\">, \"children\">;\n input?: Partial<TagProps<T>>;\n }\n}\n\nconst Input = React.forwardRef(<T extends TagComponentType = \"div\">({ value, refs, ...props }: InputProps<T>, ref?: React.Ref<any>) => {\n let [{\n startIcon,\n endIcon,\n iconPlacement,\n color,\n\n name,\n placeholder,\n type,\n readOnly,\n autoFocus,\n autoComplete,\n onFocus,\n onBlur,\n onChange,\n onKeyDown,\n onKeyUp,\n\n focused,\n disabled,\n variant,\n error,\n helperText,\n multiline,\n size,\n rows,\n minRows,\n maxRows,\n fullWidth,\n slotProps,\n\n ...rest\n }, theme] = useInterface<any>(\"Input\", props, {})\n\n const _p: any = {}\n if (startIcon) _p.startIcon = startIcon\n if (endIcon) _p.endIcon = endIcon\n if (iconPlacement) _p.iconPlacement = iconPlacement\n if (color) _p.color = color\n if (variant) _p.variant = variant\n if (helperText) _p.helperText = helperText\n if (size) _p.size = size\n if (rows) _p.rows = rows\n if (minRows) _p.minRows = minRows\n if (maxRows) _p.maxRows = maxRows\n const p: any = useBreakpointProps(_p)\n startIcon = p.startIcon\n endIcon = p.endIcon\n iconPlacement = p.iconPlacement\n color = p.color ?? \"brand\"\n variant = p.variant ?? \"fill\"\n helperText = p.helperText\n size = p.size ?? 'medium'\n rows = p.rows\n minRows = p.minRows\n maxRows = p.maxRows\n\n iconPlacement ??= multiline ? \"end\" : \"center\"\n if (!value) iconPlacement = 'center'\n\n const [_focused, setFocused] = useState(false)\n let _focus = focused || _focused\n const inputRef = React.useRef<HTMLInputElement | HTMLTextAreaElement>(null);\n const inputMergeRef = useMergeRefs(inputRef, refs?.input as any);\n\n useEffect(() => {\n if (autoFocus) {\n setTimeout(() => {\n inputRef.current?.focus()\n }, 100);\n }\n }, [autoFocus])\n\n let _rows = useMemo(() => {\n if (rows) return rows\n if (value && multiline) {\n let lines = (value as string).split(`\\n`).length\n if (minRows && minRows > lines) {\n return minRows\n } else if (maxRows && maxRows < lines) {\n return maxRows\n } else {\n return lines\n }\n }\n }, [value]) || 1\n\n const sizes: any = {\n small: {\n height: 40,\n gap: .5,\n fontSize: 'button',\n },\n medium: {\n height: 48,\n gap: 1,\n fontSize: \"text\"\n },\n large: {\n height: 52,\n gap: 1,\n fontSize: 'big'\n }\n }\n\n const _size = sizes[size]\n let borderColor = _focus ? color : (variant === \"fill\" ? \"transparent\" : \"divider\")\n borderColor = error ? \"danger.primary\" : borderColor\n let multiprops: any = {}\n if (multiline) {\n multiprops = {\n rows: _rows,\n sx: {\n resize: \"none\"\n }\n }\n }\n\n return (\n <Tag\n width={fullWidth ? \"100%\" : undefined}\n {...rest}\n ref={ref}\n baseClass={'input-root'}\n classNames={{\n 'input-full-width': fullWidth || false,\n 'input-focused': _focus,\n 'input-error': error || false,\n [`input-variant-${variant}`]: true,\n [`input-size-${size}`]: true,\n }}\n >\n <Tag\n {...slotProps?.rootContainer}\n ref={refs?.rootContainer}\n baseClass='root-container'\n sxr={{\n width: \"100%\",\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: iconPlacement === 'center' ? iconPlacement : `flex-${iconPlacement}`,\n flexWrap: \"nowrap\",\n transitionProperty: \"border, box-shadow, background\",\n bgcolor: error ? \"danger.soft.primary\" : variant === \"fill\" ? \"background.secondary\" : \"background.primary\",\n border: variant === \"text\" ? 0 : \"1px solid\",\n borderColor: borderColor,\n borderRadius: 1,\n px: 1,\n py: .5,\n }}\n disabled={disabled || false}\n {..._size}\n height={multiline ? \"auto\" : _size.height}\n minHeight={_size.height}\n >\n {startIcon && <Tag\n {...slotProps?.startIcon}\n ref={refs?.startIcon}\n flex={\"0 0 auto\"}\n sxr={{\n height: \"100%\",\n alignItems: 'center',\n justifyContent: \"center\",\n display: \"flex\",\n color: error ? \"danger.primary\" : \"text.secondary\",\n }}\n baseClass=\"input-start-icon\"\n >{startIcon}</Tag>}\n <Tag\n {...slotProps?.inputContainer}\n ref={refs?.inputContainer}\n baseClass='input-container'\n flex={1}\n sxr={{\n width: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n flex: 1,\n minHeight: _size.height,\n \"& textarea\": {\n resize: \"none\"\n },\n \"& input:-webkit-autofill,& input:-webkit-autofill:hover, & input:-webkit-autofill:focus,& input:-webkit-autofill:active\": {\n \"-webkit-text-fill-color\": \"text.primary\",\n \"box-shadow\": `0 0 0px 1000px ${variant === \"fill\" ? theme.colors.background.secondary : theme.colors.background.primary} inset`,\n transition: \"background-color 5000s ease-in-out 0s\"\n } as any\n }}\n >\n <Tag\n {...slotProps?.input}\n ref={inputMergeRef}\n baseClass='input'\n component={multiline ? 'textarea' : 'input'}\n {...multiprops}\n sxr={{\n border: 0,\n outline: 0,\n bgcolor: \"transparent\",\n color: error ? \"danger.primary\" : \"text.primary\",\n fontSize: _size.fontSize,\n height: multiline ? \"auto\" : _size.height + \"px!important\",\n width: \"100%\",\n maxHeight: 200,\n }}\n value={value}\n onChange={onChange}\n onFocus={(e: any) => {\n focused ?? setFocused(true)\n onFocus && onFocus(e)\n }}\n onBlur={(e: any) => {\n focused ?? setFocused(false)\n onBlur && onBlur(e)\n }}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n name={name}\n placeholder={placeholder}\n type={type}\n readOnly={readOnly}\n autoComplete={autoComplete}\n />\n </Tag>\n {endIcon && <Tag\n {...slotProps?.endIcon}\n ref={refs?.endIcon}\n flex={\"0 0 auto\"}\n sxr={{\n height: \"100%\",\n alignItems: 'center',\n justifyContent: \"center\",\n display: 'flex',\n color: error ? \"danger.primary\" : \"text.secondary\",\n }}\n baseClass=\"input-end-icon\"\n >{endIcon}</Tag>}\n </Tag>\n {helperText && <Tag\n {...slotProps?.helperText}\n ref={refs?.helperText}\n baseClass=\"input-helper-text\"\n sxr={{\n color: error ? \"danger.primary\" : \"text.primary\",\n fontSize: \"small\",\n lineHeight: \"text\",\n fontWeight: 'text',\n pl: .5,\n }}\n >{helperText}</Tag>}\n </Tag>\n )\n})\n\nexport default Input\n"],"names":[],"mappings":";;;;;;;;AAwDA;;;AACI;;AAmCA;AAAe;AACf;AAAa;AACb;AAAmB;AACnB;AAAW;AACX;AAAa;AACb;AAAgB;AAChB;AAAU;AACV;AAAU;AACV;AAAa;AACb;AAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;;;AAGA;;AAEA;;;;;AAKY;;;AAGZ;AAEA;AACI;AAAU;AACV;;AAEI;AACI;;AACG;AACH;;;AAEA;;;AAGZ;AAEA;AACI;AACI;AACA;AACA;AACH;AACD;AACI;AACA;AACA;AACH;AACD;AACI;AACA;AACA;AACH;;AAGL;;;;;AAKI;AACI;AACA;AACI;AACH;;;;;AAYG;;AAEA;AACA;;AAQI;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAYI;AACA;AACA;AACA;;AAEH;AASG;AACA;AACA;AACA;;AAEA;AACI;AACH;AACD;AACI;;AAEA;AACI;AACX;AASO;AACA;AACA;;;AAGA;AACA;AACA;AACH;;AAKG;AACJ;;AAGI;;AAgBJ;AACA;AACA;AACA;;AAEH;;AAUD;AACA;AACA;AACA;AACH;AAIjB;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Input/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { ReactElement, useEffect, useMemo, useState } from 'react';\nimport { Tag, TagProps, TagComponentType, UseColorTemplateColor, useBreakpointPropsType, useInterface, useBreakpointProps, useMergeRefs } from '@xanui/core';\nimport Label, { LabelProps } from '../Label';\n\nexport type InputProps<T extends TagComponentType = \"div\"> = Omit<TagProps<T>, \"size\" | \"color\" | \"label\"> & {\n value?: string;\n type?: TagProps<'input'>['type'];\n name?: string;\n placeholder?: string;\n readOnly?: boolean;\n autoFocus?: boolean;\n autoComplete?: string;\n label?: useBreakpointPropsType<string>;\n\n onFocus?: (e: React.FocusEvent<any>) => void;\n onBlur?: (e: React.FocusEvent<any>) => void;\n onChange?: (e: React.ChangeEvent<any>) => void;\n onInput?: (e: React.FormEvent<any>) => void;\n onKeyDown?: (e: React.KeyboardEvent<any>) => void;\n onKeyUp?: (e: React.KeyboardEvent<any>) => void;\n\n rows?: useBreakpointPropsType<number>;\n minRows?: useBreakpointPropsType<number>;\n maxRows?: useBreakpointPropsType<number>;\n fullWidth?: boolean;\n\n startIcon?: useBreakpointPropsType<ReactElement>;\n endIcon?: useBreakpointPropsType<ReactElement>;\n iconPlacement?: useBreakpointPropsType<\"start\" | \"center\" | \"end\">;\n focused?: boolean;\n color?: useBreakpointPropsType<Omit<UseColorTemplateColor, \"default\">>;\n variant?: useBreakpointPropsType<\"fill\" | \"outline\" | \"text\">;\n error?: boolean;\n helperText?: useBreakpointPropsType<string>;\n multiline?: boolean;\n size?: useBreakpointPropsType<\"small\" | \"medium\" | \"large\">;\n\n refs?: {\n inputRoot?: React.Ref<\"div\">;\n label?: React.Ref<\"label\">;\n rootContainer?: React.Ref<\"div\">;\n // startIcon?: React.Ref<ReactElement>;\n // endIcon?: React.Ref<ReactElement>;\n // inputContainer?: React.Ref<\"div\">;\n input?: React.Ref<'input' | 'textarea'>;\n helperText?: React.Ref<\"div\">;\n };\n\n slotProps?: {\n inputRoot?: Omit<TagProps<\"div\">, \"children\">;\n label?: Omit<LabelProps, \"children\">;\n rootContainer?: Omit<TagProps<\"div\">, \"children\">;\n // startIcon?: Omit<TagProps<'div'>, \"children\">;\n // endIcon?: Omit<TagProps<'div'>, \"children\">;\n // inputContainer?: Omit<TagProps<\"div\">, \"children\">;\n helperText?: Omit<TagProps<\"div\">, \"children\">;\n input?: Partial<TagProps<T>>;\n }\n}\n\nconst Input = React.forwardRef(<T extends TagComponentType = \"div\">({ value, refs, ...props }: InputProps<T>, ref?: React.Ref<any>) => {\n let [{\n startIcon,\n endIcon,\n iconPlacement,\n color,\n label,\n name,\n placeholder,\n type,\n readOnly,\n autoFocus,\n autoComplete,\n onFocus,\n onBlur,\n onChange,\n onKeyDown,\n onKeyUp,\n\n focused,\n disabled,\n variant,\n error,\n helperText,\n multiline,\n size,\n rows,\n minRows,\n maxRows,\n fullWidth,\n slotProps,\n\n ...rest\n }, theme] = useInterface<any>(\"Input\", props, {})\n\n const _p: any = {}\n if (startIcon) _p.startIcon = startIcon\n if (endIcon) _p.endIcon = endIcon\n if (iconPlacement) _p.iconPlacement = iconPlacement\n if (color) _p.color = color\n if (variant) _p.variant = variant\n if (helperText) _p.helperText = helperText\n if (size) _p.size = size\n if (rows) _p.rows = rows\n if (minRows) _p.minRows = minRows\n if (maxRows) _p.maxRows = maxRows\n const p: any = useBreakpointProps(_p)\n startIcon = p.startIcon\n endIcon = p.endIcon\n iconPlacement = p.iconPlacement\n color = p.color ?? \"brand\"\n variant = p.variant ?? \"fill\"\n helperText = p.helperText\n size = p.size ?? 'medium'\n rows = p.rows\n minRows = p.minRows\n maxRows = p.maxRows\n\n iconPlacement ??= multiline ? \"end\" : \"center\"\n if (!value) iconPlacement = 'center'\n\n const [_focused, setFocused] = useState(false)\n let _focus = focused || _focused\n const inputRef = React.useRef<HTMLInputElement | HTMLTextAreaElement>(null);\n const inputMergeRef = useMergeRefs(inputRef, refs?.input as any);\n\n useEffect(() => {\n if (autoFocus) {\n setTimeout(() => {\n inputRef.current?.focus()\n }, 100);\n }\n }, [autoFocus])\n\n let _rows = useMemo(() => {\n if (rows) return rows\n if (value && multiline) {\n let lines = (value as string).split(`\\n`).length\n if (minRows && minRows > lines) {\n return minRows\n } else if (maxRows && maxRows < lines) {\n return maxRows\n } else {\n return lines\n }\n }\n }, [value]) || 1\n\n const sizes: any = {\n small: {\n height: 38,\n gap: .5,\n fontSize: 'button',\n },\n medium: {\n height: 46,\n gap: 1,\n fontSize: \"text\"\n },\n large: {\n height: 52,\n gap: 1,\n fontSize: 'big'\n }\n }\n\n const _size = sizes[size]\n let borderColor = _focus ? color : (variant === \"fill\" ? \"transparent\" : \"divider\")\n borderColor = error ? \"danger.primary\" : borderColor\n let multiprops: any = {}\n if (multiline) {\n multiprops = {\n rows: _rows,\n sx: {\n resize: \"none\"\n }\n }\n }\n\n return (\n <Tag\n width={fullWidth ? \"100%\" : \"auto\"}\n {...rest}\n ref={ref}\n baseClass=\"input-wrapper\"\n sxr={{\n display: 'flex',\n flexDirection: 'column',\n gap: .5,\n }}\n >\n {!!label && <Label {...slotProps?.label} ref={refs?.label}>{label}</Label>}\n <Tag\n {...slotProps?.inputRoot}\n ref={refs?.inputRoot}\n baseClass={'input-root'}\n sxr={{\n width: \"100%\",\n overflow: \"hidden\",\n }}\n >\n <Tag\n {...slotProps?.rootContainer}\n ref={refs?.rootContainer}\n baseClass='input-root-container'\n sxr={{\n width: \"100%\",\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: iconPlacement === 'center' ? iconPlacement : `flex-${iconPlacement}`,\n flexWrap: \"nowrap\",\n transitionProperty: \"border, box-shadow, background\",\n bgcolor: error ? \"danger.soft.primary\" : variant === \"fill\" ? \"background.secondary\" : \"background.primary\",\n border: variant === \"text\" ? 0 : \"1px solid\",\n borderColor: borderColor,\n borderRadius: 1,\n px: 1,\n // py: .5,\n ..._size,\n height: multiline ? \"auto\" : _size.height,\n minHeight: _size.height,\n \"& input:-webkit-autofill,& input:-webkit-autofill:hover, & input:-webkit-autofill:focus,& input:-webkit-autofill:active\": {\n \"-webkit-text-fill-color\": \"text.primary\",\n \"box-shadow\": `0 0 0px 1000px ${variant === \"fill\" ? theme.colors.background.secondary : theme.colors.background.primary} inset`,\n transition: \"background-color 5000s ease-in-out 0s\"\n } as any,\n \"& textarea\": {\n resize: \"none\"\n },\n\n // ...(!!startIcon && {\n // \"& :first-child\": {\n // height: \"100%\",\n // alignItems: 'center',\n // justifyContent: \"center\",\n // display: \"flex\",\n // color: error ? \"danger.primary\" : \"text.secondary\",\n // flex: \"0 0 auto\",\n // },\n // }),\n\n // ...(!!endIcon && {\n // \"& :last-child\": {\n // height: \"100%\",\n // alignItems: 'center',\n // justifyContent: \"center\",\n // display: 'flex',\n // color: error ? \"danger.primary\" : \"text.secondary\",\n // flex: \"0 0 auto\",\n // },\n // })\n\n }}\n disabled={disabled || false}\n >\n {/* {startIcon && <Tag\n {...slotProps?.startIcon}\n ref={refs?.startIcon}\n flex={\"0 0 auto\"}\n sxr={{\n height: \"100%\",\n alignItems: 'center',\n justifyContent: \"center\",\n display: \"flex\",\n color: error ? \"danger.primary\" : \"text.secondary\",\n }}\n baseClass=\"input-start-icon\"\n >{startIcon}</Tag>} */}\n {startIcon}\n {/* <Tag\n {...slotProps?.inputContainer}\n ref={refs?.inputContainer}\n baseClass='input-container'\n flex={1}\n sxr={{\n width: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n flex: 1,\n minHeight: _size.height,\n \"& textarea\": {\n resize: \"none\"\n },\n \"& input:-webkit-autofill,& input:-webkit-autofill:hover, & input:-webkit-autofill:focus,& input:-webkit-autofill:active\": {\n \"-webkit-text-fill-color\": \"text.primary\",\n \"box-shadow\": `0 0 0px 1000px ${variant === \"fill\" ? theme.colors.background.secondary : theme.colors.background.primary} inset`,\n transition: \"background-color 5000s ease-in-out 0s\"\n } as any\n }}\n >\n \n </Tag> */}\n <Tag\n {...slotProps?.input}\n ref={inputMergeRef}\n baseClass='input'\n component={multiline ? 'textarea' : 'input'}\n {...multiprops}\n sxr={{\n border: 0,\n outline: 0,\n bgcolor: \"transparent\",\n color: error ? \"danger.primary\" : \"text.primary\",\n fontSize: _size.fontSize,\n height: multiline ? \"auto\" : _size.height + \"px!important\",\n width: \"100%\",\n maxHeight: 200,\n }}\n value={value}\n onChange={onChange}\n onFocus={(e: any) => {\n focused ?? setFocused(true)\n onFocus && onFocus(e)\n }}\n onBlur={(e: any) => {\n focused ?? setFocused(false)\n onBlur && onBlur(e)\n }}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n name={name}\n placeholder={placeholder}\n type={type}\n readOnly={readOnly}\n autoComplete={autoComplete}\n />\n {/* {endIcon && <Tag\n {...slotProps?.endIcon}\n ref={refs?.endIcon}\n flex={\"0 0 auto\"}\n sxr={{\n height: \"100%\",\n alignItems: 'center',\n justifyContent: \"center\",\n display: 'flex',\n color: error ? \"danger.primary\" : \"text.secondary\",\n }}\n baseClass=\"input-end-icon\"\n >{endIcon}</Tag>} */}\n {endIcon}\n </Tag>\n {helperText && <Tag\n {...slotProps?.helperText}\n ref={refs?.helperText}\n baseClass=\"input-helper-text\"\n sxr={{\n color: error ? \"danger.primary\" : \"text.primary\",\n fontSize: \"small\",\n lineHeight: \"text\",\n fontWeight: 'text',\n pl: .5,\n }}\n >{helperText}</Tag>}\n </Tag>\n </Tag>\n )\n})\n\nexport default Input\n"],"names":[],"mappings":";;;;;;;;;AA6DA;;;AACI;;AAmCA;AAAe;AACf;AAAa;AACb;AAAmB;AACnB;AAAW;AACX;AAAa;AACb;AAAgB;AAChB;AAAU;AACV;AAAU;AACV;AAAa;AACb;AAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;;;AAGA;;AAEA;;;;;AAKY;;;AAGZ;AAEA;AACI;AAAU;AACV;;AAEI;AACI;;AACG;AACH;;;AAEA;;;AAGZ;AAEA;AACI;AACI;AACA;AACA;AACH;AACD;AACI;AACA;AACA;AACH;AACD;AACI;AACA;AACA;AACH;;AAGL;;;;;AAKI;AACI;AACA;AACI;AACH;;;;AAWG;AACA;AACA;;AASI;AACA;AACH;AAuBW;;AAEA;AACI;AAEJ;AACH;AAuEG;AACA;AACA;;;AAGA;AACA;AACA;AACH;;AAKG;AACJ;;AAGI;AACJ;;AA8BA;AACA;AACA;AACA;AACH;AAKrB;;"}
|
package/Input/index.mjs
CHANGED
|
@@ -3,11 +3,12 @@ import { __rest } from 'tslib';
|
|
|
3
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
4
|
import React, { useState, useEffect, useMemo } from 'react';
|
|
5
5
|
import { useInterface, useBreakpointProps, useMergeRefs, Tag } from '@xanui/core';
|
|
6
|
+
import Label from '../Label/index.mjs';
|
|
6
7
|
|
|
7
8
|
const Input = React.forwardRef((_a, ref) => {
|
|
8
9
|
var _b, _c, _d;
|
|
9
10
|
var { value, refs } = _a, props = __rest(_a, ["value", "refs"]);
|
|
10
|
-
let [_e, theme] = useInterface("Input", props, {}), { startIcon, endIcon, iconPlacement, color, name, placeholder, type, readOnly, autoFocus, autoComplete, onFocus, onBlur, onChange, onKeyDown, onKeyUp, focused, disabled, variant, error, helperText, multiline, size, rows, minRows, maxRows, fullWidth, slotProps } = _e, rest = __rest(_e, ["startIcon", "endIcon", "iconPlacement", "color", "name", "placeholder", "type", "readOnly", "autoFocus", "autoComplete", "onFocus", "onBlur", "onChange", "onKeyDown", "onKeyUp", "focused", "disabled", "variant", "error", "helperText", "multiline", "size", "rows", "minRows", "maxRows", "fullWidth", "slotProps"]);
|
|
11
|
+
let [_e, theme] = useInterface("Input", props, {}), { startIcon, endIcon, iconPlacement, color, label, name, placeholder, type, readOnly, autoFocus, autoComplete, onFocus, onBlur, onChange, onKeyDown, onKeyUp, focused, disabled, variant, error, helperText, multiline, size, rows, minRows, maxRows, fullWidth, slotProps } = _e, rest = __rest(_e, ["startIcon", "endIcon", "iconPlacement", "color", "label", "name", "placeholder", "type", "readOnly", "autoFocus", "autoComplete", "onFocus", "onBlur", "onChange", "onKeyDown", "onKeyUp", "focused", "disabled", "variant", "error", "helperText", "multiline", "size", "rows", "minRows", "maxRows", "fullWidth", "slotProps"]);
|
|
11
12
|
const _p = {};
|
|
12
13
|
if (startIcon)
|
|
13
14
|
_p.startIcon = startIcon;
|
|
@@ -73,12 +74,12 @@ const Input = React.forwardRef((_a, ref) => {
|
|
|
73
74
|
}, [value]) || 1;
|
|
74
75
|
const sizes = {
|
|
75
76
|
small: {
|
|
76
|
-
height:
|
|
77
|
+
height: 38,
|
|
77
78
|
gap: .5,
|
|
78
79
|
fontSize: 'button',
|
|
79
80
|
},
|
|
80
81
|
medium: {
|
|
81
|
-
height:
|
|
82
|
+
height: 46,
|
|
82
83
|
gap: 1,
|
|
83
84
|
fontSize: "text"
|
|
84
85
|
},
|
|
@@ -100,73 +101,41 @@ const Input = React.forwardRef((_a, ref) => {
|
|
|
100
101
|
}
|
|
101
102
|
};
|
|
102
103
|
}
|
|
103
|
-
return (jsxs(Tag, Object.assign({ width: fullWidth ? "100%" :
|
|
104
|
-
'
|
|
105
|
-
'
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
[`input-size-${size}`]: true,
|
|
109
|
-
}, children: [jsxs(Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.rootContainer, { ref: refs === null || refs === void 0 ? void 0 : refs.rootContainer, baseClass: 'root-container', sxr: {
|
|
104
|
+
return (jsxs(Tag, Object.assign({ width: fullWidth ? "100%" : "auto" }, rest, { ref: ref, baseClass: "input-wrapper", sxr: {
|
|
105
|
+
display: 'flex',
|
|
106
|
+
flexDirection: 'column',
|
|
107
|
+
gap: .5,
|
|
108
|
+
}, children: [!!label && jsx(Label, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.label, { ref: refs === null || refs === void 0 ? void 0 : refs.label, children: label })), jsxs(Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.inputRoot, { ref: refs === null || refs === void 0 ? void 0 : refs.inputRoot, baseClass: 'input-root', sxr: {
|
|
110
109
|
width: "100%",
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
alignItems: iconPlacement === 'center' ? iconPlacement : `flex-${iconPlacement}`,
|
|
114
|
-
flexWrap: "nowrap",
|
|
115
|
-
transitionProperty: "border, box-shadow, background",
|
|
116
|
-
bgcolor: error ? "danger.soft.primary" : variant === "fill" ? "background.secondary" : "background.primary",
|
|
117
|
-
border: variant === "text" ? 0 : "1px solid",
|
|
118
|
-
borderColor: borderColor,
|
|
119
|
-
borderRadius: 1,
|
|
120
|
-
px: 1,
|
|
121
|
-
py: .5,
|
|
122
|
-
}, disabled: disabled || false }, _size, { height: multiline ? "auto" : _size.height, minHeight: _size.height, children: [startIcon && jsx(Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.startIcon, { ref: refs === null || refs === void 0 ? void 0 : refs.startIcon, flex: "0 0 auto", sxr: {
|
|
123
|
-
height: "100%",
|
|
124
|
-
alignItems: 'center',
|
|
125
|
-
justifyContent: "center",
|
|
126
|
-
display: "flex",
|
|
127
|
-
color: error ? "danger.primary" : "text.secondary",
|
|
128
|
-
}, baseClass: "input-start-icon", children: startIcon })), jsx(Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.inputContainer, { ref: refs === null || refs === void 0 ? void 0 : refs.inputContainer, baseClass: 'input-container', flex: 1, sxr: {
|
|
129
|
-
width: "100%",
|
|
130
|
-
display: "flex",
|
|
131
|
-
alignItems: "center",
|
|
132
|
-
flex: 1,
|
|
133
|
-
minHeight: _size.height,
|
|
134
|
-
"& textarea": {
|
|
135
|
-
resize: "none"
|
|
136
|
-
},
|
|
137
|
-
"& input:-webkit-autofill,& input:-webkit-autofill:hover, & input:-webkit-autofill:focus,& input:-webkit-autofill:active": {
|
|
110
|
+
overflow: "hidden",
|
|
111
|
+
}, children: [jsxs(Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.rootContainer, { ref: refs === null || refs === void 0 ? void 0 : refs.rootContainer, baseClass: 'input-root-container', sxr: Object.assign(Object.assign({ width: "100%", display: "flex", flexDirection: "row", alignItems: iconPlacement === 'center' ? iconPlacement : `flex-${iconPlacement}`, flexWrap: "nowrap", transitionProperty: "border, box-shadow, background", bgcolor: error ? "danger.soft.primary" : variant === "fill" ? "background.secondary" : "background.primary", border: variant === "text" ? 0 : "1px solid", borderColor: borderColor, borderRadius: 1, px: 1 }, _size), { height: multiline ? "auto" : _size.height, minHeight: _size.height, "& input:-webkit-autofill,& input:-webkit-autofill:hover, & input:-webkit-autofill:focus,& input:-webkit-autofill:active": {
|
|
138
112
|
"-webkit-text-fill-color": "text.primary",
|
|
139
113
|
"box-shadow": `0 0 0px 1000px ${variant === "fill" ? theme.colors.background.secondary : theme.colors.background.primary} inset`,
|
|
140
114
|
transition: "background-color 5000s ease-in-out 0s"
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
fontSize: "small",
|
|
166
|
-
lineHeight: "text",
|
|
167
|
-
fontWeight: 'text',
|
|
168
|
-
pl: .5,
|
|
169
|
-
}, children: helperText }))] })));
|
|
115
|
+
}, "& textarea": {
|
|
116
|
+
resize: "none"
|
|
117
|
+
} }), disabled: disabled || false, children: [startIcon, jsx(Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.input, { ref: inputMergeRef, baseClass: 'input', component: multiline ? 'textarea' : 'input' }, multiprops, { sxr: {
|
|
118
|
+
border: 0,
|
|
119
|
+
outline: 0,
|
|
120
|
+
bgcolor: "transparent",
|
|
121
|
+
color: error ? "danger.primary" : "text.primary",
|
|
122
|
+
fontSize: _size.fontSize,
|
|
123
|
+
height: multiline ? "auto" : _size.height + "px!important",
|
|
124
|
+
width: "100%",
|
|
125
|
+
maxHeight: 200,
|
|
126
|
+
}, value: value, onChange: onChange, onFocus: (e) => {
|
|
127
|
+
focused !== null && focused !== void 0 ? focused : setFocused(true);
|
|
128
|
+
onFocus && onFocus(e);
|
|
129
|
+
}, onBlur: (e) => {
|
|
130
|
+
focused !== null && focused !== void 0 ? focused : setFocused(false);
|
|
131
|
+
onBlur && onBlur(e);
|
|
132
|
+
}, onKeyDown: onKeyDown, onKeyUp: onKeyUp, name: name, placeholder: placeholder, type: type, readOnly: readOnly, autoComplete: autoComplete })), endIcon] })), helperText && jsx(Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.helperText, { ref: refs === null || refs === void 0 ? void 0 : refs.helperText, baseClass: "input-helper-text", sxr: {
|
|
133
|
+
color: error ? "danger.primary" : "text.primary",
|
|
134
|
+
fontSize: "small",
|
|
135
|
+
lineHeight: "text",
|
|
136
|
+
fontWeight: 'text',
|
|
137
|
+
pl: .5,
|
|
138
|
+
}, children: helperText }))] }))] })));
|
|
170
139
|
});
|
|
171
140
|
|
|
172
141
|
export { Input as default };
|