@purpur/library 9.0.8 → 9.0.9

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/CHANGELOG.json CHANGED
@@ -1,6 +1,18 @@
1
1
  {
2
2
  "name": "@purpur/library",
3
3
  "entries": [
4
+ {
5
+ "version": "9.0.9",
6
+ "tag": "@purpur/library_v9.0.9",
7
+ "date": "Thu, 26 Mar 2026 09:15:46 GMT",
8
+ "comments": {
9
+ "none": [
10
+ {
11
+ "comment": "Button: Make it explicit in both Storybook stories and typings that the destructive variant and iconOnly are mutually exclusive"
12
+ }
13
+ ]
14
+ }
15
+ },
4
16
  {
5
17
  "version": "9.0.8",
6
18
  "tag": "@purpur/library_v9.0.8",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Change Log - @purpur/library
2
2
 
3
- This log was last generated on Wed, 25 Mar 2026 12:05:03 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 26 Mar 2026 09:15:46 GMT and should not be manually modified.
4
+
5
+ ## 9.0.9
6
+ Thu, 26 Mar 2026 09:15:46 GMT
7
+
8
+ ### Updates
9
+
10
+ - Button: Make it explicit in both Storybook stories and typings that the destructive variant and iconOnly are mutually exclusive
4
11
 
5
12
  ## 9.0.8
6
13
  Wed, 25 Mar 2026 12:05:03 GMT
@@ -1 +1 @@
1
- {"version":3,"file":"button-BxdChrq-.js","sources":["../../action/src/action.tsx","../../../components/button/src/button.tsx"],"sourcesContent":["import { type ReactNode } from \"react\";\n\nexport const VARIANT = {\n PRIMARY: \"primary\",\n SECONDARY: \"secondary\",\n EXPRESSIVE: \"expressive\",\n} as const;\n\nexport const variants = Object.values(VARIANT);\nexport type Variant = (typeof VARIANT)[keyof typeof VARIANT];\n\nexport const SIZE = {\n XS: \"xs\",\n SM: \"sm\",\n MD: \"md\",\n LG: \"lg\",\n} as const;\n\nexport const sizes = Object.values(SIZE);\nexport type Size = (typeof SIZE)[keyof typeof SIZE];\n\ntype DefaultProps<TVariant, T = object> = {\n [\"data-testid\"]?: string;\n children?: ReactNode;\n className?: string;\n fullWidth?: boolean;\n negative?: boolean;\n size?: Size;\n variant: TVariant | Variant;\n} & T;\n\nexport type UnionParams<TVariant> =\n | DefaultProps<TVariant, { iconOnly: boolean; [\"aria-label\"]: string }>\n | DefaultProps<TVariant, { [\"aria-label\"]?: string }>;\n\ntype UnionKeys<T> = T extends T ? keyof T : never;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype StrictUnionHelper<T, TAll> = T extends any\n ? T & Partial<Record<Exclude<UnionKeys<TAll>, keyof T>, never>>\n : never;\n\ntype StrictUnion<T> = StrictUnionHelper<T, T>;\n\nexport type ActionProps<TVariant extends string = Variant> = StrictUnion<UnionParams<TVariant>>;\n","import React, { type ButtonHTMLAttributes, forwardRef, type MouseEvent } from \"react\";\nimport { type ActionProps, SIZE, VARIANT } from \"@purpur/action\";\nimport type { BaseProps } from \"@purpur/common-types\";\nimport { Spinner } from \"@purpur/spinner\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./button.module.scss\";\n\nexport const BUTTON_VARIANT = {\n ...VARIANT,\n DESTRUCTIVE: \"destructive\",\n TERTIARY_PURPLE: \"tertiary-purple\",\n TEXT: \"text\",\n} as const;\n\nexport const buttonVariants = Object.values(BUTTON_VARIANT);\nexport type ButtonVariant = (typeof BUTTON_VARIANT)[keyof typeof BUTTON_VARIANT];\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-button\";\n\ntype ButtonType = Pick<ButtonHTMLAttributes<HTMLButtonElement>, \"type\">[\"type\"];\nexport const BUTTON_TYPES: ButtonType[] = [\"button\", \"submit\", \"reset\"] as const;\n\nexport type ButtonProps = ActionProps<ButtonVariant> & BaseProps<\"button\"> & { loading?: boolean };\n\nexport const Button = forwardRef<\n HTMLButtonElement,\n Omit<ButtonProps, \"type\"> & { type?: ButtonType }\n>(\n (\n {\n children,\n className,\n disabled = false,\n fullWidth = false,\n iconOnly,\n loading = false,\n negative = false,\n onClick,\n size = \"md\",\n variant,\n type = \"button\",\n ...props\n },\n ref\n ) => {\n if (iconOnly && variant === \"destructive\") {\n return null;\n }\n\n const classes = cx(\n [\n rootClassName,\n `${rootClassName}--${negative ? `${variant}-negative` : variant}`,\n `${rootClassName}--${size}`,\n ],\n {\n [`${rootClassName}--icon-only`]: iconOnly,\n [`${rootClassName}--negative`]: negative,\n [`${rootClassName}--full-width`]: fullWidth,\n [`${rootClassName}--disabled`]: disabled || loading,\n },\n className\n );\n\n const handleClick = (e: MouseEvent<HTMLButtonElement>) => {\n if (disabled || loading) {\n e.preventDefault();\n } else if (onClick) {\n onClick(e);\n }\n };\n\n const _disabled = Boolean(props[\"aria-disabled\"]) || disabled || loading;\n\n return (\n <button\n className={classes}\n type={type}\n ref={ref}\n aria-disabled={_disabled}\n onClick={handleClick}\n {...props}\n >\n {loading && (\n <Spinner\n size={size === SIZE.LG ? \"xs\" : \"xxs\"}\n negative={negative}\n disabled={_disabled}\n className={cx(`${rootClassName}__spinner`)}\n />\n )}{\" \"}\n {children}\n </button>\n );\n }\n);\n\nButton.displayName = \"Button\";\n"],"names":["VARIANT","SIZE","BUTTON_VARIANT","buttonVariants","cx","c","styles","rootClassName","BUTTON_TYPES","Button","forwardRef","children","className","disabled","fullWidth","iconOnly","loading","negative","onClick","size","variant","type","props","ref","classes","handleClick","e","_disabled","jsxs","jsx","Spinner"],"mappings":"wIAEaA,EAAU,CACrB,QAAS,UACT,UAAW,YACX,WAAY,YACd,EAKaC,EAAO,CAIlB,GAAI,IACN,+6CCRaC,EAAiB,CAC5B,GAAGF,EACH,YAAa,cACb,gBAAiB,kBACjB,KAAM,MACR,EAEaG,EAAiB,OAAO,OAAOD,CAAc,EAGpDE,EAAKC,EAAAA,EAAE,KAAKC,CAAM,EAClBC,EAAgB,gBAGTC,EAA6B,CAAC,SAAU,SAAU,OAAO,EAIzDC,EAASC,EAAAA,WAIpB,CACE,CACE,SAAAC,EACA,UAAAC,EACA,SAAAC,EAAW,GACX,UAAAC,EAAY,GACZ,SAAAC,EACA,QAAAC,EAAU,GACV,SAAAC,EAAW,GACX,QAAAC,EACA,KAAAC,EAAO,KACP,QAAAC,EACA,KAAAC,EAAO,SACP,GAAGC,CAAA,EAELC,IACG,CACH,GAAIR,GAAYK,IAAY,cAC1B,OAAO,KAGT,MAAMI,EAAUpB,EACd,CACEG,EACA,GAAGA,CAAa,KAAKU,EAAW,GAAGG,CAAO,YAAcA,CAAO,GAC/D,GAAGb,CAAa,KAAKY,CAAI,EAAA,EAE3B,CACE,CAAC,GAAGZ,CAAa,aAAa,EAAGQ,EACjC,CAAC,GAAGR,CAAa,YAAY,EAAGU,EAChC,CAAC,GAAGV,CAAa,cAAc,EAAGO,EAClC,CAAC,GAAGP,CAAa,YAAY,EAAGM,GAAYG,CAAA,EAE9CJ,CAAA,EAGIa,EAAeC,GAAqC,CACpDb,GAAYG,EACdU,EAAE,eAAA,EACOR,GACTA,EAAQQ,CAAC,CAEb,EAEMC,EAAY,EAAQL,EAAM,eAAe,GAAMT,GAAYG,EAEjE,OACEY,EAAAA,KAAC,SAAA,CACC,UAAWJ,EACX,KAAAH,EACA,IAAAE,EACA,gBAAeI,EACf,QAASF,EACR,GAAGH,EAEH,SAAA,CAAAN,GACCa,EAAAA,IAACC,EAAAA,QAAA,CACC,KAAMX,IAASlB,EAAK,GAAK,KAAO,MAChC,SAAAgB,EACA,SAAUU,EACV,UAAWvB,EAAG,GAAGG,CAAa,WAAW,CAAA,CAAA,EAE1C,IACFI,CAAA,CAAA,CAAA,CAGP,CACF,EAEAF,EAAO,YAAc"}
1
+ {"version":3,"file":"button-BxdChrq-.js","sources":["../../action/src/action.tsx","../../../components/button/src/button.tsx"],"sourcesContent":["import { type ReactNode } from \"react\";\n\nexport const VARIANT = {\n PRIMARY: \"primary\",\n SECONDARY: \"secondary\",\n EXPRESSIVE: \"expressive\",\n} as const;\n\nexport const variants = Object.values(VARIANT);\nexport type Variant = (typeof VARIANT)[keyof typeof VARIANT];\n\nexport const SIZE = {\n XS: \"xs\",\n SM: \"sm\",\n MD: \"md\",\n LG: \"lg\",\n} as const;\n\nexport const sizes = Object.values(SIZE);\nexport type Size = (typeof SIZE)[keyof typeof SIZE];\n\ntype DefaultProps<TVariant, T = object> = {\n [\"data-testid\"]?: string;\n children?: ReactNode;\n className?: string;\n fullWidth?: boolean;\n negative?: boolean;\n size?: Size;\n variant: TVariant | Variant;\n} & T;\n\nexport type UnionParams<TVariant> =\n | DefaultProps<TVariant, { iconOnly: boolean; [\"aria-label\"]: string }>\n | DefaultProps<TVariant, { [\"aria-label\"]?: string }>;\n\ntype UnionKeys<T> = T extends T ? keyof T : never;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype StrictUnionHelper<T, TAll> = T extends any\n ? T & Partial<Record<Exclude<UnionKeys<TAll>, keyof T>, never>>\n : never;\n\ntype StrictUnion<T> = StrictUnionHelper<T, T>;\n\nexport type ActionProps<TVariant extends string = Variant> = StrictUnion<UnionParams<TVariant>>;\n","import React, { type ButtonHTMLAttributes, forwardRef, type MouseEvent } from \"react\";\nimport { type ActionProps, SIZE, VARIANT } from \"@purpur/action\";\nimport type { BaseProps } from \"@purpur/common-types\";\nimport { Spinner } from \"@purpur/spinner\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./button.module.scss\";\n\nexport const BUTTON_VARIANT = {\n ...VARIANT,\n DESTRUCTIVE: \"destructive\",\n TERTIARY_PURPLE: \"tertiary-purple\",\n TEXT: \"text\",\n} as const;\n\nexport const buttonVariants = Object.values(BUTTON_VARIANT);\nexport type ButtonVariant = (typeof BUTTON_VARIANT)[keyof typeof BUTTON_VARIANT];\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-button\";\n\ntype ButtonType = Pick<ButtonHTMLAttributes<HTMLButtonElement>, \"type\">[\"type\"];\nexport const BUTTON_TYPES: ButtonType[] = [\"button\", \"submit\", \"reset\"] as const;\n\ntype ButtonBaseProps = BaseProps<\"button\"> & { loading?: boolean };\n\nexport type ButtonProps =\n | (ActionProps<ButtonVariant> & ButtonBaseProps & { iconOnly?: false | undefined })\n | (ActionProps<Exclude<ButtonVariant, \"destructive\">> & ButtonBaseProps & { iconOnly: true });\n\ntype DistributiveOmit<T, K extends keyof never> = T extends unknown ? Omit<T, K> : never;\n\nexport const Button = forwardRef<\n HTMLButtonElement,\n DistributiveOmit<ButtonProps, \"type\"> & { type?: ButtonType }\n>(\n (\n {\n children,\n className,\n disabled = false,\n fullWidth = false,\n iconOnly,\n loading = false,\n negative = false,\n onClick,\n size = \"md\",\n variant,\n type = \"button\",\n ...props\n },\n ref\n ) => {\n if (iconOnly && variant === (\"destructive\" as string)) {\n return null;\n }\n\n const classes = cx(\n [\n rootClassName,\n `${rootClassName}--${negative ? `${variant}-negative` : variant}`,\n `${rootClassName}--${size}`,\n ],\n {\n [`${rootClassName}--icon-only`]: iconOnly,\n [`${rootClassName}--negative`]: negative,\n [`${rootClassName}--full-width`]: fullWidth,\n [`${rootClassName}--disabled`]: disabled || loading,\n },\n className\n );\n\n const handleClick = (e: MouseEvent<HTMLButtonElement>) => {\n if (disabled || loading) {\n e.preventDefault();\n } else if (onClick) {\n onClick(e);\n }\n };\n\n const _disabled = Boolean(props[\"aria-disabled\"]) || disabled || loading;\n\n return (\n <button\n className={classes}\n type={type}\n ref={ref}\n aria-disabled={_disabled}\n onClick={handleClick}\n {...props}\n >\n {loading && (\n <Spinner\n size={size === SIZE.LG ? \"xs\" : \"xxs\"}\n negative={negative}\n disabled={_disabled}\n className={cx(`${rootClassName}__spinner`)}\n />\n )}{\" \"}\n {children}\n </button>\n );\n }\n);\n\nButton.displayName = \"Button\";\n"],"names":["VARIANT","SIZE","BUTTON_VARIANT","buttonVariants","cx","c","styles","rootClassName","BUTTON_TYPES","Button","forwardRef","children","className","disabled","fullWidth","iconOnly","loading","negative","onClick","size","variant","type","props","ref","classes","handleClick","e","_disabled","jsxs","jsx","Spinner"],"mappings":"wIAEaA,EAAU,CACrB,QAAS,U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,CAAa,WAAW,CAAA,CAAA,EAE1C,IACFI,CAAA,CAAA,CAAA,CAGP,CACF,EAEAF,EAAO,YAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"button-D-BBdNhd.mjs","sources":["../../action/src/action.tsx","../../../components/button/src/button.tsx"],"sourcesContent":["import { type ReactNode } from \"react\";\n\nexport const VARIANT = {\n PRIMARY: \"primary\",\n SECONDARY: \"secondary\",\n EXPRESSIVE: \"expressive\",\n} as const;\n\nexport const variants = Object.values(VARIANT);\nexport type Variant = (typeof VARIANT)[keyof typeof VARIANT];\n\nexport const SIZE = {\n XS: \"xs\",\n SM: \"sm\",\n MD: \"md\",\n LG: \"lg\",\n} as const;\n\nexport const sizes = Object.values(SIZE);\nexport type Size = (typeof SIZE)[keyof typeof SIZE];\n\ntype DefaultProps<TVariant, T = object> = {\n [\"data-testid\"]?: string;\n children?: ReactNode;\n className?: string;\n fullWidth?: boolean;\n negative?: boolean;\n size?: Size;\n variant: TVariant | Variant;\n} & T;\n\nexport type UnionParams<TVariant> =\n | DefaultProps<TVariant, { iconOnly: boolean; [\"aria-label\"]: string }>\n | DefaultProps<TVariant, { [\"aria-label\"]?: string }>;\n\ntype UnionKeys<T> = T extends T ? keyof T : never;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype StrictUnionHelper<T, TAll> = T extends any\n ? T & Partial<Record<Exclude<UnionKeys<TAll>, keyof T>, never>>\n : never;\n\ntype StrictUnion<T> = StrictUnionHelper<T, T>;\n\nexport type ActionProps<TVariant extends string = Variant> = StrictUnion<UnionParams<TVariant>>;\n","import React, { type ButtonHTMLAttributes, forwardRef, type MouseEvent } from \"react\";\nimport { type ActionProps, SIZE, VARIANT } from \"@purpur/action\";\nimport type { BaseProps } from \"@purpur/common-types\";\nimport { Spinner } from \"@purpur/spinner\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./button.module.scss\";\n\nexport const BUTTON_VARIANT = {\n ...VARIANT,\n DESTRUCTIVE: \"destructive\",\n TERTIARY_PURPLE: \"tertiary-purple\",\n TEXT: \"text\",\n} as const;\n\nexport const buttonVariants = Object.values(BUTTON_VARIANT);\nexport type ButtonVariant = (typeof BUTTON_VARIANT)[keyof typeof BUTTON_VARIANT];\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-button\";\n\ntype ButtonType = Pick<ButtonHTMLAttributes<HTMLButtonElement>, \"type\">[\"type\"];\nexport const BUTTON_TYPES: ButtonType[] = [\"button\", \"submit\", \"reset\"] as const;\n\nexport type ButtonProps = ActionProps<ButtonVariant> & BaseProps<\"button\"> & { loading?: boolean };\n\nexport const Button = forwardRef<\n HTMLButtonElement,\n Omit<ButtonProps, \"type\"> & { type?: ButtonType }\n>(\n (\n {\n children,\n className,\n disabled = false,\n fullWidth = false,\n iconOnly,\n loading = false,\n negative = false,\n onClick,\n size = \"md\",\n variant,\n type = \"button\",\n ...props\n },\n ref\n ) => {\n if (iconOnly && variant === \"destructive\") {\n return null;\n }\n\n const classes = cx(\n [\n rootClassName,\n `${rootClassName}--${negative ? `${variant}-negative` : variant}`,\n `${rootClassName}--${size}`,\n ],\n {\n [`${rootClassName}--icon-only`]: iconOnly,\n [`${rootClassName}--negative`]: negative,\n [`${rootClassName}--full-width`]: fullWidth,\n [`${rootClassName}--disabled`]: disabled || loading,\n },\n className\n );\n\n const handleClick = (e: MouseEvent<HTMLButtonElement>) => {\n if (disabled || loading) {\n e.preventDefault();\n } else if (onClick) {\n onClick(e);\n }\n };\n\n const _disabled = Boolean(props[\"aria-disabled\"]) || disabled || loading;\n\n return (\n <button\n className={classes}\n type={type}\n ref={ref}\n aria-disabled={_disabled}\n onClick={handleClick}\n {...props}\n >\n {loading && (\n <Spinner\n size={size === SIZE.LG ? \"xs\" : \"xxs\"}\n negative={negative}\n disabled={_disabled}\n className={cx(`${rootClassName}__spinner`)}\n />\n )}{\" \"}\n {children}\n </button>\n );\n }\n);\n\nButton.displayName = \"Button\";\n"],"names":["VARIANT","SIZE","BUTTON_VARIANT","buttonVariants","cx","c","styles","rootClassName","BUTTON_TYPES","Button","forwardRef","children","className","disabled","fullWidth","iconOnly","loading","negative","onClick","size","variant","type","props","ref","classes","handleClick","e","_disabled","jsxs","jsx","Spinner"],"mappings":";;;;AAEO,MAAMA,IAAU;AAAA,EACrB,SAAS;AAAA,EACT,WAAW;AAAA,EACX,YAAY;AACd,GAKaC,IAAO;AAAA,EAIlB,IAAI;AACN;;;;;;;;;;;;;;;;;;;;;;;GCRaC,IAAiB;AAAA,EAC5B,GAAGF;AAAA,EACH,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,MAAM;AACR,GAEaG,IAAiB,OAAO,OAAOD,CAAc,GAGpDE,IAAKC,EAAE,KAAKC,CAAM,GAClBC,IAAgB,iBAGTC,IAA6B,CAAC,UAAU,UAAU,OAAO,GAIzDC,IAASC;AAAA,EAIpB,CACE;AAAA,IACE,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,WAAAC,IAAY;AAAA,IACZ,UAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,IACV,UAAAC,IAAW;AAAA,IACX,SAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,SAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,GAAGC;AAAA,EAAA,GAELC,MACG;AACH,QAAIR,KAAYK,MAAY;AAC1B,aAAO;AAGT,UAAMI,IAAUpB;AAAA,MACd;AAAA,QACEG;AAAA,QACA,GAAGA,CAAa,KAAKU,IAAW,GAAGG,CAAO,cAAcA,CAAO;AAAA,QAC/D,GAAGb,CAAa,KAAKY,CAAI;AAAA,MAAA;AAAA,MAE3B;AAAA,QACE,CAAC,GAAGZ,CAAa,aAAa,GAAGQ;AAAA,QACjC,CAAC,GAAGR,CAAa,YAAY,GAAGU;AAAA,QAChC,CAAC,GAAGV,CAAa,cAAc,GAAGO;AAAA,QAClC,CAAC,GAAGP,CAAa,YAAY,GAAGM,KAAYG;AAAA,MAAA;AAAA,MAE9CJ;AAAA,IAAA,GAGIa,IAAc,CAACC,MAAqC;AACxD,MAAIb,KAAYG,IACdU,EAAE,eAAA,IACOR,KACTA,EAAQQ,CAAC;AAAA,IAEb,GAEMC,IAAY,EAAQL,EAAM,eAAe,KAAMT,KAAYG;AAEjE,WACE,gBAAAY;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAWJ;AAAA,QACX,MAAAH;AAAA,QACA,KAAAE;AAAA,QACA,iBAAeI;AAAA,QACf,SAASF;AAAA,QACR,GAAGH;AAAA,QAEH,UAAA;AAAA,UAAAN,KACC,gBAAAa;AAAA,YAACC;AAAA,YAAA;AAAA,cACC,MAAMX,MAASlB,EAAK,KAAK,OAAO;AAAA,cAChC,UAAAgB;AAAA,cACA,UAAUU;AAAA,cACV,WAAWvB,EAAG,GAAGG,CAAa,WAAW;AAAA,YAAA;AAAA,UAAA;AAAA,UAE1C;AAAA,UACFI;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;AAEAF,EAAO,cAAc;"}
1
+ {"version":3,"file":"button-D-BBdNhd.mjs","sources":["../../action/src/action.tsx","../../../components/button/src/button.tsx"],"sourcesContent":["import { type ReactNode } from \"react\";\n\nexport const VARIANT = {\n PRIMARY: \"primary\",\n SECONDARY: \"secondary\",\n EXPRESSIVE: \"expressive\",\n} as const;\n\nexport const variants = Object.values(VARIANT);\nexport type Variant = (typeof VARIANT)[keyof typeof VARIANT];\n\nexport const SIZE = {\n XS: \"xs\",\n SM: \"sm\",\n MD: \"md\",\n LG: \"lg\",\n} as const;\n\nexport const sizes = Object.values(SIZE);\nexport type Size = (typeof SIZE)[keyof typeof SIZE];\n\ntype DefaultProps<TVariant, T = object> = {\n [\"data-testid\"]?: string;\n children?: ReactNode;\n className?: string;\n fullWidth?: boolean;\n negative?: boolean;\n size?: Size;\n variant: TVariant | Variant;\n} & T;\n\nexport type UnionParams<TVariant> =\n | DefaultProps<TVariant, { iconOnly: boolean; [\"aria-label\"]: string }>\n | DefaultProps<TVariant, { [\"aria-label\"]?: string }>;\n\ntype UnionKeys<T> = T extends T ? keyof T : never;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype StrictUnionHelper<T, TAll> = T extends any\n ? T & Partial<Record<Exclude<UnionKeys<TAll>, keyof T>, never>>\n : never;\n\ntype StrictUnion<T> = StrictUnionHelper<T, T>;\n\nexport type ActionProps<TVariant extends string = Variant> = StrictUnion<UnionParams<TVariant>>;\n","import React, { type ButtonHTMLAttributes, forwardRef, type MouseEvent } from \"react\";\nimport { type ActionProps, SIZE, VARIANT } from \"@purpur/action\";\nimport type { BaseProps } from \"@purpur/common-types\";\nimport { Spinner } from \"@purpur/spinner\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./button.module.scss\";\n\nexport const BUTTON_VARIANT = {\n ...VARIANT,\n DESTRUCTIVE: \"destructive\",\n TERTIARY_PURPLE: \"tertiary-purple\",\n TEXT: \"text\",\n} as const;\n\nexport const buttonVariants = Object.values(BUTTON_VARIANT);\nexport type ButtonVariant = (typeof BUTTON_VARIANT)[keyof typeof BUTTON_VARIANT];\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-button\";\n\ntype ButtonType = Pick<ButtonHTMLAttributes<HTMLButtonElement>, \"type\">[\"type\"];\nexport const BUTTON_TYPES: ButtonType[] = [\"button\", \"submit\", \"reset\"] as const;\n\ntype ButtonBaseProps = BaseProps<\"button\"> & { loading?: boolean };\n\nexport type ButtonProps =\n | (ActionProps<ButtonVariant> & ButtonBaseProps & { iconOnly?: false | undefined })\n | (ActionProps<Exclude<ButtonVariant, \"destructive\">> & ButtonBaseProps & { iconOnly: true });\n\ntype DistributiveOmit<T, K extends keyof never> = T extends unknown ? Omit<T, K> : never;\n\nexport const Button = forwardRef<\n HTMLButtonElement,\n DistributiveOmit<ButtonProps, \"type\"> & { type?: ButtonType }\n>(\n (\n {\n children,\n className,\n disabled = false,\n fullWidth = false,\n iconOnly,\n loading = false,\n negative = false,\n onClick,\n size = \"md\",\n variant,\n type = \"button\",\n ...props\n },\n ref\n ) => {\n if (iconOnly && variant === (\"destructive\" as string)) {\n return null;\n }\n\n const classes = cx(\n [\n rootClassName,\n `${rootClassName}--${negative ? `${variant}-negative` : variant}`,\n `${rootClassName}--${size}`,\n ],\n {\n [`${rootClassName}--icon-only`]: iconOnly,\n [`${rootClassName}--negative`]: negative,\n [`${rootClassName}--full-width`]: fullWidth,\n [`${rootClassName}--disabled`]: disabled || loading,\n },\n className\n );\n\n const handleClick = (e: MouseEvent<HTMLButtonElement>) => {\n if (disabled || loading) {\n e.preventDefault();\n } else if (onClick) {\n onClick(e);\n }\n };\n\n const _disabled = Boolean(props[\"aria-disabled\"]) || disabled || loading;\n\n return (\n <button\n className={classes}\n type={type}\n ref={ref}\n aria-disabled={_disabled}\n onClick={handleClick}\n {...props}\n >\n {loading && (\n <Spinner\n size={size === SIZE.LG ? \"xs\" : \"xxs\"}\n negative={negative}\n disabled={_disabled}\n className={cx(`${rootClassName}__spinner`)}\n />\n )}{\" \"}\n {children}\n </button>\n );\n }\n);\n\nButton.displayName = \"Button\";\n"],"names":["VARIANT","SIZE","BUTTON_VARIANT","buttonVariants","cx","c","styles","rootClassName","BUTTON_TYPES","Button","forwardRef","children","className","disabled","fullWidth","iconOnly","loading","negative","onClick","size","variant","type","props","ref","classes","handleClick","e","_disabled","jsxs","jsx","Spinner"],"mappings":";;;;AAEO,MAAMA,IAAU;AAAA,EACrB,SAAS;AAAA,EACT,WAAW;AAAA,EACX,YAAY;AACd,GAKaC,IAAO;AAAA,EAIlB,IAAI;AACN;;;;;;;;;;;;;;;;;;;;;;;GCRaC,IAAiB;AAAA,EAC5B,GAAGF;AAAA,EACH,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,MAAM;AACR,GAEaG,IAAiB,OAAO,OAAOD,CAAc,GAGpDE,IAAKC,EAAE,KAAKC,CAAM,GAClBC,IAAgB,iBAGTC,IAA6B,CAAC,UAAU,UAAU,OAAO,GAUzDC,IAASC;AAA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A,YAAA;AAAA,UAAA;AAAA,UAE1C;AAAA,UACFI;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;AAEAF,EAAO,cAAc;"}
@@ -13,11 +13,70 @@ export declare const buttonVariants: ("text" | "primary" | "secondary" | "expres
13
13
  export type ButtonVariant = (typeof BUTTON_VARIANT)[keyof typeof BUTTON_VARIANT];
14
14
  type ButtonType = Pick<ButtonHTMLAttributes<HTMLButtonElement>, "type">["type"];
15
15
  export declare const BUTTON_TYPES: ButtonType[];
16
- export type ButtonProps = ActionProps<ButtonVariant> & BaseProps<"button"> & {
16
+ type ButtonBaseProps = BaseProps<"button"> & {
17
17
  loading?: boolean;
18
18
  };
19
- export declare const Button: React.ForwardRefExoticComponent<Omit<Omit<ButtonProps, "type"> & {
19
+ export type ButtonProps = (ActionProps<ButtonVariant> & ButtonBaseProps & {
20
+ iconOnly?: false | undefined;
21
+ }) | (ActionProps<Exclude<ButtonVariant, "destructive">> & ButtonBaseProps & {
22
+ iconOnly: true;
23
+ });
24
+ export declare const Button: React.ForwardRefExoticComponent<(Omit<Omit<{
25
+ "data-testid"?: string;
26
+ children?: React.ReactNode;
27
+ className?: string;
28
+ fullWidth?: boolean;
29
+ negative?: boolean;
30
+ size?: import('../../../libraries/action/src/action').Size;
31
+ variant: "text" | "primary" | "secondary" | "expressive" | "destructive" | "tertiary-purple";
32
+ } & {
33
+ iconOnly: boolean;
34
+ "aria-label": string;
35
+ } & Partial<Record<never, never>> & React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement> & {
36
+ [key: `data-${string}`]: string | undefined;
37
+ } & {
38
+ loading?: boolean;
39
+ } & {
40
+ iconOnly?: false | undefined;
41
+ }, "type"> & {
42
+ type?: ButtonType;
43
+ }, "ref"> | Omit<Omit<{
44
+ "data-testid"?: string;
45
+ children?: React.ReactNode;
46
+ className?: string;
47
+ fullWidth?: boolean;
48
+ negative?: boolean;
49
+ size?: import('../../../libraries/action/src/action').Size;
50
+ variant: "text" | "primary" | "secondary" | "expressive" | "destructive" | "tertiary-purple";
51
+ } & {
52
+ "aria-label"?: string;
53
+ } & Partial<Record<"iconOnly", never>> & React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement> & {
54
+ [key: `data-${string}`]: string | undefined;
55
+ } & {
56
+ loading?: boolean;
57
+ } & {
58
+ iconOnly?: false | undefined;
59
+ }, "type"> & {
60
+ type?: ButtonType;
61
+ }, "ref"> | Omit<Omit<{
62
+ "data-testid"?: string;
63
+ children?: React.ReactNode;
64
+ className?: string;
65
+ fullWidth?: boolean;
66
+ negative?: boolean;
67
+ size?: import('../../../libraries/action/src/action').Size;
68
+ variant: "text" | "tertiary-purple" | import('../../../libraries/action/src/action').Variant;
69
+ } & {
70
+ iconOnly: boolean;
71
+ "aria-label": string;
72
+ } & Partial<Record<never, never>> & React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement> & {
73
+ [key: `data-${string}`]: string | undefined;
74
+ } & {
75
+ loading?: boolean;
76
+ } & {
77
+ iconOnly: true;
78
+ }, "type"> & {
20
79
  type?: ButtonType;
21
- }, "ref"> & React.RefAttributes<HTMLButtonElement>>;
80
+ }, "ref">) & React.RefAttributes<HTMLButtonElement>>;
22
81
  export {};
23
82
  //# sourceMappingURL=button.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../../../../components/button/src/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,oBAAoB,EAA+B,MAAM,OAAO,CAAC;AACtF,OAAO,EAAE,KAAK,WAAW,EAAiB,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAMtD,eAAO,MAAM,cAAc;;;;;;;CAKjB,CAAC;AAEX,eAAO,MAAM,cAAc,yFAAgC,CAAC;AAC5D,MAAM,MAAM,aAAa,GAAG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SAAS,CAAA;CAAE,CAAC,GACjF,CAAC,WAAW,CAAC,OAAO,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,GAAG,eAAe,GAAG;IAAE,QAAQ,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC;AAIhG,eAAO,MAAM,MAAM;;;;;;;;;;;;;;cARsC,OAAO;;eAGC,KAAK,GAAG,SAAS;;WAO/B,UAAU;;;;;;;;;;;;;;cAVJ,OAAO;;eAGC,KAAK,GAAG,SAAS;;WAO/B,UAAU;;;;;;;;;;;;;;;cAVJ,OAAO;;cAIwB,IAAI;;WAMzC,UAAU;oDAqE5D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpur/library",
3
- "version": "9.0.8",
3
+ "version": "9.0.9",
4
4
  "license": "AGPL-3.0-only",
5
5
  "sideEffects": [
6
6
  "*.css",
@@ -108,67 +108,67 @@
108
108
  "shx": "~0.4.0",
109
109
  "@purpur/accordion": "8.21.0",
110
110
  "@purpur/action": "8.21.0",
111
- "@purpur/badge": "8.21.0",
112
111
  "@purpur/alert-badge": "8.21.0",
113
112
  "@purpur/autocomplete": "8.21.0",
113
+ "@purpur/badge": "8.21.0",
114
114
  "@purpur/breadcrumbs": "8.21.0",
115
- "@purpur/card": "8.21.0",
116
115
  "@purpur/button": "8.21.0",
116
+ "@purpur/card": "8.21.0",
117
117
  "@purpur/calendar": "8.21.0",
118
+ "@purpur/color-dot": "8.21.0",
118
119
  "@purpur/checkbox": "8.21.0",
119
120
  "@purpur/chip-group": "8.21.0",
120
- "@purpur/color-dot": "8.21.0",
121
121
  "@purpur/common-types": "8.21.0",
122
122
  "@purpur/component-rig": "1.0.0",
123
123
  "@purpur/container": "8.21.0",
124
- "@purpur/countdown": "8.21.0",
125
- "@purpur/counter-badge": "8.21.0",
126
124
  "@purpur/content-block": "8.21.0",
125
+ "@purpur/countdown": "8.21.0",
127
126
  "@purpur/cta-link": "8.21.0",
128
- "@purpur/date-picker": "8.21.0",
127
+ "@purpur/counter-badge": "8.21.0",
129
128
  "@purpur/date-field": "8.21.0",
129
+ "@purpur/date-picker": "8.21.0",
130
130
  "@purpur/dismissable-chip-group": "8.21.0",
131
- "@purpur/field-helper-text": "8.21.0",
132
- "@purpur/drawer": "8.21.0",
133
131
  "@purpur/field-error-text": "8.21.0",
132
+ "@purpur/drawer": "8.21.0",
133
+ "@purpur/field-helper-text": "8.21.0",
134
134
  "@purpur/footer": "8.21.0",
135
135
  "@purpur/heading": "8.21.0",
136
- "@purpur/grid": "8.21.0",
137
- "@purpur/icon": "8.21.0",
138
136
  "@purpur/hero-banner": "8.21.0",
139
- "@purpur/illustrative-icon": "8.21.0",
140
- "@purpur/link": "8.21.0",
137
+ "@purpur/icon": "8.21.0",
138
+ "@purpur/grid": "8.21.0",
141
139
  "@purpur/label": "8.21.0",
142
- "@purpur/listbox": "8.21.0",
140
+ "@purpur/link": "8.21.0",
141
+ "@purpur/illustrative-icon": "8.21.0",
143
142
  "@purpur/logo": "8.21.0",
143
+ "@purpur/listbox": "8.21.0",
144
+ "@purpur/modal": "8.21.0",
144
145
  "@purpur/notification-banner": "8.21.0",
145
146
  "@purpur/notification": "8.21.0",
146
- "@purpur/modal": "8.21.0",
147
- "@purpur/paragraph": "8.21.0",
148
147
  "@purpur/pagination": "8.21.0",
149
- "@purpur/product-card": "8.21.0",
150
- "@purpur/password-field": "8.21.0",
148
+ "@purpur/paragraph": "8.21.0",
151
149
  "@purpur/popover": "8.21.0",
152
- "@purpur/quantity-selector": "8.21.0",
150
+ "@purpur/product-card": "8.21.0",
153
151
  "@purpur/promotion-card": "8.21.0",
152
+ "@purpur/quantity-selector": "8.21.0",
153
+ "@purpur/password-field": "8.21.0",
154
154
  "@purpur/radio-button-group": "8.21.0",
155
155
  "@purpur/radio-card-group": "8.21.0",
156
- "@purpur/search-field": "8.21.0",
157
156
  "@purpur/rich-text": "8.21.0",
158
157
  "@purpur/skeleton": "8.21.0",
158
+ "@purpur/slider": "8.21.0",
159
159
  "@purpur/spacer": "8.21.0",
160
- "@purpur/spinner": "8.21.0",
161
160
  "@purpur/select": "8.21.0",
162
- "@purpur/slider": "8.21.0",
161
+ "@purpur/search-field": "8.21.0",
162
+ "@purpur/spinner": "8.21.0",
163
163
  "@purpur/stepper": "8.21.0",
164
164
  "@purpur/table": "8.21.0",
165
165
  "@purpur/tabs": "8.21.0",
166
166
  "@purpur/text-area": "8.21.0",
167
167
  "@purpur/text-field": "8.21.0",
168
168
  "@purpur/text-spacing": "8.21.0",
169
- "@purpur/toggle": "8.21.0",
170
169
  "@purpur/theme": "8.21.0",
171
170
  "@purpur/tokens": "8.21.0",
171
+ "@purpur/toggle": "8.21.0",
172
172
  "@purpur/tooltip": "8.21.0",
173
173
  "@purpur/visually-hidden": "8.21.0"
174
174
  },