maquinaweb-ui 2.75.0 → 2.75.2
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/dist/actions.js +0 -1
- package/dist/actions.js.map +1 -1
- package/dist/analytics/core.d.ts.map +1 -1
- package/dist/analytics/core.js +0 -1
- package/dist/analytics/core.js.map +1 -1
- package/dist/analytics/delegated-clicks.d.ts.map +1 -1
- package/dist/analytics/delegated-clicks.js +0 -1
- package/dist/analytics/delegated-clicks.js.map +1 -1
- package/dist/analytics/provider.d.ts +2 -2
- package/dist/analytics/provider.d.ts.map +1 -1
- package/dist/analytics/provider.js +0 -1
- package/dist/analytics/provider.js.map +1 -1
- package/dist/analytics/types.d.ts.map +1 -1
- package/dist/analytics.js +0 -1
- package/dist/container-animation/container-animation.d.ts +2 -2
- package/dist/container-animation/container-animation.d.ts.map +1 -1
- package/dist/container-animation/container-animation.js +1 -2
- package/dist/container-animation/container-animation.js.map +1 -1
- package/dist/container-animation.js +0 -1
- package/dist/date-field/DateField.d.ts +2 -2
- package/dist/date-field/DateField.d.ts.map +1 -1
- package/dist/date-field/DateField.js +0 -1
- package/dist/date-field/DateField.js.map +1 -1
- package/dist/date-field.js +0 -1
- package/dist/date-hour-field/DateHourField.d.ts +2 -2
- package/dist/date-hour-field/DateHourField.d.ts.map +1 -1
- package/dist/date-hour-field/DateHourField.js +0 -1
- package/dist/date-hour-field/DateHourField.js.map +1 -1
- package/dist/date-hour-field/time-wheel-column.js.map +1 -1
- package/dist/date-hour-field.js +0 -1
- package/dist/input-suggest/input-suggest.d.ts +2 -2
- package/dist/input-suggest/input-suggest.d.ts.map +1 -1
- package/dist/input-suggest/input-suggest.js +6 -7
- package/dist/input-suggest/input-suggest.js.map +1 -1
- package/dist/input-suggest.js +0 -1
- package/dist/kanban-dnd/constants.js +1 -4
- package/dist/kanban-dnd/constants.js.map +1 -1
- package/dist/kanban-dnd/context.d.ts +0 -4
- package/dist/kanban-dnd/context.d.ts.map +1 -1
- package/dist/kanban-dnd/context.js +0 -1
- package/dist/kanban-dnd/context.js.map +1 -1
- package/dist/kanban-dnd/drag-preview.js +4 -4
- package/dist/kanban-dnd/drag-preview.js.map +1 -1
- package/dist/kanban-dnd/drop-animation.js.map +1 -1
- package/dist/kanban-dnd/kanban-card-item.d.ts +2 -2
- package/dist/kanban-dnd/kanban-card-item.d.ts.map +1 -1
- package/dist/kanban-dnd/kanban-card-item.js +0 -1
- package/dist/kanban-dnd/kanban-card-item.js.map +1 -1
- package/dist/kanban-dnd/kanban-dnd-monitor.d.ts +2 -2
- package/dist/kanban-dnd/kanban-dnd-monitor.d.ts.map +1 -1
- package/dist/kanban-dnd/kanban-dnd-monitor.js +0 -1
- package/dist/kanban-dnd/kanban-dnd-monitor.js.map +1 -1
- package/dist/kanban-dnd/kanban-dropzone.d.ts +2 -2
- package/dist/kanban-dnd/kanban-dropzone.d.ts.map +1 -1
- package/dist/kanban-dnd/kanban-dropzone.js +0 -1
- package/dist/kanban-dnd/kanban-dropzone.js.map +1 -1
- package/dist/kanban-dnd/kanban-selector.d.ts +2 -2
- package/dist/kanban-dnd/kanban-selector.d.ts.map +1 -1
- package/dist/kanban-dnd/kanban-selector.js +0 -1
- package/dist/kanban-dnd/kanban-selector.js.map +1 -1
- package/dist/kanban-dnd/move-cards.d.ts.map +1 -1
- package/dist/kanban-dnd/move-cards.js.map +1 -1
- package/dist/kanban-dnd/types.d.ts.map +1 -1
- package/dist/kanban-dnd/use-kanban-column-dnd.d.ts.map +1 -1
- package/dist/kanban-dnd/use-kanban-column-dnd.js +0 -1
- package/dist/kanban-dnd/use-kanban-column-dnd.js.map +1 -1
- package/dist/kanban-dnd/use-kanban-selector-auto-scroll.js.map +1 -1
- package/dist/kanban-dnd.d.ts +0 -1
- package/dist/kanban-dnd.js +0 -1
- package/dist/landing-text/client-landing-text.js +0 -1
- package/dist/landing-text/client-landing-text.js.map +1 -1
- package/dist/landing-text/landing-content.d.ts +0 -2
- package/dist/landing-text/landing-content.d.ts.map +1 -1
- package/dist/landing-text/landing-content.js.map +1 -1
- package/dist/landing-text/landing-text.d.ts +2 -2
- package/dist/landing-text/landing-text.d.ts.map +1 -1
- package/dist/landing-text/landing-text.js +1 -1
- package/dist/landing-text/landing-text.js.map +1 -1
- package/dist/landing-text/server-landing-text.d.ts +2 -2
- package/dist/landing-text/server-landing-text.d.ts.map +1 -1
- package/dist/landing-text/server-landing-text.js +1 -1
- package/dist/landing-text/server-landing-text.js.map +1 -1
- package/dist/landing-text/types.d.ts.map +1 -1
- package/dist/node_modules/framer-motion/dist/es/utils/use-in-view.js +0 -1
- package/dist/node_modules/framer-motion/dist/es/utils/use-in-view.js.map +1 -1
- package/dist/node_modules/framer-motion/dist/types/index.d.ts +4 -0
- package/dist/node_modules/framer-motion/dist/types.d-DOCC-kZB.d.ts +1 -0
- package/dist/node_modules/motion/dist/react.d.ts +2 -0
- package/dist/node_modules/motion-dom/dist/index.d.ts +1001 -0
- package/dist/node_modules/motion-dom/dist/index.d.ts.map +1 -0
- package/dist/node_modules/motion-utils/dist/index.d.ts +17 -0
- package/dist/node_modules/motion-utils/dist/index.d.ts.map +1 -0
- package/dist/page-header/page-header.d.ts +2 -2
- package/dist/page-header/page-header.d.ts.map +1 -1
- package/dist/page-header/page-header.js.map +1 -1
- package/dist/page-header.js +0 -1
- package/dist/remote-selector/remote-selector.d.ts +3 -3
- package/dist/remote-selector/remote-selector.d.ts.map +1 -1
- package/dist/remote-selector/remote-selector.js +3 -4
- package/dist/remote-selector/remote-selector.js.map +1 -1
- package/dist/remote-selector.js +0 -1
- package/dist/server-infinite-scroll/server-infinite-scroll-items.d.ts +2 -2
- package/dist/server-infinite-scroll/server-infinite-scroll-items.d.ts.map +1 -1
- package/dist/server-infinite-scroll/server-infinite-scroll-items.js.map +1 -1
- package/dist/server-infinite-scroll/server-infinite-scroll-list.d.ts +2 -2
- package/dist/server-infinite-scroll/server-infinite-scroll-list.d.ts.map +1 -1
- package/dist/server-infinite-scroll/server-infinite-scroll-list.js +6 -7
- package/dist/server-infinite-scroll/server-infinite-scroll-list.js.map +1 -1
- package/dist/server-infinite-scroll/server-infinite-scroll-observer.d.ts +2 -2
- package/dist/server-infinite-scroll/server-infinite-scroll-observer.d.ts.map +1 -1
- package/dist/server-infinite-scroll/server-infinite-scroll-observer.js +0 -1
- package/dist/server-infinite-scroll/server-infinite-scroll-observer.js.map +1 -1
- package/dist/server-infinite-scroll/server-infinite-scroll.d.ts +2 -2
- package/dist/server-infinite-scroll/server-infinite-scroll.d.ts.map +1 -1
- package/dist/server-infinite-scroll/types.d.ts.map +1 -1
- package/dist/split-text-poor/split-text-poor.d.ts.map +1 -1
- package/dist/split-text-poor/split-text-poor.js +1 -2
- package/dist/split-text-poor/split-text-poor.js.map +1 -1
- package/dist/split-text-poor.js +0 -1
- package/dist/src/hooks/get-mask-options.js.map +1 -1
- package/dist/src/hooks/is-server.js +1 -2
- package/dist/src/hooks/is-server.js.map +1 -1
- package/dist/src/hooks/use-money-input.js +1 -3
- package/dist/src/hooks/use-money-input.js.map +1 -1
- package/dist/src/hooks/with-mask.d.ts +0 -1
- package/dist/src/hooks/with-mask.d.ts.map +1 -1
- package/dist/src/hooks/with-mask.js +2 -2
- package/dist/src/hooks/with-mask.js.map +1 -1
- package/dist/text-field/TextField.d.ts +5 -5
- package/dist/text-field/TextField.d.ts.map +1 -1
- package/dist/text-field/TextField.js +8 -9
- package/dist/text-field/TextField.js.map +1 -1
- package/dist/text-field.js +0 -1
- package/dist/toggle-field/ToggleField.d.ts.map +1 -1
- package/dist/toggle-field/ToggleField.js +1 -2
- package/dist/toggle-field/ToggleField.js.map +1 -1
- package/dist/toggle-field/ToggleGroup.d.ts +6 -6
- package/dist/toggle-field/ToggleGroup.d.ts.map +1 -1
- package/dist/toggle-field/ToggleGroup.js +2 -3
- package/dist/toggle-field/ToggleGroup.js.map +1 -1
- package/dist/toggle-field.js +0 -1
- package/dist/ui/badge.js +1 -1
- package/dist/ui/badge.js.map +1 -1
- package/dist/ui/button.js +1 -1
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/calendar.js +8 -9
- package/dist/ui/calendar.js.map +1 -1
- package/dist/ui/checkbox.js +1 -2
- package/dist/ui/checkbox.js.map +1 -1
- package/dist/ui/command.js +5 -6
- package/dist/ui/command.js.map +1 -1
- package/dist/ui/content-help.js.map +1 -1
- package/dist/ui/form.js +4 -5
- package/dist/ui/form.js.map +1 -1
- package/dist/ui/input-date-field.js +1 -1
- package/dist/ui/input-date-field.js.map +1 -1
- package/dist/ui/input-help.js +0 -1
- package/dist/ui/input-help.js.map +1 -1
- package/dist/ui/input.js +1 -1
- package/dist/ui/input.js.map +1 -1
- package/dist/ui/label.js +1 -2
- package/dist/ui/label.js.map +1 -1
- package/dist/ui/popover.js +1 -2
- package/dist/ui/popover.js.map +1 -1
- package/dist/ui/scroll-area.js +1 -2
- package/dist/ui/scroll-area.js.map +1 -1
- package/dist/ui/selector.d.ts +0 -2
- package/dist/ui/selector.d.ts.map +1 -1
- package/dist/ui/selector.js +3 -4
- package/dist/ui/selector.js.map +1 -1
- package/dist/ui/tooltip.js +2 -3
- package/dist/ui/tooltip.js.map +1 -1
- package/dist/ui/tree-item-renderer.js +1 -3
- package/dist/ui/tree-item-renderer.js.map +1 -1
- package/package.json +16 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split-text-poor.js","names":[
|
|
1
|
+
{"version":3,"file":"split-text-poor.js","names":[],"sources":["../../src/components/split-text-poor/split-text-poor.tsx"],"sourcesContent":["'use client';\n\nimport { Children, cloneElement, isValidElement } from 'react';\n\nimport { cn } from '@/lib/utils';\nimport * as motion from 'motion/react-m';\n\nconst defaultConfig = {\n hidden: {\n transform: 'translateY(20px) skewY(6deg)',\n opacity: 0,\n filter: 'blur(7px)',\n },\n visible: ({ index, delay }: { index: number; delay: number }) => ({\n transform: 'translateY(0px) skewY(0deg)',\n opacity: 1,\n filter: 'blur(0px)',\n transition: {\n duration: 0.4,\n delay: index * 0.08 + delay,\n },\n }),\n};\n\nconst configs = {\n sm: {\n hidden: {\n transform: 'translateY(10px)',\n filter: 'blur(7px)',\n opacity: 0,\n },\n visible: ({ index, delay }: { index: number; delay: number }) => ({\n transform: 'translateY(0px)',\n filter: 'blur(0px)',\n opacity: 1,\n transition: {\n duration: 0.4,\n delay: index * 0.06 + delay,\n },\n }),\n },\n default: defaultConfig,\n};\n\nexport type SplitTextPoorProps = {\n children: React.ReactNode;\n className?: string;\n config?: keyof typeof configs;\n split?: string;\n delay?: number;\n as?: any;\n};\n\nconst SplitTextPoor: React.FC<SplitTextPoorProps> = ({\n children,\n className,\n config = 'default',\n as: As = 'div',\n split = ' ',\n delay = 0,\n ...props\n}) => {\n const selectedConfig = configs[config] || defaultConfig;\n let wordIndex = 0;\n\n const wrapWords = (node: React.ReactNode): React.ReactNode => {\n if (typeof node === 'string') {\n return node.split(split).map((word, index) => {\n wordIndex++;\n return (\n <motion.span\n custom={{\n index: wordIndex - 1,\n delay,\n }}\n initial=\"hidden\"\n key={index}\n style={{ display: 'inline-block', whiteSpace: 'nowrap' }}\n variants={selectedConfig}\n viewport={{ once: true }}\n whileInView=\"visible\"\n >\n {word}\n {index < node.split(split).length - 1 && '\\u00A0'}\n </motion.span>\n );\n });\n }\n\n if (isValidElement(node)) {\n return cloneElement(node, {\n children: Children.map((node.props as any).children, wrapWords),\n } as any);\n }\n\n return node;\n };\n\n return (\n <As\n className={cn(\n className,\n 'initial-opacity will-change-[transform,filter]'\n )}\n style={{ display: 'inline-block' }}\n {...props}\n >\n {Children.map(children, wrapWords)}\n </As>\n );\n};\n\nexport { SplitTextPoor };\n"],"mappings":";;;;;;;;AAOA,MAAM,gBAAgB;CACpB,QAAQ;EACN,WAAW;EACX,SAAS;EACT,QAAQ;EACT;CACD,UAAU,EAAE,OAAO,aAA+C;EAChE,WAAW;EACX,SAAS;EACT,QAAQ;EACR,YAAY;GACV,UAAU;GACV,OAAO,QAAQ,MAAO;GACvB;EACF;CACF;AAED,MAAM,UAAU;CACd,IAAI;EACF,QAAQ;GACN,WAAW;GACX,QAAQ;GACR,SAAS;GACV;EACD,UAAU,EAAE,OAAO,aAA+C;GAChE,WAAW;GACX,QAAQ;GACR,SAAS;GACT,YAAY;IACV,UAAU;IACV,OAAO,QAAQ,MAAO;IACvB;GACF;EACF;CACD,SAAS;CACV;AAWD,MAAM,iBAA+C,EACnD,UACA,WACA,SAAS,WACT,IAAI,KAAK,OACT,QAAQ,KACR,QAAQ,GACR,GAAG,YACC;CACJ,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,IAAI,YAAY;CAEhB,MAAM,aAAa,SAA2C;AAC5D,MAAI,OAAO,SAAS,SAClB,QAAO,KAAK,MAAM,MAAM,CAAC,KAAK,MAAM,UAAU;AAC5C;AACA,UACE,qBAAC,OAAO,MAAR;IACE,QAAQ;KACN,OAAO,YAAY;KACnB;KACD;IACD,SAAQ;IAER,OAAO;KAAE,SAAS;KAAgB,YAAY;KAAU;IACxD,UAAU;IACV,UAAU,EAAE,MAAM,MAAM;IACxB,aAAY;cAVd,CAYG,MACA,QAAQ,KAAK,MAAM,MAAM,CAAC,SAAS,KAAK,OAC7B;MARP,MAQO;IAEhB;AAGJ,MAAI,eAAe,KAAK,CACtB,QAAO,aAAa,MAAM,EACxB,UAAU,SAAS,IAAK,KAAK,MAAc,UAAU,UAAU,EAChE,CAAQ;AAGX,SAAO;;AAGT,QACE,oBAAC,IAAD;EACE,WAAW,GACT,WACA,iDACD;EACD,OAAO,EAAE,SAAS,gBAAgB;EAClC,GAAI;YAEH,SAAS,IAAI,UAAU,UAAU;EAC/B"}
|
package/dist/split-text-poor.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-mask-options.js","names":[
|
|
1
|
+
{"version":3,"file":"get-mask-options.js","names":[],"sources":["../../../src/hooks/get-mask-options.ts"],"sourcesContent":["import type { Mask, Options } from './with-mask';\n\nexport default function getMaskOptions(\n mask?: Mask,\n _options?: Options\n): Options {\n const options: Options = {\n jitMasking: false,\n ..._options,\n };\n if (!mask) return options;\n\n const masks: Record<string, Inputmask.Options> = {\n datetime: {\n alias: 'datetime',\n ...options,\n },\n email: {\n alias: 'email',\n placeholder: '',\n ...options,\n },\n numeric: {\n alias: 'numeric',\n placeholder: '',\n ...options,\n },\n currency: {\n alias: 'currency',\n prefix: '$ ',\n placeholder: '',\n ...options,\n },\n decimal: {\n alias: 'decimal',\n placeholder: '',\n ...options,\n },\n integer: {\n alias: 'integer',\n placeholder: '',\n ...options,\n },\n percentage: {\n alias: 'percentage',\n placeholder: ' %',\n suffix: ' %',\n ...options,\n },\n url: {\n alias: 'url',\n placeholder: 'https://',\n ...options,\n },\n ip: {\n alias: 'ip',\n ...options,\n },\n mac: {\n alias: 'mac',\n ...options,\n },\n ssn: {\n alias: 'ssn',\n ...options,\n },\n\n // alias for brazilians <3\n // ty <3\n 'brl-currency': {\n alias: 'currency',\n prefix: 'R$ ',\n placeholder: '0,00',\n displayFormat: 'currency',\n radixPoint: ',',\n autoUnmask: true,\n ...options,\n },\n cpf: {\n mask: '999.999.999-99',\n placeholder: '___.___.___-__',\n ...options,\n },\n cnpj: {\n mask: '99.999.999/9999-99',\n placeholder: '__.___.___/____-__',\n ...options,\n },\n };\n\n if (typeof mask === 'string' && masks[mask]) return masks[mask];\n\n return {\n mask,\n ...options,\n };\n}\n"],"mappings":";AAEA,SAAwB,eACtB,MACA,UACS;CACT,MAAM,UAAmB;EACvB,YAAY;EACZ,GAAG;EACJ;AACD,KAAI,CAAC,KAAM,QAAO;CAElB,MAAM,QAA2C;EAC/C,UAAU;GACR,OAAO;GACP,GAAG;GACJ;EACD,OAAO;GACL,OAAO;GACP,aAAa;GACb,GAAG;GACJ;EACD,SAAS;GACP,OAAO;GACP,aAAa;GACb,GAAG;GACJ;EACD,UAAU;GACR,OAAO;GACP,QAAQ;GACR,aAAa;GACb,GAAG;GACJ;EACD,SAAS;GACP,OAAO;GACP,aAAa;GACb,GAAG;GACJ;EACD,SAAS;GACP,OAAO;GACP,aAAa;GACb,GAAG;GACJ;EACD,YAAY;GACV,OAAO;GACP,aAAa;GACb,QAAQ;GACR,GAAG;GACJ;EACD,KAAK;GACH,OAAO;GACP,aAAa;GACb,GAAG;GACJ;EACD,IAAI;GACF,OAAO;GACP,GAAG;GACJ;EACD,KAAK;GACH,OAAO;GACP,GAAG;GACJ;EACD,KAAK;GACH,OAAO;GACP,GAAG;GACJ;EAID,gBAAgB;GACd,OAAO;GACP,QAAQ;GACR,aAAa;GACb,eAAe;GACf,YAAY;GACZ,YAAY;GACZ,GAAG;GACJ;EACD,KAAK;GACH,MAAM;GACN,aAAa;GACb,GAAG;GACJ;EACD,MAAM;GACJ,MAAM;GACN,aAAa;GACb,GAAG;GACJ;EACF;AAED,KAAI,OAAO,SAAS,YAAY,MAAM,MAAO,QAAO,MAAM;AAE1D,QAAO;EACL;EACA,GAAG;EACJ"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
//#region src/hooks/is-server.ts
|
|
2
2
|
const isServer = !(typeof window !== "undefined" && window.document?.createElement);
|
|
3
|
-
var is_server_default = isServer;
|
|
4
3
|
|
|
5
4
|
//#endregion
|
|
6
|
-
export {
|
|
5
|
+
export { isServer as default };
|
|
7
6
|
//# sourceMappingURL=is-server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-server.js","names":[],"sources":["../../../src/hooks/is-server.ts"],"sourcesContent":["const isServer = !(\n typeof window !== 'undefined' && window.document?.createElement\n);\n\nexport default isServer;\n"],"mappings":";AAAA,MAAM,WAAW,EACf,OAAO,WAAW,eAAe,OAAO,UAAU
|
|
1
|
+
{"version":3,"file":"is-server.js","names":[],"sources":["../../../src/hooks/is-server.ts"],"sourcesContent":["const isServer = !(\n typeof window !== 'undefined' && window.document?.createElement\n);\n\nexport default isServer;\n"],"mappings":";AAAA,MAAM,WAAW,EACf,OAAO,WAAW,eAAe,OAAO,UAAU"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
import { useEffect, useState } from "react";
|
|
5
4
|
|
|
6
5
|
//#region src/hooks/use-money-input.ts
|
|
@@ -32,8 +31,7 @@ const useMoneyInput = ({ config = defaultConfig, onChange, value }) => {
|
|
|
32
31
|
handleChange
|
|
33
32
|
};
|
|
34
33
|
};
|
|
35
|
-
var use_money_input_default = useMoneyInput;
|
|
36
34
|
|
|
37
35
|
//#endregion
|
|
38
|
-
export {
|
|
36
|
+
export { useMoneyInput as default };
|
|
39
37
|
//# sourceMappingURL=use-money-input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-money-input.js","names":[
|
|
1
|
+
{"version":3,"file":"use-money-input.js","names":[],"sources":["../../../src/hooks/use-money-input.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\n\ntype useMoneyInputProps = {\n config?: Intl.NumberFormatOptions & { prefix?: string; suffix?: string };\n value?: number;\n onChange?: (value?: number) => void;\n};\n\nconst defaultConfig: Intl.NumberFormatOptions = {\n currency: 'BRL',\n currencyDisplay: 'symbol',\n currencySign: 'standard',\n style: 'currency',\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n};\n\nconst useMoneyInput = ({\n config = defaultConfig,\n onChange,\n value,\n}: useMoneyInputProps) => {\n const prefix = config?.prefix || '';\n const suffix = config?.suffix || '';\n const divider = Math.pow(10, config?.maximumFractionDigits || 2);\n const moneyFormatter = Intl.NumberFormat('pt-BR', config);\n const [displayValue, setDisplayValue] = useState(() =>\n value ? `${prefix}${moneyFormatter.format(value)}${suffix}` : ''\n );\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const digits = e.target.value.replace(/\\D/g, '');\n const realValue = digits ? Number(digits) / divider : undefined;\n const formattedValue =\n digits && realValue\n ? `${prefix}${moneyFormatter.format(realValue)}${suffix}`\n : '';\n\n setDisplayValue(formattedValue);\n onChange?.(realValue);\n };\n\n useEffect(() => {\n const formatted = value\n ? `${prefix}${moneyFormatter.format(value)}${suffix}`\n : '';\n setDisplayValue(formatted);\n }, [value]);\n\n return { displayValue, handleChange };\n};\n\nexport default useMoneyInput;\n"],"mappings":";;;;;AAUA,MAAM,gBAA0C;CAC9C,UAAU;CACV,iBAAiB;CACjB,cAAc;CACd,OAAO;CACP,uBAAuB;CACvB,uBAAuB;CACxB;AAED,MAAM,iBAAiB,EACrB,SAAS,eACT,UACA,YACwB;CACxB,MAAM,SAAS,QAAQ,UAAU;CACjC,MAAM,SAAS,QAAQ,UAAU;CACjC,MAAM,UAAU,KAAK,IAAI,IAAI,QAAQ,yBAAyB,EAAE;CAChE,MAAM,iBAAiB,KAAK,aAAa,SAAS,OAAO;CACzD,MAAM,CAAC,cAAc,mBAAmB,eACtC,QAAQ,GAAG,SAAS,eAAe,OAAO,MAAM,GAAG,WAAW,GAC/D;CAED,MAAM,gBAAgB,MAA2C;EAC/D,MAAM,SAAS,EAAE,OAAO,MAAM,QAAQ,OAAO,GAAG;EAChD,MAAM,YAAY,SAAS,OAAO,OAAO,GAAG,UAAU;AAMtD,kBAJE,UAAU,YACN,GAAG,SAAS,eAAe,OAAO,UAAU,GAAG,WAC/C,GAEyB;AAC/B,aAAW,UAAU;;AAGvB,iBAAgB;AAId,kBAHkB,QACd,GAAG,SAAS,eAAe,OAAO,MAAM,GAAG,WAC3C,GACsB;IACzB,CAAC,MAAM,CAAC;AAEX,QAAO;EAAE;EAAc;EAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-mask.d.ts","names":[],"sources":["../../../src/hooks/with-mask.ts"],"
|
|
1
|
+
{"version":3,"file":"with-mask.d.ts","names":[],"sources":["../../../src/hooks/with-mask.ts"],"mappings":";;;KAQY,IAAA;AAAA,KAkBA,OAAA,GAAU,SAAA,CAAU,OAAA"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import getMaskOptions from "./get-mask-options.js";
|
|
2
|
-
import
|
|
2
|
+
import isServer from "./is-server.js";
|
|
3
3
|
import interopDefaultSync from "./module-interop.js";
|
|
4
4
|
import inputmask from "inputmask";
|
|
5
5
|
|
|
6
6
|
//#region src/hooks/with-mask.ts
|
|
7
7
|
function withMask(mask, options) {
|
|
8
8
|
return (input) => {
|
|
9
|
-
if (
|
|
9
|
+
if (isServer || mask === null || !input) return;
|
|
10
10
|
interopDefaultSync(inputmask)(getMaskOptions(mask, options)).mask(input);
|
|
11
11
|
};
|
|
12
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-mask.js","names":[
|
|
1
|
+
{"version":3,"file":"with-mask.js","names":[],"sources":["../../../src/hooks/with-mask.ts"],"sourcesContent":["import inputmask from 'inputmask';\nimport Inputmask from 'inputmask';\nimport getMaskOptions from './get-mask-options';\nimport isServer from './is-server';\nimport interopDefaultSync from './module-interop';\n\nexport type { UseFormRegister, UseFormRegisterReturn } from 'react-hook-form';\n\nexport type Mask =\n | 'datetime'\n | 'email'\n | 'numeric'\n | 'currency'\n | 'decimal'\n | 'integer'\n | 'percentage'\n | 'url'\n | 'ip'\n | 'mac'\n | 'ssn'\n | 'brl-currency'\n | 'cpf'\n | 'cnpj'\n | (string & {})\n | (string[] & {})\n | null;\nexport type Options = Inputmask.Options;\nexport type Input = HTMLInputElement | HTMLTextAreaElement | HTMLElement;\n\nexport default function withMask(mask: Mask, options?: Options) {\n return (input: Input | null): void => {\n if (isServer || mask === null || !input) return;\n\n const maskInput = interopDefaultSync(inputmask)(\n getMaskOptions(mask, options)\n );\n\n maskInput.mask(input);\n };\n}\n"],"mappings":";;;;;;AA6BA,SAAwB,SAAS,MAAY,SAAmB;AAC9D,SAAQ,UAA8B;AACpC,MAAI,YAAY,SAAS,QAAQ,CAAC,MAAO;AAMzC,EAJkB,mBAAmB,UAAU,CAC7C,eAAe,MAAM,QAAQ,CAGtB,CAAC,KAAK,MAAM"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Options as Options$1 } from "../src/hooks/with-mask.js";
|
|
2
2
|
import { FieldPath, FieldPathValue, FieldValues, UseControllerProps } from "react-hook-form";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
4
|
import { Options } from "nuqs";
|
|
5
5
|
|
|
6
6
|
//#region src/components/text-field/TextField.d.ts
|
|
@@ -57,7 +57,7 @@ declare function InputText({
|
|
|
57
57
|
name,
|
|
58
58
|
onChange,
|
|
59
59
|
...props
|
|
60
|
-
}: InputTextProps):
|
|
60
|
+
}: InputTextProps): _$react_jsx_runtime0.JSX.Element;
|
|
61
61
|
interface TextFieldProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends UseControllerProps<TFieldValues, TFieldName> {
|
|
62
62
|
disabled?: boolean;
|
|
63
63
|
required?: boolean;
|
|
@@ -75,7 +75,7 @@ declare function TextField<TFieldValues extends FieldValues = FieldValues, TFiel
|
|
|
75
75
|
transform,
|
|
76
76
|
prefix,
|
|
77
77
|
...props
|
|
78
|
-
}: TextFieldProps<TFieldValues, TFieldName> & Omit<InputTextProps, 'onChange'>):
|
|
78
|
+
}: TextFieldProps<TFieldValues, TFieldName> & Omit<InputTextProps, 'onChange'>): _$react_jsx_runtime0.JSX.Element;
|
|
79
79
|
interface QueryTextFieldProps extends Omit<InputTextProps, 'onChange'> {
|
|
80
80
|
name: string;
|
|
81
81
|
defaultValue?: string;
|
|
@@ -87,7 +87,7 @@ declare function QueryTextField({
|
|
|
87
87
|
defaultValue,
|
|
88
88
|
options,
|
|
89
89
|
...props
|
|
90
|
-
}: QueryTextFieldProps):
|
|
90
|
+
}: QueryTextFieldProps): _$react_jsx_runtime0.JSX.Element;
|
|
91
91
|
interface CookieTextFieldProps extends InputTextProps {
|
|
92
92
|
name: string;
|
|
93
93
|
maxAge?: number;
|
|
@@ -97,7 +97,7 @@ declare function CookieTextField({
|
|
|
97
97
|
maxAge,
|
|
98
98
|
onChange,
|
|
99
99
|
...inputProps
|
|
100
|
-
}: CookieTextFieldProps):
|
|
100
|
+
}: CookieTextFieldProps): _$react_jsx_runtime0.JSX.Element;
|
|
101
101
|
//#endregion
|
|
102
102
|
export { CookieTextField, CookieTextFieldProps, InputText, InputTextProps, QueryTextField, QueryTextFieldProps, TextField, TextFieldProps };
|
|
103
103
|
//# sourceMappingURL=TextField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.d.ts","names":[],"sources":["../../src/components/text-field/TextField.tsx"],"
|
|
1
|
+
{"version":3,"file":"TextField.d.ts","names":[],"sources":["../../src/components/text-field/TextField.tsx"],"mappings":";;;;;;KAwBK,IAAA;AAAA,UAmBY,cAAA,SACP,KAAA,CAAM,mBAAA,CAAoB,gBAAA;EAClC,GAAA,GAAM,KAAA,CAAM,YAAA,CAAa,gBAAA;EACzB,KAAA;EACA,WAAA;EACA,WAAA;EACA,SAAA;EACA,QAAA;EACA,SAAA;EACA,IAAA;EACA,QAAA;EACA,OAAA,GAAU,KAAA,CAAM,YAAA;EAChB,QAAA,GAAW,KAAA,CAAM,SAAA;EACjB,IAAA,GAAO,IAAA;EACP,WAAA,GAAc,SAAA;EACd,KAAA,GAAQ,KAAA,CAAM,SAAA;EACd,EAAA;EACA,MAAA;EACA,eAAA;EACA,cAAA;EACA,IAAA;EACA,QAAA,IAAY,KAAA;EACZ,WAAA,GAAc,IAAA,CAAK,mBAAA;IAAwB,MAAA;IAAiB,MAAA;EAAA;AAAA;AAAA,iBAErD,SAAA,CAAA;EACP,KAAA;EACA,WAAA;EACA,WAAA;EACA,SAAA;EACA,QAAA;EACA,QAAA;EACA,IAAA;EACA,QAAA;EACA,OAAA;EACA,IAAA;EACA,SAAA;EACA,WAAA;EACA,KAAA;EACA,QAAA;EACA,EAAA;EACA,GAAA;EACA,MAAA;EACA,eAAA;EACA,cAAA;EACA,IAAA;EACA,KAAA;EACA,WAAA;EACA,IAAA;EACA,QA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import { Label } from "../ui/label.js";
|
|
6
|
-
import
|
|
5
|
+
import useMoneyInput from "../src/hooks/use-money-input.js";
|
|
7
6
|
import withMask from "../src/hooks/with-mask.js";
|
|
8
7
|
import { FormItem } from "../ui/form.js";
|
|
9
8
|
import { Input } from "../ui/input.js";
|
|
@@ -15,11 +14,11 @@ import { useCookiesNext } from "cookies-next";
|
|
|
15
14
|
import { parseAsString, useQueryState } from "nuqs";
|
|
16
15
|
|
|
17
16
|
//#region src/components/text-field/TextField.tsx
|
|
18
|
-
function InputText({ label, description, placeholder, className, children, disabled, type, required, maskRef, mask, inputType = "default", maskOptions, error, setError, id, ref, detail, detailClassName, inputClassName, help, value, moneyConfig, name, onChange
|
|
19
|
-
const { displayValue, handleChange } =
|
|
17
|
+
function InputText({ label, description, placeholder, className, children, disabled, type, required, maskRef, mask, inputType = "default", maskOptions, error, setError, id, ref, detail, detailClassName, inputClassName, help, value, moneyConfig, name, onChange, ...props }) {
|
|
18
|
+
const { displayValue, handleChange } = useMoneyInput({
|
|
20
19
|
config: moneyConfig,
|
|
21
|
-
onChange(value
|
|
22
|
-
onChange?.({ target: { value
|
|
20
|
+
onChange(value) {
|
|
21
|
+
onChange?.({ target: { value } });
|
|
23
22
|
},
|
|
24
23
|
value: Number(value)
|
|
25
24
|
});
|
|
@@ -103,7 +102,7 @@ function InputText({ label, description, placeholder, className, children, disab
|
|
|
103
102
|
});
|
|
104
103
|
}
|
|
105
104
|
const defaultTransform = (value) => value;
|
|
106
|
-
function TextField({ name, className, required, defaultValue, onChange, transform = defaultTransform, prefix
|
|
105
|
+
function TextField({ name, className, required, defaultValue, onChange, transform = defaultTransform, prefix, ...props }) {
|
|
107
106
|
const { control, setError, watch } = useFormContext();
|
|
108
107
|
const inputName = prefix ? `${prefix}.${name}` : name;
|
|
109
108
|
const id = useId();
|
|
@@ -135,7 +134,7 @@ function TextField({ name, className, required, defaultValue, onChange, transfor
|
|
|
135
134
|
})
|
|
136
135
|
});
|
|
137
136
|
}
|
|
138
|
-
function QueryTextField({ name, defaultValue, options
|
|
137
|
+
function QueryTextField({ name, defaultValue, options, ...props }) {
|
|
139
138
|
const id = useId();
|
|
140
139
|
const [error, setError] = useState(void 0);
|
|
141
140
|
const [filter, setFilter] = useQueryState(name, parseAsString.withOptions({
|
|
@@ -160,7 +159,7 @@ function QueryTextField({ name, defaultValue, options,...props }) {
|
|
|
160
159
|
setError
|
|
161
160
|
});
|
|
162
161
|
}
|
|
163
|
-
function CookieTextField({ name, maxAge = 3600 * 24 * 7, onChange
|
|
162
|
+
function CookieTextField({ name, maxAge = 3600 * 24 * 7, onChange, ...inputProps }) {
|
|
164
163
|
const { getCookie, setCookie, deleteCookie } = useCookiesNext();
|
|
165
164
|
const [error, setError] = useState(void 0);
|
|
166
165
|
const [value, setValue] = useState("");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.js","names":["useMoneyInput","value"],"sources":["../../src/components/text-field/TextField.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect, useId, useState } from 'react';\n\nimport {\n type FieldPath,\n type FieldPathValue,\n type FieldValues,\n type UseControllerProps,\n useController,\n useFormContext,\n} from 'react-hook-form';\nimport useMoneyInput from '@/hooks/use-money-input';\nimport withMask, { type Options as MaskOptions } from '@/hooks/with-mask';\n\nimport { FormItem } from '@/components/ui/form';\nimport { Input } from '@/components/ui/input';\nimport { InputHelp } from '@/components/ui/input-help';\nimport { Label } from '@/components/ui/label';\n\nimport { cn } from '@/lib/utils';\nimport { useCookiesNext } from 'cookies-next';\nimport { type Options, parseAsString, useQueryState } from 'nuqs';\n\ntype Mask =\n | 'datetime'\n | 'email'\n | 'numeric'\n | 'currency'\n | 'decimal'\n | 'integer'\n | 'percentage'\n | 'url'\n | 'ip'\n | 'mac'\n | 'ssn'\n | 'brl-currency'\n | 'cpf'\n | 'cnpj'\n | (string & {})\n | (string[] & {})\n | null;\n\nexport interface InputTextProps\n extends React.InputHTMLAttributes<HTMLInputElement> {\n ref?: React.ForwardedRef<HTMLInputElement>;\n label?: string;\n placeholder?: string;\n description?: string;\n className?: string;\n disabled?: boolean;\n inputType?: 'default' | 'money';\n type?: string;\n required?: boolean;\n maskRef?: React.ForwardedRef<any>;\n children?: React.ReactNode;\n mask?: Mask;\n maskOptions?: MaskOptions;\n error?: React.ReactNode;\n id?: string;\n detail?: string;\n detailClassName?: string;\n inputClassName?: string;\n help?: string;\n setError?: (error: string | undefined) => void;\n moneyConfig?: Intl.NumberFormatOptions & { prefix?: string; suffix?: string };\n}\nfunction InputText({\n label,\n description,\n placeholder,\n className,\n children,\n disabled,\n type,\n required,\n maskRef,\n mask,\n inputType = 'default',\n maskOptions,\n error,\n setError,\n id,\n ref,\n detail,\n detailClassName,\n inputClassName,\n help,\n value,\n moneyConfig,\n name,\n onChange,\n ...props\n}: InputTextProps) {\n const { displayValue, handleChange } = useMoneyInput({\n config: moneyConfig,\n onChange(value) {\n onChange?.({\n ...({} as React.ChangeEvent<HTMLInputElement>),\n target: { value: value as any },\n } as React.ChangeEvent<HTMLInputElement>);\n },\n value: Number(value),\n });\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (inputType === 'money') {\n const rawNumber = Number(e.target.value.replace(/\\D/g, '')) / 100;\n\n if (props.max && rawNumber >= Number(props.max)) {\n setError?.(`O valor deve ser menor que ${props.max}`);\n return;\n }\n\n if (props.min && rawNumber <= Number(props.min)) {\n setError?.(`O valor deve ser maior que ${props.min}`);\n return;\n }\n\n setError?.(undefined);\n\n handleChange?.(e);\n } else {\n onChange?.(e);\n }\n };\n\n return (\n <div\n className={cn('w-full flex flex-col gap-1', className)}\n id={`input-${name?.replace('.', '-')}`}\n ref={ref}\n >\n {(label || detail || help) && (\n <div className=\"flex items-end gap-1.5\">\n <div className={cn('flex !gap-0 flex-col', className)}>\n {label && (\n <Label\n className={cn(\n error && 'text-destructive',\n className,\n disabled && 'text-muted-foreground',\n 'inline-flex items-center flex-row gap-0.5 leading-none'\n )}\n htmlFor={id}\n >\n {label}:\n {required && (\n <span className=\"text-red-500 text-lg leading-[1px]\">*</span>\n )}\n </Label>\n )}\n {detail && (\n <Label\n className={cn(\n 'text-sm text-muted-foreground font-normal leading-none',\n detailClassName\n )}\n htmlFor={id}\n >\n {detail}\n </Label>\n )}\n </div>\n\n <InputHelp help={help} name={name} />\n </div>\n )}\n <div className=\"flex flex-col gap-1\">\n <div className=\"relative\">\n <Input\n className={cn(error && 'border-destructive', inputClassName)}\n disabled={disabled}\n id={id}\n onInput={handleInputChange as any}\n placeholder={placeholder}\n ref={\n maskRef ||\n ((mask\n ? withMask(mask, {\n autoUnmask: true,\n ...maskOptions,\n showMaskOnHover: false,\n showMaskOnFocus: false,\n clearMaskOnLostFocus: true,\n })\n : undefined) as any)\n }\n type={type}\n value={value && inputType === 'money' ? displayValue : value}\n {...props}\n />\n {children}\n </div>\n {description && (\n <p className={cn('text-sm text-muted-foreground', className)}>\n {description}\n </p>\n )}\n {error && (\n <p className=\"text-destructive text-xs\" data-slot=\"form-message\">\n {error}\n </p>\n )}\n </div>\n </div>\n );\n}\n\nexport interface TextFieldProps<\n TFieldValues extends FieldValues = FieldValues,\n TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> extends UseControllerProps<TFieldValues, TFieldName> {\n disabled?: boolean;\n required?: boolean;\n children?: React.ReactNode;\n defaultValue?: FieldPathValue<TFieldValues, TFieldName>;\n onChange?: (value: string) => Promise<void> | void;\n transform?: (value: string) => string;\n}\n\nconst defaultTransform = (value: string) => value;\n\nfunction TextField<\n TFieldValues extends FieldValues = FieldValues,\n TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n name,\n className,\n required,\n defaultValue,\n onChange,\n transform = defaultTransform,\n prefix,\n ...props\n}: TextFieldProps<TFieldValues, TFieldName> &\n Omit<InputTextProps, 'onChange'>) {\n const { control, setError, watch } = useFormContext();\n const inputName = prefix ? `${prefix}.${name}` : name;\n const id = useId();\n const { field, fieldState } = useController({\n control,\n name: inputName,\n rules: { required: required ? 'Campo obrigatório' : false },\n defaultValue,\n });\n\n const watchedValue = watch(inputName);\n\n return (\n <FormItem className={cn('w-full', className)}>\n <InputText\n {...field}\n {...props}\n disabled={props.disabled}\n error={fieldState?.error?.message}\n id={`${id}-${inputName.replaceAll('.', '-')}`}\n name={inputName}\n onChange={(e) => {\n field.onChange(transform(e.target.value));\n onChange?.(transform(e.target.value));\n }}\n required={required}\n setError={(error) => {\n setError(inputName, { message: error || '' });\n }}\n value={watchedValue ?? field.value ?? ''}\n />\n </FormItem>\n );\n}\n\nexport interface QueryTextFieldProps extends Omit<InputTextProps, 'onChange'> {\n name: string;\n defaultValue?: string;\n options?: Options;\n onChange?: (value: string) => void;\n}\n\nfunction QueryTextField({\n name,\n defaultValue,\n options,\n ...props\n}: QueryTextFieldProps) {\n const id = useId();\n const [error, setError] = useState<string | undefined>(undefined);\n const [filter, setFilter] = useQueryState(\n name,\n parseAsString\n .withOptions({\n clearOnDefault: true,\n shallow: false,\n limitUrlUpdates: {\n method: 'debounce',\n timeMs: 400,\n },\n ...options,\n })\n .withDefault(defaultValue ?? '')\n );\n\n return (\n <InputText\n id={`${id}-${name}`}\n name={name}\n value={filter}\n {...props}\n error={error}\n onChange={(e) => {\n setFilter(e.target.value);\n props.onChange?.(e.target.value);\n }}\n setError={setError}\n />\n );\n}\n\nexport interface CookieTextFieldProps extends InputTextProps {\n name: string;\n maxAge?: number;\n}\n\nfunction CookieTextField({\n name,\n maxAge = 60 * 60 * 24 * 7,\n onChange,\n ...inputProps\n}: CookieTextFieldProps) {\n const { getCookie, setCookie, deleteCookie } = useCookiesNext();\n const [error, setError] = useState<string | undefined>(undefined);\n const [value, setValue] = useState('');\n\n useEffect(() => {\n const stored = getCookie(`input-${name}`);\n if (stored && typeof stored === 'string') {\n setValue(stored);\n onChange?.(stored as any);\n }\n }, [name, getCookie]);\n\n useEffect(() => {\n if (value !== '' && value !== undefined) {\n setCookie(`input-${name}`, value, { maxAge });\n } else {\n deleteCookie(`input-${name}`);\n }\n }, [name, value, setCookie]);\n\n return (\n <InputText\n {...inputProps}\n error={error}\n id={`cookie-${name}`}\n name={name}\n onChange={(e) => {\n setValue(e.target.value);\n onChange?.(e.target.value as any);\n }}\n setError={setError}\n value={value}\n />\n );\n}\n\nexport { InputText, TextField, QueryTextField, CookieTextField };\n"],"mappings":";;;;;;;;;;;;;;;;;AAmEA,SAAS,UAAU,EACjB,OACA,aACA,aACA,WACA,UACA,UACA,MACA,UACA,SACA,MACA,YAAY,WACZ,aACA,OACA,UACA,IACA,KACA,QACA,iBACA,gBACA,MACA,OACA,aACA,MACA,SACA,GAAG,SACc;CACjB,MAAM,EAAE,cAAc,iBAAiBA,wBAAc;EACnD,QAAQ;EACR,SAAS,SAAO;AACd,cAAW,EAET,QAAQ,EAAE,OAAOC,SAAc,EAChC,CAAwC;;EAE3C,OAAO,OAAO,MAAM;EACrB,CAAC;CAEF,MAAM,qBAAqB,MAA2C;AACpE,MAAI,cAAc,SAAS;GACzB,MAAM,YAAY,OAAO,EAAE,OAAO,MAAM,QAAQ,OAAO,GAAG,CAAC,GAAG;AAE9D,OAAI,MAAM,OAAO,aAAa,OAAO,MAAM,IAAI,EAAE;AAC/C,eAAW,8BAA8B,MAAM,MAAM;AACrD;;AAGF,OAAI,MAAM,OAAO,aAAa,OAAO,MAAM,IAAI,EAAE;AAC/C,eAAW,8BAA8B,MAAM,MAAM;AACrD;;AAGF,cAAW,OAAU;AAErB,kBAAe,EAAE;QAEjB,YAAW,EAAE;;AAIjB,QACE,qBAAC;EACC,WAAW,GAAG,8BAA8B,UAAU;EACtD,IAAI,SAAS,MAAM,QAAQ,KAAK,IAAI;EAC/B;cAEH,SAAS,UAAU,SACnB,qBAAC;GAAI,WAAU;cACb,qBAAC;IAAI,WAAW,GAAG,wBAAwB,UAAU;eAClD,SACC,qBAAC;KACC,WAAW,GACT,SAAS,oBACT,WACA,YAAY,yBACZ,yDACD;KACD,SAAS;;MAER;MAAM;MACN,YAC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O,MAAM;AACxB,cAAW,EAAE,OAAO,MAAa;;EAEzB;EACH;GACP"}
|
|
1
|
+
{"version":3,"file":"TextField.js","names":[],"sources":["../../src/components/text-field/TextField.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect, useId, useState } from 'react';\n\nimport {\n type FieldPath,\n type FieldPathValue,\n type FieldValues,\n type UseControllerProps,\n useController,\n useFormContext,\n} from 'react-hook-form';\nimport useMoneyInput from '@/hooks/use-money-input';\nimport withMask, { type Options as MaskOptions } from '@/hooks/with-mask';\n\nimport { FormItem } from '@/components/ui/form';\nimport { Input } from '@/components/ui/input';\nimport { InputHelp } from '@/components/ui/input-help';\nimport { Label } from '@/components/ui/label';\n\nimport { cn } from '@/lib/utils';\nimport { useCookiesNext } from 'cookies-next';\nimport { type Options, parseAsString, useQueryState } from 'nuqs';\n\ntype Mask =\n | 'datetime'\n | 'email'\n | 'numeric'\n | 'currency'\n | 'decimal'\n | 'integer'\n | 'percentage'\n | 'url'\n | 'ip'\n | 'mac'\n | 'ssn'\n | 'brl-currency'\n | 'cpf'\n | 'cnpj'\n | (string & {})\n | (string[] & {})\n | null;\n\nexport interface InputTextProps\n extends React.InputHTMLAttributes<HTMLInputElement> {\n ref?: React.ForwardedRef<HTMLInputElement>;\n label?: string;\n placeholder?: string;\n description?: string;\n className?: string;\n disabled?: boolean;\n inputType?: 'default' | 'money';\n type?: string;\n required?: boolean;\n maskRef?: React.ForwardedRef<any>;\n children?: React.ReactNode;\n mask?: Mask;\n maskOptions?: MaskOptions;\n error?: React.ReactNode;\n id?: string;\n detail?: string;\n detailClassName?: string;\n inputClassName?: string;\n help?: string;\n setError?: (error: string | undefined) => void;\n moneyConfig?: Intl.NumberFormatOptions & { prefix?: string; suffix?: string };\n}\nfunction InputText({\n label,\n description,\n placeholder,\n className,\n children,\n disabled,\n type,\n required,\n maskRef,\n mask,\n inputType = 'default',\n maskOptions,\n error,\n setError,\n id,\n ref,\n detail,\n detailClassName,\n inputClassName,\n help,\n value,\n moneyConfig,\n name,\n onChange,\n ...props\n}: InputTextProps) {\n const { displayValue, handleChange } = useMoneyInput({\n config: moneyConfig,\n onChange(value) {\n onChange?.({\n ...({} as React.ChangeEvent<HTMLInputElement>),\n target: { value: value as any },\n } as React.ChangeEvent<HTMLInputElement>);\n },\n value: Number(value),\n });\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (inputType === 'money') {\n const rawNumber = Number(e.target.value.replace(/\\D/g, '')) / 100;\n\n if (props.max && rawNumber >= Number(props.max)) {\n setError?.(`O valor deve ser menor que ${props.max}`);\n return;\n }\n\n if (props.min && rawNumber <= Number(props.min)) {\n setError?.(`O valor deve ser maior que ${props.min}`);\n return;\n }\n\n setError?.(undefined);\n\n handleChange?.(e);\n } else {\n onChange?.(e);\n }\n };\n\n return (\n <div\n className={cn('w-full flex flex-col gap-1', className)}\n id={`input-${name?.replace('.', '-')}`}\n ref={ref}\n >\n {(label || detail || help) && (\n <div className=\"flex items-end gap-1.5\">\n <div className={cn('flex !gap-0 flex-col', className)}>\n {label && (\n <Label\n className={cn(\n error && 'text-destructive',\n className,\n disabled && 'text-muted-foreground',\n 'inline-flex items-center flex-row gap-0.5 leading-none'\n )}\n htmlFor={id}\n >\n {label}:\n {required && (\n <span className=\"text-red-500 text-lg leading-[1px]\">*</span>\n )}\n </Label>\n )}\n {detail && (\n <Label\n className={cn(\n 'text-sm text-muted-foreground font-normal leading-none',\n detailClassName\n )}\n htmlFor={id}\n >\n {detail}\n </Label>\n )}\n </div>\n\n <InputHelp help={help} name={name} />\n </div>\n )}\n <div className=\"flex flex-col gap-1\">\n <div className=\"relative\">\n <Input\n className={cn(error && 'border-destructive', inputClassName)}\n disabled={disabled}\n id={id}\n onInput={handleInputChange as any}\n placeholder={placeholder}\n ref={\n maskRef ||\n ((mask\n ? withMask(mask, {\n autoUnmask: true,\n ...maskOptions,\n showMaskOnHover: false,\n showMaskOnFocus: false,\n clearMaskOnLostFocus: true,\n })\n : undefined) as any)\n }\n type={type}\n value={value && inputType === 'money' ? displayValue : value}\n {...props}\n />\n {children}\n </div>\n {description && (\n <p className={cn('text-sm text-muted-foreground', className)}>\n {description}\n </p>\n )}\n {error && (\n <p className=\"text-destructive text-xs\" data-slot=\"form-message\">\n {error}\n </p>\n )}\n </div>\n </div>\n );\n}\n\nexport interface TextFieldProps<\n TFieldValues extends FieldValues = FieldValues,\n TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> extends UseControllerProps<TFieldValues, TFieldName> {\n disabled?: boolean;\n required?: boolean;\n children?: React.ReactNode;\n defaultValue?: FieldPathValue<TFieldValues, TFieldName>;\n onChange?: (value: string) => Promise<void> | void;\n transform?: (value: string) => string;\n}\n\nconst defaultTransform = (value: string) => value;\n\nfunction TextField<\n TFieldValues extends FieldValues = FieldValues,\n TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n name,\n className,\n required,\n defaultValue,\n onChange,\n transform = defaultTransform,\n prefix,\n ...props\n}: TextFieldProps<TFieldValues, TFieldName> &\n Omit<InputTextProps, 'onChange'>) {\n const { control, setError, watch } = useFormContext();\n const inputName = prefix ? `${prefix}.${name}` : name;\n const id = useId();\n const { field, fieldState } = useController({\n control,\n name: inputName,\n rules: { required: required ? 'Campo obrigatório' : false },\n defaultValue,\n });\n\n const watchedValue = watch(inputName);\n\n return (\n <FormItem className={cn('w-full', className)}>\n <InputText\n {...field}\n {...props}\n disabled={props.disabled}\n error={fieldState?.error?.message}\n id={`${id}-${inputName.replaceAll('.', '-')}`}\n name={inputName}\n onChange={(e) => {\n field.onChange(transform(e.target.value));\n onChange?.(transform(e.target.value));\n }}\n required={required}\n setError={(error) => {\n setError(inputName, { message: error || '' });\n }}\n value={watchedValue ?? field.value ?? ''}\n />\n </FormItem>\n );\n}\n\nexport interface QueryTextFieldProps extends Omit<InputTextProps, 'onChange'> {\n name: string;\n defaultValue?: string;\n options?: Options;\n onChange?: (value: string) => void;\n}\n\nfunction QueryTextField({\n name,\n defaultValue,\n options,\n ...props\n}: QueryTextFieldProps) {\n const id = useId();\n const [error, setError] = useState<string | undefined>(undefined);\n const [filter, setFilter] = useQueryState(\n name,\n parseAsString\n .withOptions({\n clearOnDefault: true,\n shallow: false,\n limitUrlUpdates: {\n method: 'debounce',\n timeMs: 400,\n },\n ...options,\n })\n .withDefault(defaultValue ?? '')\n );\n\n return (\n <InputText\n id={`${id}-${name}`}\n name={name}\n value={filter}\n {...props}\n error={error}\n onChange={(e) => {\n setFilter(e.target.value);\n props.onChange?.(e.target.value);\n }}\n setError={setError}\n />\n );\n}\n\nexport interface CookieTextFieldProps extends InputTextProps {\n name: string;\n maxAge?: number;\n}\n\nfunction CookieTextField({\n name,\n maxAge = 60 * 60 * 24 * 7,\n onChange,\n ...inputProps\n}: CookieTextFieldProps) {\n const { getCookie, setCookie, deleteCookie } = useCookiesNext();\n const [error, setError] = useState<string | undefined>(undefined);\n const [value, setValue] = useState('');\n\n useEffect(() => {\n const stored = getCookie(`input-${name}`);\n if (stored && typeof stored === 'string') {\n setValue(stored);\n onChange?.(stored as any);\n }\n }, [name, getCookie]);\n\n useEffect(() => {\n if (value !== '' && value !== undefined) {\n setCookie(`input-${name}`, value, { maxAge });\n } else {\n deleteCookie(`input-${name}`);\n }\n }, [name, value, setCookie]);\n\n return (\n <InputText\n {...inputProps}\n error={error}\n id={`cookie-${name}`}\n name={name}\n onChange={(e) => {\n setValue(e.target.value);\n onChange?.(e.target.value as any);\n }}\n setError={setError}\n value={value}\n />\n );\n}\n\nexport { InputText, TextField, QueryTextField, CookieTextField };\n"],"mappings":";;;;;;;;;;;;;;;;AAmEA,SAAS,UAAU,EACjB,OACA,aACA,aACA,WACA,UACA,UACA,MACA,UACA,SACA,MACA,YAAY,WACZ,aACA,OACA,UACA,IACA,KACA,QACA,iBACA,gBACA,MACA,OACA,aACA,MACA,UACA,GAAG,SACc;CACjB,MAAM,EAAE,cAAc,iBAAiB,cAAc;EACnD,QAAQ;EACR,SAAS,OAAO;A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f,QAAQ;GACR,QAAQ;GACT;EACD,GAAG;EACJ,CAAC,CACD,YAAY,gBAAgB,GAAG,CACnC;AAED,QACE,oBAAC,WAAD;EACE,IAAI,GAAG,GAAG,GAAG;EACP;EACN,OAAO;EACP,GAAI;EACG;EACP,WAAW,MAAM;AACf,aAAU,EAAE,OAAO,MAAM;AACzB,SAAM,WAAW,EAAE,OAAO,MAAM;;EAExB;EACV;;AASN,SAAS,gBAAgB,EACvB,MACA,SAAS,OAAU,KAAK,GACxB,UACA,GAAG,cACoB;CACvB,MAAM,EAAE,WAAW,WAAW,iBAAiB,gBAAgB;CAC/D,MAAM,CAAC,OAAO,YAAY,SAA6B,OAAU;CACjE,MAAM,CAAC,OAAO,YAAY,SAAS,GAAG;AAEtC,iBAAgB;EACd,MAAM,SAAS,UAAU,SAAS,OAAO;AACzC,MAAI,UAAU,OAAO,WAAW,UAAU;AACxC,YAAS,OAAO;AAChB,cAAW,OAAc;;IAE1B,CAAC,MAAM,UAAU,CAAC;AAErB,iBAAgB;AACd,MAAI,UAAU,MAAM,UAAU,OAC5B,WAAU,SAAS,QAAQ,OAAO,EAAE,QAAQ,CAAC;MAE7C,cAAa,SAAS,OAAO;IAE9B;EAAC;EAAM;EAAO;EAAU,CAAC;AAE5B,QACE,oBAAC,WAAD;EACE,GAAI;EACG;EACP,IAAI,UAAU;EACR;EACN,WAAW,MAAM;AACf,YAAS,EAAE,OAAO,MAAM;AACxB,cAAW,EAAE,OAAO,MAAa;;EAEzB;EACH;EACP"}
|
package/dist/text-field.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToggleField.d.ts","names":[],"sources":["../../src/components/toggle-field/ToggleField.tsx"],"
|
|
1
|
+
{"version":3,"file":"ToggleField.d.ts","names":[],"sources":["../../src/components/toggle-field/ToggleField.tsx"],"mappings":";;;KAUY,YAAA;EAAiB,KAAA;EAAe,KAAA,WAAgB,KAAA,CAAM,SAAA;AAAA;AAAA,KAEtD,gBAAA,GAAmB,IAAA,CAC7B,KAAA,CAAM,cAAA,QAAsB,WAAA;EAG5B,KAAA;EACA,OAAA,EAAS,YAAA;EACT,IAAA;EACA,IAAA;EACA,YAAA,GAAe,YAAA,GAAe,YAAA;EAC9B,kBAAA;AAAA;AAAA,cAGI,WAAA,EAAa,KAAA,CAAM,EAAA,CAAG,gBAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
import { Label } from "../ui/label.js";
|
|
5
4
|
import { ToggleGroup, ToggleGroupItem } from "./ToggleGroup.js";
|
|
6
5
|
import { useController, useFormContext } from "react-hook-form";
|
|
@@ -8,7 +7,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
8
7
|
import { Check } from "lucide-react";
|
|
9
8
|
|
|
10
9
|
//#region src/components/toggle-field/ToggleField.tsx
|
|
11
|
-
const ToggleField = ({ label, options, type = "single", variant = "outline", name, defaultValue, defaultFirstOption = false
|
|
10
|
+
const ToggleField = ({ label, options, type = "single", variant = "outline", name, defaultValue, defaultFirstOption = false, ...props }) => {
|
|
12
11
|
const resolvedDefault = defaultValue ?? (defaultFirstOption && options.length > 0 ? type === "multiple" ? [options[0]] : options[0] : void 0);
|
|
13
12
|
const { control } = useFormContext();
|
|
14
13
|
const { field } = useController({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToggleField.js","names":[
|
|
1
|
+
{"version":3,"file":"ToggleField.js","names":[],"sources":["../../src/components/toggle-field/ToggleField.tsx"],"sourcesContent":["'use client';\n\nimport { useController, useFormContext } from 'react-hook-form';\n\nimport { Label } from '@/components/ui/label';\n\nimport { Check } from 'lucide-react';\n\nimport { ToggleGroup, ToggleGroupItem } from './ToggleGroup';\n\nexport type ToggleOption = { value: string; label: string | React.ReactNode };\n\nexport type ToggleFieldProps = Omit<\n React.ComponentProps<typeof ToggleGroup>,\n 'type'\n> & {\n label?: string;\n options: ToggleOption[];\n type?: 'single' | 'multiple';\n name: string;\n defaultValue?: ToggleOption | ToggleOption[];\n defaultFirstOption?: boolean;\n};\n\nconst ToggleField: React.FC<ToggleFieldProps> = ({\n label,\n options,\n type = 'single',\n variant = 'outline',\n name,\n defaultValue,\n defaultFirstOption = false,\n ...props\n}) => {\n const resolvedDefault =\n defaultValue ??\n (defaultFirstOption && options.length > 0\n ? type === 'multiple'\n ? [options[0]]\n : options[0]\n : undefined);\n\n const { control } = useFormContext();\n const { field } = useController({\n control,\n name,\n defaultValue: resolvedDefault,\n });\n\n const isMultiple = type === 'multiple';\n const currentValue = field.value;\n\n const selectedOptions = isMultiple\n ? Array.isArray(currentValue)\n ? currentValue\n : []\n : [];\n const selectedOption =\n !isMultiple && currentValue && !Array.isArray(currentValue)\n ? currentValue\n : null;\n\n const toggleValue = isMultiple\n ? selectedOptions.map(({ value }: ToggleOption) => value)\n : (selectedOption?.value ?? '');\n\n const handleValueChange = (next: string | string[]) =>\n field.onChange(\n isMultiple\n ? options.filter(({ value }) => (next as string[]).includes(value))\n : (options.find(({ value }) => value === next) ?? null)\n );\n\n const isSelected = (optionValue: string) =>\n isMultiple\n ? selectedOptions.some(({ value }: ToggleOption) => value === optionValue)\n : selectedOption?.value === optionValue;\n\n return (\n <div className=\"flex flex-col gap-1\">\n {label && (\n <Label className=\"inline-flex items-center gap-0.5 leading-none\">\n {label}\n </Label>\n )}\n <ToggleGroup\n {...props}\n onValueChange={handleValueChange}\n type={type}\n value={toggleValue}\n variant={variant}\n >\n {options.map((option) => (\n <ToggleGroupItem key={`${name}-${option.value}`} value={option.value}>\n {isSelected(option.value) && <Check className=\"size-3\" />}\n {option.label}\n </ToggleGroupItem>\n ))}\n </ToggleGroup>\n </div>\n );\n};\n\nexport { ToggleField };\n"],"mappings":";;;;;;;;;AAwBA,MAAM,eAA2C,EAC/C,OACA,SACA,OAAO,UACP,UAAU,WACV,MACA,cACA,qBAAqB,OACrB,GAAG,YACC;CACJ,MAAM,kBACJ,iBACC,sBAAsB,QAAQ,SAAS,IACpC,SAAS,aACP,CAAC,QAAQ,GAAG,GACZ,QAAQ,KACV;CAEN,MAAM,EAAE,YAAY,gBAAgB;CACpC,MAAM,EAAE,UAAU,cAAc;EAC9B;EACA;EACA,cAAc;EACf,CAAC;CAEF,MAAM,aAAa,SAAS;CAC5B,MAAM,eAAe,MAAM;CAE3B,MAAM,kBAAkB,aACpB,MAAM,QAAQ,aAAa,GACzB,eACA,EAAE,GACJ,EAAE;CACN,MAAM,iBACJ,CAAC,cAAc,gBAAgB,CAAC,MAAM,QAAQ,aAAa,GACvD,eACA;CAEN,MAAM,cAAc,aAChB,gBAAgB,KAAK,EAAE,YAA0B,MAAM,GACtD,gBAAgB,SAAS;CAE9B,MAAM,qBAAqB,SACzB,MAAM,SACJ,aACI,QAAQ,QAAQ,EAAE,YAAa,KAAkB,SAAS,MAAM,CAAC,GAChE,QAAQ,MAAM,EAAE,YAAY,UAAU,KAAK,IAAI,KACrD;CAEH,MAAM,cAAc,gBAClB,aACI,gBAAgB,MAAM,EAAE,YAA0B,UAAU,YAAY,GACxE,gBAAgB,UAAU;AAEhC,QACE,qBAAC,OAAD;EAAK,WAAU;YAAf,CACG,SACC,oBAAC,OAAD;GAAO,WAAU;aACd;GACK,GAEV,oBAAC,aAAD;GACE,GAAI;GACJ,eAAe;GACT;GACN,OAAO;GACE;aAER,QAAQ,KAAK,WACZ,qBAAC,iBAAD;IAAiD,OAAO,OAAO;cAA/D,CACG,WAAW,OAAO,MAAM,IAAI,oBAAC,OAAD,EAAO,WAAU,UAAW,GACxD,OAAO,MACQ;MAHI,GAAG,KAAK,GAAG,OAAO,QAGtB,CAClB;GACU,EACV"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { Transition } from "../node_modules/motion-dom/dist/index.js";
|
|
1
2
|
import * as React from "react";
|
|
2
|
-
import * as
|
|
3
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
4
|
import { Item, Root } from "@radix-ui/react-toggle-group";
|
|
4
5
|
import { VariantProps } from "class-variance-authority";
|
|
5
|
-
import * as class_variance_authority_types0 from "class-variance-authority/types";
|
|
6
|
-
import { Transition } from "motion/react";
|
|
6
|
+
import * as _$class_variance_authority_types0 from "class-variance-authority/types";
|
|
7
7
|
|
|
8
8
|
//#region src/components/toggle-field/ToggleGroup.d.ts
|
|
9
9
|
declare const toggleVariants: (props?: ({
|
|
@@ -11,10 +11,10 @@ declare const toggleVariants: (props?: ({
|
|
|
11
11
|
variant?: "default" | "outline" | "primary" | null | undefined;
|
|
12
12
|
size?: "default" | "sm" | "lg" | null | undefined;
|
|
13
13
|
direction?: "horizontal" | "vertical" | null | undefined;
|
|
14
|
-
} & class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
14
|
+
} & _$class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
15
15
|
declare const toggleGroupVariants: (props?: ({
|
|
16
16
|
direction?: "horizontal" | "vertical" | null | undefined;
|
|
17
|
-
} & class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
17
|
+
} & _$class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
18
18
|
type ToggleGroupProps = React.ComponentProps<typeof Root> & Omit<VariantProps<typeof toggleVariants>, 'type'> & VariantProps<typeof toggleGroupVariants> & {
|
|
19
19
|
transition?: Transition;
|
|
20
20
|
activeClassName?: string;
|
|
@@ -28,7 +28,7 @@ declare function ToggleGroup({
|
|
|
28
28
|
transition,
|
|
29
29
|
activeClassName,
|
|
30
30
|
...props
|
|
31
|
-
}: ToggleGroupProps):
|
|
31
|
+
}: ToggleGroupProps): _$react_jsx_runtime0.JSX.Element;
|
|
32
32
|
//#endregion
|
|
33
33
|
export { ToggleGroup };
|
|
34
34
|
//# sourceMappingURL=ToggleGroup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToggleGroup.d.ts","names":[],"sources":["../../src/components/toggle-field/ToggleGroup.tsx"],"
|
|
1
|
+
{"version":3,"file":"ToggleGroup.d.ts","names":[],"sources":["../../src/components/toggle-field/ToggleGroup.tsx"],"mappings":";;;;;;;;cAiBa,cAAA,GAAc,KAAA;;;;;IA8B1B,iCAAA,CAAA,SAAA;AAAA,cAEK,mBAAA,GAAmB,KAAA;;IAOvB,iCAAA,CAAA,SAAA;AAAA,KAqBG,gBAAA,GAAmB,KAAA,CAAM,cAAA,QAAsB,IAAA,IAClD,IAAA,CAAK,YAAA,QAAoB,cAAA,aACzB,YAAA,QAAoB,mBAAA;EAClB,UAAA,GAAa,UAAA;EACb,eAAA;AAAA;AAAA,iBAGK,WAAA,CAAA;EACP,SAAA;EACA,OAAA;EACA,SAAA;EACA,IAAA;EACA,QAAA;EACA,UAAA;EACA,eAAA;EAAA,GACG;AAAA,GACF,gBAAA,GAAgB,oBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
import { cn } from "../src/lib/utils.js";
|
|
5
4
|
import { useController, useFormContext } from "react-hook-form";
|
|
6
5
|
import * as React from "react";
|
|
@@ -52,7 +51,7 @@ function ToggleGroup({ className, variant, direction = "horizontal", size, child
|
|
|
52
51
|
bounce: 0,
|
|
53
52
|
stiffness: 200,
|
|
54
53
|
damping: 25
|
|
55
|
-
}, activeClassName
|
|
54
|
+
}, activeClassName, ...props }) {
|
|
56
55
|
const globalId = React.useId();
|
|
57
56
|
return /* @__PURE__ */ jsx(ToggleGroupContext.Provider, {
|
|
58
57
|
value: {
|
|
@@ -72,7 +71,7 @@ function ToggleGroup({ className, variant, direction = "horizontal", size, child
|
|
|
72
71
|
})
|
|
73
72
|
});
|
|
74
73
|
}
|
|
75
|
-
function ToggleGroupItem({ ref, className, children, variant, size, buttonProps, spanProps
|
|
74
|
+
function ToggleGroupItem({ ref, className, children, variant, size, buttonProps, spanProps, ...props }) {
|
|
76
75
|
const { activeClassName, transition, type, variant: contextVariant, size: contextSize, globalId, direction } = useToggleGroup();
|
|
77
76
|
const itemRef = React.useRef(null);
|
|
78
77
|
React.useImperativeHandle(ref, () => itemRef.current);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToggleGroup.js","names":["ToggleGroupRoot","ToggleGroupItemPrimitive"],"sources":["../../src/components/toggle-field/ToggleGroup.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport { useController, useFormContext } from 'react-hook-form';\n\nimport { Root as CheckboxRoot } from '@radix-ui/react-checkbox';\nimport {\n Item as ToggleGroupItemPrimitive,\n Root as ToggleGroupRoot,\n} from '@radix-ui/react-toggle-group';\n\nimport { cn } from '@/lib/utils';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport type { HTMLMotionProps, Transition } from 'motion/react';\nimport * as m from 'motion/react-m';\n\nexport const toggleVariants = cva(\n \"cursor-pointer inline-flex items-center justify-center gap-1 rounded-md text-sm font-medium hover:text-muted-foreground text-accent-foreground transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50 data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none focus:outline-none aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap\",\n {\n variants: {\n type: {\n single: '',\n multiple:\n 'border border-input/20 data-[state=on]:border-input data-[state=on]:bg-accent',\n },\n variant: {\n default: 'bg-transparent',\n outline: 'border border-input/15 bg-transparent shadow-xs',\n primary:\n 'border data-[state=on]:bg-primary/5 data-[state=on]:border-primary',\n },\n size: {\n default: 'h-9 px-2 min-w-9',\n sm: 'h-8 px-1.5 min-w-8',\n lg: 'h-10 px-2.5 min-w-10',\n },\n direction: {\n horizontal: '',\n vertical: 'w-full justify-start',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'default',\n },\n }\n);\n\nconst toggleGroupVariants = cva('flex flex-wrap items-center gap-2 relative', {\n variants: {\n direction: {\n horizontal: 'flex-row',\n vertical: 'flex-col',\n },\n },\n});\n\ntype ToggleGroupContextProps = VariantProps<typeof toggleVariants> & {\n type?: 'single' | 'multiple';\n transition?: Transition;\n activeClassName?: string;\n globalId: string;\n};\n\nconst ToggleGroupContext = React.createContext<\n ToggleGroupContextProps | undefined\n>(undefined);\n\nconst useToggleGroup = (): ToggleGroupContextProps => {\n const context = React.useContext(ToggleGroupContext);\n if (!context) {\n throw new Error('useToggleGroup must be used within a ToggleGroup');\n }\n return context;\n};\n\ntype ToggleGroupProps = React.ComponentProps<typeof ToggleGroupRoot> &\n Omit<VariantProps<typeof toggleVariants>, 'type'> &\n VariantProps<typeof toggleGroupVariants> & {\n transition?: Transition;\n activeClassName?: string;\n };\n\nfunction ToggleGroup({\n className,\n variant,\n direction = 'horizontal',\n size,\n children,\n transition = { type: 'spring', bounce: 0, stiffness: 200, damping: 25 },\n activeClassName,\n ...props\n}: ToggleGroupProps) {\n const globalId = React.useId();\n\n return (\n <ToggleGroupContext.Provider\n value={{\n variant,\n size,\n type: props.type,\n transition,\n activeClassName,\n globalId,\n direction,\n }}\n >\n <ToggleGroupRoot\n className={cn(toggleGroupVariants({ direction }), className)}\n data-slot=\"toggle-group\"\n {...props}\n >\n {children}\n </ToggleGroupRoot>\n </ToggleGroupContext.Provider>\n );\n}\n\ntype ToggleGroupItemProps = React.ComponentProps<\n typeof ToggleGroupItemPrimitive\n> &\n Omit<VariantProps<typeof toggleVariants>, 'type'> & {\n children?: React.ReactNode;\n buttonProps?: HTMLMotionProps<'button'>;\n spanProps?: React.ComponentProps<'span'>;\n };\n\nfunction ToggleGroupItem({\n ref,\n className,\n children,\n variant,\n size,\n buttonProps,\n spanProps,\n ...props\n}: ToggleGroupItemProps) {\n const {\n activeClassName,\n transition,\n type,\n variant: contextVariant,\n size: contextSize,\n globalId,\n direction,\n } = useToggleGroup();\n const itemRef = React.useRef<HTMLButtonElement | null>(null);\n React.useImperativeHandle(ref, () => itemRef.current as HTMLButtonElement);\n const [isActive, setIsActive] = React.useState(false);\n\n React.useEffect(() => {\n const node = itemRef.current;\n if (!node) return;\n const observer = new MutationObserver(() => {\n setIsActive(node.getAttribute('data-state') === 'on');\n });\n observer.observe(node, {\n attributes: true,\n attributeFilter: ['data-state'],\n });\n setIsActive(node.getAttribute('data-state') === 'on');\n return () => observer.disconnect();\n }, []);\n\n return (\n <ToggleGroupItemPrimitive ref={itemRef} {...props} asChild>\n <m.button\n data-slot=\"toggle-group-item\"\n initial={{ scale: 1 }}\n whileTap={{ scale: 0.9 }}\n {...buttonProps}\n className={cn(\n 'relative',\n direction === 'vertical' && 'w-full',\n buttonProps?.className\n )}\n layout\n >\n <span\n {...spanProps}\n className={cn(\n 'relative z-[1]',\n toggleVariants({\n variant: variant || contextVariant,\n size: size || contextSize,\n type,\n direction,\n }),\n className,\n spanProps?.className\n )}\n data-state={isActive ? 'on' : 'off'}\n >\n {children}\n </span>\n\n {isActive && type === 'single' && (\n <m.span\n animate={{ opacity: isActive ? 1 : 0 }}\n className={cn(\n 'absolute inset-0 z-0 rounded-md bg-muted border border-input',\n activeClassName\n )}\n data-slot=\"active-toggle-group-item\"\n initial={{ opacity: 0 }}\n layoutId={`active-toggle-group-item-${globalId}`}\n transition={transition}\n />\n )}\n </m.button>\n </ToggleGroupItemPrimitive>\n );\n}\n\nconst ToggleGroupField: React.FC<\n ToggleGroupProps & {\n name: string;\n }\n> = ({ children, name, ...props }) => {\n const { control } = useFormContext();\n const { field } = useController({\n control,\n name,\n });\n\n return (\n <ToggleGroup onValueChange={field.onChange} value={field.value} {...props}>\n {children}\n </ToggleGroup>\n );\n};\n\nconst ToggleGroupItemField: React.FC<\n ToggleGroupItemProps & {\n name: string;\n }\n> = ({ children, name, ...props }) => {\n const { control } = useFormContext();\n const { field } = useController({\n control,\n name,\n });\n\n return (\n <CheckboxRoot checked={field.value} onCheckedChange={field.onChange}>\n <ToggleGroupItem {...props}>{children}</ToggleGroupItem>\n </CheckboxRoot>\n );\n};\n\nexport {\n ToggleGroup,\n ToggleGroupItem,\n ToggleGroupField,\n ToggleGroupItemField,\n type ToggleGroupProps,\n type ToggleGroupItemProps,\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ToggleGroup.js","names":["ToggleGroupRoot","ToggleGroupItemPrimitive"],"sources":["../../src/components/toggle-field/ToggleGroup.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport { useController, useFormContext } from 'react-hook-form';\n\nimport { Root as CheckboxRoot } from '@radix-ui/react-checkbox';\nimport {\n Item as ToggleGroupItemPrimitive,\n Root as ToggleGroupRoot,\n} from '@radix-ui/react-toggle-group';\n\nimport { cn } from '@/lib/utils';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport type { HTMLMotionProps, Transition } from 'motion/react';\nimport * as m from 'motion/react-m';\n\nexport const toggleVariants = cva(\n \"cursor-pointer inline-flex items-center justify-center gap-1 rounded-md text-sm font-medium hover:text-muted-foreground text-accent-foreground transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50 data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none focus:outline-none aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap\",\n {\n variants: {\n type: {\n single: '',\n multiple:\n 'border border-input/20 data-[state=on]:border-input data-[state=on]:bg-accent',\n },\n variant: {\n default: 'bg-transparent',\n outline: 'border border-input/15 bg-transparent shadow-xs',\n primary:\n 'border data-[state=on]:bg-primary/5 data-[state=on]:border-primary',\n },\n size: {\n default: 'h-9 px-2 min-w-9',\n sm: 'h-8 px-1.5 min-w-8',\n lg: 'h-10 px-2.5 min-w-10',\n },\n direction: {\n horizontal: '',\n vertical: 'w-full justify-start',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'default',\n },\n }\n);\n\nconst toggleGroupVariants = cva('flex flex-wrap items-center gap-2 relative', {\n variants: {\n direction: {\n horizontal: 'flex-row',\n vertical: 'flex-col',\n },\n },\n});\n\ntype ToggleGroupContextProps = VariantProps<typeof toggleVariants> & {\n type?: 'single' | 'multiple';\n transition?: Transition;\n activeClassName?: string;\n globalId: string;\n};\n\nconst ToggleGroupContext = React.createContext<\n ToggleGroupContextProps | undefined\n>(undefined);\n\nconst useToggleGroup = (): ToggleGroupContextProps => {\n const context = React.useContext(ToggleGroupContext);\n if (!context) {\n throw new Error('useToggleGroup must be used within a ToggleGroup');\n }\n return context;\n};\n\ntype ToggleGroupProps = React.ComponentProps<typeof ToggleGroupRoot> &\n Omit<VariantProps<typeof toggleVariants>, 'type'> &\n VariantProps<typeof toggleGroupVariants> & {\n transition?: Transition;\n activeClassName?: string;\n };\n\nfunction ToggleGroup({\n className,\n variant,\n direction = 'horizontal',\n size,\n children,\n transition = { type: 'spring', bounce: 0, stiffness: 200, damping: 25 },\n activeClassName,\n ...props\n}: ToggleGroupProps) {\n const globalId = React.useId();\n\n return (\n <ToggleGroupContext.Provider\n value={{\n variant,\n size,\n type: props.type,\n transition,\n activeClassName,\n globalId,\n direction,\n }}\n >\n <ToggleGroupRoot\n className={cn(toggleGroupVariants({ direction }), className)}\n data-slot=\"toggle-group\"\n {...props}\n >\n {children}\n </ToggleGroupRoot>\n </ToggleGroupContext.Provider>\n );\n}\n\ntype ToggleGroupItemProps = React.ComponentProps<\n typeof ToggleGroupItemPrimitive\n> &\n Omit<VariantProps<typeof toggleVariants>, 'type'> & {\n children?: React.ReactNode;\n buttonProps?: HTMLMotionProps<'button'>;\n spanProps?: React.ComponentProps<'span'>;\n };\n\nfunction ToggleGroupItem({\n ref,\n className,\n children,\n variant,\n size,\n buttonProps,\n spanProps,\n ...props\n}: ToggleGroupItemProps) {\n const {\n activeClassName,\n transition,\n type,\n variant: contextVariant,\n size: contextSize,\n globalId,\n direction,\n } = useToggleGroup();\n const itemRef = React.useRef<HTMLButtonElement | null>(null);\n React.useImperativeHandle(ref, () => itemRef.current as HTMLButtonElement);\n const [isActive, setIsActive] = React.useState(false);\n\n React.useEffect(() => {\n const node = itemRef.current;\n if (!node) return;\n const observer = new MutationObserver(() => {\n setIsActive(node.getAttribute('data-state') === 'on');\n });\n observer.observe(node, {\n attributes: true,\n attributeFilter: ['data-state'],\n });\n setIsActive(node.getAttribute('data-state') === 'on');\n return () => observer.disconnect();\n }, []);\n\n return (\n <ToggleGroupItemPrimitive ref={itemRef} {...props} asChild>\n <m.button\n data-slot=\"toggle-group-item\"\n initial={{ scale: 1 }}\n whileTap={{ scale: 0.9 }}\n {...buttonProps}\n className={cn(\n 'relative',\n direction === 'vertical' && 'w-full',\n buttonProps?.className\n )}\n layout\n >\n <span\n {...spanProps}\n className={cn(\n 'relative z-[1]',\n toggleVariants({\n variant: variant || contextVariant,\n size: size || contextSize,\n type,\n direction,\n }),\n className,\n spanProps?.className\n )}\n data-state={isActive ? 'on' : 'off'}\n >\n {children}\n </span>\n\n {isActive && type === 'single' && (\n <m.span\n animate={{ opacity: isActive ? 1 : 0 }}\n className={cn(\n 'absolute inset-0 z-0 rounded-md bg-muted border border-input',\n activeClassName\n )}\n data-slot=\"active-toggle-group-item\"\n initial={{ opacity: 0 }}\n layoutId={`active-toggle-group-item-${globalId}`}\n transition={transition}\n />\n )}\n </m.button>\n </ToggleGroupItemPrimitive>\n );\n}\n\nconst ToggleGroupField: React.FC<\n ToggleGroupProps & {\n name: string;\n }\n> = ({ children, name, ...props }) => {\n const { control } = useFormContext();\n const { field } = useController({\n control,\n name,\n });\n\n return (\n <ToggleGroup onValueChange={field.onChange} value={field.value} {...props}>\n {children}\n </ToggleGroup>\n );\n};\n\nconst ToggleGroupItemField: React.FC<\n ToggleGroupItemProps & {\n name: string;\n }\n> = ({ children, name, ...props }) => {\n const { control } = useFormContext();\n const { field } = useController({\n control,\n name,\n });\n\n return (\n <CheckboxRoot checked={field.value} onCheckedChange={field.onChange}>\n <ToggleGroupItem {...props}>{children}</ToggleGroupItem>\n </CheckboxRoot>\n );\n};\n\nexport {\n ToggleGroup,\n ToggleGroupItem,\n ToggleGroupField,\n ToggleGroupItemField,\n type ToggleGroupProps,\n type ToggleGroupItemProps,\n};\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAa,iBAAiB,IAC5B,ikBACA;CACE,UAAU;EACR,MAAM;GACJ,QAAQ;GACR,UACE;GACH;EACD,SAAS;GACP,SAAS;GACT,SAAS;GACT,SACE;GACH;EACD,MAAM;GACJ,SAAS;GACT,IAAI;GACJ,IAAI;GACL;EACD,WAAW;GACT,YAAY;GACZ,UAAU;GACX;EACF;CACD,iBAAiB;EACf,SAAS;EACT,MAAM;EACP;CACF,CACF;AAED,MAAM,sBAAsB,IAAI,8CAA8C,EAC5E,UAAU,EACR,WAAW;CACT,YAAY;CACZ,UAAU;CACX,EACF,EACF,CAAC;AASF,MAAM,qBAAqB,MAAM,cAE/B,OAAU;AAEZ,MAAM,uBAAgD;CACpD,MAAM,UAAU,MAAM,WAAW,mBAAmB;AACpD,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,mDAAmD;AAErE,QAAO;;AAUT,SAAS,YAAY,EACnB,WACA,SACA,YAAY,cACZ,MACA,UACA,aAAa;CAAE,MAAM;CAAU,QAAQ;CAAG,WAAW;CAAK,SAAS;CAAI,EACvE,iBACA,GAAG,SACgB;CACnB,MAAM,WAAW,MAAM,OAAO;AAE9B,QACE,oBAAC,mBAAmB,UAApB;EACE,OAAO;GACL;GACA;GACA,MAAM,MAAM;GACZ;GACA;GACA;GACA;GACD;YAED,oBAACA,MAAD;GACE,WAAW,GAAG,oBAAoB,EAAE,WAAW,CAAC,EAAE,UAAU;GAC5D,aAAU;GACV,GAAI;GAEH;GACe;EACU;;AAalC,SAAS,gBAAgB,EACvB,KACA,WACA,UACA,SACA,MACA,aACA,WACA,GAAG,SACoB;CACvB,MAAM,EACJ,iBACA,YACA,MACA,SAAS,gBACT,MAAM,aACN,UACA,cACE,gBAAgB;CACpB,MAAM,UAAU,MAAM,OAAiC,KAAK;AAC5D,OAAM,oBAAoB,WAAW,QAAQ,QAA6B;CAC1E,MAAM,CAAC,UAAU,eAAe,MAAM,SAAS,MAAM;AAErD,OAAM,gBAAgB;EACpB,MAAM,OAAO,QAAQ;AACrB,MAAI,CAAC,KAAM;EACX,MAAM,WAAW,IAAI,uBAAuB;AAC1C,eAAY,KAAK,aAAa,aAAa,KAAK,KAAK;IACrD;AACF,WAAS,QAAQ,MAAM;GACrB,YAAY;GACZ,iBAAiB,CAAC,aAAa;GAChC,CAAC;AACF,cAAY,KAAK,aAAa,aAAa,KAAK,KAAK;AACrD,eAAa,SAAS,YAAY;IACjC,EAAE,CAAC;AAEN,QACE,oBAACC,MAAD;EAA0B,KAAK;EAAS,GAAI;EAAO;YACjD,qBAAC,EAAE,QAAH;GACE,aAAU;GACV,SAAS,EAAE,OAAO,GAAG;GACrB,UAAU,EAAE,OAAO,IAAK;GACxB,GAAI;GACJ,WAAW,GACT,YACA,cAAc,cAAc,UAC5B,aAAa,UACd;GACD;aAVF,CAYE,oBAAC,QAAD;IACE,GAAI;IACJ,WAAW,GACT,kBACA,eAAe;KACb,SAAS,WAAW;KACpB,MAAM,QAAQ;KACd;KACA;KACD,CAAC,EACF,WACA,WAAW,UACZ;IACD,cAAY,WAAW,OAAO;IAE7B;IACI,GAEN,YAAY,SAAS,YACpB,oBAAC,EAAE,MAAH;IACE,SAAS,EAAE,SAAS,WAAW,IAAI,GAAG;IACtC,WAAW,GACT,gEACA,gBACD;IACD,aAAU;IACV,SAAS,EAAE,SAAS,GAAG;IACvB,UAAU,4BAA4B;IAC1B;IACZ,EAEK;;EACc"}
|
package/dist/toggle-field.js
CHANGED
package/dist/ui/badge.js
CHANGED
|
@@ -14,7 +14,7 @@ const badgeVariants = cva("inline-flex items-center rounded-full border px-2.5 p
|
|
|
14
14
|
} },
|
|
15
15
|
defaultVariants: { variant: "default" }
|
|
16
16
|
});
|
|
17
|
-
function Badge({ className, variant
|
|
17
|
+
function Badge({ className, variant, ...props }) {
|
|
18
18
|
return /* @__PURE__ */ jsx("div", {
|
|
19
19
|
className: cn(badgeVariants({ variant }), className),
|
|
20
20
|
...props
|
package/dist/ui/badge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badge.js","names":[],"sources":["../../src/components/ui/badge.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { cn } from '@/lib/utils';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nconst badgeVariants = cva(\n 'inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2',\n {\n variants: {\n variant: {\n default:\n 'border-transparent bg-primary text-primary-foreground hover:bg-primary/80',\n secondary:\n 'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80',\n destructive:\n 'border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80',\n warning: 'border-transparent bg-warning text-warning-foreground',\n outline: 'text-foreground',\n },\n },\n defaultVariants: {\n variant: 'default',\n },\n }\n);\n\nexport interface BadgeProps\n extends React.HTMLAttributes<HTMLDivElement>,\n VariantProps<typeof badgeVariants> {}\n\nfunction Badge({ className, variant, ...props }: BadgeProps) {\n return (\n <div className={cn(badgeVariants({ variant }), className)} {...props} />\n );\n}\n\nexport { Badge, badgeVariants };\n"],"mappings":";;;;;;AAKA,MAAM,gBAAgB,IACpB,4JACA;CACE,UAAU,EACR,SAAS;EACP,SACE;EACF,WACE;EACF,aACE;EACF,SAAS;EACT,SAAS;EACV,EACF;CACD,iBAAiB,EACf,SAAS,WACV;CACF,CACF;AAMD,SAAS,MAAM,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"badge.js","names":[],"sources":["../../src/components/ui/badge.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { cn } from '@/lib/utils';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nconst badgeVariants = cva(\n 'inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2',\n {\n variants: {\n variant: {\n default:\n 'border-transparent bg-primary text-primary-foreground hover:bg-primary/80',\n secondary:\n 'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80',\n destructive:\n 'border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80',\n warning: 'border-transparent bg-warning text-warning-foreground',\n outline: 'text-foreground',\n },\n },\n defaultVariants: {\n variant: 'default',\n },\n }\n);\n\nexport interface BadgeProps\n extends React.HTMLAttributes<HTMLDivElement>,\n VariantProps<typeof badgeVariants> {}\n\nfunction Badge({ className, variant, ...props }: BadgeProps) {\n return (\n <div className={cn(badgeVariants({ variant }), className)} {...props} />\n );\n}\n\nexport { Badge, badgeVariants };\n"],"mappings":";;;;;;AAKA,MAAM,gBAAgB,IACpB,4JACA;CACE,UAAU,EACR,SAAS;EACP,SACE;EACF,WACE;EACF,aACE;EACF,SAAS;EACT,SAAS;EACV,EACF;CACD,iBAAiB,EACf,SAAS,WACV;CACF,CACF;AAMD,SAAS,MAAM,EAAE,WAAW,SAAS,GAAG,SAAqB;AAC3D,QACE,oBAAC,OAAD;EAAK,WAAW,GAAG,cAAc,EAAE,SAAS,CAAC,EAAE,UAAU;EAAE,GAAI;EAAS"}
|
package/dist/ui/button.js
CHANGED
|
@@ -27,7 +27,7 @@ const buttonVariants = cva("inline-flex items-center justify-center gap-2 whites
|
|
|
27
27
|
size: "default"
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
function Button({ className, variant, size, asChild = false
|
|
30
|
+
function Button({ className, variant, size, asChild = false, ...props }) {
|
|
31
31
|
return /* @__PURE__ */ jsx(asChild ? Slot : "button", {
|
|
32
32
|
className: cn(buttonVariants({
|
|
33
33
|
variant,
|
package/dist/ui/button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","names":[],"sources":["../../src/components/ui/button.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Slot } from '@radix-ui/react-slot';\n\nimport { cn } from '@/lib/utils';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nconst buttonVariants = cva(\n \"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive\",\n {\n variants: {\n variant: {\n default: 'bg-primary text-primary-foreground hover:bg-primary/90',\n destructive:\n 'bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',\n outline:\n 'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50',\n secondary:\n 'bg-secondary text-secondary-foreground hover:bg-secondary/80',\n ghost:\n 'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',\n link: 'text-primary underline-offset-4 hover:underline',\n },\n size: {\n default: 'h-9 px-4 py-2 has-[>svg]:px-3',\n sm: 'h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5',\n lg: 'h-10 rounded-md px-6 has-[>svg]:px-4',\n icon: 'size-9',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'default',\n },\n }\n);\n\nfunction Button({\n className,\n variant,\n size,\n asChild = false,\n ...props\n}: React.ComponentProps<'button'> &\n VariantProps<typeof buttonVariants> & {\n asChild?: boolean;\n }) {\n const Comp = asChild ? Slot : 'button';\n\n return (\n <Comp\n className={cn(buttonVariants({ variant, size, className }))}\n data-slot=\"button\"\n {...(props as any)}\n />\n );\n}\n\nexport { Button, buttonVariants };\n"],"mappings":";;;;;;;AAOA,MAAM,iBAAiB,IACrB,+bACA;CACE,UAAU;EACR,SAAS;GACP,SAAS;GACT,aACE;GACF,SACE;GACF,WACE;GACF,OACE;GACF,MAAM;GACP;EACD,MAAM;GACJ,SAAS;GACT,IAAI;GACJ,IAAI;GACJ,MAAM;GACP;EACF;CACD,iBAAiB;EACf,SAAS;EACT,MAAM;EACP;CACF,CACF;AAED,SAAS,OAAO,EACd,WACA,SACA,MACA,UAAU,
|
|
1
|
+
{"version":3,"file":"button.js","names":[],"sources":["../../src/components/ui/button.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Slot } from '@radix-ui/react-slot';\n\nimport { cn } from '@/lib/utils';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nconst buttonVariants = cva(\n \"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive\",\n {\n variants: {\n variant: {\n default: 'bg-primary text-primary-foreground hover:bg-primary/90',\n destructive:\n 'bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',\n outline:\n 'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50',\n secondary:\n 'bg-secondary text-secondary-foreground hover:bg-secondary/80',\n ghost:\n 'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',\n link: 'text-primary underline-offset-4 hover:underline',\n },\n size: {\n default: 'h-9 px-4 py-2 has-[>svg]:px-3',\n sm: 'h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5',\n lg: 'h-10 rounded-md px-6 has-[>svg]:px-4',\n icon: 'size-9',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'default',\n },\n }\n);\n\nfunction Button({\n className,\n variant,\n size,\n asChild = false,\n ...props\n}: React.ComponentProps<'button'> &\n VariantProps<typeof buttonVariants> & {\n asChild?: boolean;\n }) {\n const Comp = asChild ? Slot : 'button';\n\n return (\n <Comp\n className={cn(buttonVariants({ variant, size, className }))}\n data-slot=\"button\"\n {...(props as any)}\n />\n );\n}\n\nexport { Button, buttonVariants };\n"],"mappings":";;;;;;;AAOA,MAAM,iBAAiB,IACrB,+bACA;CACE,UAAU;EACR,SAAS;GACP,SAAS;GACT,aACE;GACF,SACE;GACF,WACE;GACF,OACE;GACF,MAAM;GACP;EACD,MAAM;GACJ,SAAS;GACT,IAAI;GACJ,IAAI;GACJ,MAAM;GACP;EACF;CACD,iBAAiB;EACf,SAAS;EACT,MAAM;EACP;CACF,CACF;AAED,SAAS,OAAO,EACd,WACA,SACA,MACA,UAAU,OACV,GAAG,SAIA;AAGH,QACE,oBAHW,UAAU,OAAO,UAG5B;EACE,WAAW,GAAG,eAAe;GAAE;GAAS;GAAM;GAAW,CAAC,CAAC;EAC3D,aAAU;EACV,GAAK;EACL"}
|