@fuf-stack/pixels 0.0.5 → 0.0.6
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/components/Button/Button.cjs.map +1 -0
- package/dist/components/Button/Button.js +8 -0
- package/dist/components/Button/index.cjs.map +1 -0
- package/dist/{Button → components/Button}/index.js +2 -2
- package/dist/components/Button/index.js.map +1 -0
- package/dist/components/Button/subcomponents/LoadingSpinner.cjs.map +1 -0
- package/dist/{Button → components/Button}/subcomponents/LoadingSpinner.js +1 -1
- package/dist/components/Card/Card.cjs.map +1 -0
- package/dist/{Card → components/Card}/Card.js +1 -1
- package/dist/components/Card/index.cjs.map +1 -0
- package/dist/{Card → components/Card}/index.js +1 -1
- package/dist/components/Card/index.js.map +1 -0
- package/dist/hooks/useDebounce.cjs +43 -0
- package/dist/hooks/useDebounce.cjs.map +1 -0
- package/dist/hooks/useDebounce.d.cts +3 -0
- package/dist/hooks/useDebounce.d.ts +3 -0
- package/dist/hooks/useDebounce.js +22 -0
- package/dist/hooks/useDebounce.js.map +1 -0
- package/dist/hooks/useLocalStorage.cjs +73 -0
- package/dist/hooks/useLocalStorage.cjs.map +1 -0
- package/dist/hooks/useLocalStorage.d.cts +5 -0
- package/dist/hooks/useLocalStorage.d.ts +5 -0
- package/dist/hooks/useLocalStorage.js +52 -0
- package/dist/hooks/useLocalStorage.js.map +1 -0
- package/package.json +4 -1
- package/.eslintrc +0 -16
- package/.storybook/main.ts +0 -8
- package/.storybook/preview-head.html +0 -3
- package/.storybook/preview.tsx +0 -7
- package/CHANGELOG.md +0 -36
- package/Globals.d.ts +0 -3
- package/dist/Button/Button.cjs.map +0 -1
- package/dist/Button/Button.js +0 -8
- package/dist/Button/index.cjs.map +0 -1
- package/dist/Button/index.js.map +0 -1
- package/dist/Button/subcomponents/LoadingSpinner.cjs.map +0 -1
- package/dist/Card/Card.cjs.map +0 -1
- package/dist/Card/index.cjs.map +0 -1
- package/dist/Card/index.js.map +0 -1
- package/src/components/Button/Button.stories.tsx +0 -75
- package/src/components/Button/Button.test.tsx +0 -9
- package/src/components/Button/Button.tsx +0 -74
- package/src/components/Button/__snapshots__/Button.test.tsx.snap +0 -235
- package/src/components/Button/index.ts +0 -7
- package/src/components/Button/subcomponents/LoadingSpinner.tsx +0 -26
- package/src/components/Card/Card.stories.tsx +0 -56
- package/src/components/Card/Card.test.tsx +0 -9
- package/src/components/Card/Card.tsx +0 -120
- package/src/components/Card/__snapshots__/Card.test.tsx.snap +0 -94
- package/src/components/Card/index.ts +0 -3
- package/tailwind.config.js +0 -7
- package/tsconfig.json +0 -7
- package/tsup.config.ts +0 -15
- package/vitest.config.ts +0 -9
- /package/dist/{Button → components/Button}/Button.cjs +0 -0
- /package/dist/{Button → components/Button}/Button.d.cts +0 -0
- /package/dist/{Button → components/Button}/Button.d.ts +0 -0
- /package/dist/{Button → components/Button}/Button.js.map +0 -0
- /package/dist/{Button → components/Button}/index.cjs +0 -0
- /package/dist/{Button → components/Button}/index.d.cts +0 -0
- /package/dist/{Button → components/Button}/index.d.ts +0 -0
- /package/dist/{Button → components/Button}/subcomponents/LoadingSpinner.cjs +0 -0
- /package/dist/{Button → components/Button}/subcomponents/LoadingSpinner.d.cts +0 -0
- /package/dist/{Button → components/Button}/subcomponents/LoadingSpinner.d.ts +0 -0
- /package/dist/{Button → components/Button}/subcomponents/LoadingSpinner.js.map +0 -0
- /package/dist/{Card → components/Card}/Card.cjs +0 -0
- /package/dist/{Card → components/Card}/Card.d.cts +0 -0
- /package/dist/{Card → components/Card}/Card.d.ts +0 -0
- /package/dist/{Card → components/Card}/Card.js.map +0 -0
- /package/dist/{Card → components/Card}/index.cjs +0 -0
- /package/dist/{Card → components/Card}/index.d.cts +0 -0
- /package/dist/{Card → components/Card}/index.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Button/Button.tsx","../../../src/components/Button/subcomponents/LoadingSpinner.tsx"],"sourcesContent":["import type { ButtonProps as NextButtonProps } from '@nextui-org/button';\nimport type { ReactNode } from 'react';\n\nimport { Button as NextButton } from '@nextui-org/button';\nimport cn from 'classnames';\n\nimport LoadingSpinner from './subcomponents/LoadingSpinner';\n\nexport interface ButtonProps {\n /** sets HTML aria-label attribute */\n ariaLabel?: string;\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string | string[];\n /** next ui button color */\n color?: NextButtonProps['color'];\n /** disables function of the button. */\n disabled?: boolean;\n /** If set loading animation is shown */\n loading?: boolean;\n /** optional icon */\n icon?: ReactNode;\n /** on click event */\n onClick?: NextButtonProps['onPress'];\n /** 3 size options */\n size?: NextButtonProps['size'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** sets the button type. */\n type?: 'button' | 'submit' | 'reset' | undefined;\n /** next ui button variants */\n variant?: NextButtonProps['variant'];\n}\n\n/**\n * Button component based on [NextUI Button](https://nextui.org/docs/components/button)\n */\nconst Button = ({\n ariaLabel = undefined,\n children = undefined,\n className = undefined,\n color = 'default',\n disabled = false,\n icon = undefined,\n loading = false,\n onClick = undefined,\n size = undefined,\n testId = undefined,\n type = undefined,\n variant = 'solid',\n}: ButtonProps) => {\n return (\n <NextButton\n aria-label={ariaLabel}\n className={cn(className)}\n color={color}\n data-testid={testId}\n isDisabled={disabled}\n isIconOnly={!!(icon && !children)}\n isLoading={loading}\n onPress={onClick}\n size={size}\n spinner={<LoadingSpinner />}\n type={type}\n variant={variant}\n >\n {icon}\n {children}\n </NextButton>\n );\n};\n\nexport default Button;\n","/**\n * svg loading spinner for button\n * @see https://nextui.org/docs/components/button#loading\n * */\nexport default () => (\n <svg\n className=\"animate-spin h-5 w-5 text-current\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <circle\n className=\"opacity-25\"\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n />\n <path\n className=\"opacity-75\"\n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ACH;AAEJ;AAEA,IAAO,iBAAQ;","names":["import_jsx_runtime","NextButton","cn"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Button/index.ts","../../../src/components/Button/Button.tsx","../../../src/components/Button/subcomponents/LoadingSpinner.tsx"],"sourcesContent":["import type { ButtonProps } from './Button';\n\nimport Button from './Button';\n\nexport default Button;\n\nexport type { ButtonProps };\n","import type { ButtonProps as NextButtonProps } from '@nextui-org/button';\nimport type { ReactNode } from 'react';\n\nimport { Button as NextButton } from '@nextui-org/button';\nimport cn from 'classnames';\n\nimport LoadingSpinner from './subcomponents/LoadingSpinner';\n\nexport interface ButtonProps {\n /** sets HTML aria-label attribute */\n ariaLabel?: string;\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string | string[];\n /** next ui button color */\n color?: NextButtonProps['color'];\n /** disables function of the button. */\n disabled?: boolean;\n /** If set loading animation is shown */\n loading?: boolean;\n /** optional icon */\n icon?: ReactNode;\n /** on click event */\n onClick?: NextButtonProps['onPress'];\n /** 3 size options */\n size?: NextButtonProps['size'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** sets the button type. */\n type?: 'button' | 'submit' | 'reset' | undefined;\n /** next ui button variants */\n variant?: NextButtonProps['variant'];\n}\n\n/**\n * Button component based on [NextUI Button](https://nextui.org/docs/components/button)\n */\nconst Button = ({\n ariaLabel = undefined,\n children = undefined,\n className = undefined,\n color = 'default',\n disabled = false,\n icon = undefined,\n loading = false,\n onClick = undefined,\n size = undefined,\n testId = undefined,\n type = undefined,\n variant = 'solid',\n}: ButtonProps) => {\n return (\n <NextButton\n aria-label={ariaLabel}\n className={cn(className)}\n color={color}\n data-testid={testId}\n isDisabled={disabled}\n isIconOnly={!!(icon && !children)}\n isLoading={loading}\n onPress={onClick}\n size={size}\n spinner={<LoadingSpinner />}\n type={type}\n variant={variant}\n >\n {icon}\n {children}\n </NextButton>\n );\n};\n\nexport default Button;\n","/**\n * svg loading spinner for button\n * @see https://nextui.org/docs/components/button#loading\n * */\nexport default () => (\n <svg\n className=\"animate-spin h-5 w-5 text-current\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <circle\n className=\"opacity-25\"\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n />\n <path\n className=\"opacity-75\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n fill=\"currentColor\"\n />\n </svg>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,iBAAAA;AAAA;AAAA;;;ACGA,oBAAqC;AACrC,wBAAe;;;ACCb;AADF,IAAO,yBAAQ,MACb;AAAA,EAAC;AAAA;AAAA,IACC,WAAU;AAAA,IACV,MAAK;AAAA,IACL,SAAQ;AAAA,IACR,OAAM;AAAA,IAEN;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,IAAG;AAAA,UACH,IAAG;AAAA,UACH,GAAE;AAAA,UACF,QAAO;AAAA,UACP,aAAY;AAAA;AAAA,MACd;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,GAAE;AAAA,UACF,MAAK;AAAA;AAAA,MACP;AAAA;AAAA;AACF;;;AD6BE,IAAAC,sBAAA;AAfJ,IAAM,SAAS,CAAC;AAAA,EACd,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,OAAO;AAAA,EACP,UAAU;AAAA,EACV,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,OAAO;AAAA,EACP,UAAU;AACZ,MAAmB;AACjB,SACE;AAAA,IAAC,cAAAC;AAAA,IAAA;AAAA,MACC,cAAY;AAAA,MACZ,eAAW,kBAAAC,SAAG,SAAS;AAAA,MACvB;AAAA,MACA,eAAa;AAAA,MACb,YAAY;AAAA,MACZ,YAAY,CAAC,EAAE,QAAQ,CAAC;AAAA,MACxB,WAAW;AAAA,MACX,SAAS;AAAA,MACT;AAAA,MACA,SAAS,6CAAC,0BAAe;AAAA,MACzB;AAAA,MACA;AAAA,MAEC;AAAA;AAAA,QACA;AAAA;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,iBAAQ;;;ADrEf,IAAOC,kBAAQ;","names":["Button_default","import_jsx_runtime","NextButton","cn","Button_default"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Button/index.ts"],"sourcesContent":["import type { ButtonProps } from './Button';\n\nimport Button from './Button';\n\nexport default Button;\n\nexport type { ButtonProps };\n"],"mappings":";;;;;;AAIA,IAAOA,kBAAQ;","names":["Button_default"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Button/subcomponents/LoadingSpinner.tsx"],"sourcesContent":["/**\n * svg loading spinner for button\n * @see https://nextui.org/docs/components/button#loading\n * */\nexport default () => (\n <svg\n className=\"animate-spin h-5 w-5 text-current\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <circle\n className=\"opacity-25\"\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n />\n <path\n className=\"opacity-75\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n fill=\"currentColor\"\n />\n </svg>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKE;AADF,IAAO,yBAAQ,MACb;AAAA,EAAC;AAAA;AAAA,IACC,WAAU;AAAA,IACV,MAAK;AAAA,IACL,SAAQ;AAAA,IACR,OAAM;AAAA,IAEN;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,IAAG;AAAA,UACH,IAAG;AAAA,UACH,GAAE;AAAA,UACF,QAAO;AAAA,UACP,aAAY;AAAA;AAAA,MACd;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,GAAE;AAAA,UACF,MAAK;AAAA;AAAA,MACP;AAAA;AAAA;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Card/Card.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { VariantProps } from 'tailwind-variants';\n\nimport {\n Card as NextCard,\n CardBody as NextCardBody,\n CardFooter as NextCardFooter,\n CardHeader as NextCardHeader,\n} from '@nextui-org/card';\nimport { Divider as NextDivider } from '@nextui-org/divider';\nimport createDebug from 'debug';\nimport { tv } from 'tailwind-variants';\n\nconst debug = createDebug('component:Card');\n\n// card styling variants\nexport const cardVariants = tv({\n slots: {\n base: 'border border-slate-300',\n body: '',\n divider: 'my-0 bg-slate-300',\n footer: '',\n header: 'text-base font-semibold',\n },\n});\n\ntype CardVariantProps = VariantProps<typeof cardVariants>;\ntype CardVariantSlots = Partial<\n Record<keyof ReturnType<typeof cardVariants>, string>\n>;\n\nexport interface CardProps extends CardVariantProps {\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string | CardVariantSlots;\n /** footer content */\n footer?: ReactNode;\n /** header content */\n header?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * Card component based on [NextUI Card](https://nextui.org/docs/components/card)\n */\nconst Card = ({\n children = null,\n className = undefined,\n testId = undefined,\n header = undefined,\n footer = undefined,\n}: CardProps) => {\n debug('Card', { className, testId });\n const {\n base: baseSlot,\n body: bodySlot,\n divider: dividerSlot,\n footer: footerSlot,\n header: headerSlot,\n } = cardVariants();\n\n return (\n <NextCard\n data-testid={testId && `card_${testId}`}\n className={baseSlot({\n className: typeof className === 'object' ? className.base : className,\n })}\n fullWidth\n radius=\"sm\"\n shadow=\"none\"\n >\n {header && (\n <>\n <NextCardHeader\n data-testid={testId && `card_header_${testId}`}\n className={headerSlot({\n className: typeof className === 'object' && className.header,\n })}\n >\n {header}\n </NextCardHeader>\n <NextDivider\n className={dividerSlot({\n className: typeof className === 'object' && className.divider,\n })}\n />\n </>\n )}\n <NextCardBody\n data-testid={testId && `card_body_${testId}`}\n className={bodySlot({\n className: typeof className === 'object' && className.body,\n })}\n >\n {children}\n </NextCardBody>\n {footer && (\n <>\n <NextDivider\n className={dividerSlot({\n className: typeof className === 'object' && className.divider,\n })}\n />\n <NextCardFooter\n data-testid={testId && `card_footer_${testId}`}\n className={footerSlot({\n className: typeof className === 'object' && className.footer,\n })}\n >\n {footer}\n </NextCardFooter>\n </>\n )}\n </NextCard>\n );\n};\n\nexport default Card;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAKO;AACP,qBAAuC;AACvC,mBAAwB;AACxB,+BAAmB;AA+DX;AA7DR,IAAM,YAAQ,aAAAA,SAAY,gBAAgB;AAGnC,IAAM,mBAAe,6BAAG;AAAA,EAC7B,OAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV;AACF,CAAC;AAuBD,IAAM,OAAO,CAAC;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AACX,MAAiB;AACf,QAAM,QAAQ,EAAE,WAAW,OAAO,CAAC;AACnC,QAAM;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV,IAAI,aAAa;AAEjB,SACE;AAAA,IAA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}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Card/index.ts","../../../src/components/Card/Card.tsx"],"sourcesContent":["import Card from './Card';\n\nexport default Card;\n","import type { ReactNode } from 'react';\nimport type { VariantProps } from 'tailwind-variants';\n\nimport {\n Card as NextCard,\n CardBody as NextCardBody,\n CardFooter as NextCardFooter,\n CardHeader as NextCardHeader,\n} from '@nextui-org/card';\nimport { Divider as NextDivider } from '@nextui-org/divider';\nimport createDebug from 'debug';\nimport { tv } from 'tailwind-variants';\n\nconst debug = createDebug('component:Card');\n\n// card styling variants\nexport const cardVariants = tv({\n slots: {\n base: 'border border-slate-300',\n body: '',\n divider: 'my-0 bg-slate-300',\n footer: '',\n header: 'text-base font-semibold',\n },\n});\n\ntype CardVariantProps = VariantProps<typeof cardVariants>;\ntype CardVariantSlots = Partial<\n Record<keyof ReturnType<typeof cardVariants>, string>\n>;\n\nexport interface CardProps extends CardVariantProps {\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string | CardVariantSlots;\n /** footer content */\n footer?: ReactNode;\n /** header content */\n header?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * Card component based on [NextUI Card](https://nextui.org/docs/components/card)\n */\nconst Card = ({\n children = null,\n className = undefined,\n testId = undefined,\n header = undefined,\n footer = undefined,\n}: CardProps) => {\n debug('Card', { className, testId });\n const {\n base: baseSlot,\n body: bodySlot,\n divider: dividerSlot,\n footer: footerSlot,\n header: headerSlot,\n } = cardVariants();\n\n return (\n <NextCard\n data-testid={testId && `card_${testId}`}\n className={baseSlot({\n className: typeof className === 'object' ? className.base : className,\n })}\n fullWidth\n radius=\"sm\"\n shadow=\"none\"\n >\n {header && (\n <>\n <NextCardHeader\n data-testid={testId && `card_header_${testId}`}\n className={headerSlot({\n className: typeof className === 'object' && className.header,\n })}\n >\n {header}\n </NextCardHeader>\n <NextDivider\n className={dividerSlot({\n className: typeof className === 'object' && className.divider,\n })}\n />\n </>\n )}\n <NextCardBody\n data-testid={testId && `card_body_${testId}`}\n className={bodySlot({\n className: typeof className === 'object' && className.body,\n })}\n >\n {children}\n </NextCardBody>\n {footer && (\n <>\n <NextDivider\n className={dividerSlot({\n className: typeof className === 'object' && className.divider,\n })}\n />\n <NextCardFooter\n data-testid={testId && `card_footer_${testId}`}\n className={footerSlot({\n className: typeof className === 'object' && className.footer,\n })}\n >\n {footer}\n </NextCardFooter>\n </>\n )}\n </NextCard>\n );\n};\n\nexport default Card;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,iBAAAA;AAAA;AAAA;;;ACGA,kBAKO;AACP,qBAAuC;AACvC,mBAAwB;AACxB,+BAAmB;AA+DX;AA7DR,IAAM,YAAQ,aAAAC,SAAY,gBAAgB;AAGnC,IAAM,mBAAe,6BAAG;AAAA,EAC7B,OAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV;AACF,CAAC;AAuBD,IAAM,OAAO,CAAC;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AACX,MAAiB;AACf,QAAM,QAAQ,EAAE,WAAW,OAAO,CAAC;AACnC,QAAM;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV,IAAI,aAAa;AAEjB,SACE;AAAA,IAAC,YAAAC;AAAA,IAAA;AAAA,MACC,eAAa,UAAU,QAAQ,MAAM;AAAA,MACrC,WAAW,SAAS;AAAA,QAClB,WAAW,OAAO,cAAc,WAAW,UAAU,OAAO;AAAA,MAC9D,CAAC;AAAA,MACD,WAAS;AAAA,MACT,QAAO;AAAA,MACP,QAAO;AAAA,MAEN;AAAA,kBACC,4EACE;AAAA;AAAA,YAAC,YAAAC;AAAA,YAAA;AAAA,cACC,eAAa,UAAU,eAAe,MAAM;AAAA,cAC5C,WAAW,WAAW;AAAA,gBACpB,WAAW,OAAO,cAAc,YAAY,UAAU;AAAA,cACxD,CAAC;AAAA,cAEA;AAAA;AAAA,UACH;AAAA,UACA;AAAA,YAAC,eAAAC;AAAA,YAAA;AAAA,cACC,WAAW,YAAY;AAAA,gBACrB,WAAW,OAAO,cAAc,YAAY,UAAU;AAAA,cACxD,CAAC;AAAA;AAAA,UACH;AAAA,WACF;AAAA,QAEF;AAAA,UAAC,YAAAC;AAAA,UAAA;AAAA,YACC,eAAa,UAAU,aAAa,MAAM;AAAA,YAC1C,WAAW,SAAS;AAAA,cAClB,WAAW,OAAO,cAAc,YAAY,UAAU;AAAA,YACxD,CAAC;AAAA,YAEA;AAAA;AAAA,QACH;AAAA,QACC,UACC,4EACE;AAAA;AAAA,YAAC,eAAAD;AAAA,YAAA;AAAA,cACC,WAAW,YAAY;AAAA,gBACrB,WAAW,OAAO,cAAc,YAAY,UAAU;AAAA,cACxD,CAAC;AAAA;AAAA,UACH;AAAA,UACA;AAAA,YAAC,YAAAE;AAAA,YAAA;AAAA,cACC,eAAa,UAAU,eAAe,MAAM;AAAA,cAC5C,WAAW,WAAW;AAAA,gBACpB,WAAW,OAAO,cAAc,YAAY,UAAU;AAAA,cACxD,CAAC;AAAA,cAEA;AAAA;AAAA,UACH;AAAA,WACF;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,eAAQ;;;ADrHf,IAAOC,gBAAQ;","names":["Card_default","createDebug","NextCard","NextCardHeader","NextDivider","NextCardBody","NextCardFooter","Card_default"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Card/index.ts"],"sourcesContent":["import Card from './Card';\n\nexport default Card;\n"],"mappings":";;;;;AAEA,IAAOA,gBAAQ;","names":["Card_default"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/hooks/useDebounce.ts
|
|
21
|
+
var useDebounce_exports = {};
|
|
22
|
+
__export(useDebounce_exports, {
|
|
23
|
+
default: () => useDebounce_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(useDebounce_exports);
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var useDebounce_default = (value, delay) => {
|
|
28
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react.useState)(value);
|
|
29
|
+
(0, import_react.useEffect)(
|
|
30
|
+
() => {
|
|
31
|
+
const handler = setTimeout(() => {
|
|
32
|
+
setDebouncedValue(value);
|
|
33
|
+
}, delay);
|
|
34
|
+
return () => {
|
|
35
|
+
clearTimeout(handler);
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
[value, delay]
|
|
39
|
+
// Only re-call effect if value or delay changes
|
|
40
|
+
);
|
|
41
|
+
return debouncedValue;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=useDebounce.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useDebounce.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nexport default <Value>(value: Value, delay: number) => {\n // State and setters for debounced value\n const [debouncedValue, setDebouncedValue] = useState(value);\n useEffect(\n () => {\n // Update debounced value after delay\n const handler = setTimeout(() => {\n setDebouncedValue(value);\n }, delay);\n // Cancel the timeout if value changes (also on delay change or unmount)\n // This is how we prevent debounced value from updating if value is changed ...\n // .. within the delay period. Timeout gets cleared and restarted.\n return () => {\n clearTimeout(handler);\n };\n },\n [value, delay], // Only re-call effect if value or delay changes\n );\n return debouncedValue;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAoC;AAEpC,IAAO,sBAAQ,CAAQ,OAAc,UAAkB;AAErD,QAAM,CAAC,gBAAgB,iBAAiB,QAAI,uBAAS,KAAK;AAC1D;AAAA,IACE,MAAM;AAEJ,YAAM,UAAU,WAAW,MAAM;AAC/B,0BAAkB,KAAK;AAAA,MACzB,GAAG,KAAK;AAIR,aAAO,MAAM;AACX,qBAAa,OAAO;AAAA,MACtB;AAAA,IACF;AAAA,IACA,CAAC,OAAO,KAAK;AAAA;AAAA,EACf;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/hooks/useDebounce.ts
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
var useDebounce_default = (value, delay) => {
|
|
4
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
5
|
+
useEffect(
|
|
6
|
+
() => {
|
|
7
|
+
const handler = setTimeout(() => {
|
|
8
|
+
setDebouncedValue(value);
|
|
9
|
+
}, delay);
|
|
10
|
+
return () => {
|
|
11
|
+
clearTimeout(handler);
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
[value, delay]
|
|
15
|
+
// Only re-call effect if value or delay changes
|
|
16
|
+
);
|
|
17
|
+
return debouncedValue;
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
useDebounce_default as default
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=useDebounce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useDebounce.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nexport default <Value>(value: Value, delay: number) => {\n // State and setters for debounced value\n const [debouncedValue, setDebouncedValue] = useState(value);\n useEffect(\n () => {\n // Update debounced value after delay\n const handler = setTimeout(() => {\n setDebouncedValue(value);\n }, delay);\n // Cancel the timeout if value changes (also on delay change or unmount)\n // This is how we prevent debounced value from updating if value is changed ...\n // .. within the delay period. Timeout gets cleared and restarted.\n return () => {\n clearTimeout(handler);\n };\n },\n [value, delay], // Only re-call effect if value or delay changes\n );\n return debouncedValue;\n};\n"],"mappings":";AAAA,SAAS,WAAW,gBAAgB;AAEpC,IAAO,sBAAQ,CAAQ,OAAc,UAAkB;AAErD,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS,KAAK;AAC1D;AAAA,IACE,MAAM;AAEJ,YAAM,UAAU,WAAW,MAAM;AAC/B,0BAAkB,KAAK;AAAA,MACzB,GAAG,KAAK;AAIR,aAAO,MAAM;AACX,qBAAa,OAAO;AAAA,MACtB;AAAA,IACF;AAAA,IACA,CAAC,OAAO,KAAK;AAAA;AAAA,EACf;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/hooks/useLocalStorage.ts
|
|
21
|
+
var useLocalStorage_exports = {};
|
|
22
|
+
__export(useLocalStorage_exports, {
|
|
23
|
+
default: () => useLocalStorage_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(useLocalStorage_exports);
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var useLocalStorage = (key, initialValue) => {
|
|
28
|
+
const readValue = () => {
|
|
29
|
+
if (typeof window === "undefined") {
|
|
30
|
+
return initialValue;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const item = window.localStorage.getItem(key);
|
|
34
|
+
return item ? JSON.parse(item) : initialValue;
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.warn(`Error reading localStorage key \u201C${key}\u201D:`, error);
|
|
37
|
+
return initialValue;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const [storedValue, setStoredValue] = (0, import_react.useState)(readValue);
|
|
41
|
+
const setValue = (value) => {
|
|
42
|
+
if (typeof window === "undefined") {
|
|
43
|
+
console.warn(
|
|
44
|
+
`Tried setting localStorage key \u201C${key}\u201D even though environment is not a client`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const newValue = value instanceof Function ? value(storedValue) : value;
|
|
49
|
+
window.localStorage.setItem(key, JSON.stringify(newValue));
|
|
50
|
+
setStoredValue(newValue);
|
|
51
|
+
window.dispatchEvent(new Event("local-storage"));
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.warn(`Error setting localStorage key \u201C${key}\u201D:`, error);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
(0, import_react.useEffect)(() => {
|
|
57
|
+
setStoredValue(readValue());
|
|
58
|
+
}, []);
|
|
59
|
+
(0, import_react.useEffect)(() => {
|
|
60
|
+
const handleStorageChange = () => {
|
|
61
|
+
setStoredValue(readValue());
|
|
62
|
+
};
|
|
63
|
+
window.addEventListener("storage", handleStorageChange);
|
|
64
|
+
window.addEventListener("local-storage", handleStorageChange);
|
|
65
|
+
return () => {
|
|
66
|
+
window.removeEventListener("storage", handleStorageChange);
|
|
67
|
+
window.removeEventListener("local-storage", handleStorageChange);
|
|
68
|
+
};
|
|
69
|
+
}, []);
|
|
70
|
+
return [storedValue, setValue];
|
|
71
|
+
};
|
|
72
|
+
var useLocalStorage_default = useLocalStorage;
|
|
73
|
+
//# sourceMappingURL=useLocalStorage.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useLocalStorage.ts"],"sourcesContent":["import type { Dispatch, SetStateAction } from 'react';\n\nimport { useEffect, useState } from 'react';\n\nconst useLocalStorage = <T>(\n key: string,\n initialValue: T | (() => T),\n): [T, Dispatch<SetStateAction<T>>] => {\n // Get from local storage then\n // parse stored json or return initialValue\n const readValue = () => {\n // Prevent build error \"window is undefined\" but keep keep working\n if (typeof window === 'undefined') {\n return initialValue;\n }\n\n try {\n const item = window.localStorage.getItem(key);\n return item ? JSON.parse(item) : initialValue;\n } catch (error) {\n console.warn(`Error reading localStorage key “${key}”:`, error);\n return initialValue;\n }\n };\n\n // State to store our value\n // Pass initial state function to useState so logic is only executed once\n const [storedValue, setStoredValue] = useState<T>(readValue);\n\n // Return a wrapped version of useState's setter function that ...\n // ... persists the new value to localStorage.\n const setValue: Dispatch<SetStateAction<T>> = (value) => {\n // Prevent build error \"window is undefined\" but keeps working\n if (typeof window === 'undefined') {\n console.warn(\n `Tried setting localStorage key “${key}” even though environment is not a client`,\n );\n }\n\n try {\n // Allow value to be a function so we have the same API as useState\n const newValue = value instanceof Function ? value(storedValue) : value;\n\n // Save to local storage\n window.localStorage.setItem(key, JSON.stringify(newValue));\n\n // Save state\n setStoredValue(newValue);\n\n // We dispatch a custom event so every useLocalStorage hook are notified\n window.dispatchEvent(new Event('local-storage'));\n } catch (error) {\n console.warn(`Error setting localStorage key “${key}”:`, error);\n }\n };\n\n useEffect(() => {\n setStoredValue(readValue());\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n const handleStorageChange = () => {\n setStoredValue(readValue());\n };\n\n // this only works for other documents, not the current one\n window.addEventListener('storage', handleStorageChange);\n\n // this is a custom event, triggered in writeValueToLocalStorage\n window.addEventListener('local-storage', handleStorageChange);\n\n return () => {\n window.removeEventListener('storage', handleStorageChange);\n window.removeEventListener('local-storage', handleStorageChange);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return [storedValue, setValue];\n};\n\nexport default useLocalStorage;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAoC;AAEpC,IAAM,kBAAkB,CACtB,KACA,iBACqC;AAGrC,QAAM,YAAY,MAAM;AAEtB,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO;AAAA,IACT;AAEA,QAAI;AACF,YAAM,OAAO,OAAO,aAAa,QAAQ,GAAG;AAC5C,aAAO,OAAO,KAAK,MAAM,IAAI,IAAI;AAAA,IACnC,SAAS,OAAO;AACd,cAAQ,KAAK,wCAAmC,GAAG,WAAM,KAAK;AAC9D,aAAO;AAAA,IACT;AAAA,EACF;AAIA,QAAM,CAAC,aAAa,cAAc,QAAI,uBAAY,SAAS;AAI3D,QAAM,WAAwC,CAAC,UAAU;AAEvD,QAAI,OAAO,WAAW,aAAa;AACjC,cAAQ;AAAA,QACN,wCAAmC,GAAG;AAAA,MACxC;AAAA,IACF;AAEA,QAAI;AAEF,YAAM,WAAW,iBAAiB,WAAW,MAAM,WAAW,IAAI;AAGlE,aAAO,aAAa,QAAQ,KAAK,KAAK,UAAU,QAAQ,CAAC;AAGzD,qBAAe,QAAQ;AAGvB,aAAO,cAAc,IAAI,MAAM,eAAe,CAAC;AAAA,IACjD,SAAS,OAAO;AACd,cAAQ,KAAK,wCAAmC,GAAG,WAAM,KAAK;AAAA,IAChE;AAAA,EACF;AAEA,8BAAU,MAAM;AACd,mBAAe,UAAU,CAAC;AAAA,EAE5B,GAAG,CAAC,CAAC;AAEL,8BAAU,MAAM;AACd,UAAM,sBAAsB,MAAM;AAChC,qBAAe,UAAU,CAAC;AAAA,IAC5B;AAGA,WAAO,iBAAiB,WAAW,mBAAmB;AAGtD,WAAO,iBAAiB,iBAAiB,mBAAmB;AAE5D,WAAO,MAAM;AACX,aAAO,oBAAoB,WAAW,mBAAmB;AACzD,aAAO,oBAAoB,iBAAiB,mBAAmB;AAAA,IACjE;AAAA,EAEF,GAAG,CAAC,CAAC;AAEL,SAAO,CAAC,aAAa,QAAQ;AAC/B;AAEA,IAAO,0BAAQ;","names":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/hooks/useLocalStorage.ts
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
var useLocalStorage = (key, initialValue) => {
|
|
4
|
+
const readValue = () => {
|
|
5
|
+
if (typeof window === "undefined") {
|
|
6
|
+
return initialValue;
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
const item = window.localStorage.getItem(key);
|
|
10
|
+
return item ? JSON.parse(item) : initialValue;
|
|
11
|
+
} catch (error) {
|
|
12
|
+
console.warn(`Error reading localStorage key \u201C${key}\u201D:`, error);
|
|
13
|
+
return initialValue;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const [storedValue, setStoredValue] = useState(readValue);
|
|
17
|
+
const setValue = (value) => {
|
|
18
|
+
if (typeof window === "undefined") {
|
|
19
|
+
console.warn(
|
|
20
|
+
`Tried setting localStorage key \u201C${key}\u201D even though environment is not a client`
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const newValue = value instanceof Function ? value(storedValue) : value;
|
|
25
|
+
window.localStorage.setItem(key, JSON.stringify(newValue));
|
|
26
|
+
setStoredValue(newValue);
|
|
27
|
+
window.dispatchEvent(new Event("local-storage"));
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.warn(`Error setting localStorage key \u201C${key}\u201D:`, error);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
setStoredValue(readValue());
|
|
34
|
+
}, []);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const handleStorageChange = () => {
|
|
37
|
+
setStoredValue(readValue());
|
|
38
|
+
};
|
|
39
|
+
window.addEventListener("storage", handleStorageChange);
|
|
40
|
+
window.addEventListener("local-storage", handleStorageChange);
|
|
41
|
+
return () => {
|
|
42
|
+
window.removeEventListener("storage", handleStorageChange);
|
|
43
|
+
window.removeEventListener("local-storage", handleStorageChange);
|
|
44
|
+
};
|
|
45
|
+
}, []);
|
|
46
|
+
return [storedValue, setValue];
|
|
47
|
+
};
|
|
48
|
+
var useLocalStorage_default = useLocalStorage;
|
|
49
|
+
export {
|
|
50
|
+
useLocalStorage_default as default
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=useLocalStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useLocalStorage.ts"],"sourcesContent":["import type { Dispatch, SetStateAction } from 'react';\n\nimport { useEffect, useState } from 'react';\n\nconst useLocalStorage = <T>(\n key: string,\n initialValue: T | (() => T),\n): [T, Dispatch<SetStateAction<T>>] => {\n // Get from local storage then\n // parse stored json or return initialValue\n const readValue = () => {\n // Prevent build error \"window is undefined\" but keep keep working\n if (typeof window === 'undefined') {\n return initialValue;\n }\n\n try {\n const item = window.localStorage.getItem(key);\n return item ? JSON.parse(item) : initialValue;\n } catch (error) {\n console.warn(`Error reading localStorage key “${key}”:`, error);\n return initialValue;\n }\n };\n\n // State to store our value\n // Pass initial state function to useState so logic is only executed once\n const [storedValue, setStoredValue] = useState<T>(readValue);\n\n // Return a wrapped version of useState's setter function that ...\n // ... persists the new value to localStorage.\n const setValue: Dispatch<SetStateAction<T>> = (value) => {\n // Prevent build error \"window is undefined\" but keeps working\n if (typeof window === 'undefined') {\n console.warn(\n `Tried setting localStorage key “${key}” even though environment is not a client`,\n );\n }\n\n try {\n // Allow value to be a function so we have the same API as useState\n const newValue = value instanceof Function ? value(storedValue) : value;\n\n // Save to local storage\n window.localStorage.setItem(key, JSON.stringify(newValue));\n\n // Save state\n setStoredValue(newValue);\n\n // We dispatch a custom event so every useLocalStorage hook are notified\n window.dispatchEvent(new Event('local-storage'));\n } catch (error) {\n console.warn(`Error setting localStorage key “${key}”:`, error);\n }\n };\n\n useEffect(() => {\n setStoredValue(readValue());\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n const handleStorageChange = () => {\n setStoredValue(readValue());\n };\n\n // this only works for other documents, not the current one\n window.addEventListener('storage', handleStorageChange);\n\n // this is a custom event, triggered in writeValueToLocalStorage\n window.addEventListener('local-storage', handleStorageChange);\n\n return () => {\n window.removeEventListener('storage', handleStorageChange);\n window.removeEventListener('local-storage', handleStorageChange);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return [storedValue, setValue];\n};\n\nexport default useLocalStorage;\n"],"mappings":";AAEA,SAAS,WAAW,gBAAgB;AAEpC,IAAM,kBAAkB,CACtB,KACA,iBACqC;AAGrC,QAAM,YAAY,MAAM;AAEtB,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO;AAAA,IACT;AAEA,QAAI;AACF,YAAM,OAAO,OAAO,aAAa,QAAQ,GAAG;AAC5C,aAAO,OAAO,KAAK,MAAM,IAAI,IAAI;AAAA,IACnC,SAAS,OAAO;AACd,cAAQ,KAAK,wCAAmC,GAAG,WAAM,KAAK;AAC9D,aAAO;AAAA,IACT;AAAA,EACF;AAIA,QAAM,CAAC,aAAa,cAAc,IAAI,SAAY,SAAS;AAI3D,QAAM,WAAwC,CAAC,UAAU;AAEvD,QAAI,OAAO,WAAW,aAAa;AACjC,cAAQ;AAAA,QACN,wCAAmC,GAAG;AAAA,MACxC;AAAA,IACF;AAEA,QAAI;AAEF,YAAM,WAAW,iBAAiB,WAAW,MAAM,WAAW,IAAI;AAGlE,aAAO,aAAa,QAAQ,KAAK,KAAK,UAAU,QAAQ,CAAC;AAGzD,qBAAe,QAAQ;AAGvB,aAAO,cAAc,IAAI,MAAM,eAAe,CAAC;AAAA,IACjD,SAAS,OAAO;AACd,cAAQ,KAAK,wCAAmC,GAAG,WAAM,KAAK;AAAA,IAChE;AAAA,EACF;AAEA,YAAU,MAAM;AACd,mBAAe,UAAU,CAAC;AAAA,EAE5B,GAAG,CAAC,CAAC;AAEL,YAAU,MAAM;AACd,UAAM,sBAAsB,MAAM;AAChC,qBAAe,UAAU,CAAC;AAAA,IAC5B;AAGA,WAAO,iBAAiB,WAAW,mBAAmB;AAGtD,WAAO,iBAAiB,iBAAiB,mBAAmB;AAE5D,WAAO,MAAM;AACX,aAAO,oBAAoB,WAAW,mBAAmB;AACzD,aAAO,oBAAoB,iBAAiB,mBAAmB;AAAA,IACjE;AAAA,EAEF,GAAG,CAAC,CAAC;AAEL,SAAO,CAAC,aAAa,QAAQ;AAC/B;AAEA,IAAO,0BAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@fuf-stack/pixels",
|
|
3
3
|
"description": "fuf react component library",
|
|
4
4
|
"author": "Hannes Tiede",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.6",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
8
8
|
"./": "./dist/",
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
]
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
|
+
"files": [
|
|
19
|
+
"./dist"
|
|
20
|
+
],
|
|
18
21
|
"homepage": "https://github.com/fuf-stack/uniforms#readme",
|
|
19
22
|
"license": "MIT",
|
|
20
23
|
"publishConfig": {
|
package/.eslintrc
DELETED
package/.storybook/main.ts
DELETED
package/.storybook/preview.tsx
DELETED
package/CHANGELOG.md
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## [0.0.5](https://github.com/fuf-stack/uniform/compare/pixels-v0.0.4...pixels-v0.0.5) (2024-04-12)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
### Bug Fixes
|
|
7
|
-
|
|
8
|
-
* **pixels:** move components into components folder ([9da42b1](https://github.com/fuf-stack/uniform/commit/9da42b10afe5a65351c93850139531659d1f6780))
|
|
9
|
-
|
|
10
|
-
## [0.0.4](https://github.com/fuf-stack/uniform/compare/pixels-v0.0.3...pixels-v0.0.4) (2024-04-12)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
### Bug Fixes
|
|
14
|
-
|
|
15
|
-
* **pixels:** fix exports definition ([ab58ff9](https://github.com/fuf-stack/uniform/commit/ab58ff9464fe41327fce7fd03b083e57b9fbfaaf))
|
|
16
|
-
|
|
17
|
-
## [0.0.3](https://github.com/fuf-stack/uniform/compare/pixels-v0.0.2...pixels-v0.0.3) (2024-04-12)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
### Bug Fixes
|
|
21
|
-
|
|
22
|
-
* **pixels:** add exports definition ([052874c](https://github.com/fuf-stack/uniform/commit/052874c5d6709b5aa31e10f6f4a34ac40dd20c3d))
|
|
23
|
-
|
|
24
|
-
## [0.0.2](https://github.com/fuf-stack/uniform/compare/pixels-v0.0.1...pixels-v0.0.2) (2024-04-12)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
### Bug Fixes
|
|
28
|
-
|
|
29
|
-
* **pixels:** add npm publish config ([e148803](https://github.com/fuf-stack/uniform/commit/e148803d5259943dd53e059d1fa1c506556f03d9))
|
|
30
|
-
|
|
31
|
-
## 0.0.1 (2024-04-12)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
### Features
|
|
35
|
-
|
|
36
|
-
* **pixels:** add inital package ([ad580ee](https://github.com/fuf-stack/uniform/commit/ad580eec37a2fefc5a61e08ce25c8e0328ba582f))
|
package/Globals.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Button/Button.tsx","../../src/components/Button/subcomponents/LoadingSpinner.tsx"],"sourcesContent":["import type { ButtonProps as NextButtonProps } from '@nextui-org/button';\nimport type { ReactNode } from 'react';\n\nimport { Button as NextButton } from '@nextui-org/button';\nimport cn from 'classnames';\n\nimport LoadingSpinner from './subcomponents/LoadingSpinner';\n\nexport interface ButtonProps {\n /** sets HTML aria-label attribute */\n ariaLabel?: string;\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string | string[];\n /** next ui button color */\n color?: NextButtonProps['color'];\n /** disables function of the button. */\n disabled?: boolean;\n /** If set loading animation is shown */\n loading?: boolean;\n /** optional icon */\n icon?: ReactNode;\n /** on click event */\n onClick?: NextButtonProps['onPress'];\n /** 3 size options */\n size?: NextButtonProps['size'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** sets the button type. */\n type?: 'button' | 'submit' | 'reset' | undefined;\n /** next ui button variants */\n variant?: NextButtonProps['variant'];\n}\n\n/**\n * Button component based on [NextUI Button](https://nextui.org/docs/components/button)\n */\nconst Button = ({\n ariaLabel = undefined,\n children = undefined,\n className = undefined,\n color = 'default',\n disabled = false,\n icon = undefined,\n loading = false,\n onClick = undefined,\n size = undefined,\n testId = undefined,\n type = undefined,\n variant = 'solid',\n}: ButtonProps) => {\n return (\n <NextButton\n aria-label={ariaLabel}\n className={cn(className)}\n color={color}\n data-testid={testId}\n isDisabled={disabled}\n isIconOnly={!!(icon && !children)}\n isLoading={loading}\n onPress={onClick}\n size={size}\n spinner={<LoadingSpinner />}\n type={type}\n variant={variant}\n >\n {icon}\n {children}\n </NextButton>\n );\n};\n\nexport default Button;\n","/**\n * svg loading spinner for button\n * @see https://nextui.org/docs/components/button#loading\n * */\nexport default () => (\n <svg\n className=\"animate-spin h-5 w-5 text-current\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <circle\n className=\"opacity-25\"\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n />\n <path\n className=\"opacity-75\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n fill=\"currentColor\"\n />\n </svg>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAqC;AACrC,wBAAe;;;ACCb;AADF,IAAO,yBAAQ,MACb;AAAA,EAAC;AAAA;AAAA,IACC,WAAU;AAAA,IACV,MAAK;AAAA,IACL,SAAQ;AAAA,IACR,OAAM;AAAA,IAEN;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,IAAG;AAAA,UACH,IAAG;AAAA,UACH,GAAE;AAAA,UACF,QAAO;AAAA,UACP,aAAY;AAAA;AAAA,MACd;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,GAAE;AAAA,UACF,MAAK;AAAA;AAAA,MACP;AAAA;AAAA;AACF;;;AD6BE,IAAAA,sBAAA;AAfJ,IAAM,SAAS,CAAC;AAAA,EACd,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,OAAO;AAAA,EACP,UAAU;AAAA,EACV,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,OAAO;AAAA,EACP,UAAU;AACZ,MAAmB;AACjB,SACE;AAAA,IAAC,cAAAC;AAAA,IAAA;AAAA,MACC,cAAY;AAAA,MACZ,eAAW,kBAAAC,SAAG,SAAS;AAAA,MACvB;AAAA,MACA,eAAa;AAAA,MACb,YAAY;AAAA,MACZ,YAAY,CAAC,EAAE,QAAQ,CAAC;AAAA,MACxB,WAAW;AAAA,MACX,SAAS;AAAA,MACT;AAAA,MACA,SAAS,6CAAC,0BAAe;AAAA,MACzB;AAAA,MACA;AAAA,MAEC;AAAA;AAAA,QACA;AAAA;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,iBAAQ;","names":["import_jsx_runtime","NextButton","cn"]}
|
package/dist/Button/Button.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Button/index.ts","../../src/components/Button/Button.tsx","../../src/components/Button/subcomponents/LoadingSpinner.tsx"],"sourcesContent":["import type { ButtonProps } from './Button';\n\nimport Button from './Button';\n\nexport default Button;\n\nexport type { ButtonProps };\n","import type { ButtonProps as NextButtonProps } from '@nextui-org/button';\nimport type { ReactNode } from 'react';\n\nimport { Button as NextButton } from '@nextui-org/button';\nimport cn from 'classnames';\n\nimport LoadingSpinner from './subcomponents/LoadingSpinner';\n\nexport interface ButtonProps {\n /** sets HTML aria-label attribute */\n ariaLabel?: string;\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string | string[];\n /** next ui button color */\n color?: NextButtonProps['color'];\n /** disables function of the button. */\n disabled?: boolean;\n /** If set loading animation is shown */\n loading?: boolean;\n /** optional icon */\n icon?: ReactNode;\n /** on click event */\n onClick?: NextButtonProps['onPress'];\n /** 3 size options */\n size?: NextButtonProps['size'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** sets the button type. */\n type?: 'button' | 'submit' | 'reset' | undefined;\n /** next ui button variants */\n variant?: NextButtonProps['variant'];\n}\n\n/**\n * Button component based on [NextUI Button](https://nextui.org/docs/components/button)\n */\nconst Button = ({\n ariaLabel = undefined,\n children = undefined,\n className = undefined,\n color = 'default',\n disabled = false,\n icon = undefined,\n loading = false,\n onClick = undefined,\n size = undefined,\n testId = undefined,\n type = undefined,\n variant = 'solid',\n}: ButtonProps) => {\n return (\n <NextButton\n aria-label={ariaLabel}\n className={cn(className)}\n color={color}\n data-testid={testId}\n isDisabled={disabled}\n isIconOnly={!!(icon && !children)}\n isLoading={loading}\n onPress={onClick}\n size={size}\n spinner={<LoadingSpinner />}\n type={type}\n variant={variant}\n >\n {icon}\n {children}\n </NextButton>\n );\n};\n\nexport default Button;\n","/**\n * svg loading spinner for button\n * @see https://nextui.org/docs/components/button#loading\n * */\nexport default () => (\n <svg\n className=\"animate-spin h-5 w-5 text-current\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <circle\n className=\"opacity-25\"\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n />\n <path\n className=\"opacity-75\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n fill=\"currentColor\"\n />\n </svg>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,iBAAAA;AAAA;AAAA;;;ACGA,oBAAqC;AACrC,wBAAe;;;ACCb;AADF,IAAO,yBAAQ,MACb;AAAA,EAAC;AAAA;AAAA,IACC,WAAU;AAAA,IACV,MAAK;AAAA,IACL,SAAQ;AAAA,IACR,OAAM;AAAA,IAEN;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,IAAG;AAAA,UACH,IAAG;AAAA,UACH,GAAE;AAAA,UACF,QAAO;AAAA,UACP,aAAY;AAAA;AAAA,MACd;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,GAAE;AAAA,UACF,MAAK;AAAA;AAAA,MACP;AAAA;AAAA;AACF;;;AD6BE,IAAAC,sBAAA;AAfJ,IAAM,SAAS,CAAC;AAAA,EACd,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,OAAO;AAAA,EACP,UAAU;AAAA,EACV,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,OAAO;AAAA,EACP,UAAU;AACZ,MAAmB;AACjB,SACE;AAAA,IAAC,cAAAC;AAAA,IAAA;AAAA,MACC,cAAY;AAAA,MACZ,eAAW,kBAAAC,SAAG,SAAS;AAAA,MACvB;AAAA,MACA,eAAa;AAAA,MACb,YAAY;AAAA,MACZ,YAAY,CAAC,EAAE,QAAQ,CAAC;AAAA,MACxB,WAAW;AAAA,MACX,SAAS;AAAA,MACT;AAAA,MACA,SAAS,6CAAC,0BAAe;AAAA,MACzB;AAAA,MACA;AAAA,MAEC;AAAA;AAAA,QACA;AAAA;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,iBAAQ;;;ADrEf,IAAOC,kBAAQ;","names":["Button_default","import_jsx_runtime","NextButton","cn","Button_default"]}
|
package/dist/Button/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Button/index.ts"],"sourcesContent":["import type { ButtonProps } from './Button';\n\nimport Button from './Button';\n\nexport default Button;\n\nexport type { ButtonProps };\n"],"mappings":";;;;;;AAIA,IAAOA,kBAAQ;","names":["Button_default"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Button/subcomponents/LoadingSpinner.tsx"],"sourcesContent":["/**\n * svg loading spinner for button\n * @see https://nextui.org/docs/components/button#loading\n * */\nexport default () => (\n <svg\n className=\"animate-spin h-5 w-5 text-current\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <circle\n className=\"opacity-25\"\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n />\n <path\n className=\"opacity-75\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n fill=\"currentColor\"\n />\n </svg>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKE;AADF,IAAO,yBAAQ,MACb;AAAA,EAAC;AAAA;AAAA,IACC,WAAU;AAAA,IACV,MAAK;AAAA,IACL,SAAQ;AAAA,IACR,OAAM;AAAA,IAEN;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,IAAG;AAAA,UACH,IAAG;AAAA,UACH,GAAE;AAAA,UACF,QAAO;AAAA,UACP,aAAY;AAAA;AAAA,MACd;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,GAAE;AAAA,UACF,MAAK;AAAA;AAAA,MACP;AAAA;AAAA;AACF;","names":[]}
|
package/dist/Card/Card.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Card/Card.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { VariantProps } from 'tailwind-variants';\n\nimport {\n Card as NextCard,\n CardBody as NextCardBody,\n CardFooter as NextCardFooter,\n CardHeader as NextCardHeader,\n} from '@nextui-org/card';\nimport { Divider as NextDivider } from '@nextui-org/divider';\nimport createDebug from 'debug';\nimport { tv } from 'tailwind-variants';\n\nconst debug = createDebug('component:Card');\n\n// card styling variants\nexport const cardVariants = tv({\n slots: {\n base: 'border border-slate-300',\n body: '',\n divider: 'my-0 bg-slate-300',\n footer: '',\n header: 'text-base font-semibold',\n },\n});\n\ntype CardVariantProps = VariantProps<typeof cardVariants>;\ntype CardVariantSlots = Partial<\n Record<keyof ReturnType<typeof cardVariants>, string>\n>;\n\nexport interface CardProps extends CardVariantProps {\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string | CardVariantSlots;\n /** footer content */\n footer?: ReactNode;\n /** header content */\n header?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * Card component based on [NextUI Card](https://nextui.org/docs/components/card)\n */\nconst Card = ({\n children = null,\n className = undefined,\n testId = undefined,\n header = undefined,\n footer = undefined,\n}: CardProps) => {\n debug('Card', { className, testId });\n const {\n base: baseSlot,\n body: bodySlot,\n divider: dividerSlot,\n footer: footerSlot,\n header: headerSlot,\n } = cardVariants();\n\n return (\n <NextCard\n data-testid={testId && `card_${testId}`}\n className={baseSlot({\n className: typeof className === 'object' ? className.base : className,\n })}\n fullWidth\n radius=\"sm\"\n shadow=\"none\"\n >\n {header && (\n <>\n <NextCardHeader\n data-testid={testId && `card_header_${testId}`}\n className={headerSlot({\n className: typeof className === 'object' && className.header,\n })}\n >\n {header}\n </NextCardHeader>\n <NextDivider\n className={dividerSlot({\n className: typeof className === 'object' && className.divider,\n })}\n />\n </>\n )}\n <NextCardBody\n data-testid={testId && `card_body_${testId}`}\n className={bodySlot({\n className: typeof className === 'object' && className.body,\n })}\n >\n {children}\n </NextCardBody>\n {footer && (\n <>\n <NextDivider\n className={dividerSlot({\n className: typeof className === 'object' && className.divider,\n })}\n />\n <NextCardFooter\n data-testid={testId && `card_footer_${testId}`}\n className={footerSlot({\n className: typeof className === 'object' && className.footer,\n })}\n >\n {footer}\n </NextCardFooter>\n </>\n )}\n </NextCard>\n );\n};\n\nexport default Card;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAKO;AACP,qBAAuC;AACvC,mBAAwB;AACxB,+BAAmB;AA+DX;AA7DR,IAAM,YAAQ,aAAAA,SAAY,gBAAgB;AAGnC,IAAM,mBAAe,6BAAG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AAA,YAAC,eAAAD;AAAA,YAAA;AAAA,cACC,WAAW,YAAY;AAAA,gBACrB,WAAW,OAAO,cAAc,YAAY,UAAU;AAAA,cACxD,CAAC;AAAA;AAAA,UACH;AAAA,UACA;AAAA,YAAC,YAAAE;AAAA,YAAA;AAAA,cACC,eAAa,UAAU,eAAe,MAAM;AAAA,cAC5C,WAAW,WAAW;AAAA,gBACpB,WAAW,OAAO,cAAc,YAAY,UAAU;AAAA,cACxD,CAAC;AAAA,cAEA;AAAA;AAAA,UACH;AAAA,WACF;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,eAAQ;","names":["createDebug","NextCard","NextCardHeader","NextDivider","NextCardBody","NextCardFooter"]}
|
package/dist/Card/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Card/index.ts","../../src/components/Card/Card.tsx"],"sourcesContent":["import Card from './Card';\n\nexport default Card;\n","import type { ReactNode } from 'react';\nimport type { VariantProps } from 'tailwind-variants';\n\nimport {\n Card as NextCard,\n CardBody as NextCardBody,\n CardFooter as NextCardFooter,\n CardHeader as NextCardHeader,\n} from '@nextui-org/card';\nimport { Divider as NextDivider } from '@nextui-org/divider';\nimport createDebug from 'debug';\nimport { tv } from 'tailwind-variants';\n\nconst debug = createDebug('component:Card');\n\n// card styling variants\nexport const cardVariants = tv({\n slots: {\n base: 'border border-slate-300',\n body: '',\n divider: 'my-0 bg-slate-300',\n footer: '',\n header: 'text-base font-semibold',\n },\n});\n\ntype CardVariantProps = VariantProps<typeof cardVariants>;\ntype CardVariantSlots = Partial<\n Record<keyof ReturnType<typeof cardVariants>, string>\n>;\n\nexport interface CardProps extends CardVariantProps {\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string | CardVariantSlots;\n /** footer content */\n footer?: ReactNode;\n /** header content */\n header?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * Card component based on [NextUI Card](https://nextui.org/docs/components/card)\n */\nconst Card = ({\n children = null,\n className = undefined,\n testId = undefined,\n header = undefined,\n footer = undefined,\n}: CardProps) => {\n debug('Card', { className, testId });\n const {\n base: baseSlot,\n body: bodySlot,\n divider: dividerSlot,\n footer: footerSlot,\n header: headerSlot,\n } = cardVariants();\n\n return (\n <NextCard\n data-testid={testId && `card_${testId}`}\n className={baseSlot({\n className: typeof className === 'object' ? className.base : className,\n })}\n fullWidth\n radius=\"sm\"\n shadow=\"none\"\n >\n {header && (\n <>\n <NextCardHeader\n data-testid={testId && `card_header_${testId}`}\n className={headerSlot({\n className: typeof className === 'object' && className.header,\n })}\n >\n {header}\n </NextCardHeader>\n <NextDivider\n className={dividerSlot({\n className: typeof className === 'object' && className.divider,\n })}\n />\n </>\n )}\n <NextCardBody\n data-testid={testId && `card_body_${testId}`}\n className={bodySlot({\n className: typeof className === 'object' && className.body,\n })}\n >\n {children}\n </NextCardBody>\n {footer && (\n <>\n <NextDivider\n className={dividerSlot({\n className: typeof className === 'object' && className.divider,\n })}\n />\n <NextCardFooter\n data-testid={testId && `card_footer_${testId}`}\n className={footerSlot({\n className: typeof className === 'object' && className.footer,\n })}\n >\n {footer}\n </NextCardFooter>\n </>\n )}\n </NextCard>\n );\n};\n\nexport default Card;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,iBAAAA;AAAA;AAAA;;;ACGA,kBAKO;AACP,qBAAuC;AACvC,mBAAwB;AACxB,+BAAmB;AA+DX;AA7DR,IAAM,YAAQ,aAAAC,SAAY,gBAAgB;AAGnC,IAAM,mBAAe,6BAAG;AAAA,EAC7B,OAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV;AACF,CAAC;AAuBD,IAAM,OAAO,CAAC;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,SAAS;AAAA,EACT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AAAA,gBACpB,WAAW,OAAO,cAAc,YAAY,UAAU;AAAA,cACxD,CAAC;AAAA,cAEA;AAAA;AAAA,UACH;AAAA,WACF;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,eAAQ;;;ADrHf,IAAOC,gBAAQ;","names":["Card_default","createDebug","NextCard","NextCardHeader","NextDivider","NextCardBody","NextCardFooter","Card_default"]}
|
package/dist/Card/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Card/index.ts"],"sourcesContent":["import Card from './Card';\n\nexport default Card;\n"],"mappings":";;;;;AAEA,IAAOA,gBAAQ;","names":["Card_default"]}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import type { ButtonProps } from './Button';
|
|
3
|
-
|
|
4
|
-
import Button from './Button';
|
|
5
|
-
|
|
6
|
-
const meta: Meta<typeof Button> = {
|
|
7
|
-
title: 'pixels/Button',
|
|
8
|
-
component: Button,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default meta;
|
|
12
|
-
type Story = StoryObj<typeof Button>;
|
|
13
|
-
|
|
14
|
-
export const Default: Story = {
|
|
15
|
-
args: {
|
|
16
|
-
children: 'Button',
|
|
17
|
-
testId: 'some-test-id',
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const Disabled: StoryObj<typeof Button> = {
|
|
22
|
-
args: {
|
|
23
|
-
children: 'Button',
|
|
24
|
-
disabled: true,
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const Loading: StoryObj<typeof Button> = {
|
|
29
|
-
args: {
|
|
30
|
-
children: 'Button',
|
|
31
|
-
loading: true,
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const AllColors: StoryObj<typeof Button> = {
|
|
36
|
-
render: () => (
|
|
37
|
-
<>
|
|
38
|
-
{['default', 'primary', 'secondary', 'success', 'warning', 'danger'].map(
|
|
39
|
-
(color) => (
|
|
40
|
-
<div key={color} style={{ marginTop: '10px' }}>
|
|
41
|
-
<Button color={color as ButtonProps['color']}>{color}</Button>
|
|
42
|
-
</div>
|
|
43
|
-
),
|
|
44
|
-
)}
|
|
45
|
-
</>
|
|
46
|
-
),
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const AllSizes: StoryObj<typeof Button> = {
|
|
50
|
-
render: () => (
|
|
51
|
-
<>
|
|
52
|
-
{['sm', 'md', 'lg'].map((size) => (
|
|
53
|
-
<div key={size} style={{ marginTop: '10px' }}>
|
|
54
|
-
<Button size={size as ButtonProps['size']}>{size}</Button>
|
|
55
|
-
</div>
|
|
56
|
-
))}
|
|
57
|
-
</>
|
|
58
|
-
),
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export const AllVariants: StoryObj<typeof Button> = {
|
|
62
|
-
render: () => (
|
|
63
|
-
<>
|
|
64
|
-
{['solid', 'bordered', 'light', 'flat', 'faded', 'shadow', 'ghost'].map(
|
|
65
|
-
(variant) => (
|
|
66
|
-
<div key={variant} style={{ marginTop: '10px' }}>
|
|
67
|
-
<Button variant={variant as ButtonProps['variant']}>
|
|
68
|
-
{variant}
|
|
69
|
-
</Button>
|
|
70
|
-
</div>
|
|
71
|
-
),
|
|
72
|
-
)}
|
|
73
|
-
</>
|
|
74
|
-
),
|
|
75
|
-
};
|