@alto-avios/alto-ui 5.1.2 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CalendarDate-uEuHKGse.js +2 -0
- package/dist/CalendarDate-uEuHKGse.js.map +1 -0
- package/dist/{DateField-oLDKE7Lh.js → DateField-rBq9QuR6.js} +4 -4
- package/dist/DateField-rBq9QuR6.js.map +1 -0
- package/dist/DatePicker.module-DlLCFGCM.js +2 -0
- package/dist/DatePicker.module-DlLCFGCM.js.map +1 -0
- package/dist/assets/Accordion.css +1 -1
- package/dist/assets/AviosCurrency.css +1 -1
- package/dist/assets/AviosCurrencyBadge.css +1 -1
- package/dist/assets/AviosCurrencySymbol.css +1 -1
- package/dist/assets/Badge.css +1 -1
- package/dist/assets/Button.css +1 -1
- package/dist/assets/CalloutBanner.css +1 -1
- package/dist/assets/Checkbox.css +1 -1
- package/dist/assets/ClearFieldButton.css +1 -1
- package/dist/assets/Dialog.css +1 -1
- package/dist/assets/ErrorSummary.css +1 -1
- package/dist/assets/Link.css +1 -1
- package/dist/assets/Radio.css +1 -1
- package/dist/assets/SelectCard.css +1 -1
- package/dist/assets/Tag.css +1 -1
- package/dist/components/Accordion/Accordion.js +12 -12
- package/dist/components/Accordion/Accordion.js.map +1 -1
- package/dist/components/AviosBadge/AviosBadge.js.map +1 -1
- package/dist/components/AviosCurrency/AviosCurrency.js +4 -4
- package/dist/components/AviosCurrency/AviosCurrency.js.map +1 -1
- package/dist/components/AviosCurrencyBadge/AviosCurrencyBadge.js +2 -2
- package/dist/components/AviosCurrencyBadge/AviosCurrencyBadge.js.map +1 -1
- package/dist/components/AviosCurrencySymbol/AviosCurrencySymbol.js +6 -6
- package/dist/components/AviosCurrencySymbol/AviosCurrencySymbol.js.map +1 -1
- package/dist/components/Badge/Badge.js +2 -2
- package/dist/components/Badge/Badge.js.map +1 -1
- package/dist/components/Box/Box.js +2 -2
- package/dist/components/Button/Button.d.ts +12 -83
- package/dist/components/Button/Button.js +3 -3
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/ButtonGroup/ButtonGroup.js +1 -1
- package/dist/components/Calendar/Calendar.js +1 -1
- package/dist/components/CalendarRange/CalendarRange.js +1 -1
- package/dist/components/CalendarRange/CalendarRange.js.map +1 -1
- package/dist/components/CalloutBanner/CalloutBanner.js +9 -9
- package/dist/components/CardSection/CardSection.js +1 -1
- package/dist/components/Carousel/Carousel.js +4 -4
- package/dist/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.js +5 -5
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/ClearFieldButton/ClearFieldButton.js +2 -1
- package/dist/components/ClearFieldButton/ClearFieldButton.js.map +1 -1
- package/dist/components/CreditCardNumberField/CreditCardNumberField.js +1 -1
- package/dist/components/CreditCardSecurityCodeField/CreditCardSecurityCodeField.js +1 -1
- package/dist/components/Currency/Currency.js +1 -1
- package/dist/components/DateField/DateField.d.ts +5 -1
- package/dist/components/DateField/DateField.js +1 -1
- package/dist/components/DateField/index.js +1 -1
- package/dist/components/DatePicker/DatePicker.js +3 -3
- package/dist/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.js +3 -3
- package/dist/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/components/Dialog/Dialog.js +5 -5
- package/dist/components/ErrorSummary/ErrorSummary.js +2 -2
- package/dist/components/Eyebrow/Eyebrow.js +1 -1
- package/dist/components/Form/Form.js +1 -1
- package/dist/components/Grid/Grid.d.ts +3 -3
- package/dist/components/Grid/Grid.js.map +1 -1
- package/dist/components/Heading/Heading.js +2 -2
- package/dist/components/Icon/Icon.js +1 -1
- package/dist/components/IconBackdrop/IconBackdrop.js +1 -1
- package/dist/components/IconButton/IconButton.js +1 -1
- package/dist/components/IconButton/IconButton.js.map +1 -1
- package/dist/components/Image/Image.js +1 -1
- package/dist/components/Label/Label.js +1 -1
- package/dist/components/Link/Link.d.ts +7 -2
- package/dist/components/Link/Link.js +3 -3
- package/dist/components/Link/Link.js.map +1 -1
- package/dist/components/LoadingSpinner/LoadingSpinner.js +1 -1
- package/dist/components/Menu/Menu.d.ts +8 -36
- package/dist/components/Menu/Menu.js +1 -1
- package/dist/components/Menu/Menu.js.map +1 -1
- package/dist/components/NumberField/NumberField.js +2 -2
- package/dist/components/NumberField/NumberField.js.map +1 -1
- package/dist/components/Paragraph/Paragraph.js +1 -1
- package/dist/components/PasswordField/PasswordField.js +1 -1
- package/dist/components/PhoneNumberField/PhoneNumberField.js +1 -1
- package/dist/components/Radio/Radio.js +1 -1
- package/dist/components/Section/Section.js +1 -1
- package/dist/components/SelectCard/SelectCard.js +5 -5
- package/dist/components/Spacer/Spacer.js +1 -1
- package/dist/components/SubHeading/SubHeading.js +1 -1
- package/dist/components/Tabs/TabList.js +1 -1
- package/dist/components/Tabs/Tabs.js +1 -1
- package/dist/components/Tag/Tag.js +2 -2
- package/dist/components/ToggleButton/ToggleButton.js +1 -1
- package/dist/components/ToggleIconButton/ToggleIconButton.js +1 -1
- package/dist/components/_base/Calendar/Calendar.js +1 -1
- package/dist/components/_base/Input/Input.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/{flex-D0sfBoFP.js → flex-BJOhaXnU.js} +2 -2
- package/dist/{flex-D0sfBoFP.js.map → flex-BJOhaXnU.js.map} +1 -1
- package/dist/index-CCUt_dAN.js +2 -0
- package/dist/{index-DiYWUa65.js.map → index-CCUt_dAN.js.map} +1 -1
- package/dist/index.js +1 -1
- package/dist/{input-DoPyN5PO.js → input-Ct1NB1lu.js} +2 -2
- package/dist/{input-DoPyN5PO.js.map → input-Ct1NB1lu.js.map} +1 -1
- package/dist/{padding-BPweMQaC.js → padding-nClUzhWp.js} +2 -2
- package/dist/{padding-BPweMQaC.js.map → padding-nClUzhWp.js.map} +1 -1
- package/dist/react-number-format.es-kdABQClE.js +2 -0
- package/dist/react-number-format.es-kdABQClE.js.map +1 -0
- package/dist/useCalendarState-BKam8aTi.js +2 -0
- package/dist/useCalendarState-BKam8aTi.js.map +1 -0
- package/dist/useControlledState-CLJIwghQ.js +2 -0
- package/dist/useControlledState-CLJIwghQ.js.map +1 -0
- package/dist/useGlobalListeners-CGYK0FZ8.js +2 -0
- package/dist/useGlobalListeners-CGYK0FZ8.js.map +1 -0
- package/dist/utils/backgroundColor/backgroundColor.js +1 -1
- package/dist/utils/border/border.js +1 -1
- package/dist/utils/date/date.js +1 -1
- package/dist/utils/flex/flex.js +1 -1
- package/dist/utils/focus/focusStyles.js +1 -1
- package/dist/utils/foregroundColour/foregroundColor.js +1 -1
- package/dist/utils/forms/field.js +1 -1
- package/dist/utils/forms/input/input.js +1 -1
- package/dist/utils/padding/padding.js +1 -1
- package/dist/utils/position/position.js +1 -1
- package/dist/utils/stories/DraggableContainer.js +2 -2
- package/dist/utils/stories/DraggableContainer.js.map +1 -1
- package/package.json +10 -5
- package/dist/CalendarDate-B7n_TjYa.js +0 -2
- package/dist/CalendarDate-B7n_TjYa.js.map +0 -1
- package/dist/DateField-oLDKE7Lh.js.map +0 -1
- package/dist/DatePicker.module-CGXPuf59.js +0 -2
- package/dist/DatePicker.module-CGXPuf59.js.map +0 -1
- package/dist/index-DiYWUa65.js +0 -2
- package/dist/react-number-format.es-7RDg5nwN.js +0 -2
- package/dist/react-number-format.es-7RDg5nwN.js.map +0 -1
- package/dist/useCalendarState-C9LlCwg-.js +0 -2
- package/dist/useCalendarState-C9LlCwg-.js.map +0 -1
- package/dist/useControlledState-DCczKDCM.js +0 -2
- package/dist/useControlledState-DCczKDCM.js.map +0 -1
- package/dist/useFormValidationState-CqKt4CQY.js +0 -2
- package/dist/useFormValidationState-CqKt4CQY.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AviosCurrency.js","sources":["../../../src/components/AviosCurrency/AviosCurrency.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport styles from './AviosCurrency.module.css';\nimport { cva } from 'class-variance-authority';\nimport AviosCurrencySymbol, {\n type AviosCurrencySymbolProps,\n} from '../AviosCurrencySymbol';\nimport Icon, { IconSize } from '../Icon/Icon';\n\nconst aviosCurrency = cva(styles
|
|
1
|
+
{"version":3,"file":"AviosCurrency.js","sources":["../../../src/components/AviosCurrency/AviosCurrency.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport styles from './AviosCurrency.module.css';\nimport { cva } from 'class-variance-authority';\nimport AviosCurrencySymbol, {\n type AviosCurrencySymbolProps,\n} from '../AviosCurrencySymbol';\nimport Icon, { IconSize } from '../Icon/Icon';\n\nconst aviosCurrency = cva(styles['avios-currency'], {\n variants: {\n styleVariant: {\n primary: styles['avios-currency--primary'],\n secondary: styles['avios-currency--secondary'],\n white: styles['avios-currency--white'],\n onSpend: styles['avios-currency--on-spend'],\n onCollect: styles['avios-currency--on-collect'],\n accentPrimary: styles['avios-currency--accent-primary'],\n accentSecondary: styles['avios-currency--accent-secondary'],\n },\n size: {\n xl: styles['avios-currency--xl'],\n lg: styles['avios-currency--lg'],\n md: styles['avios-currency--md'],\n sm: styles['avios-currency--sm'],\n xs: styles['avios-currency--xs'],\n '2xs': styles['avios-currency--2xs'],\n '3xs': styles['avios-currency--3xs'],\n '4xs': styles['avios-currency--4xs'],\n '5xs': styles['avios-currency--5xs'],\n },\n isStrikethrough: {\n true: styles['avios-currency--strikethrough'],\n false: '',\n },\n },\n defaultVariants: {\n styleVariant: 'accentSecondary',\n },\n});\n\nexport interface AviosCurrencyProps\n extends Omit<AviosCurrencySymbolProps, 'styleVariant'> {\n children?: number;\n /**\n * The style variant of the Avios currency\n */\n styleVariant?: AviosCurrencySymbolProps['styleVariant'];\n /**\n * The size of the Avios currency\n */\n size?: 'xl' | 'lg' | 'md' | 'sm' | 'xs' | '2xs' | '3xs' | '4xs' | '5xs';\n /**\n * Whether to display the currency name \" Avios\"\n */\n hasCurrencyName?: boolean;\n /**\n * The decorator to display\n */\n decorator?: 'link' | 'dropdown';\n /**\n * Whether to display the Avios currency as a strikethrough\n */\n isStrikethrough?: boolean;\n}\n\nexport function getIconSize(size: AviosCurrencyProps['size']): IconSize {\n switch (size) {\n case 'sm':\n return '0.75x';\n case '2xs':\n case '3xs':\n case '4xs':\n case '5xs':\n return '0.5x';\n default:\n return '1x';\n }\n}\n\nexport const AviosCurrency = ({\n children = 0,\n styleVariant = 'accentSecondary',\n kind = 'balance',\n size = 'xl',\n hasCurrencyName = false,\n decorator,\n isStrikethrough = false,\n ...props\n}: AviosCurrencyProps) => {\n const formattedChildren = new Intl.NumberFormat('en-GB', {\n style: 'decimal',\n maximumFractionDigits: 0,\n }).format(children);\n\n const { isLink, isDropdown } = useMemo(() => {\n if (decorator === 'link') {\n return { isLink: true, isDropdown: false };\n }\n if (decorator === 'dropdown') {\n return { isLink: false, isDropdown: true };\n }\n return { isLink: false, isDropdown: false };\n }, [decorator]);\n\n const iconSize = useMemo(() => getIconSize(size), [size]);\n\n return (\n <span className={aviosCurrency({ styleVariant, size, isStrikethrough })}>\n <AviosCurrencySymbol {...props} styleVariant={styleVariant} kind={kind} />\n <span className={styles.aviosCurrency__points}>{formattedChildren}</span>\n {isLink && (\n <Icon iconName=\"chevron-right\" iconSize={iconSize} data-testid=\"icon\" />\n )}\n {isDropdown && (\n <Icon\n iconName=\"angles-up-down\"\n iconSize={iconSize}\n data-testid=\"icon\"\n />\n )}\n {hasCurrencyName && (\n <span className={styles['avios-currency__name']}>Avios</span>\n )}\n </span>\n );\n};\n\nexport default AviosCurrency;\n"],"names":["aviosCurrency","cva","styles","variants","styleVariant","primary","secondary","white","onSpend","onCollect","accentPrimary","accentSecondary","size","xl","lg","md","sm","xs","isStrikethrough","true","false","defaultVariants","getIconSize","AviosCurrency","children","kind","hasCurrencyName","decorator","props","formattedChildren","Intl","NumberFormat","style","maximumFractionDigits","format","isLink","isDropdown","useMemo","iconSize","jsxs","className","AviosCurrencySymbol","jsx","aviosCurrency__points","Icon","iconName"],"mappings":"y2CAQMA,EAAgBC,EAAIC,EAAO,kBAAmB,CAClDC,SAAU,CACRC,aAAc,CACZC,QAASH,EAAO,2BAChBI,UAAWJ,EAAO,6BAClBK,MAAOL,EAAO,yBACdM,QAASN,EAAO,4BAChBO,UAAWP,EAAO,8BAClBQ,cAAeR,EAAO,kCACtBS,gBAAiBT,EAAO,qCAE1BU,KAAM,CACJC,GAAIX,EAAO,sBACXY,GAAIZ,EAAO,sBACXa,GAAIb,EAAO,sBACXc,GAAId,EAAO,sBACXe,GAAIf,EAAO,sBACX,MAAOA,EAAO,uBACd,MAAOA,EAAO,uBACd,MAAOA,EAAO,uBACd,MAAOA,EAAO,wBAEhBgB,gBAAiB,CACfC,KAAMjB,EAAO,iCACbkB,MAAO,KAGXC,gBAAiB,CACfjB,aAAc,qBA6BX,SAASkB,EAAYV,GAC1B,OAAQA,GACN,IAAK,KACH,MAAO,QACT,IAAK,MACL,IAAK,MACL,IAAK,MACL,IAAK,MACH,MAAO,OACT,QACE,MAAO,KAEb,CAEO,MAAMW,EAAgB,EAC3BC,WAAW,EACXpB,eAAe,kBACfqB,OAAO,UACPb,OAAO,KACPc,mBAAkB,EAClBC,YACAT,mBAAkB,KACfU,MAEH,MAAMC,EAAoB,IAAIC,KAAKC,aAAa,QAAS,CACvDC,MAAO,UACPC,sBAAuB,IACtBC,OAAOV,IAEJW,OAAEA,EAAAC,WAAQA,GAAeC,EAAQ,IACnB,SAAdV,EACK,CAAEQ,QAAQ,EAAMC,YAAY,GAEnB,aAAdT,EACK,CAAEQ,QAAQ,EAAOC,YAAY,GAE/B,CAAED,QAAQ,EAAOC,YAAY,GACnC,CAACT,IAEEW,EAAWD,EAAQ,IAAMf,EAAYV,GAAO,CAACA;AAEnD,OACE2B,EAAC,QAAKC,UAAWxC,EAAc,CAAEI,eAAcQ,OAAMM,oBACnDM,SAAA;iBAACiB,EAAA,IAAwBb,EAAOxB,eAA4BqB;eAC5DiB,EAAC,OAAA,CAAKF,UAAWtC,EAAOyC,sBAAwBnB,SAAAK,IAC/CM,oBACES,EAAA,CAAKC,SAAS,gBAAgBP,WAAoB,cAAY,SAEhEF,kBACCM,EAACE,EAAA,CACCC,SAAS,iBACTP,WACA,cAAY,SAGfZ,kBACCgB,EAAC,OAAA,CAAKF,UAAWtC,EAAO,wBAAyBsB,SAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{jsxs as e,jsx as
|
|
2
|
-
return e("span",{"data-testid":"avios-currency-badge","aria-label":
|
|
1
|
+
import{jsxs as e,jsx as s}from"react/jsx-runtime";import{AviosCurrency as d}from"../AviosCurrency/AviosCurrency.js";import{c as r}from"../../index-CCUt_dAN.js";import{useMemo as a,isValidElement as i}from"react";import '../../assets/AviosCurrencyBadge.css';const o="_avios-currency-badge__text--xs-bold_1d5jx_78",t="_avios-currency-badge__text--sm-bold_1d5jx_79",c="_avios-currency-badge__text--md-bold_1d5jx_80",l="_avios-currency-badge__text--lg-bold_1d5jx_81",n="_avios-currency-badge__text--xl-bold_1d5jx_85",_="_avios-currency-badge__text_1d5jx_78",x=r("_avios-currency-badge_1d5jx_1",{variants:{size:{xs:"_avios-currency-badge--xs_1d5jx_28",sm:"_avios-currency-badge--sm_1d5jx_35",md:"_avios-currency-badge--md_1d5jx_47",lg:"_avios-currency-badge--lg_1d5jx_59",xl:"_avios-currency-badge--xl_1d5jx_71"},kind:{collect:"_avios-currency-badge--collect_1d5jx_16",spend:"_avios-currency-badge--spend_1d5jx_21"}},defaultVariants:{size:"md",kind:"collect"}}),m=r(_,{variants:{size:{xs:void 0,sm:void 0,md:void 0,lg:void 0,xl:void 0},bold:{true:void 0,false:void 0}},defaultVariants:{size:"md",bold:!1},compoundVariants:[{size:"xs",bold:!0,className:o},{size:"sm",bold:!0,className:t},{size:"md",bold:!0,className:c},{size:"lg",bold:!0,className:l},{size:"xl",bold:!0,className:n}]}),b=["xs","sm","md","lg","xl"],u={xs:"5xs",sm:"4xs",md:"3xs",lg:"2xs",xl:"xs"};function v(e){return"string"==typeof e||"number"==typeof e?String(e):Array.isArray(e)?e.map(v).join(" "):i(e)&&e.props&&e.props.children?v(e.props.children):""}const g=({kind:r="collect",size:i="md",textStart:o,textEnd:t,textStartBold:c=!1,textEndBold:l=!1,ariaLabel:n,role:_,children:b=0,...g})=>{const y=b.toLocaleString(),p=a(()=>{if(n)return n;const e=y??"";return`${v(o)||""} ${e} Avios ${v(t)||""}`.trim()},[n,o,t,y]),j=u[i]??"3xs";/* @__PURE__ */
|
|
2
|
+
return e("span",{"data-testid":"avios-currency-badge","aria-label":p,role:_||void 0,className:x({size:i,kind:r}),children:[o&&/* @__PURE__ */s("span",{className:m({size:i,bold:c}),children:o}),"number"==typeof b&&/* @__PURE__ */s(d,{"aria-hidden":!0,styleVariant:"collect"===r?"onCollect":"onSpend",size:j,kind:r,...g,children:b}),t&&/* @__PURE__ */s("span",{className:m({size:i,bold:l}),children:t})]})};export{g as AviosCurrencyBadge,b as BADGE_SIZES,g as default,m as textCva};
|
|
3
3
|
//# sourceMappingURL=AviosCurrencyBadge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AviosCurrencyBadge.js","sources":["../../../src/components/AviosCurrencyBadge/AviosCurrencyBadge.tsx"],"sourcesContent":["import styles from './AviosCurrencyBadge.module.css';\nimport AviosCurrency, {\n AviosCurrencyProps,\n} from '../AviosCurrency/AviosCurrency';\nimport { cva } from 'class-variance-authority';\nimport { useMemo, type ReactNode, isValidElement } from 'react';\n\nconst aviosCurrencyBadge = cva(styles
|
|
1
|
+
{"version":3,"file":"AviosCurrencyBadge.js","sources":["../../../src/components/AviosCurrencyBadge/AviosCurrencyBadge.tsx"],"sourcesContent":["import styles from './AviosCurrencyBadge.module.css';\nimport AviosCurrency, {\n AviosCurrencyProps,\n} from '../AviosCurrency/AviosCurrency';\nimport { cva } from 'class-variance-authority';\nimport { useMemo, type ReactNode, isValidElement } from 'react';\n\nconst aviosCurrencyBadge = cva(styles['avios-currency-badge'], {\n variants: {\n size: {\n xs: styles['avios-currency-badge--xs'],\n sm: styles['avios-currency-badge--sm'],\n md: styles['avios-currency-badge--md'],\n lg: styles['avios-currency-badge--lg'],\n xl: styles['avios-currency-badge--xl'],\n },\n kind: {\n collect: styles['avios-currency-badge--collect'],\n spend: styles['avios-currency-badge--spend'],\n },\n },\n defaultVariants: {\n size: 'md',\n kind: 'collect',\n },\n});\n\nexport const textCva = cva(styles['avios-currency-badge__text'], {\n variants: {\n // we pull in size so we can fire off the .xs-bold/.sm-bold/etc macros\n size: {\n xs: undefined,\n sm: undefined,\n md: undefined,\n lg: undefined,\n xl: undefined,\n },\n bold: {\n true: undefined,\n false: undefined,\n },\n },\n defaultVariants: {\n size: 'md',\n bold: false,\n },\n compoundVariants: [\n {\n size: 'xs',\n bold: true,\n className: styles['avios-currency-badge__text--xs-bold'],\n },\n {\n size: 'sm',\n bold: true,\n className: styles['avios-currency-badge__text--sm-bold'],\n },\n {\n size: 'md',\n bold: true,\n className: styles['avios-currency-badge__text--md-bold'],\n },\n {\n size: 'lg',\n bold: true,\n className: styles['avios-currency-badge__text--lg-bold'],\n },\n {\n size: 'xl',\n bold: true,\n className: styles['avios-currency-badge__text--xl-bold'],\n },\n ],\n});\n\nexport const BADGE_SIZES = ['xs', 'sm', 'md', 'lg', 'xl'] as const;\nexport type BadgeSize = (typeof BADGE_SIZES)[number];\n\nexport interface AviosCurrencyBadgeProps\n extends Omit<\n AviosCurrencyProps,\n 'isStrikethrough' | 'decorator' | 'styleVariant'\n > {\n /**\n * The kind of Avios badge (collect or spend)\n * @default 'collect'\n */\n kind?: 'collect' | 'spend';\n /**\n * Additional content to be displayed at the start of the badge\n */\n textStart?: ReactNode;\n /**\n * Additional content to be displayed at the end of the badge\n */\n textEnd?: ReactNode;\n /**\n * Whether the text at the start of the badge should be bold\n * @default false\n */\n textStartBold?: boolean;\n /**\n * Whether the text at the end of the badge should be bold\n * @default false\n */\n textEndBold?: boolean;\n /**\n * Size of the badge\n * @default 'md'\n */\n size?: BadgeSize;\n /**\n * A string representation of the badge's contents, used for accessibility\n * Example: \"Collect 50,000 Avios points\"\n */\n ariaLabel?: string;\n /**\n * ARIA role for the badge container. This should only be used when changes to the currency badge need to be announced.\n */\n role?: string;\n /**\n * Number of Avios points\n */\n children?: number;\n}\n\nconst sizeMap: Record<BadgeSize, AviosCurrencyProps['size']> = {\n xs: '5xs',\n sm: '4xs',\n md: '3xs',\n lg: '2xs',\n xl: 'xs',\n};\n\nfunction extractText(node: ReactNode): string {\n if (typeof node === 'string' || typeof node === 'number') return String(node);\n if (Array.isArray(node)) return node.map(extractText).join(' ');\n if (isValidElement(node) && node.props && node.props.children) {\n return extractText(node.props.children);\n }\n return '';\n}\n\nexport const AviosCurrencyBadge = ({\n kind = 'collect',\n size = 'md',\n textStart,\n textEnd,\n textStartBold = false,\n textEndBold = false,\n ariaLabel,\n role,\n children = 0,\n ...props\n}: AviosCurrencyBadgeProps) => {\n const formattedPoints = children.toLocaleString();\n\n const computedAriaLabel = useMemo(() => {\n if (ariaLabel) return ariaLabel;\n\n const formatted = formattedPoints ?? '';\n const startText = extractText(textStart);\n const endText = extractText(textEnd);\n return `${startText || ''} ${formatted} Avios ${endText || ''}`.trim();\n }, [ariaLabel, textStart, textEnd, formattedPoints]);\n\n const aviosCurrencySize = sizeMap[size] ?? '3xs';\n\n return (\n <span\n data-testid=\"avios-currency-badge\"\n aria-label={computedAriaLabel}\n role={role || undefined}\n className={aviosCurrencyBadge({\n size,\n kind,\n })}\n >\n {textStart && (\n <span className={textCva({ size, bold: textStartBold })}>\n {textStart}\n </span>\n )}\n {typeof children === 'number' && (\n <AviosCurrency\n aria-hidden\n styleVariant={kind === 'collect' ? 'onCollect' : 'onSpend'}\n size={aviosCurrencySize}\n kind={kind}\n {...props}\n >\n {children}\n </AviosCurrency>\n )}\n {textEnd && (\n <span className={textCva({ size, bold: textEndBold })}>{textEnd}</span>\n )}\n </span>\n );\n};\n\nexport default AviosCurrencyBadge;\n"],"names":["aviosCurrencyBadge","cva","variants","size","xs","sm","md","lg","xl","kind","collect","spend","defaultVariants","textCva","styles","bold","true","false","compoundVariants","className","BADGE_SIZES","sizeMap","extractText","node","String","Array","isArray","map","join","isValidElement","props","children","AviosCurrencyBadge","textStart","textEnd","textStartBold","textEndBold","ariaLabel","role","formattedPoints","toLocaleString","computedAriaLabel","useMemo","formatted","trim","aviosCurrencySize","jsxs","jsx","AviosCurrency","styleVariant"],"mappings":"6fAOMA,EAAqBC,kCAAoC,CAC7DC,SAAU,CACRC,KAAM,CACJC,wCACAC,wCACAC,wCACAC,wCACAC,yCAEFC,KAAM,CACJC,kDACAC,gDAGJC,gBAAiB,CACfT,KAAM,KACNM,KAAM,aAIGI,EAAUZ,EAAIa,EAAsC,CAC/DZ,SAAU,CAERC,KAAM,CACJC,QAAI,EACJC,QAAI,EACJC,QAAI,EACJC,QAAI,EACJC,QAAI,GAENO,KAAM,CACJC,UAAM,EACNC,WAAO,IAGXL,gBAAiB,CACfT,KAAM,KACNY,MAAM,GAERG,iBAAkB,CAChB,CACEf,KAAM,KACNY,MAAM,EACNI,UAAWL,GAEb,CACEX,KAAM,KACNY,MAAM,EACNI,UAAWL,GAEb,CACEX,KAAM,KACNY,MAAM,EACNI,UAAWL,GAEb,CACEX,KAAM,KACNY,MAAM,EACNI,UAAWL,GAEb,CACEX,KAAM,KACNY,MAAM,EACNI,UAAWL,MAKJM,EAAc,CAAC,KAAM,KAAM,KAAM,KAAM,MAmD9CC,EAAyD,CAC7DjB,GAAI,MACJC,GAAI,MACJC,GAAI,MACJC,GAAI,MACJC,GAAI,MAGN,SAASc,EAAYC,GACnB,MAAoB,iBAATA,GAAqC,iBAATA,EAA0BC,OAAOD,GACpEE,MAAMC,QAAQH,GAAcA,EAAKI,IAAIL,GAAaM,KAAK,KACvDC,EAAeN,IAASA,EAAKO,OAASP,EAAKO,MAAMC,SAC5CT,EAAYC,EAAKO,MAAMC,UAEzB,EACT,CAEO,MAAMC,EAAqB,EAChCvB,OAAO,UACPN,OAAO,KACP8B,YACAC,UACAC,iBAAgB,EAChBC,eAAc,EACdC,YACAC,OACAP,WAAW,KACRD,MAEH,MAAMS,EAAkBR,EAASS,iBAE3BC,EAAoBC,EAAQ,KAChC,GAAIL,EAAW,OAAOA,EAEtB,MAAMM,EAAYJ,GAAmB,GAGrC,MAAO,GAFWjB,EAAYW,IAEP,MAAMU,WADbrB,EAAYY,IAC+B,KAAKU,QAC/D,CAACP,EAAWJ,EAAWC,EAASK,IAE7BM,EAAoBxB,EAAQlB,IAAS;AAE3C,OACE2C,EAAC,OAAA,CACC,cAAY,uBACZ,aAAYL,EACZH,KAAMA,QAAQ,EACdnB,UAAWnB,EAAmB,CAC5BG,OACAM,SAGDsB,SAAA,CAAAE,kBACCc,EAAC,OAAA,CAAK5B,UAAWN,EAAQ,CAAEV,OAAMY,KAAMoB,IACpCJ,SAAAE,IAGgB,iBAAbF,kBACNgB,EAACC,EAAA,CACC,eAAW,EACXC,aAAuB,YAATxC,EAAqB,YAAc,UACjDN,KAAM0C,EACNpC,UACIqB,EAEHC,aAGJG,kBACCa,EAAC,OAAA,CAAK5B,UAAWN,EAAQ,CAAEV,OAAMY,KAAMqB,IAAiBL,SAAAG"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{jsxs as
|
|
2
|
-
return
|
|
3
|
-
return
|
|
4
|
-
return
|
|
5
|
-
/* @__PURE__ */
|
|
6
|
-
/* @__PURE__ */
|
|
1
|
+
import{jsxs as a,jsx as r}from"react/jsx-runtime";import e from"react";import{c as i}from"../../index-CCUt_dAN.js";import '../../assets/AviosCurrencySymbol.css';const c=i("_avios-currency-symbol_dvvi8_1",{variants:{styleVariant:{primary:"_avios-currency-symbol--primary_dvvi8_4",secondary:"_avios-currency-symbol--secondary_dvvi8_14",white:"_avios-currency-symbol--white_dvvi8_24",onSpend:"_avios-currency-symbol--on-spend_dvvi8_34",onCollect:"_avios-currency-symbol--on-collect_dvvi8_44",accentPrimary:"_avios-currency-symbol--accent-primary_dvvi8_54",accentSecondary:"_avios-currency-symbol--accent-secondary_dvvi8_64"}},defaultVariants:{styleVariant:"primary"}}),t=({kind:a="collect"})=>{switch(a){case"collect":/* @__PURE__ */
|
|
2
|
+
return r("path",{fill:"currentColor",d:"M7.562 11.188a.317.317 0 0 0 .317-.318V8.648h2.222a.317.317 0 0 0 .317-.317V7.06a.317.317 0 0 0-.317-.317H7.879V4.522a.317.317 0 0 0-.317-.318h-1.27a.317.317 0 0 0-.317.318v2.222H3.752a.317.317 0 0 0-.317.317v1.27c0 .175.142.317.317.317h2.223v2.222c0 .175.142.318.317.318z"});case"spend":/* @__PURE__ */
|
|
3
|
+
return r("path",{fill:"currentColor",d:"M9.288 4.914a.3.3 0 0 1 .056.005.27.27 0 0 1 .217.268v4.371a.273.273 0 0 1-.273.273H8.195a.273.273 0 0 1-.273-.273V7.712l-3.265 3.265a.273.273 0 0 1-.386 0l-.773-.773a.273.273 0 0 1 0-.386l3.265-3.265H4.917a.273.273 0 0 1-.274-.273V5.187c0-.151.123-.273.274-.273z"});case"balance":return null}},n={width:"24px",height:"24px"},l=({kind:i="collect",styleVariant:l="accentPrimary",width:o,height:s,label:d,...v})=>{const y=e.useMemo(()=>o&&s?{width:o,height:s}:o?{width:o,height:o}:s?{width:s,height:s}:n,[o,s]),h=d||v["aria-label"];/* @__PURE__ */
|
|
4
|
+
return a("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0.82 0.52 14.00 14.02",className:c({styleVariant:l}),"aria-label":h,"aria-hidden":v["aria-hidden"]??!0,role:v["aria-hidden"]?void 0:"img",...y,...v,children:[
|
|
5
|
+
/* @__PURE__ */r("path",{fill:"#0032A0",d:"M14.512 5.968C14.025 5.127 9.659.865 4.364.526c-.923-.06-1.797.448-2.18 1.262-1.01 2.17-2.246 7.022-.459 11.442a2.06 2.06 0 0 0 1.94 1.312c.098 0 .191-.005.29-.016 6.043-.744 9.923-4.946 10.579-6.306.246-.514.508-1.3-.033-2.24z"}),
|
|
6
|
+
/* @__PURE__ */r(t,{kind:i})]})};l.displayName="AviosCurrencySymbol";export{l as AviosCurrencySymbol,l as default};
|
|
7
7
|
//# sourceMappingURL=AviosCurrencySymbol.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AviosCurrencySymbol.js","sources":["../../../src/components/AviosCurrencySymbol/AviosCurrencySymbol.tsx"],"sourcesContent":["import React from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport styles from './AviosCurrencySymbol.module.css';\n\nconst aviosCurrencySymbol = cva(styles
|
|
1
|
+
{"version":3,"file":"AviosCurrencySymbol.js","sources":["../../../src/components/AviosCurrencySymbol/AviosCurrencySymbol.tsx"],"sourcesContent":["import React from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport styles from './AviosCurrencySymbol.module.css';\n\nconst aviosCurrencySymbol = cva(styles['avios-currency-symbol'], {\n variants: {\n styleVariant: {\n primary: styles['avios-currency-symbol--primary'],\n secondary: styles['avios-currency-symbol--secondary'],\n white: styles['avios-currency-symbol--white'],\n onSpend: styles['avios-currency-symbol--on-spend'],\n onCollect: styles['avios-currency-symbol--on-collect'],\n accentPrimary: styles['avios-currency-symbol--accent-primary'],\n accentSecondary: styles['avios-currency-symbol--accent-secondary'],\n },\n },\n defaultVariants: {\n styleVariant: 'primary',\n },\n});\n\nexport type AviosCurrencySymbolVariants = VariantProps<\n typeof aviosCurrencySymbol\n>;\n\nexport type AviosCurrencySymbolKind = 'collect' | 'spend' | 'balance';\nexport type AviosCurrencySymbolStyleVariant =\n | 'primary'\n | 'secondary'\n | 'white'\n | 'onSpend'\n | 'onCollect'\n | 'accentPrimary'\n | 'accentSecondary';\n\nexport interface AviosCurrencySymbolProps\n extends Omit<React.SVGProps<SVGSVGElement>, 'fill' | 'className' | 'style'> {\n /**\n * The style variant to use for the Avios currency symbol\n * @default 'primary'\n */\n styleVariant?: AviosCurrencySymbolStyleVariant;\n /**\n * The kind of Avios currency to display \"collect\", \"spend\", or \"balance\"\n * @default 'collect'\n */\n kind?: AviosCurrencySymbolKind;\n /**\n * The screen reader label to use for the SVG element\n * @default \"Avios ${kind} currency symbol\"\n * @deprecated Use `aria-label` instead\n */\n label?: string;\n}\n\nconst AviosCurrencyKindPath = ({\n kind = 'collect',\n}: Pick<AviosCurrencySymbolProps, 'kind'>) => {\n switch (kind) {\n case 'collect':\n return (\n <path\n fill=\"currentColor\"\n d=\"M7.562 11.188a.317.317 0 0 0 .317-.318V8.648h2.222a.317.317 0 0 0 .317-.317V7.06a.317.317 0 0 0-.317-.317H7.879V4.522a.317.317 0 0 0-.317-.318h-1.27a.317.317 0 0 0-.317.318v2.222H3.752a.317.317 0 0 0-.317.317v1.27c0 .175.142.317.317.317h2.223v2.222c0 .175.142.318.317.318z\"\n />\n );\n case 'spend':\n return (\n <path\n fill=\"currentColor\"\n d=\"M9.288 4.914a.3.3 0 0 1 .056.005.27.27 0 0 1 .217.268v4.371a.273.273 0 0 1-.273.273H8.195a.273.273 0 0 1-.273-.273V7.712l-3.265 3.265a.273.273 0 0 1-.386 0l-.773-.773a.273.273 0 0 1 0-.386l3.265-3.265H4.917a.273.273 0 0 1-.274-.273V5.187c0-.151.123-.273.274-.273z\"\n />\n );\n case 'balance':\n return null;\n }\n};\n\nconst DEFAULT_DIMENSIONS = {\n width: '24px',\n height: '24px',\n};\n\nexport const AviosCurrencySymbol = ({\n kind = 'collect',\n styleVariant = 'accentPrimary',\n width,\n height,\n label,\n ...props\n}: AviosCurrencySymbolProps) => {\n // Handle custom dimensions from props\n const dimensions = React.useMemo(() => {\n if (width && height) {\n return {\n width,\n height,\n };\n }\n\n if (width) {\n return {\n width,\n height: width,\n };\n }\n\n if (height) {\n return {\n width: height,\n height: height,\n };\n }\n\n return DEFAULT_DIMENSIONS;\n }, [width, height]);\n\n // TODO: Remove deprecated `label` prop in future major release\n const screenReaderLabel = label || props['aria-label'];\n\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0.82 0.52 14.00 14.02\"\n className={aviosCurrencySymbol({ styleVariant })}\n aria-label={screenReaderLabel}\n aria-hidden={props['aria-hidden'] ?? true}\n role={props['aria-hidden'] ? undefined : 'img'}\n {...dimensions}\n {...props}\n >\n <path\n fill=\"#0032A0\"\n d=\"M14.512 5.968C14.025 5.127 9.659.865 4.364.526c-.923-.06-1.797.448-2.18 1.262-1.01 2.17-2.246 7.022-.459 11.442a2.06 2.06 0 0 0 1.94 1.312c.098 0 .191-.005.29-.016 6.043-.744 9.923-4.946 10.579-6.306.246-.514.508-1.3-.033-2.24z\"\n ></path>\n <AviosCurrencyKindPath kind={kind} />\n </svg>\n );\n};\n\nAviosCurrencySymbol.displayName = 'AviosCurrencySymbol';\nexport default AviosCurrencySymbol;\n"],"names":["aviosCurrencySymbol","cva","variants","styleVariant","primary","secondary","white","onSpend","onCollect","accentPrimary","accentSecondary","defaultVariants","AviosCurrencyKindPath","kind","jsx","fill","d","DEFAULT_DIMENSIONS","width","height","AviosCurrencySymbol","label","props","dimensions","React","useMemo","screenReaderLabel","jsxs","xmlns","viewBox","className","role","children","displayName"],"mappings":"yHAIMA,EAAsBC,mCAAqC,CAC/DC,SAAU,CACRC,aAAc,CACZC,kDACAC,uDACAC,+CACAC,oDACAC,wDACAC,gEACAC,sEAGJC,gBAAiB,CACfR,aAAc,aAsCZS,EAAwB,EAC5BC,OAAO,cAEP,OAAQA,GACN,IAAK;AACH,OACEC,EAAC,OAAA,CACCC,KAAK,eACLC,EAAE,qRAGR,IAAK;AACH,OACEF,EAAC,OAAA,CACCC,KAAK,eACLC,EAAE,4QAGR,IAAK,UACH,OAAO,OAIPC,EAAqB,CACzBC,MAAO,OACPC,OAAQ,QAGGC,EAAsB,EACjCP,OAAO,UACPV,eAAe,gBACfe,QACAC,SACAE,WACGC,MAGH,MAAMC,EAAaC,EAAMC,QAAQ,IAC3BP,GAASC,EACJ,CACLD,QACAC,UAIAD,EACK,CACLA,QACAC,OAAQD,GAIRC,EACK,CACLD,MAAOC,EACPA,UAIGF,EACN,CAACC,EAAOC,IAGLO,EAAoBL,GAASC,EAAM;AAEzC,OACEK,EAAC,MAAA,CACCC,MAAM,6BACNb,KAAK,OACLc,QAAQ,wBACRC,UAAW9B,EAAoB,CAAEG,iBACjC,aAAYuB,EACZ,cAAaJ,EAAM,iBAAkB,EACrCS,KAAMT,EAAM,oBAAiB,EAAY,SACrCC,KACAD,EAEJU,SAAA;eAAAlB,EAAC,OAAA,CACCC,KAAK,UACLC,EAAE;eAEJF,EAACF,GAAsBC,aAK7BO,EAAoBa,YAAc"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{jsxs as
|
|
2
|
-
return
|
|
1
|
+
import{jsxs as a,jsx as e}from"react/jsx-runtime";import{c as s}from"../../index-CCUt_dAN.js";import{Icon as t}from"../Icon/Icon.js";import{focusStyleVariants as i}from"../../utils/focus/focusStyles.js";import '../../assets/Badge.css';const r=s("_badge_1xfg2_1",{variants:{size:{sm:"_badge--sm_1xfg2_24",md:"_badge--md_1xfg2_15"},styleVariant:{neutral:"_badge--neutral_1xfg2_33",critical:"_badge--critical_1xfg2_38",warning:"_badge--warning_1xfg2_43",caution:"_badge--caution_1xfg2_48",success:"_badge--success_1xfg2_53",info:"_badge--info_1xfg2_58",brand:"_badge--brand_1xfg2_63",sale:"_badge--sale_1xfg2_68",white:"_badge--white_1xfg2_73"}},defaultVariants:{size:"md",styleVariant:"neutral"}}),_=({children:s,size:_="md",styleVariant:n,ariaLabel:d,iconStartProps:c,iconEndProps:g,focusStyle:o="default",className:f,...l})=>{const u={iconSize:"md"===_?"0.75x":"0.5x",iconPrefix:"fas",padding:"square"};/* @__PURE__ */
|
|
2
|
+
return a("span",{"data-testid":"badge",className:`${r({size:_,styleVariant:n})} ${i({focusStyle:o})} ${f||""}`,role:"status","aria-label":d,...l,children:[c&&/* @__PURE__ */e(t,{...{...u,...c}}),s,g&&/* @__PURE__ */e(t,{...{...u,...g}})]})};export{_ as Badge,_ as default};
|
|
3
3
|
//# sourceMappingURL=Badge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","sources":["../../../src/components/Badge/Badge.tsx"],"sourcesContent":["import React from 'react';\nimport { cva } from 'class-variance-authority';\nimport { Icon, IconProps } from '../Icon/Icon';\nimport styles from './Badge.module.css';\nimport { focusStyleVariants } from '../../utils/focus/focusStyles';\n\nconst badge = cva(styles.badge, {\n variants: {\n size: {\n sm: styles
|
|
1
|
+
{"version":3,"file":"Badge.js","sources":["../../../src/components/Badge/Badge.tsx"],"sourcesContent":["import React from 'react';\nimport { cva } from 'class-variance-authority';\nimport { Icon, IconProps } from '../Icon/Icon';\nimport styles from './Badge.module.css';\nimport { focusStyleVariants } from '../../utils/focus/focusStyles';\n\nconst badge = cva(styles.badge, {\n variants: {\n size: {\n sm: styles['badge--sm'],\n md: styles['badge--md'],\n },\n styleVariant: {\n neutral: styles['badge--neutral'],\n critical: styles['badge--critical'],\n warning: styles['badge--warning'],\n caution: styles['badge--caution'],\n success: styles['badge--success'],\n info: styles['badge--info'],\n brand: styles['badge--brand'],\n sale: styles['badge--sale'],\n white: styles['badge--white'],\n },\n },\n defaultVariants: {\n size: 'md',\n styleVariant: 'neutral',\n },\n});\n\nexport interface BadgeProps {\n /**\n * The children of the component\n */\n children?: React.ReactNode;\n /**\n * A string representation of the tag's contents, used for accessibility.\n */\n ariaLabel?: string;\n /**\n * The size of the tag\n */\n size?: 'sm' | 'md';\n /**\n * The style variant of the tag\n */\n styleVariant?:\n | 'neutral'\n | 'critical'\n | 'warning'\n | 'caution'\n | 'success'\n | 'info'\n | 'brand'\n | 'sale'\n | 'white';\n /**\n * Whether an icon should display at the start of the Button and icon properties\n */\n iconStartProps?: IconProps;\n /**\n * Whether an icon should display at the end of Button and icon properties\n */\n iconEndProps?: IconProps;\n /**\n * The focus style of the button\n */\n focusStyle?: 'default' | 'white';\n /**\n * @internal\n * Internal className prop for design system use only\n */\n className?: string;\n}\n\nexport const Badge = ({\n children,\n size = 'md',\n styleVariant,\n ariaLabel,\n iconStartProps,\n iconEndProps,\n focusStyle = 'default',\n className,\n ...props\n}: BadgeProps) => {\n // Set default icon props which are overwritten if passed explicity\n const defaultIconProps: Partial<IconProps> = {\n iconSize: size === 'md' ? '0.75x' : '0.5x',\n iconPrefix: 'fas',\n padding: 'square',\n };\n\n return (\n <span\n data-testid=\"badge\"\n className={`${badge({ size, styleVariant })} ${focusStyleVariants({ focusStyle })} ${className || ''}`}\n role=\"status\"\n aria-label={ariaLabel}\n {...props}\n >\n {iconStartProps && (\n <Icon {...{ ...defaultIconProps, ...iconStartProps }} />\n )}\n {children}\n {iconEndProps && <Icon {...{ ...defaultIconProps, ...iconEndProps }} />}\n </span>\n );\n};\n\nexport default Badge;\n"],"names":["badge","cva","variants","size","sm","md","styleVariant","neutral","critical","warning","caution","success","info","brand","sale","white","defaultVariants","Badge","children","ariaLabel","iconStartProps","iconEndProps","focusStyle","className","props","defaultIconProps","iconSize","iconPrefix","padding","jsxs","focusStyleVariants","role","jsx","Icon"],"mappings":"iNAMMA,EAAQC,mBAAkB,CAC9BC,SAAU,CACRC,KAAM,CACJC,yBACAC,0BAEFC,aAAc,CACZC,mCACAC,qCACAC,mCACAC,mCACAC,mCACAC,6BACAC,+BACAC,6BACAC,iCAGJC,gBAAiB,CACfb,KAAM,KACNG,aAAc,aAiDLW,EAAQ,EACnBC,WACAf,OAAO,KACPG,eACAa,YACAC,iBACAC,eACAC,aAAa,UACbC,eACGC,MAGH,MAAMC,EAAuC,CAC3CC,SAAmB,OAATvB,EAAgB,QAAU,OACpCwB,WAAY,MACZC,QAAS;AAGX,OACEC,EAAC,OAAA,CACC,cAAY,QACZN,UAAW,GAAGvB,EAAM,CAAEG,OAAMG,oBAAmBwB,EAAmB,CAAER,kBAAiBC,GAAa,KAClGQ,KAAK,SACL,aAAYZ,KACRK,EAEHN,SAAA,CAAAE,kBACCY,EAACC,MAAS,IAAKR,KAAqBL,KAErCF,EACAG,oBAAiBY,EAAA,IAAS,IAAKR,KAAqBJ"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{jsx as o}from"react/jsx-runtime";import{backgroundColorVariants as i}from"../../utils/backgroundColor/backgroundColor.js";import{f as r,a as
|
|
2
|
-
return o(e,{className:[m.box,a({...k,borderWidth:po,borderTopWidth:lo,borderRightWidth:go,borderBottomWidth:mo,borderLeftWidth:so}),J,K,i({backgroundColor:k.backgroundColor,...k}),n({position:v}),...M,...O,...Q,...U,...Z,...$,...oo,...io,...ro,...to,...eo,...ao,...no].filter(Boolean).join(" "),style:fo,"data-testid":w,children:
|
|
1
|
+
import{jsx as o}from"react/jsx-runtime";import{backgroundColorVariants as i}from"../../utils/backgroundColor/backgroundColor.js";import{f as r,a as t}from"../../flex-BJOhaXnU.js";import{p as d,a as e}from"../../padding-nClUzhWp.js";import{borderVariants as a}from"../../utils/border/border.js";import{positionVariants as n}from"../../utils/position/position.js";import{getBaseValueOrUndefined as p,generateResponsiveClasses as l}from"../../utils/breakpoint/responsiveSSR.js";import{responsiveToCssVars as g}from"../../utils/breakpoint/responsiveToCssVars.js";import '../../assets/Box.css';const m={box:"_box_n638f_1"},s=l(t),f=l(e),h=({children:t,as:e="div",width:l,height:h,minHeight:b,zIndex:x,top:u,right:W,bottom:c,left:C,position:v,dataTestId:w="box",overflowWrap:j,wordBreak:B,...k})=>{const T=p(k.justifyContent),R=p(k.flexDirection),y=p(k.gap),G=p(k.rowGap),L=p(k.columnGap),I=p(k.alignItems),H=p(k.display),S=p(k.flexWrap),D=p(k.flexGrow),P=p(k.flexShrink),X=p(k.paddingTop),Y=p(k.paddingRight),_=p(k.paddingBottom),z=p(k.paddingLeft),N=p(k.padding),V=p(k.paddingX),q=p(k.paddingY),A=g(k.maxWidth,{varPrefix:"--box-max-width",normalise:o=>"pageWidth"===o?"var(--alto-section-container-max-width)":o}),E=g(k.maxHeight,{varPrefix:"--box-max-height",normalise:o=>o}),F=g(k.minWidth,{varPrefix:"--box-min-width",normalise:o=>o}),J=r({display:H,justifyContent:T,flexDirection:R,gap:y,rowGap:G,columnGap:L,alignItems:I,flexWrap:S,flexGrow:D,flexShrink:P}),K=d({paddingTop:X,paddingRight:Y,paddingBottom:_,paddingLeft:z,padding:N,paddingX:V,paddingY:q}),M=s(k.justifyContent,"flex-justify-content"),O=s(k.flexDirection,"flex-direction"),Q=s(k.gap,"flex-gap"),U=s(k.rowGap,"flex-row-gap"),Z=s(k.columnGap,"flex-column-gap"),$=s(k.alignItems,"flex-align-items"),oo=f(k.paddingTop,"padding-top"),io=f(k.paddingRight,"padding-right"),ro=f(k.paddingBottom,"padding-bottom"),to=f(k.paddingLeft,"padding-left"),eo=f(k.padding,"padding"),ao=f(k.paddingX,"padding-x"),no=f(k.paddingY,"padding-y"),po=k?.borderWidth||void 0===k.borderColour||"none"===k.borderColour?k.borderWidth:"sm",lo=k?.borderTopWidth||void 0===k.borderTopColour||"none"===k.borderTopColour?k.borderTopWidth:"sm",go=k?.borderRightWidth||void 0===k.borderRightColour||"none"===k.borderRightColour?k.borderRightWidth:"sm",mo=k?.borderBottomWidth||void 0===k.borderBottomColour||"none"===k.borderBottomColour?k.borderBottomWidth:"sm",so=k?.borderLeftWidth||void 0===k.borderLeftColour||"none"===k.borderLeftColour?k.borderLeftWidth:"sm",fo={width:"full"===l?"100%":l,height:"full"===h?"100%":h,minHeight:b,zIndex:x,top:u,right:W,bottom:c,left:C,...A,...F,...E,overflow:k.maxHeight||k.maxWidth?"auto":void 0,overflowWrap:j,wordBreak:B};/* @__PURE__ */
|
|
2
|
+
return o(e,{className:[m.box,a({...k,borderWidth:po,borderTopWidth:lo,borderRightWidth:go,borderBottomWidth:mo,borderLeftWidth:so}),J,K,i({backgroundColor:k.backgroundColor,...k}),n({position:v}),...M,...O,...Q,...U,...Z,...$,...oo,...io,...ro,...to,...eo,...ao,...no].filter(Boolean).join(" "),style:fo,"data-testid":w,children:t})};export{h as Box,h as default};
|
|
3
3
|
//# sourceMappingURL=Box.js.map
|
|
@@ -2,10 +2,10 @@ import { ComponentType, ElementType, ReactNode, JSX } from 'react';
|
|
|
2
2
|
import { AriaButtonOptions } from '@react-aria/button';
|
|
3
3
|
import { HoverProps } from '@react-aria/interactions';
|
|
4
4
|
import { IconProps } from '../Icon/Icon';
|
|
5
|
+
import { WithResponsiveProps } from '../../utils/breakpoint/responsiveSSR';
|
|
5
6
|
type ButtonSize = 'lg' | 'md' | 'sm';
|
|
6
7
|
type ButtonTextAlignement = 'left' | 'center' | 'right';
|
|
7
|
-
export type
|
|
8
|
-
export type ButtonProps<T extends ElementType = 'button'> = AriaButtonOptions<T> & HoverProps & {
|
|
8
|
+
export type ButtonBaseProps<T extends ElementType = 'button'> = AriaButtonOptions<T> & HoverProps & {
|
|
9
9
|
/**
|
|
10
10
|
* The HTML element to be rendered as the button.
|
|
11
11
|
* @default 'button'
|
|
@@ -29,7 +29,7 @@ export type ButtonProps<T extends ElementType = 'button'> = AriaButtonOptions<T>
|
|
|
29
29
|
*/
|
|
30
30
|
emphasis?: 'primary' | 'secondary' | 'secondaryFilled' | 'tertiary' | 'quaternary';
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* **[Responsive]** The size of the button
|
|
33
33
|
* @default 'md'
|
|
34
34
|
*/
|
|
35
35
|
size?: ButtonSize;
|
|
@@ -47,7 +47,7 @@ export type ButtonProps<T extends ElementType = 'button'> = AriaButtonOptions<T>
|
|
|
47
47
|
*/
|
|
48
48
|
isLoading?: boolean;
|
|
49
49
|
/**
|
|
50
|
-
* The text alignment of the button
|
|
50
|
+
* **[Responsive]** The text alignment of the button
|
|
51
51
|
*/
|
|
52
52
|
textAlign?: ButtonTextAlignement;
|
|
53
53
|
/**
|
|
@@ -59,7 +59,7 @@ export type ButtonProps<T extends ElementType = 'button'> = AriaButtonOptions<T>
|
|
|
59
59
|
*/
|
|
60
60
|
type?: 'button' | 'submit' | 'reset';
|
|
61
61
|
/**
|
|
62
|
-
* Whether the button should be full width.
|
|
62
|
+
* **[Responsive]** Whether the button should be full width.
|
|
63
63
|
*/
|
|
64
64
|
fullWidth?: boolean;
|
|
65
65
|
/**
|
|
@@ -84,83 +84,12 @@ export type ButtonProps<T extends ElementType = 'button'> = AriaButtonOptions<T>
|
|
|
84
84
|
*/
|
|
85
85
|
passthroughProps?: Partial<T extends ComponentType<infer P> ? P : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : never>;
|
|
86
86
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* For NextJS support. If `as` is used for next/link, this prop should be set to 'a' or the desired element for prop typing.
|
|
96
|
-
* @default 'button'
|
|
97
|
-
* @example 'a' | 'button'
|
|
98
|
-
*/
|
|
99
|
-
elementType?: "a" | "button";
|
|
100
|
-
/**
|
|
101
|
-
* What the base style of button is
|
|
102
|
-
* @default 'accent'
|
|
103
|
-
*/
|
|
104
|
-
styleVariant?: "accent" | "critical" | "neutral" | "white";
|
|
105
|
-
/**
|
|
106
|
-
* What the purpose is for the button
|
|
107
|
-
* @default 'primary'
|
|
108
|
-
*/
|
|
109
|
-
emphasis?: "primary" | "secondary" | "secondaryFilled" | "tertiary" | "quaternary";
|
|
110
|
-
/**
|
|
111
|
-
* How large should the button be?
|
|
112
|
-
* @default 'md'
|
|
113
|
-
*/
|
|
114
|
-
size?: ButtonSize;
|
|
115
|
-
/**
|
|
116
|
-
* Whether an icon should display at the end of Button and icon properties
|
|
117
|
-
* @default
|
|
118
|
-
*/
|
|
119
|
-
iconEndProps?: IconProps;
|
|
120
|
-
/**
|
|
121
|
-
* Whether an icon should display at the start of the Button and icon properties
|
|
122
|
-
*/
|
|
123
|
-
iconStartProps?: IconProps;
|
|
124
|
-
/**
|
|
125
|
-
* isLoading is a boolean that will show a spinner in the button
|
|
126
|
-
*/
|
|
127
|
-
isLoading?: boolean;
|
|
128
|
-
/**
|
|
129
|
-
* The text alignment of the button
|
|
130
|
-
*/
|
|
131
|
-
textAlign?: ButtonTextAlignement;
|
|
132
|
-
/**
|
|
133
|
-
* The content for the button.
|
|
134
|
-
*/
|
|
135
|
-
children?: ReactNode;
|
|
136
|
-
/**
|
|
137
|
-
* Whether the element should receive focus on render.
|
|
138
|
-
*/
|
|
139
|
-
type?: "button" | "submit" | "reset";
|
|
140
|
-
/**
|
|
141
|
-
* Whether the button should be full width.
|
|
142
|
-
*/
|
|
143
|
-
fullWidth?: boolean;
|
|
144
|
-
/**
|
|
145
|
-
* The target of the link (if `as` is set to 'a').
|
|
146
|
-
*/
|
|
147
|
-
target?: "_blank" | "_self" | "_parent" | "_top";
|
|
148
|
-
/**
|
|
149
|
-
* What type of focus style to apply to the button.
|
|
150
|
-
*/
|
|
151
|
-
focusStyle?: "default" | "white";
|
|
152
|
-
/**
|
|
153
|
-
* The slot of the button
|
|
154
|
-
*/
|
|
155
|
-
slot?: string;
|
|
156
|
-
/**
|
|
157
|
-
* Set to true to style button as an icon button
|
|
158
|
-
* @ignore
|
|
159
|
-
*/
|
|
160
|
-
iconButton?: boolean;
|
|
161
|
-
/**
|
|
162
|
-
* Passthrough props for the button element.
|
|
163
|
-
*/
|
|
164
|
-
passthroughProps?: Partial<any> | undefined;
|
|
87
|
+
type ResponsivePropKeys = 'size' | 'textAlign' | 'fullWidth';
|
|
88
|
+
export type ButtonProps<T extends ElementType = 'button'> = WithResponsiveProps<ButtonBaseProps<T>, ResponsivePropKeys>;
|
|
89
|
+
export type DefaultButtonProps = ButtonProps<'button'>;
|
|
90
|
+
export declare const Button: import('react').ForwardRefExoticComponent<Omit<ButtonBaseProps<ElementType>, ResponsivePropKeys> & {
|
|
91
|
+
size?: import('../../utils/breakpoint/responsiveSSR').ResponsiveValue<NonNullable<ButtonSize | undefined>> | undefined;
|
|
92
|
+
fullWidth?: import('../../utils/breakpoint/responsiveSSR').ResponsiveValue<NonNullable<boolean | undefined>> | undefined;
|
|
93
|
+
textAlign?: import('../../utils/breakpoint/responsiveSSR').ResponsiveValue<NonNullable<ButtonTextAlignement | undefined>> | undefined;
|
|
165
94
|
} & import('react').RefAttributes<any>>;
|
|
166
95
|
export default Button;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as
|
|
2
|
-
return
|
|
3
|
-
/* @__PURE__ */
|
|
1
|
+
import{jsx as t,jsxs as a,Fragment as e}from"react/jsx-runtime";import{c as i}from"../../index-CCUt_dAN.js";import{forwardRef as l}from"react";import{useButton as r}from"@react-aria/button";import{useObjectRef as n,mergeProps as _}from"@react-aria/utils";import{useHover as s}from"@react-aria/interactions";import{useFocusRing as g}from"@react-aria/focus";import{Icon as c}from"../Icon/Icon.js";import d from"../LoadingSpinner/LoadingSpinner.js";import{focusStyleVariants as o}from"../../utils/focus/focusStyles.js";import{getBaseValue as u,generateResponsiveClasses as m}from"../../utils/breakpoint/responsiveSSR.js";import '../../assets/Button.css';const x={button:"_button_g3taa_1",content:"_content_g3taa_19",isNotLoading:"_isNotLoading_g3taa_26",loadingSpinner:"_loadingSpinner_g3taa_26",isLoading:"_isLoading_g3taa_35",focusWhite:"_focusWhite_g3taa_51",iconButton:"_iconButton_g3taa_55",iconButton__sm:"_iconButton__sm_g3taa_59",iconButton__md:"_iconButton__md_g3taa_63",iconButton__lg:"_iconButton__lg_g3taa_67","full-width--true":"_full-width--true_g3taa_71","full-width--false":"_full-width--false_g3taa_75","size--sm":"_size--sm_g3taa_120","size--md":"_size--md_g3taa_123","size--lg":"_size--lg_g3taa_126","text-align--left":"_text-align--left_g3taa_143","text-align--center":"_text-align--center_g3taa_146","text-align--right":"_text-align--right_g3taa_149","sm:size--sm":"_sm:size--sm_g3taa_1","sm:size--md":"_sm:size--md_g3taa_1","sm:size--lg":"_sm:size--lg_g3taa_1","sm:text-align--left":"_sm:text-align--left_g3taa_1","sm:text-align--center":"_sm:text-align--center_g3taa_1","sm:text-align--right":"_sm:text-align--right_g3taa_1","sm:full-width--true":"_sm:full-width--true_g3taa_1","sm:full-width--false":"_sm:full-width--false_g3taa_1","md:size--sm":"_md:size--sm_g3taa_1","md:size--md":"_md:size--md_g3taa_1","md:size--lg":"_md:size--lg_g3taa_1","md:text-align--left":"_md:text-align--left_g3taa_1","md:text-align--center":"_md:text-align--center_g3taa_1","md:text-align--right":"_md:text-align--right_g3taa_1","md:full-width--true":"_md:full-width--true_g3taa_1","md:full-width--false":"_md:full-width--false_g3taa_1","lg:size--sm":"_lg:size--sm_g3taa_1","lg:size--md":"_lg:size--md_g3taa_1","lg:size--lg":"_lg:size--lg_g3taa_1","lg:text-align--left":"_lg:text-align--left_g3taa_1","lg:text-align--center":"_lg:text-align--center_g3taa_1","lg:text-align--right":"_lg:text-align--right_g3taa_1","lg:full-width--true":"_lg:full-width--true_g3taa_1","lg:full-width--false":"_lg:full-width--false_g3taa_1","xl:size--sm":"_xl:size--sm_g3taa_1","xl:size--md":"_xl:size--md_g3taa_1","xl:size--lg":"_xl:size--lg_g3taa_1","xl:text-align--left":"_xl:text-align--left_g3taa_1","xl:text-align--center":"_xl:text-align--center_g3taa_1","xl:text-align--right":"_xl:text-align--right_g3taa_1","xl:full-width--true":"_xl:full-width--true_g3taa_1","xl:full-width--false":"_xl:full-width--false_g3taa_1","xxl:size--sm":"_xxl:size--sm_g3taa_1","xxl:size--md":"_xxl:size--md_g3taa_1","xxl:size--lg":"_xxl:size--lg_g3taa_1","xxl:text-align--left":"_xxl:text-align--left_g3taa_1","xxl:text-align--center":"_xxl:text-align--center_g3taa_1","xxl:text-align--right":"_xxl:text-align--right_g3taa_1","xxl:full-width--true":"_xxl:full-width--true_g3taa_1","xxl:full-width--false":"_xxl:full-width--false_g3taa_1",accentPrimary:"_accentPrimary_g3taa_189",accentSecondary:"_accentSecondary_g3taa_213",accentTertiary:"_accentTertiary_g3taa_247",accentQuaternary:"_accentQuaternary_g3taa_277",accentSecondaryFilled:"_accentSecondaryFilled_g3taa_306",criticalPrimary:"_criticalPrimary_g3taa_346",criticalSecondary:"_criticalSecondary_g3taa_371",criticalTertiary:"_criticalTertiary_g3taa_405",criticalQuaternary:"_criticalQuaternary_g3taa_435",criticalSecondaryFilled:"_criticalSecondaryFilled_g3taa_465",neutralPrimary:"_neutralPrimary_g3taa_505",neutralSecondary:"_neutralSecondary_g3taa_530",neutralTertiary:"_neutralTertiary_g3taa_563",neutralQuaternary:"_neutralQuaternary_g3taa_593",neutralSecondaryFilled:"_neutralSecondaryFilled_g3taa_623",whitePrimary:"_whitePrimary_g3taa_663",whiteSecondary:"_whiteSecondary_g3taa_693",whiteTertiary:"_whiteTertiary_g3taa_726",whiteQuaternary:"_whiteQuaternary_g3taa_756",whiteSecondaryFilled:"_whiteSecondaryFilled_g3taa_786","fa-spinner-third":"_fa-spinner-third_g3taa_827","icon-wrapper":"_icon-wrapper_g3taa_832"},f=m(x),y=i(x.button,{variants:{size:{sm:x["size--sm"],md:x["size--md"],lg:x["size--lg"]},accent:{primary:x.accentPrimary,secondary:x.accentSecondary,tertiary:x.accentTertiary,quaternary:x.accentQuaternary,secondaryFilled:x.accentSecondaryFilled},critical:{primary:x.criticalPrimary,secondary:x.criticalSecondary,tertiary:x.criticalTertiary,quaternary:x.criticalQuaternary,secondaryFilled:x.criticalSecondaryFilled},neutral:{primary:x.neutralPrimary,secondary:x.neutralSecondary,tertiary:x.neutralTertiary,quaternary:x.neutralQuaternary,secondaryFilled:x.neutralSecondaryFilled},white:{primary:x.whitePrimary,secondary:x.whiteSecondary,tertiary:x.whiteTertiary,quaternary:x.whiteQuaternary,secondaryFilled:x.whiteSecondaryFilled},fullWidth:{true:x["full-width--true"],false:x["full-width--false"]},focusStyle:{default:void 0,white:x.focusWhite},isLoading:{false:x.isNotLoading,true:x.isLoading},textAlign:{left:x["text-align--left"],center:x["text-align--center"],right:x["text-align--right"]},iconButton:{true:x.iconButton}},compoundVariants:[{size:"md",accent:"primary",className:x.accentPrimary},{size:"sm",iconButton:!0,className:x.iconButton__sm},{size:"md",iconButton:!0,className:x.iconButton__md},{size:"lg",iconButton:!0,className:x.iconButton__lg}],defaultVariants:{size:"md"}}),h=l(function({as:i,elementType:l,styleVariant:m,emphasis:h="primary",size:z="md",iconStartProps:p,iconEndProps:w,children:S,fullWidth:P,textAlign:B="center",focusStyle:F="default",passthroughProps:b,isLoading:v=!1,iconButton:T,slot:L,...Q},N){const j=n(N),{buttonProps:W,isPressed:q}=r({...Q,elementType:l??i},j),{hoverProps:V,isHovered:A}=s(Q),{isFocusVisible:D,focusProps:I,isFocused:k}=g(Q),E=u(z,"md"),H=u(B,"center"),R=u(P,!1),$=f(z,"size"),C=f(B,"text-align"),G=f(P,"full-width"),J=m??"accent",K=y({size:E,focusStyle:F,isLoading:v,textAlign:H,fullWidth:R,iconButton:T,[J]:h});/* @__PURE__ */
|
|
2
|
+
return t(i??"button",{className:[K,o({focusStyle:F}),...$,...C,...G].filter(Boolean).join(" "),ref:j,"data-focused":!!k||void 0,"data-focus-visible":!!D||void 0,"data-hovered":!!A||void 0,"data-pressed":!!q||void 0,"aria-label":(()=>{if(v)return"Loading Spinner";const t=W["aria-label"]||("string"==typeof S?S:void 0);return Q.isDisabled&&t?`${t}, unavailable`:t})(),"aria-disabled":!!Q.isDisabled||void 0,"data-testid":"alto-button",slot:L,..._(W,V,I),...b,children:/* @__PURE__ */a(e,{children:[v&&/* @__PURE__ */t(d,{className:x.loadingSpinner,size:"lg"===z?"1.25x":"1x","aria-hidden":"true"}),p&&/* @__PURE__ */t(c,{...p,"aria-hidden":"true"}),
|
|
3
|
+
/* @__PURE__ */t("span",{className:x.content,children:S}),w&&/* @__PURE__ */t(c,{...w,"aria-hidden":"true"})]})})});export{h as Button,h as default};
|
|
4
4
|
//# sourceMappingURL=Button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import { cva } from 'class-variance-authority';\nimport {\n ComponentType,\n ElementType,\n ReactNode,\n forwardRef,\n ForwardedRef,\n type JSX,\n} from 'react';\nimport { AriaButtonOptions, useButton } from '@react-aria/button';\nimport styles from './Button.module.css';\nimport { useObjectRef, mergeProps } from '@react-aria/utils';\nimport { useHover, HoverProps } from '@react-aria/interactions';\nimport { useFocusRing } from '@react-aria/focus';\nimport Icon, { IconProps } from '../Icon/Icon';\nimport LoadingSpinner from '../LoadingSpinner';\nimport { focusStyleVariants } from '../../utils/focus/focusStyles';\n\nconst button = cva(styles.button, {\n variants: {\n size: {\n sm: styles.sm,\n md: styles.md,\n lg: styles.lg,\n },\n accent: {\n primary: styles.accentPrimary,\n secondary: styles.accentSecondary,\n tertiary: styles.accentTertiary,\n quaternary: styles.accentQuaternary,\n secondaryFilled: styles.accentSecondaryFilled,\n },\n critical: {\n primary: styles.criticalPrimary,\n secondary: styles.criticalSecondary,\n tertiary: styles.criticalTertiary,\n quaternary: styles.criticalQuaternary,\n secondaryFilled: styles.criticalSecondaryFilled,\n },\n neutral: {\n primary: styles.neutralPrimary,\n secondary: styles.neutralSecondary,\n tertiary: styles.neutralTertiary,\n quaternary: styles.neutralQuaternary,\n secondaryFilled: styles.neutralSecondaryFilled,\n },\n white: {\n primary: styles.whitePrimary,\n secondary: styles.whiteSecondary,\n tertiary: styles.whiteTertiary,\n quaternary: styles.whiteQuaternary,\n secondaryFilled: styles.whiteSecondaryFilled,\n },\n fullWidth: {\n true: styles.fullWidth,\n },\n focusStyle: {\n default: undefined,\n white: styles.focusWhite,\n },\n isLoading: {\n false: styles.isNotLoading,\n true: styles.isLoading,\n },\n textAlign: {\n left: styles.textAlignLeft,\n center: styles.textAlignCenter,\n right: styles.textAlignRight,\n },\n iconButton: {\n true: styles.iconButton,\n },\n },\n compoundVariants: [\n { size: 'md', accent: 'primary', className: styles.accentPrimary },\n { size: 'sm', iconButton: true, className: styles.iconButton__sm },\n { size: 'md', iconButton: true, className: styles.iconButton__md },\n { size: 'lg', iconButton: true, className: styles.iconButton__lg },\n ],\n defaultVariants: {\n size: 'md',\n },\n});\n\ntype ButtonSize = 'lg' | 'md' | 'sm';\ntype ButtonTextAlignement = 'left' | 'center' | 'right';\n\nexport type DefaultButtonProps = ButtonProps<'button'>;\n\nexport type ButtonProps<T extends ElementType = 'button'> =\n AriaButtonOptions<T> &\n HoverProps & {\n /**\n * The HTML element to be rendered as the button.\n * @default 'button'\n * @example 'a' | 'button' | 'div'\n */\n as?: T;\n /**\n * For NextJS support. If `as` is used for next/link, this prop should be set to 'a' or the desired element for prop typing.\n * @default 'button'\n * @example 'a' | 'button'\n */\n elementType?: 'a' | 'button';\n /**\n * What the base style of button is\n * @default 'accent'\n */\n styleVariant?: 'accent' | 'critical' | 'neutral' | 'white';\n\n /**\n * What the purpose is for the button\n * @default 'primary'\n */\n emphasis?:\n | 'primary'\n | 'secondary'\n | 'secondaryFilled'\n | 'tertiary'\n | 'quaternary';\n\n /**\n * How large should the button be?\n * @default 'md'\n */\n size?: ButtonSize;\n\n /**\n * Whether an icon should display at the end of Button and icon properties\n * @default\n */\n iconEndProps?: IconProps;\n\n /**\n * Whether an icon should display at the start of the Button and icon properties\n */\n iconStartProps?: IconProps;\n /**\n * isLoading is a boolean that will show a spinner in the button\n */\n isLoading?: boolean;\n\n /**\n * The text alignment of the button\n */\n textAlign?: ButtonTextAlignement;\n\n /**\n * The content for the button.\n */\n children?: ReactNode;\n\n /**\n * \tWhether the element should receive focus on render.\n */\n type?: 'button' | 'submit' | 'reset';\n\n /**\n * Whether the button should be full width.\n */\n fullWidth?: boolean;\n\n /**\n * The target of the link (if `as` is set to 'a').\n */\n target?: '_blank' | '_self' | '_parent' | '_top';\n\n /**\n * What type of focus style to apply to the button.\n */\n focusStyle?: 'default' | 'white';\n\n /**\n * The slot of the button\n */\n slot?: string;\n\n /**\n * Set to true to style button as an icon button\n * @ignore\n */\n iconButton?: boolean;\n\n /**\n * Passthrough props for the button element.\n */\n passthroughProps?: Partial<\n T extends ComponentType<infer P>\n ? P\n : T extends keyof JSX.IntrinsicElements\n ? JSX.IntrinsicElements[T]\n : never\n >;\n };\n\nexport const Button = forwardRef(function Button<\n T extends ElementType = 'button',\n>(\n {\n as,\n elementType,\n styleVariant,\n emphasis = 'primary',\n size = 'md',\n iconStartProps,\n iconEndProps,\n children,\n fullWidth,\n textAlign = 'center',\n focusStyle = 'default',\n passthroughProps,\n isLoading = false,\n iconButton,\n slot,\n ...props\n }: ButtonProps<T>,\n // Not using <T> here as typescript cannot narrow it properly from consuming component\n // see - https://www.tsteele.dev/posts/react-polymorphic-forwardref for potential\n // solutions if proper typing is required.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n forwardedRef?: ForwardedRef<any>,\n) {\n const ref = useObjectRef(forwardedRef);\n\n // Call useButton to get the props and state needed for accessibility and interaction\n const { buttonProps, isPressed } = useButton(\n { ...props, elementType: elementType ?? as },\n ref,\n );\n const { hoverProps, isHovered } = useHover(props);\n const { isFocusVisible, focusProps, isFocused } = useFocusRing(props);\n\n const getAriaLabel = () => {\n if (isLoading) {\n return 'Loading Spinner';\n }\n\n const label =\n buttonProps['aria-label'] ||\n (typeof children === 'string' ? children : undefined);\n\n if (props.isDisabled && label) {\n return `${label}, unavailable`;\n }\n\n return label;\n };\n\n const resolvedStyleVariant = styleVariant ?? 'accent';\n\n const className = button({\n size,\n fullWidth,\n focusStyle,\n isLoading,\n textAlign,\n iconButton,\n [resolvedStyleVariant]: emphasis,\n });\n\n const Component: ElementType = as ?? 'button';\n\n return (\n <Component\n className={`${className} ${focusStyleVariants({ focusStyle })}`}\n ref={ref}\n data-focused={isFocused ? true : undefined}\n data-focus-visible={isFocusVisible ? true : undefined}\n data-hovered={isHovered ? true : undefined}\n data-pressed={isPressed ? true : undefined}\n aria-label={getAriaLabel()}\n aria-disabled={props.isDisabled ? true : undefined}\n data-testid=\"alto-button\"\n slot={slot}\n {...mergeProps(buttonProps, hoverProps, focusProps)}\n {...passthroughProps}\n >\n <>\n {isLoading && (\n <LoadingSpinner\n className={styles.loadingSpinner}\n size={size === 'lg' ? '1.25x' : '1x'}\n aria-hidden=\"true\"\n />\n )}\n {iconStartProps && <Icon {...iconStartProps} aria-hidden=\"true\" />}\n <span className={styles.content}>{children}</span>\n {iconEndProps && <Icon {...iconEndProps} aria-hidden=\"true\" />}\n </>\n </Component>\n );\n});\n\nexport default Button;\n"],"names":["button","cva","variants","size","sm","md","lg","accent","primary","styles","secondary","tertiary","quaternary","secondaryFilled","critical","neutral","white","fullWidth","true","focusStyle","default","isLoading","false","textAlign","left","center","right","iconButton","compoundVariants","className","defaultVariants","Button","forwardRef","as","elementType","styleVariant","emphasis","iconStartProps","iconEndProps","children","passthroughProps","slot","props","forwardedRef","ref","useObjectRef","buttonProps","isPressed","useButton","hoverProps","isHovered","useHover","isFocusVisible","focusProps","isFocused","useFocusRing","resolvedStyleVariant","jsx","focusStyleVariants","label","isDisabled","getAriaLabel","mergeProps","jsxs","Fragment","LoadingSpinner","Icon"],"mappings":"0lBAkBMA,EAASC,oBAAmB,CAChCC,SAAU,CACRC,KAAM,CACJC,kBACAC,kBACAC,mBAEFC,OAAQ,CACNC,QAASC,EACTC,uCACAC,qCACAC,yCACAC,oDAEFC,SAAU,CACRN,qCACAE,yCACAC,uCACAC,2CACAC,sDAEFE,QAAS,CACPP,oCACAE,wCACAC,sCACAC,0CACAC,qDAEFG,MAAO,CACLR,kCACAE,sCACAC,oCACAC,wCACAC,mDAEFI,UAAW,CACTC,6BAEFC,WAAY,CACVC,aAAS,EACTJ,8BAEFK,UAAW,CACTC,+BACAJ,4BAEFK,UAAW,CACTC,gCACAC,oCACAC,mCAEFC,WAAY,CACVT,8BAGJU,iBAAkB,CAChB,CAAEzB,KAAM,KAAMI,OAAQ,UAAWsB,UAAWpB,GAC5C,CAAEN,KAAM,KAAMwB,YAAY,EAAME,sCAChC,CAAE1B,KAAM,KAAMwB,YAAY,EAAME,sCAChC,CAAE1B,KAAM,KAAMwB,YAAY,EAAME,uCAElCC,gBAAiB,CACf3B,KAAM,QAmHG4B,EAASC,EAAW,UAG/BC,GACEA,EAAAC,YACAA,EAAAC,aACAA,EAAAC,SACAA,EAAW,UAAAjC,KACXA,EAAO,KAAAkC,eACPA,EAAAC,aACAA,EAAAC,SACAA,EACAtB,UAAAA,EAAAA,UACAM,EAAY,SAAAJ,WACZA,EAAa,UAAAqB,iBACbA,EACAnB,UAAAA,GAAY,EACZM,WAAAA,EAAAA,KACAc,KACGC,GAMLC,GAEA,MAAMC,EAAMC,EAAaF,IAGnBG,YAAEA,EAAAC,UAAaA,GAAcC,EACjC,IAAKN,EAAOR,YAAaA,GAAeD,GACxCW,IAEIK,WAAEA,EAAAC,UAAYA,GAAcC,EAAST,IACrCU,eAAEA,EAAAC,WAAgBA,EAAAC,UAAYA,GAAcC,EAAab,GAkBzDc,EAAuBrB,GAAgB,SAEvCN,EAAY7B,EAAO,CACvBG,OACAc,UAAAA,EACAE,aACAE,UAAAA,EACAE,YACAI,WAAAA,EACA6B,CAACA,GAAuBpB;AAK1B,OACEqB,EAH6BxB,GAAM,SAGlC,CACCJ,UAAW,GAAGA,KAAa6B,EAAmB,CAAEvC,iBAChDyB,MACA,iBAAcU,QAAmB,EACjC,uBAAoBF,QAAwB,EAC5C,iBAAcF,QAAmB,EACjC,iBAAcH,QAAmB,EACjC,aAtCiB,MACnB,GAAI1B,EACF,MAAO,kBAGT,MAAMsC,EACJb,EAAY,gBACS,iBAAbP,EAAwBA,OAAW,GAE7C,OAAIG,EAAMkB,YAAcD,EACf,GAAGA,iBAGLA,GAyBOE,GACZ,kBAAenB,EAAMkB,iBAAoB,EACzC,cAAY,cACZnB,UACIqB,EAAWhB,EAAaG,EAAYI,MACpCb,EAEJD,wBAAAwB,EAAAC,EAAA,CACGzB,SAAA,CAAAlB,kBACCoC,EAACQ,EAAA,CACCpC,UAAWpB,EACXN,KAAe,OAATA,EAAgB,QAAU,KAChC,cAAY,SAGfkC,oBAAmB6B,EAAA,IAAS7B,EAAgB,cAAY;iBACxD,OAAA,CAAKR,UAAWpB,EAAiB8B,aACjCD,oBAAiB4B,EAAA,IAAS5B,EAAc,cAAY,aAI7D"}
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import { cva } from 'class-variance-authority';\nimport {\n ComponentType,\n ElementType,\n ReactNode,\n forwardRef,\n ForwardedRef,\n type JSX,\n} from 'react';\nimport { AriaButtonOptions, useButton } from '@react-aria/button';\nimport styles from './Button.module.css';\nimport { useObjectRef, mergeProps } from '@react-aria/utils';\nimport { useHover, HoverProps } from '@react-aria/interactions';\nimport { useFocusRing } from '@react-aria/focus';\nimport Icon, { IconProps } from '../Icon/Icon';\nimport LoadingSpinner from '../LoadingSpinner';\nimport { focusStyleVariants } from '../../utils/focus/focusStyles';\nimport {\n generateResponsiveClasses,\n getBaseValue,\n WithResponsiveProps,\n} from '../../utils/breakpoint/responsiveSSR';\n\nconst getResponsiveClasses = generateResponsiveClasses(styles);\n\nconst button = cva(styles.button, {\n variants: {\n size: {\n sm: styles['size--sm'],\n md: styles['size--md'],\n lg: styles['size--lg'],\n },\n accent: {\n primary: styles.accentPrimary,\n secondary: styles.accentSecondary,\n tertiary: styles.accentTertiary,\n quaternary: styles.accentQuaternary,\n secondaryFilled: styles.accentSecondaryFilled,\n },\n critical: {\n primary: styles.criticalPrimary,\n secondary: styles.criticalSecondary,\n tertiary: styles.criticalTertiary,\n quaternary: styles.criticalQuaternary,\n secondaryFilled: styles.criticalSecondaryFilled,\n },\n neutral: {\n primary: styles.neutralPrimary,\n secondary: styles.neutralSecondary,\n tertiary: styles.neutralTertiary,\n quaternary: styles.neutralQuaternary,\n secondaryFilled: styles.neutralSecondaryFilled,\n },\n white: {\n primary: styles.whitePrimary,\n secondary: styles.whiteSecondary,\n tertiary: styles.whiteTertiary,\n quaternary: styles.whiteQuaternary,\n secondaryFilled: styles.whiteSecondaryFilled,\n },\n fullWidth: {\n true: styles['full-width--true'],\n false: styles['full-width--false'],\n },\n focusStyle: {\n default: undefined,\n white: styles.focusWhite,\n },\n isLoading: {\n false: styles.isNotLoading,\n true: styles.isLoading,\n },\n textAlign: {\n left: styles['text-align--left'],\n center: styles['text-align--center'],\n right: styles['text-align--right'],\n },\n iconButton: {\n true: styles.iconButton,\n },\n },\n compoundVariants: [\n { size: 'md', accent: 'primary', className: styles.accentPrimary },\n { size: 'sm', iconButton: true, className: styles.iconButton__sm },\n { size: 'md', iconButton: true, className: styles.iconButton__md },\n { size: 'lg', iconButton: true, className: styles.iconButton__lg },\n ],\n defaultVariants: {\n size: 'md',\n },\n});\n\ntype ButtonSize = 'lg' | 'md' | 'sm';\ntype ButtonTextAlignement = 'left' | 'center' | 'right';\n\nexport type ButtonBaseProps<T extends ElementType = 'button'> =\n AriaButtonOptions<T> &\n HoverProps & {\n /**\n * The HTML element to be rendered as the button.\n * @default 'button'\n * @example 'a' | 'button' | 'div'\n */\n as?: T;\n /**\n * For NextJS support. If `as` is used for next/link, this prop should be set to 'a' or the desired element for prop typing.\n * @default 'button'\n * @example 'a' | 'button'\n */\n elementType?: 'a' | 'button';\n /**\n * What the base style of button is\n * @default 'accent'\n */\n styleVariant?: 'accent' | 'critical' | 'neutral' | 'white';\n\n /**\n * What the purpose is for the button\n * @default 'primary'\n */\n emphasis?:\n | 'primary'\n | 'secondary'\n | 'secondaryFilled'\n | 'tertiary'\n | 'quaternary';\n\n /**\n * **[Responsive]** The size of the button\n * @default 'md'\n */\n size?: ButtonSize;\n\n /**\n * Whether an icon should display at the end of Button and icon properties\n * @default\n */\n iconEndProps?: IconProps;\n\n /**\n * Whether an icon should display at the start of the Button and icon properties\n */\n iconStartProps?: IconProps;\n /**\n * isLoading is a boolean that will show a spinner in the button\n */\n isLoading?: boolean;\n\n /**\n * **[Responsive]** The text alignment of the button\n */\n textAlign?: ButtonTextAlignement;\n\n /**\n * The content for the button.\n */\n children?: ReactNode;\n\n /**\n * \tWhether the element should receive focus on render.\n */\n type?: 'button' | 'submit' | 'reset';\n\n /**\n * **[Responsive]** Whether the button should be full width.\n */\n fullWidth?: boolean;\n\n /**\n * The target of the link (if `as` is set to 'a').\n */\n target?: '_blank' | '_self' | '_parent' | '_top';\n\n /**\n * What type of focus style to apply to the button.\n */\n focusStyle?: 'default' | 'white';\n\n /**\n * The slot of the button\n */\n slot?: string;\n\n /**\n * Set to true to style button as an icon button\n * @ignore\n */\n iconButton?: boolean;\n\n /**\n * Passthrough props for the button element.\n */\n passthroughProps?: Partial<\n T extends ComponentType<infer P>\n ? P\n : T extends keyof JSX.IntrinsicElements\n ? JSX.IntrinsicElements[T]\n : never\n >;\n };\n\n// ResponsivePropKeys are the keys of the props that can accept responsive values (base + breakpoint-specific)\ntype ResponsivePropKeys = 'size' | 'textAlign' | 'fullWidth';\n\nexport type ButtonProps<T extends ElementType = 'button'> = WithResponsiveProps<\n ButtonBaseProps<T>,\n ResponsivePropKeys\n>;\n\nexport type DefaultButtonProps = ButtonProps<'button'>;\n\nexport const Button = forwardRef(function Button<\n T extends ElementType = 'button',\n>(\n {\n as,\n elementType,\n styleVariant,\n emphasis = 'primary',\n size = 'md',\n iconStartProps,\n iconEndProps,\n children,\n fullWidth,\n textAlign = 'center',\n focusStyle = 'default',\n passthroughProps,\n isLoading = false,\n iconButton,\n slot,\n ...props\n }: ButtonProps<T>,\n // Not using <T> here as typescript cannot narrow it properly from consuming component\n // see - https://www.tsteele.dev/posts/react-polymorphic-forwardref for potential\n // solutions if proper typing is required.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n forwardedRef?: ForwardedRef<any>,\n) {\n const ref = useObjectRef(forwardedRef);\n\n // Call useButton to get the props and state needed for accessibility and interaction\n const { buttonProps, isPressed } = useButton(\n { ...props, elementType: elementType ?? as },\n ref,\n );\n const { hoverProps, isHovered } = useHover(props);\n const { isFocusVisible, focusProps, isFocused } = useFocusRing(props);\n\n const getAriaLabel = () => {\n if (isLoading) {\n return 'Loading Spinner';\n }\n\n const label =\n buttonProps['aria-label'] ||\n (typeof children === 'string' ? children : undefined);\n\n if (props.isDisabled && label) {\n return `${label}, unavailable`;\n }\n\n return label;\n };\n\n const baseSize = getBaseValue(size, 'md');\n const baseTextAlign = getBaseValue(textAlign, 'center');\n const baseFullWidth = getBaseValue(fullWidth, false);\n\n const sizeResponsiveClasses = getResponsiveClasses(size, 'size');\n const textAlignResponsiveClasses = getResponsiveClasses(\n textAlign,\n 'text-align',\n );\n const fullWidthResponsiveClasses = getResponsiveClasses(\n fullWidth,\n 'full-width',\n );\n\n const resolvedStyleVariant = styleVariant ?? 'accent';\n\n const className = button({\n size: baseSize,\n focusStyle,\n isLoading,\n textAlign: baseTextAlign,\n fullWidth: baseFullWidth,\n iconButton,\n [resolvedStyleVariant]: emphasis,\n });\n\n const Component: ElementType = as ?? 'button';\n\n return (\n <Component\n className={[\n className,\n focusStyleVariants({ focusStyle }),\n ...sizeResponsiveClasses,\n ...textAlignResponsiveClasses,\n ...fullWidthResponsiveClasses,\n ]\n .filter(Boolean)\n .join(' ')}\n ref={ref}\n data-focused={isFocused ? true : undefined}\n data-focus-visible={isFocusVisible ? true : undefined}\n data-hovered={isHovered ? true : undefined}\n data-pressed={isPressed ? true : undefined}\n aria-label={getAriaLabel()}\n aria-disabled={props.isDisabled ? true : undefined}\n data-testid=\"alto-button\"\n slot={slot}\n {...mergeProps(buttonProps, hoverProps, focusProps)}\n {...passthroughProps}\n >\n <>\n {isLoading && (\n <LoadingSpinner\n className={styles.loadingSpinner}\n size={size === 'lg' ? '1.25x' : '1x'}\n aria-hidden=\"true\"\n />\n )}\n {iconStartProps && <Icon {...iconStartProps} aria-hidden=\"true\" />}\n <span className={styles.content}>{children}</span>\n {iconEndProps && <Icon {...iconEndProps} aria-hidden=\"true\" />}\n </>\n </Component>\n );\n});\n\nexport default Button;\n"],"names":["getResponsiveClasses","generateResponsiveClasses","styles","button","cva","variants","size","sm","md","lg","accent","primary","accentPrimary","secondary","accentSecondary","tertiary","accentTertiary","quaternary","accentQuaternary","secondaryFilled","accentSecondaryFilled","critical","criticalPrimary","criticalSecondary","criticalTertiary","criticalQuaternary","criticalSecondaryFilled","neutral","neutralPrimary","neutralSecondary","neutralTertiary","neutralQuaternary","neutralSecondaryFilled","white","whitePrimary","whiteSecondary","whiteTertiary","whiteQuaternary","whiteSecondaryFilled","fullWidth","true","false","focusStyle","default","focusWhite","isLoading","isNotLoading","textAlign","left","center","right","iconButton","compoundVariants","className","iconButton__sm","iconButton__md","iconButton__lg","defaultVariants","Button","forwardRef","as","elementType","styleVariant","emphasis","iconStartProps","iconEndProps","children","passthroughProps","slot","props","forwardedRef","ref","useObjectRef","buttonProps","isPressed","useButton","hoverProps","isHovered","useHover","isFocusVisible","focusProps","isFocused","useFocusRing","baseSize","getBaseValue","baseTextAlign","baseFullWidth","sizeResponsiveClasses","textAlignResponsiveClasses","fullWidthResponsiveClasses","resolvedStyleVariant","jsx","focusStyleVariants","filter","Boolean","join","label","isDisabled","getAriaLabel","mergeProps","jsxs","Fragment","LoadingSpinner","loadingSpinner","Icon","content"],"mappings":"2tIAuBMA,EAAuBC,EAA0BC,GAEjDC,EAASC,EAAIF,EAAOC,OAAQ,CAChCE,SAAU,CACRC,KAAM,CACJC,GAAIL,EAAO,YACXM,GAAIN,EAAO,YACXO,GAAIP,EAAO,aAEbQ,OAAQ,CACNC,QAAST,EAAOU,cAChBC,UAAWX,EAAOY,gBAClBC,SAAUb,EAAOc,eACjBC,WAAYf,EAAOgB,iBACnBC,gBAAiBjB,EAAOkB,uBAE1BC,SAAU,CACRV,QAAST,EAAOoB,gBAChBT,UAAWX,EAAOqB,kBAClBR,SAAUb,EAAOsB,iBACjBP,WAAYf,EAAOuB,mBACnBN,gBAAiBjB,EAAOwB,yBAE1BC,QAAS,CACPhB,QAAST,EAAO0B,eAChBf,UAAWX,EAAO2B,iBAClBd,SAAUb,EAAO4B,gBACjBb,WAAYf,EAAO6B,kBACnBZ,gBAAiBjB,EAAO8B,wBAE1BC,MAAO,CACLtB,QAAST,EAAOgC,aAChBrB,UAAWX,EAAOiC,eAClBpB,SAAUb,EAAOkC,cACjBnB,WAAYf,EAAOmC,gBACnBlB,gBAAiBjB,EAAOoC,sBAE1BC,UAAW,CACTC,KAAMtC,EAAO,oBACbuC,MAAOvC,EAAO,sBAEhBwC,WAAY,CACVC,aAAS,EACTV,MAAO/B,EAAO0C,YAEhBC,UAAW,CACTJ,MAAOvC,EAAO4C,aACdN,KAAMtC,EAAO2C,WAEfE,UAAW,CACTC,KAAM9C,EAAO,oBACb+C,OAAQ/C,EAAO,sBACfgD,MAAOhD,EAAO,sBAEhBiD,WAAY,CACVX,KAAMtC,EAAOiD,aAGjBC,iBAAkB,CAChB,CAAE9C,KAAM,KAAMI,OAAQ,UAAW2C,UAAWnD,EAAOU,eACnD,CAAEN,KAAM,KAAM6C,YAAY,EAAME,UAAWnD,EAAOoD,gBAClD,CAAEhD,KAAM,KAAM6C,YAAY,EAAME,UAAWnD,EAAOqD,gBAClD,CAAEjD,KAAM,KAAM6C,YAAY,EAAME,UAAWnD,EAAOsD,iBAEpDC,gBAAiB,CACfnD,KAAM,QA2HGoD,EAASC,EAAW,UAG/BC,GACEA,EAAAC,YACAA,EAAAC,aACAA,EAAAC,SACAA,EAAW,UAAAzD,KACXA,EAAO,KAAA0D,eACPA,EAAAC,aACAA,EAAAC,SACAA,EAAA3B,UACAA,EAAAQ,UACAA,EAAY,SAAAL,WACZA,EAAa,UAAAyB,iBACbA,EACAtB,UAAAA,GAAY,EACZM,WAAAA,EAAAA,KACAiB,KACGC,GAMLC,GAEA,MAAMC,EAAMC,EAAaF,IAGnBG,YAAEA,EAAAC,UAAaA,GAAcC,EACjC,IAAKN,EAAOR,YAAaA,GAAeD,GACxCW,IAEIK,WAAEA,EAAAC,UAAYA,GAAcC,EAAST,IACrCU,eAAEA,EAAAC,WAAgBA,EAAAC,UAAYA,GAAcC,EAAab,GAkBzDc,EAAWC,EAAa9E,EAAM,MAC9B+E,EAAgBD,EAAarC,EAAW,UACxCuC,EAAgBF,EAAa7C,GAAW,GAExCgD,EAAwBvF,EAAqBM,EAAM,QACnDkF,EAA6BxF,EACjC+C,EACA,cAEI0C,EAA6BzF,EACjCuC,EACA,cAGImD,EAAuB5B,GAAgB,SAEvCT,EAAYlD,EAAO,CACvBG,KAAM6E,EACNzC,aACAG,UAAAA,EACAE,UAAWsC,EACX9C,UAAW+C,EACXnC,WAAAA,EACAuC,CAACA,GAAuB3B;AAK1B,OACE4B,EAH6B/B,GAAM,SAGlC,CACCP,UAAW,CACTA,EACAuC,EAAmB,CAAElD,kBAClB6C,KACAC,KACAC,GAEFI,OAAOC,SACPC,KAAK,KACRxB,MACA,iBAAcU,QAAmB,EACjC,uBAAoBF,QAAwB,EAC5C,iBAAcF,QAAmB,EACjC,iBAAcH,QAAmB,EACjC,aA5DiB,MACnB,GAAI7B,EACF,MAAO,kBAGT,MAAMmD,EACJvB,EAAY,gBACS,iBAAbP,EAAwBA,OAAW,GAE7C,OAAIG,EAAM4B,YAAcD,EACf,GAAGA,iBAGLA,GA+COE,GACZ,kBAAe7B,EAAM4B,iBAAoB,EACzC,cAAY,cACZ7B,UACI+B,EAAW1B,EAAaG,EAAYI,MACpCb,EAEJD,wBAAAkC,EAAAC,EAAA,CACGnC,SAAA,CAAArB,kBACC8C,EAACW,EAAA,CACCjD,UAAWnD,EAAOqG,eAClBjG,KAAe,OAATA,EAAgB,QAAU,KAChC,cAAY,SAGf0D,oBAAmBwC,EAAA,IAASxC,EAAgB,cAAY;iBACxD,OAAA,CAAKX,UAAWnD,EAAOuG,QAAUvC,aACjCD,oBAAiBuC,EAAA,IAASvC,EAAc,cAAY,aAI7D"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as a}from"react/jsx-runtime";import t from"react";import{c as i}from"../../index-
|
|
1
|
+
import{jsx as a}from"react/jsx-runtime";import t from"react";import{c as i}from"../../index-CCUt_dAN.js";import '../../assets/ButtonGroup.css';const r=i("_buttonGroup_53q76_2",{variants:{align:{start:"_alignStart_53q76_10",center:"_alignCenter_53q76_14",end:"_alignEnd_53q76_18",justify:"_alignJustify_53q76_22",split:"_alignSplit_53q76_30",stack:"_alignStack_53q76_43",stackFlip:"_alignStackFlip_53q76_48"}},defaultVariants:{align:"start"}}),n=({children:i,align:n="start"})=>/* @__PURE__ */a("div",{className:`${r({align:n})}`,role:"group","aria-label":"Button Group",children:t.Children.map(i,a=>a)});export{n as ButtonGroup,n as default};
|
|
2
2
|
//# sourceMappingURL=ButtonGroup.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{jsx as a}from"react/jsx-runtime";import{forwardRef as e}from"react";import{$ as t,a as r}from"../../useCalendarState-
|
|
1
|
+
import{jsx as a}from"react/jsx-runtime";import{forwardRef as e}from"react";import{$ as t,a as r}from"../../useCalendarState-BKam8aTi.js";import{useLocale as o}from"@react-aria/i18n";import{useObjectRef as n}from"@react-aria/utils";import{useCalendar as i}from"@react-aria/calendar";import{Calendar as u}from"../_base/Calendar/Calendar.js";import{useDatePickerContext as l}from"../DatePicker/DatePickerContext.js";import{parseDateValue as s,getVisibleDuration as c}from"../../utils/date/date.js";const f=e(function(e,f){const{locale:m}=o(),{isInDatePicker:d}=l(),p=n(f),C={...e,visibleDuration:c(e?.visibleDuration),defaultValue:s(e?.defaultValue),value:s(e?.value),onChange:a=>{if(e?.onChange){if(d){return(0,e.onChange)(a)}return(0,e.onChange)(a.toDate("UTC").toISOString())}},focusedValue:s(e?.focusedValue),defaultFocusedValue:s(e.defaultFocusedValue),onFocusChange:a=>{if(e?.onFocusChange){if(d){return(0,e.onFocusChange)(a)}return(0,e.onFocusChange)(a.toDate("UTC").toISOString())}},minValue:s(e?.minValue),maxValue:s(e?.maxValue),isDateUnavailable:a=>{if(!e?.isDateUnavailable)return!1;if(d){return(0,e.isDateUnavailable)(a)}return(0,e.isDateUnavailable)(a.toDate("UTC").toISOString())}},D=t({createCalendar:r,...C,locale:m}),{calendarProps:g,prevButtonProps:v,nextButtonProps:V}=i(C,D);/* @__PURE__ */
|
|
2
2
|
return a(u,{ref:p,state:D,calendarProps:g,prevButtonProps:v,nextButtonProps:V,...C})});export{f as Calendar,f as default};
|
|
3
3
|
//# sourceMappingURL=Calendar.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{useState as a,useRef as t,useMemo as n,forwardRef as l}from"react";import{useLocale as r}from"react-aria-components";import{b as i
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{useState as a,useRef as t,useMemo as n,forwardRef as l}from"react";import{useLocale as r}from"react-aria-components";import{b as i,c as s,$ as u,d as o,e as d,f as c,a as f}from"../../useCalendarState-BKam8aTi.js";import{b as v,c as m,d as g,e as D,f as b,g as p}from"../../CalendarDate-uEuHKGse.js";import{useRangeCalendar as C}from"@react-aria/calendar";import{useObjectRef as V}from"@react-aria/utils";import{Calendar as h}from"../_base/Calendar/Calendar.js";import{useDatePickerContext as U}from"../DatePicker/DatePickerContext.js";import{parseDateValue as S,getVisibleDuration as R}from"../../utils/date/date.js";function I(e,a){return e&&a?(a.compare(e)<0&&([e,a]=[a,e]),{start:v(e),end:v(a)}):null}function P(e,a){return e=b(e,a?.calendar||new p),a&&"hour"in a?a.set(e):e}function x(e,a,t){let n=e.add({days:t});for(;(t<0?n.compare(a.visibleRange.start)>=0:n.compare(a.visibleRange.end)<=0)&&!a.isCellUnavailable(n);)n=n.add({days:t});if(a.isCellUnavailable(n))return n.add({days:-t})}const F=l(function(l,b){const{locale:p}=r(),{isInDatePicker:F,isInDateRangePicker:j}=U(),y=V(b),B={...l,visibleDuration:R(l?.visibleDuration),defaultValue:(()=>{if(l?.defaultValue&&l.defaultValue?.start&&l.defaultValue?.end)return{start:S(l.defaultValue.start),end:S(l.defaultValue.end)}})(),value:(()=>{if(l?.value&&l.value?.start&&l.value?.end)return{start:S(l.value.start),end:S(l.value.end)}})(),onChange:e=>{if(l?.onChange){if(F||j){return(0,l.onChange)(e)}{if(!e?.start||!e?.end)return;const a={start:e.start.toDate("UTC").toISOString(),end:e.end.toDate("UTC").toISOString()};return(0,l.onChange)(a)}}},focusedValue:S(l?.focusedValue),defaultFocusedValue:S(l.defaultFocusedValue),onFocusChange:e=>{if(l?.onFocusChange){if(F||j){return(0,l.onFocusChange)(e)}return(0,l.onFocusChange)(e.toDate("UTC").toISOString())}},minValue:S(l?.minValue),maxValue:S(l?.maxValue),isDateUnavailable:e=>{if(!l?.isDateUnavailable)return!1;if(F||j){return(0,l.isDateUnavailable)(e)}return(0,l.isDateUnavailable)(e.toDate("UTC").toISOString())}},O=function(e){let{value:l,defaultValue:r,onChange:f,createCalendar:b,locale:p,visibleDuration:C={months:1},minValue:V,maxValue:h,...U}=e,[S,R]=i(l,r||null,f),[F,j]=a(null),y="center";if(S&&S.start&&S.end){let e=s(v(S.start),C,p,V,h).add(C).subtract({days:1});S.end.compare(e)>0&&(y="start")}let B=t(null),[O,k]=a(null),T=n(()=>m(V,O?.start),[V,O]),A=n(()=>g(h,O?.end),[h,O]),w=u({...U,value:S&&S.start,createCalendar:b,locale:p,visibleDuration:C,minValue:T,maxValue:A,selectionAlignment:e.selectionAlignment||y}),N=a=>{if(a&&e.isDateUnavailable&&!e.allowsNonContiguousRanges){const e=x(a,w,-1),t=x(a,w,1);B.current={start:e,end:t},k(B.current)}else B.current=null,k(null)},[$,_]=a(w.visibleRange);D(w.visibleRange.start,$.start)&&D(w.visibleRange.end,$.end)||(N(F),_(w.visibleRange));let q=e=>{e?(j(e),N(e)):(j(null),N(null))},z=F?I(F,w.focusedDate):S&&I(S.start,S.end),E=a=>{if(e.isReadOnly)return;const t=d(a,T,A),n=c(t,w.visibleRange.start,e.isDateUnavailable);if(n)if(F){let e=I(F,n);e&&R({start:P(e.start,S?.start),end:P(e.end,S?.end)}),q(null)}else q(n)},[G,H]=a(!1),{isDateUnavailable:J}=e,K=n(()=>!(!S||F)&&(!(!J||!J(S.start)&&!J(S.end))||o(S.start,V,h)||o(S.end,V,h)),[J,S,F,V,h]),L=e.isInvalid||"invalid"===e.validationState||K,M=L?"invalid":null;return{...w,value:S,setValue:R,anchorDate:F,setAnchorDate:q,highlightedRange:z,validationState:M,isValueInvalid:L,selectFocusedDate(){E(w.focusedDate)},selectDate:E,highlightDate(e){F&&w.setFocusedDate(e)},isSelected:e=>Boolean(z&&e.compare(z.start)>=0&&e.compare(z.end)<=0&&!w.isCellDisabled(e)&&!w.isCellUnavailable(e)),isInvalid:e=>w.isInvalid(e)||o(e,B.current?.start,B.current?.end),isDragging:G,setDragging:H,clearSelection(){q(null),R(null)}}}({createCalendar:f,...B,locale:p}),{calendarProps:k,prevButtonProps:T,nextButtonProps:A}=C(B,O,y);/* @__PURE__ */
|
|
2
2
|
return e(h,{ref:y,state:O,calendarProps:k,prevButtonProps:T,nextButtonProps:A,...B})});export{F as CalendarRange,F as default};
|
|
3
3
|
//# sourceMappingURL=CalendarRange.js.map
|