@atom-learning/components 10.0.1 → 10.2.0-beta.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/components/action-icon/ActionIcon.d.ts +4 -3
- package/dist/components/action-icon/ActionIcon.js +5 -3
- package/dist/components/action-icon/ActionIcon.js.map +1 -1
- package/dist/components/badge/BadgeText.js +1 -1
- package/dist/components/badge/BadgeText.js.map +1 -1
- package/dist/components/banner/BannerContainer.js.map +1 -1
- package/dist/components/banner/banner-regular/BannerRegular.d.ts +1 -0
- package/dist/components/banner/banner-regular/BannerRegularActions.js +1 -1
- package/dist/components/banner/banner-regular/BannerRegularActions.js.map +1 -1
- package/dist/components/banner/banner-regular/BannerRegularDismiss.d.ts +5 -3
- package/dist/components/banner/banner-slim/BannerSlim.d.ts +9 -2
- package/dist/components/banner/banner-slim/BannerSlimDismiss.d.ts +5 -3
- package/dist/components/button/Button.d.ts +2 -2
- package/dist/components/button/Button.js +21 -17
- package/dist/components/button/Button.js.map +1 -1
- package/dist/components/calendar/Calendar.js +2 -2
- package/dist/components/calendar/Calendar.js.map +1 -1
- package/dist/components/carousel/Carousel.js.map +1 -1
- package/dist/components/checkbox-group/CheckboxGroupAllItem.js +3 -2
- package/dist/components/checkbox-group/CheckboxGroupAllItem.js.map +1 -1
- package/dist/components/checkbox-group/CheckboxGroupChecked.context.js +1 -1
- package/dist/components/checkbox-group/CheckboxGroupChecked.context.js.map +1 -1
- package/dist/components/checkbox-group/CheckboxGroupMounted.context.js +1 -1
- package/dist/components/checkbox-group/CheckboxGroupMounted.context.js.map +1 -1
- package/dist/components/chip/Chip.js +2 -2
- package/dist/components/chip/Chip.js.map +1 -1
- package/dist/components/create-password-field/CreatePasswordField.js +5 -5
- package/dist/components/create-password-field/CreatePasswordField.js.map +1 -1
- package/dist/components/data-table/DataTableHeaderCell.js +8 -8
- package/dist/components/data-table/DataTableHeaderCell.js.map +1 -1
- package/dist/components/data-table/DataTableSelectAllRowsCheckbox.js.map +1 -1
- package/dist/components/data-table/getNewAsyncData.js +1 -1
- package/dist/components/data-table/getNewAsyncData.js.map +1 -1
- package/dist/components/date-input/DateInput.js.map +1 -1
- package/dist/components/dropdown-menu/DropdownMenu.d.ts +2 -1
- package/dist/components/dropdown-menu/DropdownMenuLinkItem.d.ts +2 -1
- package/dist/components/dropdown-menu/DropdownMenuLinkItem.js +18 -13
- package/dist/components/dropdown-menu/DropdownMenuLinkItem.js.map +1 -1
- package/dist/components/file-drop/FileDrop.js +2 -2
- package/dist/components/file-drop/FileDrop.js.map +1 -1
- package/dist/components/form/useFieldError.js +2 -1
- package/dist/components/form/useFieldError.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/link/Link.d.ts +2 -2
- package/dist/components/link/Link.js +13 -9
- package/dist/components/link/Link.js.map +1 -1
- package/dist/components/navigation/NavigationMenu.d.ts +2 -1
- package/dist/components/navigation/NavigationMenu.js +1 -1
- package/dist/components/navigation/NavigationMenu.js.map +1 -1
- package/dist/components/navigation/NavigationMenuLink.d.ts +2 -1
- package/dist/components/navigation/NavigationMenuLink.js +28 -13
- package/dist/components/navigation/NavigationMenuLink.js.map +1 -1
- package/dist/components/navigation-menu-vertical/NavigationMenuVertical.d.ts +4 -2
- package/dist/components/navigation-menu-vertical/NavigationMenuVerticalLink.d.ts +4 -2
- package/dist/components/navigation-menu-vertical/NavigationMenuVerticalLink.js +5 -3
- package/dist/components/navigation-menu-vertical/NavigationMenuVerticalLink.js.map +1 -1
- package/dist/components/number-input/NumberInputStepper.d.ts +5 -3
- package/dist/components/pagination/PaginationItems.js +2 -2
- package/dist/components/pagination/PaginationItems.js.map +1 -1
- package/dist/components/pagination/PaginationNextButton.d.ts +5 -3
- package/dist/components/pagination/PaginationPreviousButton.d.ts +5 -3
- package/dist/components/pagination/pagination.helper.js +5 -3
- package/dist/components/pagination/pagination.helper.js.map +1 -1
- package/dist/components/router-provider/Router.d.ts +9 -0
- package/dist/components/router-provider/Router.js +7 -0
- package/dist/components/router-provider/Router.js.map +1 -0
- package/dist/components/router-provider/RouterProvider.d.ts +16 -0
- package/dist/components/router-provider/RouterProvider.js +23 -0
- package/dist/components/router-provider/RouterProvider.js.map +1 -0
- package/dist/components/select-menu/SelectMenu.d.ts +16 -9
- package/dist/components/select-menu/SelectMenu.js +6 -4
- package/dist/components/select-menu/SelectMenu.js.map +1 -1
- package/dist/components/select-menu/SelectMenuContent.d.ts +5 -3
- package/dist/components/select-menu/SelectMenuContent.js +24 -65
- package/dist/components/select-menu/SelectMenuContent.js.map +1 -1
- package/dist/components/select-menu/SelectMenuItem.d.ts +5 -3
- package/dist/components/select-menu/SelectMenuItem.js +15 -15
- package/dist/components/select-menu/SelectMenuItem.js.map +1 -1
- package/dist/components/select-menu/SelectMenuLabel.d.ts +2 -2
- package/dist/components/select-menu/SelectMenuLabel.js +2 -2
- package/dist/components/select-menu/SelectMenuLabel.js.map +1 -1
- package/dist/components/select-menu/SelectMenuSeparator.d.ts +2 -2
- package/dist/components/select-menu/SelectMenuSeparator.js +2 -2
- package/dist/components/select-menu/SelectMenuSeparator.js.map +1 -1
- package/dist/components/select-menu/SelectMenuTrigger.d.ts +3 -2
- package/dist/components/select-menu/SelectMenuTrigger.js +12 -12
- package/dist/components/select-menu/SelectMenuTrigger.js.map +1 -1
- package/dist/components/select-menu-field/SelectMenuField.js +5 -5
- package/dist/components/select-menu-field/SelectMenuField.js.map +1 -1
- package/dist/components/slider/Slider.js.map +1 -1
- package/dist/components/slider-field/SliderField.js +2 -1
- package/dist/components/slider-field/SliderField.js.map +1 -1
- package/dist/components/sortable/Handle.d.ts +5 -3
- package/dist/components/stepper/Stepper.js +1 -1
- package/dist/components/stepper/Stepper.js.map +1 -1
- package/dist/components/stepper/StepperSteps.js +7 -5
- package/dist/components/stepper/StepperSteps.js.map +1 -1
- package/dist/components/table/useStickyColumnsCss.js +1 -1
- package/dist/components/table/useStickyColumnsCss.js.map +1 -1
- package/dist/components/tile-interactive/TileInteractive.d.ts +5 -3
- package/dist/components/tile-interactive/TileInteractive.js +4 -2
- package/dist/components/tile-interactive/TileInteractive.js.map +1 -1
- package/dist/components/tile-toggle-group/TileToggleGroupItem.d.ts +5 -2
- package/dist/components/top-bar/TopBar.d.ts +4 -2
- package/dist/docgen.json +1 -1
- package/dist/index.cjs.js +239 -218
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +2 -1
- package/dist/styled.js +15 -11
- package/dist/styled.js.map +1 -1
- package/dist/utilities/hooks/useResizeObserver.js +1 -3
- package/dist/utilities/hooks/useResizeObserver.js.map +1 -1
- package/dist/utilities/uri/index.js +2 -1
- package/dist/utilities/uri/index.js.map +1 -1
- package/package.json +15 -7
- package/src/utilities.css +1 -1
- package/dist/types/navigatorActions.types.d.ts +0 -5
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { NavigatorActions } from '../../types/navigatorActions.types';
|
|
3
2
|
import type { OptionalTooltipWrapperProps } from '../../utilities/optional-tooltip-wrapper/OptionalTooltipWrapper';
|
|
4
3
|
import type { Override } from '../../utilities/types';
|
|
5
4
|
declare const StyledButton: import("../..").PolymorphicComponent<"button", {
|
|
@@ -11,7 +10,9 @@ declare const StyledButton: import("../..").PolymorphicComponent<"button", {
|
|
|
11
10
|
type ActionIconProps = Override<React.ComponentProps<typeof StyledButton>, {
|
|
12
11
|
as?: React.ElementType;
|
|
13
12
|
children: React.ReactNode;
|
|
13
|
+
href?: string;
|
|
14
14
|
label: string;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
reloadDocument?: boolean;
|
|
16
|
+
} & Omit<OptionalTooltipWrapperProps, 'label'>>;
|
|
17
|
+
export declare const ActionIcon: ({ ref, children, theme, appearance, size, label, href, disabled, hasTooltip, tooltipSide, reloadDocument, ...rest }: ActionIconProps) => React.JSX.Element;
|
|
17
18
|
export {};
|
|
@@ -2,10 +2,11 @@ import { styled } from "../../styled.js";
|
|
|
2
2
|
import { Icon } from "../icon/Icon.js";
|
|
3
3
|
import { OptionalTooltipWrapper } from "../../utilities/optional-tooltip-wrapper/OptionalTooltipWrapper.js";
|
|
4
4
|
import { getExternalAnchorProps } from "../../utilities/uri/index.js";
|
|
5
|
+
import { useRouterLinkProps } from "../router-provider/RouterProvider.js";
|
|
5
6
|
import { ActionIconSizeMap } from "./ActionIcon.constants.js";
|
|
6
7
|
import * as React$1 from "react";
|
|
7
8
|
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
import invariant from "invariant";
|
|
9
|
+
import invariant from "tiny-invariant";
|
|
9
10
|
//#region src/components/action-icon/ActionIcon.tsx
|
|
10
11
|
var StyledButton = styled("button", {
|
|
11
12
|
base: [
|
|
@@ -102,16 +103,17 @@ var StyledButton = styled("button", {
|
|
|
102
103
|
isRounded: { true: ["rounded-full"] }
|
|
103
104
|
}
|
|
104
105
|
}, { enableResponsiveVariants: true });
|
|
105
|
-
var ActionIcon = ({ ref, children, theme = "primary", appearance = "simple", size = "sm", label, href, disabled, hasTooltip = true, tooltipSide, ...rest }) => {
|
|
106
|
+
var ActionIcon = ({ ref, children, theme = "primary", appearance = "simple", size = "sm", label, href, disabled, hasTooltip = true, tooltipSide, reloadDocument, ...rest }) => {
|
|
106
107
|
const INVALID_CHILDREN_MESSAGE = `A single ${Icon.name} component is permitted as a child of ActionIcon`;
|
|
107
108
|
invariant(React$1.Children.count(children) === 1, INVALID_CHILDREN_MESSAGE);
|
|
109
|
+
const routerLinkProps = useRouterLinkProps(href, { reloadDocument });
|
|
108
110
|
return /* @__PURE__ */ jsx(OptionalTooltipWrapper, {
|
|
109
111
|
hasTooltip,
|
|
110
112
|
label,
|
|
111
113
|
tooltipSide,
|
|
112
114
|
children: /* @__PURE__ */ jsx(StyledButton, {
|
|
113
115
|
...href ? {
|
|
114
|
-
as: "a",
|
|
116
|
+
as: routerLinkProps.as || "a",
|
|
115
117
|
href: disabled ? void 0 : href,
|
|
116
118
|
onClick: void 0,
|
|
117
119
|
"aria-disabled": !!disabled
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionIcon.js","names":[],"sources":["../../../src/components/action-icon/ActionIcon.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"ActionIcon.js","names":[],"sources":["../../../src/components/action-icon/ActionIcon.tsx"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\n\nimport { styled } from '../../styled'\nimport type { OptionalTooltipWrapperProps } from '../../utilities/optional-tooltip-wrapper/OptionalTooltipWrapper'\nimport { OptionalTooltipWrapper } from '../../utilities/optional-tooltip-wrapper/OptionalTooltipWrapper'\nimport type { Override } from '../../utilities/types'\nimport { getExternalAnchorProps } from '../../utilities/uri'\nimport { Icon } from '../icon/Icon'\nimport { useRouterLinkProps } from '../router-provider/RouterProvider'\nimport { ActionIconSizeMap } from './ActionIcon.constants'\n\nconst StyledButton = styled(\n 'button',\n {\n base: [\n 'items-center',\n 'appearance-none',\n 'bg-white',\n 'rounded-md',\n 'box-border',\n 'cursor-pointer',\n 'flex',\n 'shrink-0',\n 'justify-center',\n 'transition-all',\n 'duration-100',\n 'ease-out',\n 'disabled:cursor-not-allowed',\n 'disabled:opacity-30'\n ],\n variants: {\n theme: {\n neutral: [\n '[--solid-base:var(--color-white)]',\n '[--solid-interact:var(--color-grey-100)]',\n '[--solid-active:var(--color-grey-200)]',\n '[--solid-text:var(--color-grey-1200)]',\n '[--base:var(--color-grey-700)]',\n '[--interact:var(--color-primary-900)]',\n '[--active:var(--color-primary-1100)]'\n ],\n primary: [\n '[--base:var(--color-primary-800)]',\n '[--interact:var(--color-primary-900)]',\n '[--active:var(--color-primary-1000)]'\n ],\n primaryDark: [\n '[--base:var(--color-primary-1000)]',\n '[--interact:var(--color-primary-1100)]',\n '[--active:var(--color-primary-1200)]'\n ],\n success: [\n '[--base:var(--color-success)]',\n '[--interact:var(--color-success-mid)]',\n '[--active:var(--color-success-dark)]'\n ],\n warning: [\n '[--base:var(--color-warning)]',\n '[--interact:var(--color-warning-mid)]',\n '[--active:var(--color-warning-dark)]'\n ],\n danger: [\n '[--base:var(--color-danger)]',\n '[--interact:var(--color-danger-mid)]',\n '[--active:var(--color-danger-dark)]'\n ],\n white: [\n '[--base:var(--color-white)]',\n '[--interact:var(--color-white)]',\n '[--active:var(--color-white)]'\n ]\n },\n appearance: {\n simple: [\n 'bg-transparent',\n 'text-(--base)',\n 'not-disabled:hover:text-(--interact)',\n 'not-disabled:focus:text-(--interact)',\n 'not-disabled:active:text-(--active)'\n ],\n outline: [\n 'bg-[unset]',\n 'border',\n 'border-current',\n 'text-(--base)',\n 'not-disabled:hover:text-(--interact)',\n 'not-disabled:focus:text-(--interact)',\n 'not-disabled:active:text-(--active)'\n ],\n solid: [\n 'bg-(--solid-base,var(--base))',\n 'text-(--solid-text,white)',\n 'not-disabled:hover:bg-(--solid-interact,var(--interact))',\n 'not-disabled:hover:text-(--solid-text,white)',\n 'not-disabled:focus:bg-(--solid-interact,var(--interact))',\n 'not-disabled:focus:text-(--solid-text,white)',\n 'not-disabled:active:bg-(--solid-active,var(--active))'\n ]\n },\n size: {\n xs: ['size-6'],\n sm: ['size-8'],\n md: ['size-10'],\n lg: ['size-12']\n },\n isRounded: {\n true: ['rounded-full']\n }\n }\n },\n {\n enableResponsiveVariants: true\n }\n)\n\ntype ActionIconProps = Override<\n React.ComponentProps<typeof StyledButton>,\n {\n as?: React.ElementType\n children: React.ReactNode\n href?: string\n label: string\n reloadDocument?: boolean\n } & Omit<OptionalTooltipWrapperProps, 'label'>\n>\n\nexport const ActionIcon = ({\n ref,\n children,\n theme = 'primary',\n appearance = 'simple',\n size = 'sm',\n label,\n href,\n disabled,\n hasTooltip = true,\n tooltipSide,\n reloadDocument,\n ...rest\n}: ActionIconProps) => {\n const INVALID_CHILDREN_MESSAGE = `A single ${Icon.name} component is permitted as a child of ActionIcon`\n\n invariant(React.Children.count(children) === 1, INVALID_CHILDREN_MESSAGE)\n\n const routerLinkProps = useRouterLinkProps(href, { reloadDocument })\n\n // Polymorphic props: can be either button or anchor element\n const optionalLinkProps = href\n ? ({\n as: routerLinkProps.as || 'a',\n href: disabled ? undefined : href,\n onClick: undefined,\n 'aria-disabled': !!disabled\n } as const)\n : ({ type: 'button' } as const)\n\n return (\n <OptionalTooltipWrapper\n hasTooltip={hasTooltip}\n label={label}\n tooltipSide={tooltipSide}\n >\n <StyledButton\n {...optionalLinkProps}\n {...getExternalAnchorProps(href)}\n {...rest}\n aria-label={label}\n theme={theme}\n appearance={appearance}\n size={size}\n ref={ref}\n disabled={disabled}\n >\n {React.Children.map(children, (child) => {\n // TS needs this check for any following code to access child.type\n // even with optional chaining\n if (!React.isValidElement(child)) {\n throw new Error(INVALID_CHILDREN_MESSAGE)\n }\n\n invariant(\n child.type === Icon,\n `Children of type ${child?.type} aren't permitted. Only an ${Icon.name} component is allowed in ActionIcon`\n )\n\n return React.cloneElement(\n child as React.ReactElement<React.ComponentProps<typeof Icon>>,\n {\n size: ActionIconSizeMap[size as string]\n }\n )\n })}\n </StyledButton>\n </OptionalTooltipWrapper>\n )\n}\n"],"mappings":";;;;;;;;;;AAYA,IAAM,eAAe,OACnB,UACA;CACE,MAAM;EACJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,UAAU;EACR,OAAO;GACL,SAAS;IACP;IACA;IACA;IACA;IACA;IACA;IACA;GACF;GACA,SAAS;IACP;IACA;IACA;GACF;GACA,aAAa;IACX;IACA;IACA;GACF;GACA,SAAS;IACP;IACA;IACA;GACF;GACA,SAAS;IACP;IACA;IACA;GACF;GACA,QAAQ;IACN;IACA;IACA;GACF;GACA,OAAO;IACL;IACA;IACA;GACF;EACF;EACA,YAAY;GACV,QAAQ;IACN;IACA;IACA;IACA;IACA;GACF;GACA,SAAS;IACP;IACA;IACA;IACA;IACA;IACA;IACA;GACF;GACA,OAAO;IACL;IACA;IACA;IACA;IACA;IACA;IACA;GACF;EACF;EACA,MAAM;GACJ,IAAI,CAAC,QAAQ;GACb,IAAI,CAAC,QAAQ;GACb,IAAI,CAAC,SAAS;GACd,IAAI,CAAC,SAAS;EAChB;EACA,WAAW,EACT,MAAM,CAAC,cAAc,EACvB;CACF;AACF,GACA,EACE,0BAA0B,KAC5B,CACF;AAaA,IAAa,cAAc,EACzB,KACA,UACA,QAAQ,WACR,aAAa,UACb,OAAO,MACP,OACA,MACA,UACA,aAAa,MACb,aACA,gBACA,GAAG,WACkB;CACrB,MAAM,2BAA2B,YAAY,KAAK,KAAK;CAEvD,UAAU,QAAM,SAAS,MAAM,QAAQ,MAAM,GAAG,wBAAwB;CAExE,MAAM,kBAAkB,mBAAmB,MAAM,EAAE,eAAe,CAAC;CAYnE,OACE,oBAAC,wBAAD;EACc;EACL;EACM;YAEb,oBAAC,cAAD;GACE,GAhBoB,OACrB;IACC,IAAI,gBAAgB,MAAM;IAC1B,MAAM,WAAW,KAAA,IAAY;IAC7B,SAAS,KAAA;IACT,iBAAiB,CAAC,CAAC;GACrB,IACC,EAAE,MAAM,SAAS;GAUhB,GAAI,uBAAuB,IAAI;GAC/B,GAAI;GACJ,cAAY;GACL;GACK;GACN;GACD;GACK;aAET,QAAM,SAAS,IAAI,WAAW,UAAU;IAGvC,IAAI,CAAC,QAAM,eAAe,KAAK,GAC7B,MAAM,IAAI,MAAM,wBAAwB;IAG1C,UACE,MAAM,SAAS,MACf,oBAAoB,OAAO,KAAK,6BAA6B,KAAK,KAAK,oCACzE;IAEA,OAAO,QAAM,aACX,OACA,EACE,MAAM,kBAAkB,MAC1B,CACF;GACF,CAAC;EACW,CAAA;CACQ,CAAA;AAE5B"}
|
|
@@ -11,7 +11,7 @@ var ObserveBadgeTextOverflow = ({ elRef }) => {
|
|
|
11
11
|
const { setIsOverflowing } = React$1.use(BadgeContext);
|
|
12
12
|
useResizeObserver({
|
|
13
13
|
delay: 0,
|
|
14
|
-
elements: [elRef],
|
|
14
|
+
elements: React$1.useMemo(() => [elRef], [elRef]),
|
|
15
15
|
onResize: () => {
|
|
16
16
|
if (!elRef?.scrollWidth || !elRef?.clientWidth) return;
|
|
17
17
|
setIsOverflowing?.(elRef.scrollWidth > elRef.clientWidth);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BadgeText.js","names":[],"sources":["../../../src/components/badge/BadgeText.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { styled } from '../../styled'\nimport { useCallbackRefState } from '../../utilities/hooks/useCallbackRef'\nimport { useResizeObserver } from '../../utilities/hooks/useResizeObserver'\nimport { overrideStyledVariantValue } from '../../utilities/override-styled-variant-value/overrideStyledVariantValue'\nimport { Text } from '../text/Text'\nimport { BadgeContext } from './Badge.context'\n\n/*\n * Instead of sticking a resize observer on every `BadgeText`\n * regardless of overflow type, split the resize logic into a component.\n * Basically call the hook conditionally, only for the version with\n * the `overflow === 'ellipsis'` which needs it.\n * This saves us from initialising a resize observer for any badge which doesn't need it.\n */\nconst ObserveBadgeTextOverflow: React.FC<{ elRef: HTMLElement | null }> = ({\n elRef\n}) => {\n const { setIsOverflowing } = React.use(BadgeContext)\n\n useResizeObserver({\n delay: 0,\n elements
|
|
1
|
+
{"version":3,"file":"BadgeText.js","names":[],"sources":["../../../src/components/badge/BadgeText.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { styled } from '../../styled'\nimport { useCallbackRefState } from '../../utilities/hooks/useCallbackRef'\nimport { useResizeObserver } from '../../utilities/hooks/useResizeObserver'\nimport { overrideStyledVariantValue } from '../../utilities/override-styled-variant-value/overrideStyledVariantValue'\nimport { Text } from '../text/Text'\nimport { BadgeContext } from './Badge.context'\n\n/*\n * Instead of sticking a resize observer on every `BadgeText`\n * regardless of overflow type, split the resize logic into a component.\n * Basically call the hook conditionally, only for the version with\n * the `overflow === 'ellipsis'` which needs it.\n * This saves us from initialising a resize observer for any badge which doesn't need it.\n */\nconst ObserveBadgeTextOverflow: React.FC<{ elRef: HTMLElement | null }> = ({\n elRef\n}) => {\n const { setIsOverflowing } = React.use(BadgeContext)\n\n // `elements` feeds the observe effect's dependency array, so it must keep a\n // stable identity across renders — a fresh `[elRef]` literal would re-subscribe\n // the observer every render.\n const elements = React.useMemo(() => [elRef], [elRef])\n\n useResizeObserver({\n delay: 0,\n elements,\n onResize: () => {\n if (!elRef?.scrollWidth || !elRef?.clientWidth) return\n setIsOverflowing?.(elRef.scrollWidth > elRef.clientWidth)\n }\n })\n\n return null\n}\n\nconst StyledBadgeText = styled(Text, {\n base: ['py-0.5', 'capsize-none'],\n variants: {\n overflow: {\n ellipsis: ['overflow-x-hidden', 'text-ellipsis', 'whitespace-nowrap'],\n wrap: ['whitespace-normal']\n }\n }\n})\n\ntype BadgeTextProps = React.ComponentProps<typeof StyledBadgeText>\n\nconst toTextSize = {\n xs: 'sm',\n sm: 'md',\n md: 'md'\n}\n\nexport const BadgeText = ({ children, ...rest }: BadgeTextProps) => {\n // We need the return type here. Otherwise typsecript breaks when this type is used in Badge. Do not remove unless you want to tackle that issue again.\n const { size: badgeSize, overflow } = React.use(BadgeContext)\n\n const size = overrideStyledVariantValue(badgeSize, (s) => toTextSize[s])\n\n const [elRef, setElRef] = useCallbackRefState()\n\n return (\n <>\n {overflow === 'ellipsis' && <ObserveBadgeTextOverflow elRef={elRef} />}\n <StyledBadgeText size={size} overflow={overflow} ref={setElRef} {...rest}>\n {children}\n </StyledBadgeText>\n </>\n )\n}\n"],"mappings":";;;;;;;;;AAgBA,IAAM,4BAAqE,EACzE,YACI;CACJ,MAAM,EAAE,qBAAqB,QAAM,IAAI,YAAY;CAOnD,kBAAkB;EAChB,OAAO;EACP,UAJe,QAAM,cAAc,CAAC,KAAK,GAAG,CAAC,KAAK,CAIlD;EACA,gBAAgB;GACd,IAAI,CAAC,OAAO,eAAe,CAAC,OAAO,aAAa;GAChD,mBAAmB,MAAM,cAAc,MAAM,WAAW;EAC1D;CACF,CAAC;CAED,OAAO;AACT;AAEA,IAAM,kBAAkB,OAAO,MAAM;CACnC,MAAM,CAAC,UAAU,cAAc;CAC/B,UAAU,EACR,UAAU;EACR,UAAU;GAAC;GAAqB;GAAiB;EAAmB;EACpE,MAAM,CAAC,mBAAmB;CAC5B,EACF;AACF,CAAC;AAID,IAAM,aAAa;CACjB,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,IAAa,aAAa,EAAE,UAAU,GAAG,WAA2B;CAElE,MAAM,EAAE,MAAM,WAAW,aAAa,QAAM,IAAI,YAAY;CAE5D,MAAM,OAAO,2BAA2B,YAAY,MAAM,WAAW,EAAE;CAEvE,MAAM,CAAC,OAAO,YAAY,oBAAoB;CAE9C,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,aAAa,cAAc,oBAAC,0BAAD,EAAiC,MAAQ,CAAA,GACrE,oBAAC,iBAAD;EAAuB;EAAgB;EAAU,KAAK;EAAU,GAAI;EACjE;CACc,CAAA,CACjB,EAAA,CAAA;AAEN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerContainer.js","names":[],"sources":["../../../src/components/banner/BannerContainer.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {\n ColorScheme,\n type TcolorScheme\n} from '../../experiments/color-scheme/ColorScheme'\nimport { styled } from '../../styled'\nimport { Dismissible } from '../dismissible'\nimport { useBannerContext } from './Banner.context'\n\nconst StyledBannerContainer = styled(\n 'section',\n {\n base: [\n 'flex',\n 'relative',\n 'w-full',\n 'rounded-lg',\n 'overflow-hidden',\n 'text-(--foreground)',\n '[--banner-heading-color:var(--color-foreground)]',\n '[--banner-text-color:var(--color-grey-900)]'\n ],\n variants: {\n emphasis: {\n bold: [\n '[--banner-heading-color:var(--color-foreground-7-plus)]',\n '[--banner-text-color:var(--color-grey-100)]',\n 'bg-(--base-11)',\n 'text-(--foreground-7-plus)'\n ],\n subtle: ['bg-(--base-3)'],\n minimal: ['bg-(--base-1)']\n },\n size: {\n sm: [],\n md: []\n }\n }\n },\n {\n enableResponsiveVariants: true\n }\n)\n\nexport type BannerContainerProps = React.ComponentProps<\n typeof StyledBannerContainer\n> & {\n colorScheme?: TcolorScheme\n} & React.ComponentProps<typeof Dismissible>\n\nexport const BannerContainer = ({\n colorScheme = {},\n onDismiss,\n dismissed,\n ...rest\n}: BannerContainerProps) => {\n const { emphasis } = useBannerContext()\n\n return (\n <ColorScheme {...colorScheme} asChild>\n <Dismissible asChild onDismiss={onDismiss} dismissed={dismissed}>\n <StyledBannerContainer role=\"banner\" emphasis={emphasis} {...rest} />\n </Dismissible>\n </ColorScheme>\n )\n}\n"],"mappings":";;;;;;;AAUA,IAAM,wBAAwB,OAC5B,WACA;CACE,MAAM;EACJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,UAAU;EACR,UAAU;GACR,MAAM;IACJ;IACA;IACA;IACA;GACF;GACA,QAAQ,CAAC,eAAe;GACxB,SAAS,CAAC,eAAe;EAC3B;EACA,MAAM;GACJ,IAAI,CAAC;GACL,IAAI,CAAC;EACP;CACF;AACF,GACA,EACE,0BAA0B,KAC5B,CACF;AAQA,IAAa,mBAAmB,EAC9B,cAAc,CAAC,GACf,WACA,WACA,GAAG,WACuB;CAC1B,MAAM,EAAE,aAAa,iBAAiB;CAEtC,OACE,oBAAC,aAAD;EAAa,GAAI;EAAa,SAAA;YAC5B,oBAAC,aAAD;GAAa,SAAA;GAAmB;GAAsB;
|
|
1
|
+
{"version":3,"file":"BannerContainer.js","names":[],"sources":["../../../src/components/banner/BannerContainer.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {\n ColorScheme,\n type TcolorScheme\n} from '../../experiments/color-scheme/ColorScheme'\nimport { styled } from '../../styled'\nimport { Dismissible } from '../dismissible'\nimport { useBannerContext } from './Banner.context'\n\nconst StyledBannerContainer = styled(\n 'section',\n {\n base: [\n 'flex',\n 'relative',\n 'w-full',\n 'rounded-lg',\n 'overflow-hidden',\n 'text-(--foreground)',\n '[--banner-heading-color:var(--color-foreground)]',\n '[--banner-text-color:var(--color-grey-900)]'\n ],\n variants: {\n emphasis: {\n bold: [\n '[--banner-heading-color:var(--color-foreground-7-plus)]',\n '[--banner-text-color:var(--color-grey-100)]',\n 'bg-(--base-11)',\n 'text-(--foreground-7-plus)'\n ],\n subtle: ['bg-(--base-3)'],\n minimal: ['bg-(--base-1)']\n },\n size: {\n sm: [],\n md: []\n }\n }\n },\n {\n enableResponsiveVariants: true\n }\n)\n\nexport type BannerContainerProps = React.ComponentProps<\n typeof StyledBannerContainer\n> & {\n colorScheme?: TcolorScheme\n} & React.ComponentProps<typeof Dismissible>\n\nexport const BannerContainer = ({\n colorScheme = {},\n onDismiss,\n dismissed,\n ...rest\n}: BannerContainerProps) => {\n const { emphasis } = useBannerContext()\n\n return (\n <ColorScheme {...colorScheme} asChild>\n <Dismissible asChild onDismiss={onDismiss} dismissed={dismissed}>\n {/* Explicit role keeps the banner landmark regardless of where the\n banner is nested, which a native <header> would only expose at the\n top level. */}\n {/* eslint-disable-next-line jsx-a11y/prefer-tag-over-role */}\n <StyledBannerContainer role=\"banner\" emphasis={emphasis} {...rest} />\n </Dismissible>\n </ColorScheme>\n )\n}\n"],"mappings":";;;;;;;AAUA,IAAM,wBAAwB,OAC5B,WACA;CACE,MAAM;EACJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,UAAU;EACR,UAAU;GACR,MAAM;IACJ;IACA;IACA;IACA;GACF;GACA,QAAQ,CAAC,eAAe;GACxB,SAAS,CAAC,eAAe;EAC3B;EACA,MAAM;GACJ,IAAI,CAAC;GACL,IAAI,CAAC;EACP;CACF;AACF,GACA,EACE,0BAA0B,KAC5B,CACF;AAQA,IAAa,mBAAmB,EAC9B,cAAc,CAAC,GACf,WACA,WACA,GAAG,WACuB;CAC1B,MAAM,EAAE,aAAa,iBAAiB;CAEtC,OACE,oBAAC,aAAD;EAAa,GAAI;EAAa,SAAA;YAC5B,oBAAC,aAAD;GAAa,SAAA;GAAmB;GAAsB;aAKpD,oBAAC,uBAAD;IAAuB,MAAK;IAAmB;IAAU,GAAI;GAAO,CAAA;EACzD,CAAA;CACF,CAAA;AAEjB"}
|
|
@@ -336,6 +336,7 @@ export declare const BannerRegular: {
|
|
|
336
336
|
size?: ("lg" | "md" | "sm" | "xs" | Partial<Record<"@initial" | "@lg" | "@md" | "@sm" | "@xl", "lg" | "md" | "sm" | "xs">>) | undefined;
|
|
337
337
|
isRounded?: (boolean | Partial<Record<"@initial" | "@lg" | "@md" | "@sm" | "@xl", boolean>>) | undefined;
|
|
338
338
|
label: string;
|
|
339
|
+
reloadDocument?: boolean;
|
|
339
340
|
}): React.JSX.Element;
|
|
340
341
|
displayName: string;
|
|
341
342
|
};
|
|
@@ -3,7 +3,7 @@ import { useBannerContext } from "../Banner.context.js";
|
|
|
3
3
|
import { BannerRegularButton } from "./BannerRegularButton.js";
|
|
4
4
|
import * as React$1 from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
import invariant from "invariant";
|
|
6
|
+
import invariant from "tiny-invariant";
|
|
7
7
|
//#region src/components/banner/banner-regular/BannerRegularActions.tsx
|
|
8
8
|
var MAX_ALLOWED_CHILDREN = 2;
|
|
9
9
|
var toGap = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerRegularActions.js","names":[],"sources":["../../../../src/components/banner/banner-regular/BannerRegularActions.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"BannerRegularActions.js","names":[],"sources":["../../../../src/components/banner/banner-regular/BannerRegularActions.tsx"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\n\nimport { cn } from '../../../styled'\nimport { useBannerContext } from '../Banner.context'\nimport { BannerRegularButton } from './BannerRegularButton'\n\nconst MAX_ALLOWED_CHILDREN = 2\n\nconst toGap = {\n sm: 'gap-2',\n md: 'gap-4'\n}\n\nconst toDirection = {\n sm: 'flex-col',\n md: 'flex-row'\n}\n\nexport const BannerRegularActions = ({\n children,\n className,\n ...rest\n}: React.PropsWithChildren<React.ComponentProps<'div'>>) => {\n const { size } = useBannerContext()\n\n const gap = typeof size === 'string' ? toGap[size] : 'gap-2 md:gap-4'\n\n const direction =\n typeof size === 'string' ? toDirection[size] : 'flex-col md:flex-row'\n\n invariant(\n React.Children.count(children) <= MAX_ALLOWED_CHILDREN,\n `A maximum of ${MAX_ALLOWED_CHILDREN} ${BannerRegularButton.displayName} component(s) are permitted as children of ${BannerRegularActions.displayName}`\n )\n\n return (\n <div className={cn('flex', gap, direction, className)} {...rest}>\n {React.Children.map(children, (child, index) => {\n // if child is undefined or null, React.isValidElement returns false and hence error is thrown.\n // This line will prevent that from happening\n if (child == null) return child\n\n if (!React.isValidElement(child)) {\n throw new Error(\n `Child passed to ${BannerRegularActions.displayName} is not a valid element`\n )\n }\n\n invariant(\n child.type === BannerRegularButton,\n `Children of type ${child?.type} aren't permitted. Only an ${BannerRegularButton.displayName} component is allowed in ${BannerRegularActions.displayName}`\n )\n\n const propsToInject: Partial<\n React.ComponentProps<typeof BannerRegularButton>\n > = {\n // Override button appearance - make the second button outlined\n appearance: index > 0 ? 'outline' : undefined\n }\n\n return React.cloneElement(\n child as React.ReactElement<\n React.ComponentProps<typeof BannerRegularButton>\n >,\n propsToInject\n )\n })}\n </div>\n )\n}\n\nBannerRegularActions.displayName = 'BannerRegularActions'\n"],"mappings":";;;;;;;AAOA,IAAM,uBAAuB;AAE7B,IAAM,QAAQ;CACZ,IAAI;CACJ,IAAI;AACN;AAEA,IAAM,cAAc;CAClB,IAAI;CACJ,IAAI;AACN;AAEA,IAAa,wBAAwB,EACnC,UACA,WACA,GAAG,WACuD;CAC1D,MAAM,EAAE,SAAS,iBAAiB;CAElC,MAAM,MAAM,OAAO,SAAS,WAAW,MAAM,QAAQ;CAErD,MAAM,YACJ,OAAO,SAAS,WAAW,YAAY,QAAQ;CAEjD,UACE,QAAM,SAAS,MAAM,QAAQ,KAAK,sBAClC,gBAAgB,qBAAqB,GAAG,oBAAoB,YAAY,6CAA6C,qBAAqB,aAC5I;CAEA,OACE,oBAAC,OAAD;EAAK,WAAW,GAAG,QAAQ,KAAK,WAAW,SAAS;EAAG,GAAI;YACxD,QAAM,SAAS,IAAI,WAAW,OAAO,UAAU;GAG9C,IAAI,SAAS,MAAM,OAAO;GAE1B,IAAI,CAAC,QAAM,eAAe,KAAK,GAC7B,MAAM,IAAI,MACR,mBAAmB,qBAAqB,YAAY,wBACtD;GAGF,UACE,MAAM,SAAS,qBACf,oBAAoB,OAAO,KAAK,6BAA6B,oBAAoB,YAAY,2BAA2B,qBAAqB,aAC/I;GAEA,MAAM,gBAEF,EAEF,YAAY,QAAQ,IAAI,YAAY,KAAA,EACtC;GAEA,OAAO,QAAM,aACX,OAGA,aACF;EACF,CAAC;CACE,CAAA;AAET;AAEA,qBAAqB,cAAc"}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
declare const StyledDismiss: import("../../..").PolymorphicComponent<({ ref, children, theme, appearance, size, label, href, disabled, hasTooltip, tooltipSide, ...rest }: Omit<{
|
|
2
|
+
declare const StyledDismiss: import("../../..").PolymorphicComponent<({ ref, children, theme, appearance, size, label, href, disabled, hasTooltip, tooltipSide, reloadDocument, ...rest }: Omit<{
|
|
3
3
|
theme?: ("danger" | "neutral" | "primary" | "primaryDark" | "success" | "warning" | "white" | Partial<Record<"@initial" | "@lg" | "@md" | "@sm" | "@xl", "danger" | "neutral" | "primary" | "primaryDark" | "success" | "warning" | "white">>) | undefined;
|
|
4
4
|
appearance?: ("outline" | "simple" | "solid" | Partial<Record<"@initial" | "@lg" | "@md" | "@sm" | "@xl", "outline" | "simple" | "solid">>) | undefined;
|
|
5
5
|
size?: ("lg" | "md" | "sm" | "xs" | Partial<Record<"@initial" | "@lg" | "@md" | "@sm" | "@xl", "lg" | "md" | "sm" | "xs">>) | undefined;
|
|
6
6
|
isRounded?: (boolean | Partial<Record<"@initial" | "@lg" | "@md" | "@sm" | "@xl", boolean>>) | undefined;
|
|
7
7
|
} & {
|
|
8
8
|
as?: never;
|
|
9
|
-
} & Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "appearance" | "as" | "isRounded" | "size" | "theme">, "as" | "children" | "hasTooltip" | "label" | "
|
|
9
|
+
} & Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "appearance" | "as" | "isRounded" | "size" | "theme">, "as" | "children" | "hasTooltip" | "href" | "label" | "reloadDocument" | "tooltipSide"> & {
|
|
10
10
|
as?: React.ElementType;
|
|
11
11
|
children: React.ReactNode;
|
|
12
|
+
href?: string;
|
|
12
13
|
label: string;
|
|
13
|
-
|
|
14
|
+
reloadDocument?: boolean;
|
|
15
|
+
} & Omit<import("../../..").OptionalTooltipWrapperProps, "label">) => React.JSX.Element, unknown>;
|
|
14
16
|
type BannerRegularDismissProps = Omit<React.ComponentProps<typeof StyledDismiss>, 'children' | 'onClick' | 'href'>;
|
|
15
17
|
export declare function BannerRegularDismiss({ label, ...rest }: BannerRegularDismissProps): React.JSX.Element;
|
|
16
18
|
export declare namespace BannerRegularDismiss {
|
|
@@ -20,11 +20,17 @@ export declare const BannerSlim: {
|
|
|
20
20
|
size?: ("lg" | "md" | "sm" | "xl" | Partial<Record<"@initial" | "@lg" | "@md" | "@sm" | "@xl", "lg" | "md" | "sm" | "xl">>) | undefined;
|
|
21
21
|
isLoading?: (boolean | Partial<Record<"@initial" | "@lg" | "@md" | "@sm" | "@xl", boolean>>) | undefined;
|
|
22
22
|
fullWidth?: (boolean | Partial<Record<"@initial" | "@lg" | "@md" | "@sm" | "@xl", boolean>>) | undefined;
|
|
23
|
-
},
|
|
23
|
+
}, keyof {
|
|
24
24
|
children: React.ReactNode;
|
|
25
25
|
href?: string;
|
|
26
26
|
isLoading?: boolean;
|
|
27
|
-
|
|
27
|
+
reloadDocument?: boolean;
|
|
28
|
+
}> & {
|
|
29
|
+
children: React.ReactNode;
|
|
30
|
+
href?: string;
|
|
31
|
+
isLoading?: boolean;
|
|
32
|
+
reloadDocument?: boolean;
|
|
33
|
+
}>;
|
|
28
34
|
Dismiss: {
|
|
29
35
|
({ label, ...rest }: {
|
|
30
36
|
key?: React.Key | null | undefined;
|
|
@@ -329,6 +335,7 @@ export declare const BannerSlim: {
|
|
|
329
335
|
size?: ("lg" | "md" | "sm" | "xs" | Partial<Record<"@initial" | "@lg" | "@md" | "@sm" | "@xl", "lg" | "md" | "sm" | "xs">>) | undefined;
|
|
330
336
|
isRounded?: (boolean | Partial<Record<"@initial" | "@lg" | "@md" | "@sm" | "@xl", boolean>>) | undefined;
|
|
331
337
|
label: string;
|
|
338
|
+
reloadDocument?: boolean;
|
|
332
339
|
emphasis?: ("bold" | Partial<Record<"@initial" | "@lg" | "@md" | "@sm" | "@xl", "bold">>) | undefined;
|
|
333
340
|
containerSize?: ("md" | "sm" | Partial<Record<"@initial" | "@lg" | "@md" | "@sm" | "@xl", "md" | "sm">>) | undefined;
|
|
334
341
|
}): React.JSX.Element;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
declare const StyledDismiss: import("../../..").PolymorphicComponent<({ ref, children, theme, appearance, size, label, href, disabled, hasTooltip, tooltipSide, ...rest }: Omit<{
|
|
2
|
+
declare const StyledDismiss: import("../../..").PolymorphicComponent<({ ref, children, theme, appearance, size, label, href, disabled, hasTooltip, tooltipSide, reloadDocument, ...rest }: Omit<{
|
|
3
3
|
theme?: ("danger" | "neutral" | "primary" | "primaryDark" | "success" | "warning" | "white" | Partial<Record<"@initial" | "@lg" | "@md" | "@sm" | "@xl", "danger" | "neutral" | "primary" | "primaryDark" | "success" | "warning" | "white">>) | undefined;
|
|
4
4
|
appearance?: ("outline" | "simple" | "solid" | Partial<Record<"@initial" | "@lg" | "@md" | "@sm" | "@xl", "outline" | "simple" | "solid">>) | undefined;
|
|
5
5
|
size?: ("lg" | "md" | "sm" | "xs" | Partial<Record<"@initial" | "@lg" | "@md" | "@sm" | "@xl", "lg" | "md" | "sm" | "xs">>) | undefined;
|
|
6
6
|
isRounded?: (boolean | Partial<Record<"@initial" | "@lg" | "@md" | "@sm" | "@xl", boolean>>) | undefined;
|
|
7
7
|
} & {
|
|
8
8
|
as?: never;
|
|
9
|
-
} & Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "appearance" | "as" | "isRounded" | "size" | "theme">, "as" | "children" | "hasTooltip" | "label" | "
|
|
9
|
+
} & Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "appearance" | "as" | "isRounded" | "size" | "theme">, "as" | "children" | "hasTooltip" | "href" | "label" | "reloadDocument" | "tooltipSide"> & {
|
|
10
10
|
as?: React.ElementType;
|
|
11
11
|
children: React.ReactNode;
|
|
12
|
+
href?: string;
|
|
12
13
|
label: string;
|
|
13
|
-
|
|
14
|
+
reloadDocument?: boolean;
|
|
15
|
+
} & Omit<import("../../..").OptionalTooltipWrapperProps, "label">) => React.JSX.Element, {
|
|
14
16
|
emphasis?: ("bold" | Partial<Record<"@initial" | "@lg" | "@md" | "@sm" | "@xl", "bold">>) | undefined;
|
|
15
17
|
containerSize?: ("md" | "sm" | Partial<Record<"@initial" | "@lg" | "@md" | "@sm" | "@xl", "md" | "sm">>) | undefined;
|
|
16
18
|
}>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type PolymorphicComponent } from '../../styled';
|
|
3
|
-
import type { NavigatorActions } from '../../types/navigatorActions.types';
|
|
4
3
|
import type { Override } from '../../utilities/types';
|
|
5
4
|
export declare const StyledButton: PolymorphicComponent<"button", {
|
|
6
5
|
theme?: ("danger" | "neutral" | "primary" | "secondary" | "success" | "warning" | Partial<Record<"@initial" | "@lg" | "@md" | "@sm" | "@xl", "danger" | "neutral" | "primary" | "secondary" | "success" | "warning">>) | undefined;
|
|
@@ -13,7 +12,8 @@ type ButtonCustomProps = {
|
|
|
13
12
|
children: React.ReactNode;
|
|
14
13
|
href?: string;
|
|
15
14
|
isLoading?: boolean;
|
|
16
|
-
|
|
15
|
+
reloadDocument?: boolean;
|
|
16
|
+
};
|
|
17
17
|
type StyledButtonOwnProps = typeof StyledButton extends PolymorphicComponent<infer _Element extends React.ElementType, infer OwnProps> ? OwnProps : never;
|
|
18
18
|
type ButtonOwnProps = Override<StyledButtonOwnProps, ButtonCustomProps>;
|
|
19
19
|
export declare const Button: PolymorphicComponent<'button', ButtonOwnProps>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { styled } from "../../styled.js";
|
|
2
2
|
import { getExternalAnchorProps } from "../../utilities/uri/index.js";
|
|
3
|
+
import { useRouterLinkProps } from "../router-provider/RouterProvider.js";
|
|
3
4
|
import { Loader } from "../loader/Loader.js";
|
|
4
5
|
import "react";
|
|
5
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -153,23 +154,26 @@ var WithLoader = ({ size, children }) => /* @__PURE__ */ jsxs(Fragment, { childr
|
|
|
153
154
|
size,
|
|
154
155
|
children
|
|
155
156
|
})] });
|
|
156
|
-
var Button = (({ ref, children, as, href, isLoading = false, onClick, disabled, ...rest }) =>
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
href,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
children
|
|
171
|
-
|
|
172
|
-
|
|
157
|
+
var Button = (({ ref, children, as, href, isLoading = false, onClick, disabled, reloadDocument, ...rest }) => {
|
|
158
|
+
const routerLinkProps = useRouterLinkProps(href, { reloadDocument });
|
|
159
|
+
return /* @__PURE__ */ jsx(StyledButton, {
|
|
160
|
+
as: as || routerLinkProps.as || (href ? "a" : void 0),
|
|
161
|
+
...!disabled && !isLoading && {
|
|
162
|
+
href,
|
|
163
|
+
onClick
|
|
164
|
+
},
|
|
165
|
+
isLoading,
|
|
166
|
+
type: !href ? "button" : void 0,
|
|
167
|
+
disabled,
|
|
168
|
+
...rest,
|
|
169
|
+
...getExternalAnchorProps(href),
|
|
170
|
+
ref,
|
|
171
|
+
children: isLoading ? /* @__PURE__ */ jsx(WithLoader, {
|
|
172
|
+
size: rest.size,
|
|
173
|
+
children
|
|
174
|
+
}) : children
|
|
175
|
+
});
|
|
176
|
+
});
|
|
173
177
|
//#endregion
|
|
174
178
|
export { Button, StyledButton };
|
|
175
179
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","names":[],"sources":["../../../src/components/button/Button.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { type PolymorphicComponent, styled } from '../../styled'\nimport type {
|
|
1
|
+
{"version":3,"file":"Button.js","names":[],"sources":["../../../src/components/button/Button.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { type PolymorphicComponent, styled } from '../../styled'\nimport type { Override } from '../../utilities/types'\nimport { getExternalAnchorProps } from '../../utilities/uri'\nimport { Loader } from '../loader/Loader'\nimport { useRouterLinkProps } from '../router-provider/RouterProvider'\n\nexport const StyledButton = styled(\n 'button',\n {\n base: [\n 'items-center',\n 'bg-[unset]',\n 'rounded-md',\n 'cursor-pointer',\n 'flex',\n 'font-body',\n 'font-semibold',\n 'justify-center',\n 'no-underline',\n 'transition-all',\n 'duration-100',\n 'ease-out',\n 'whitespace-nowrap',\n 'w-max',\n 'disabled:cursor-not-allowed',\n 'disabled:opacity-30'\n ],\n variants: {\n theme: {\n primary: [\n '[--base:var(--color-primary-800)]',\n '[--interact:var(--color-primary-900)]',\n '[--active:var(--color-primary-1000)]'\n ],\n secondary: [\n '[--base:var(--color-primary-1000)]',\n '[--interact:var(--color-primary-1100)]',\n '[--active:var(--color-primary-1200)]'\n ],\n success: [\n '[--base:var(--color-success)]',\n '[--interact:var(--color-success-mid)]',\n '[--active:var(--color-success-dark)]'\n ],\n warning: [\n '[--base:var(--color-warning)]',\n '[--interact:var(--color-warning-mid)]',\n '[--active:var(--color-warning-dark)]',\n '[--text:var(--color-grey-800)]'\n ],\n danger: [\n '[--base:var(--color-danger)]',\n '[--interact:var(--color-danger-mid)]',\n '[--active:var(--color-danger-dark)]'\n ],\n neutral: [\n '[--base:white]',\n '[--interact:rgba(255,255,255,0.9)]',\n '[--active:rgba(255,255,255,0.75)]',\n '[--text:var(--color-primary-800)]'\n ]\n },\n appearance: {\n solid: [\n 'bg-(--base)',\n 'text-(--text,white)',\n 'disabled:opacity-30',\n 'disabled:cursor-not-allowed',\n 'not-disabled:hover:bg-(--interact)',\n 'not-disabled:hover:text-(--text,white)',\n 'not-disabled:focus:bg-(--interact)',\n 'not-disabled:focus:text-(--text,white)',\n 'not-disabled:active:bg-(--active)'\n ],\n outline: [\n 'border',\n 'border-current',\n 'text-(--base)',\n 'disabled:opacity-30',\n 'disabled:cursor-not-allowed',\n 'not-disabled:hover:no-underline',\n 'not-disabled:hover:text-(--interact)',\n 'not-disabled:focus:no-underline',\n 'not-disabled:focus:text-(--interact)',\n 'not-disabled:active:text-(--active)'\n ]\n },\n size: {\n sm: [\n 'text-sm',\n 'leading-[1.53]',\n 'h-8',\n 'px-4',\n 'gap-2',\n '[&_svg]:size-4'\n ],\n md: [\n 'text-md',\n 'leading-normal',\n 'h-10',\n 'px-8',\n 'gap-3',\n '[&_svg]:size-5'\n ],\n lg: [\n 'text-lg',\n 'leading-normal',\n 'h-12',\n 'px-8',\n 'gap-3',\n '[&_svg]:size-[22px]'\n ],\n xl: [\n 'text-lg',\n 'leading-normal',\n 'h-16',\n 'px-8',\n 'gap-3',\n '[&_svg]:size-[22px]'\n ]\n },\n isLoading: {\n true: ['cursor-not-allowed', 'opacity-60', 'pointer-events-none']\n },\n fullWidth: {\n true: ['w-full'],\n false: ['w-max']\n }\n },\n defaultVariants: {\n appearance: 'solid',\n size: 'md',\n theme: 'primary'\n }\n },\n {\n enableResponsiveVariants: true\n }\n)\n\n// @__PURE__ keeps this tree-shakable for consumers importing only\n// StyledButton from this module.\nconst LoaderContentsWrapper = /* @__PURE__ */ styled(\n 'span',\n {\n base: ['items-center', 'flex', 'justify-center', 'invisible'],\n variants: {\n size: {\n sm: ['gap-2'],\n md: ['gap-3'],\n lg: ['gap-3'],\n xl: ['gap-3']\n }\n },\n defaultVariants: {\n size: 'md'\n }\n },\n {\n enableResponsiveVariants: true\n }\n)\n\nconst WithLoader = ({\n size,\n children\n}: React.ComponentProps<typeof LoaderContentsWrapper>) => (\n <>\n <Loader className=\"absolute\" />\n <LoaderContentsWrapper size={size}>{children}</LoaderContentsWrapper>\n </>\n)\n\ntype ButtonCustomProps = {\n children: React.ReactNode\n href?: string\n isLoading?: boolean\n reloadDocument?: boolean\n}\n\ntype ButtonProps = Override<\n React.ComponentProps<typeof StyledButton>,\n ButtonCustomProps & { as?: React.ElementType }\n>\n\n// Re-expose StyledButton's variant props merged with our own, so the public\n// polymorphic type re-checks props against whatever `as` target is passed\ntype StyledButtonOwnProps =\n typeof StyledButton extends PolymorphicComponent<\n infer _Element extends React.ElementType,\n infer OwnProps\n >\n ? OwnProps\n : never\n\ntype ButtonOwnProps = Override<StyledButtonOwnProps, ButtonCustomProps>\n\nexport const Button = (({\n ref,\n children,\n as,\n href,\n isLoading = false,\n onClick,\n disabled,\n reloadDocument,\n ...rest\n}: ButtonProps) => {\n const routerLinkProps = useRouterLinkProps(href, { reloadDocument })\n\n return (\n <StyledButton\n as={as || routerLinkProps.as || (href ? 'a' : undefined)}\n {...(!disabled && !isLoading && { href, onClick })}\n isLoading={isLoading}\n type={!href ? 'button' : undefined}\n disabled={disabled}\n {...rest}\n {...getExternalAnchorProps(href)}\n ref={ref}\n >\n {isLoading ? (\n <WithLoader size={rest.size}>{children}</WithLoader>\n ) : (\n children\n )}\n </StyledButton>\n )\n}) as PolymorphicComponent<'button', ButtonOwnProps>\n"],"mappings":";;;;;;;AAQA,IAAa,eAAe,OAC1B,UACA;CACE,MAAM;EACJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,UAAU;EACR,OAAO;GACL,SAAS;IACP;IACA;IACA;GACF;GACA,WAAW;IACT;IACA;IACA;GACF;GACA,SAAS;IACP;IACA;IACA;GACF;GACA,SAAS;IACP;IACA;IACA;IACA;GACF;GACA,QAAQ;IACN;IACA;IACA;GACF;GACA,SAAS;IACP;IACA;IACA;IACA;GACF;EACF;EACA,YAAY;GACV,OAAO;IACL;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;GACA,SAAS;IACP;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;EACF;EACA,MAAM;GACJ,IAAI;IACF;IACA;IACA;IACA;IACA;IACA;GACF;GACA,IAAI;IACF;IACA;IACA;IACA;IACA;IACA;GACF;GACA,IAAI;IACF;IACA;IACA;IACA;IACA;IACA;GACF;GACA,IAAI;IACF;IACA;IACA;IACA;IACA;IACA;GACF;EACF;EACA,WAAW,EACT,MAAM;GAAC;GAAsB;GAAc;EAAqB,EAClE;EACA,WAAW;GACT,MAAM,CAAC,QAAQ;GACf,OAAO,CAAC,OAAO;EACjB;CACF;CACA,iBAAiB;EACf,YAAY;EACZ,MAAM;EACN,OAAO;CACT;AACF,GACA,EACE,0BAA0B,KAC5B,CACF;;AAIA,IAAM,wBAAwC,uBAC5C,QACA;CACE,MAAM;EAAC;EAAgB;EAAQ;EAAkB;CAAW;CAC5D,UAAU,EACR,MAAM;EACJ,IAAI,CAAC,OAAO;EACZ,IAAI,CAAC,OAAO;EACZ,IAAI,CAAC,OAAO;EACZ,IAAI,CAAC,OAAO;CACd,EACF;CACA,iBAAiB,EACf,MAAM,KACR;AACF,GACA,EACE,0BAA0B,KAC5B,CACF;AAEA,IAAM,cAAc,EAClB,MACA,eAEA,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,QAAD,EAAQ,WAAU,WAAY,CAAA,GAC9B,oBAAC,uBAAD;CAA6B;CAAO;AAAgC,CAAA,CACpE,EAAA,CAAA;AA2BJ,IAAa,WAAW,EACtB,KACA,UACA,IACA,MACA,YAAY,OACZ,SACA,UACA,gBACA,GAAG,WACc;CACjB,MAAM,kBAAkB,mBAAmB,MAAM,EAAE,eAAe,CAAC;CAEnE,OACE,oBAAC,cAAD;EACE,IAAI,MAAM,gBAAgB,OAAO,OAAO,MAAM,KAAA;EAC9C,GAAK,CAAC,YAAY,CAAC,aAAa;GAAE;GAAM;EAAQ;EACrC;EACX,MAAM,CAAC,OAAO,WAAW,KAAA;EACf;EACV,GAAI;EACJ,GAAI,uBAAuB,IAAI;EAC1B;YAEJ,YACC,oBAAC,YAAD;GAAY,MAAM,KAAK;GAAO;EAAqB,CAAA,IAEnD;CAEU,CAAA;AAElB"}
|
|
@@ -26,7 +26,7 @@ var StyledButton = styled(Button, {
|
|
|
26
26
|
});
|
|
27
27
|
var offsetWeekdayNames = (weekdayNames, firstDayOfWeek) => {
|
|
28
28
|
const start = weekdayNames.slice(0, firstDayOfWeek);
|
|
29
|
-
return weekdayNames.slice(firstDayOfWeek)
|
|
29
|
+
return [...weekdayNames.slice(firstDayOfWeek), ...start];
|
|
30
30
|
};
|
|
31
31
|
var Calendar = ({ className, refDateSelected, refDateToday, firstDayOfWeek = 0, monthNames = monthNamesShort, weekdayNames = weekdayNamesShort, labels = DEFAULT_LABELS, date: dateProp, minDate, maxDate, setYear, ...rest }) => {
|
|
32
32
|
const [fallbackDate] = React$1.useState(() => /* @__PURE__ */ new Date());
|
|
@@ -88,7 +88,7 @@ var Calendar = ({ className, refDateSelected, refDateToday, firstDayOfWeek = 0,
|
|
|
88
88
|
onClick: () => handleSetYear(year),
|
|
89
89
|
selected: isCurrentYear,
|
|
90
90
|
children: year
|
|
91
|
-
},
|
|
91
|
+
}, year);
|
|
92
92
|
})
|
|
93
93
|
}),
|
|
94
94
|
!showYears && calendars.map(({ month, year, weeks }) => /* @__PURE__ */ jsxs("div", { children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.js","names":[],"sources":["../../../src/components/calendar/Calendar.tsx"],"sourcesContent":["import { ChevronLeft, ChevronRight } from '@atom-learning/icons'\nimport type { Props as DayzedInterface } from 'dayzed'\nimport { useDayzed } from 'dayzed'\nimport * as React from 'react'\n\nimport { styled, cn } from '../../styled'\nimport { ActionIcon } from '../action-icon/ActionIcon'\nimport { Button } from '../button/Button'\nimport { Icon } from '../icon/Icon'\nimport { Text } from '../text/Text'\nimport { DEFAULT_LABELS, monthNamesShort, weekdayNamesShort } from './constants'\nimport { Day } from './Day'\n\nconst StyledButton = styled(Button, {\n base: ['text-grey-1000', 'p-3', 'w-16'],\n variants: {\n selected: {\n false: [\n 'disabled:bg-white!',\n 'font-normal',\n 'hover:bg-grey-200!',\n 'hover:text-grey-1000!',\n 'text-grey-1000!'\n ]\n }\n }\n})\n\nexport type CalendarTranslationProps = {\n monthNames?: string[]\n weekdayNames?: string[]\n labels?: {\n open: string\n next: string\n previous: string\n nextYear: string\n previousYear: string\n }\n}\n\ntype CalendarProps = DayzedInterface &\n CalendarTranslationProps & {\n refDateToday?: React.RefObject<HTMLButtonElement | null>\n refDateSelected?: React.RefObject<HTMLButtonElement | null>\n setYear: (date: Date) => Promise<void>\n className?: string\n }\n\nconst offsetWeekdayNames = (\n weekdayNames: string[],\n firstDayOfWeek: number\n): string[] => {\n const start = weekdayNames.slice(0, firstDayOfWeek)\n const end = weekdayNames.slice(firstDayOfWeek)\n return end.concat(start)\n}\n\nexport const Calendar = ({\n className,\n refDateSelected,\n refDateToday,\n firstDayOfWeek = 0,\n monthNames = monthNamesShort,\n weekdayNames = weekdayNamesShort,\n labels = DEFAULT_LABELS,\n date: dateProp,\n minDate,\n maxDate,\n setYear,\n ...rest\n}: CalendarProps) => {\n // `new Date()` as a default parameter runs on every render (impure render,\n // and a server/client hydration divergence near midnight) — capture the\n // fallback once instead.\n const [fallbackDate] = React.useState(() => new Date())\n const date = dateProp ?? fallbackDate\n\n const [showYears, setShowYears] = React.useState<boolean>(false)\n const [currentYear, setCurrentYear] = React.useState<number>(\n date?.getFullYear()\n )\n\n const handleSetYear = (year: number): void => {\n // Copy before setFullYear — mutating the `date` prop in place changes the\n // caller's object.\n const newDate = new Date(date)\n newDate.setFullYear(year)\n setYear(newDate)\n setShowYears(false)\n }\n\n const isAtMinYear = minDate && currentYear - 16 <= minDate.getFullYear()\n const isAtMaxYear = maxDate && currentYear >= maxDate.getFullYear()\n\n const yearList = Array.from({ length: 16 }, (_, i) => {\n const year = currentYear - i\n if (\n (maxDate && year > maxDate.getFullYear()) ||\n (minDate && year < minDate.getFullYear())\n )\n return 0\n return year\n })\n\n const { calendars, getBackProps, getForwardProps, getDateProps } = useDayzed({\n firstDayOfWeek,\n showOutsideDays: true,\n date,\n minDate,\n maxDate,\n ...rest\n })\n\n if (!calendars.length) return null\n\n return (\n <div className={cn('relative', 'w-fit', '-mt-1', className)}>\n <div className=\"absolute top-0 -right-1 flex\">\n <ActionIcon\n label={labels[showYears ? 'previousYear' : 'previous']}\n theme=\"neutral\"\n size=\"md\"\n {...(!showYears && getBackProps({ calendars }))}\n {...(showYears && {\n onClick: () => setCurrentYear(currentYear - 16)\n })}\n disabled={showYears && isAtMinYear}\n >\n <Icon is={ChevronLeft} />\n </ActionIcon>\n <ActionIcon\n label={labels[showYears ? 'nextYear' : 'next']}\n theme=\"neutral\"\n size=\"md\"\n {...(!showYears && getForwardProps({ calendars }))}\n {...(showYears && {\n onClick: () => setCurrentYear(currentYear + 16)\n })}\n disabled={showYears && isAtMaxYear}\n >\n <Icon is={ChevronRight} />\n </ActionIcon>\n </div>\n {showYears && (\n <div className=\"grid grid-cols-4 gap-x-1 gap-y-3 pt-12 [direction:rtl]\">\n {yearList.map((year, i) => {\n const isCurrentYear = year === date.getFullYear()\n if (!year) return <div key={i} className=\"h-10 w-16\" />\n\n return (\n <StyledButton\n key={`${year}${i}`}\n theme={isCurrentYear ? 'primary' : 'neutral'}\n onClick={() => handleSetYear(year)}\n selected={isCurrentYear}\n >\n {year}\n </StyledButton>\n )\n })}\n </div>\n )}\n {!showYears &&\n calendars.map(({ month, year, weeks }) => (\n <div key={`${month}${year}`}>\n <div className=\"mb-4 flex h-10 items-center\">\n <Button\n theme=\"neutral\"\n onClick={() => setShowYears(true)}\n className=\"text-grey-1000 px-0\"\n >\n {monthNames[month]} {year}\n </Button>\n </div>\n <div className=\"mb-3 grid grid-cols-7 gap-x-2 gap-y-1\">\n {offsetWeekdayNames(weekdayNames, firstDayOfWeek).map(\n (weekday) => (\n <Text\n as=\"span\"\n size=\"sm\"\n weight=\"bold\"\n key={`${month}${year}${weekday}`}\n className=\"text-center\"\n >\n {weekday}\n </Text>\n )\n )}\n </div>\n <div className=\"grid grid-cols-7 gap-x-2 gap-y-1\">\n {weeks.map((week, weekIndex) =>\n week.map((dateObj, index) => {\n const key = `${month}${year}${weekIndex}${index}`\n\n if (!dateObj) return <div key={key} />\n\n const { date, selected, today, prevMonth, nextMonth } =\n dateObj\n\n return (\n <Day\n isOutsideMonth={prevMonth || nextMonth}\n isSelected={selected}\n isToday={today}\n key={key}\n ref={\n selected ? refDateSelected : today ? refDateToday : null\n }\n {...getDateProps({ dateObj })}\n type=\"button\"\n >\n {date.getDate()}\n </Day>\n )\n })\n )}\n </div>\n </div>\n ))}\n </div>\n )\n}\n\nCalendar.displayName = 'Calendar'\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"Calendar.js","names":[],"sources":["../../../src/components/calendar/Calendar.tsx"],"sourcesContent":["import { ChevronLeft, ChevronRight } from '@atom-learning/icons'\nimport type { Props as DayzedInterface } from 'dayzed'\nimport { useDayzed } from 'dayzed'\nimport * as React from 'react'\n\nimport { styled, cn } from '../../styled'\nimport { ActionIcon } from '../action-icon/ActionIcon'\nimport { Button } from '../button/Button'\nimport { Icon } from '../icon/Icon'\nimport { Text } from '../text/Text'\nimport { DEFAULT_LABELS, monthNamesShort, weekdayNamesShort } from './constants'\nimport { Day } from './Day'\n\nconst StyledButton = styled(Button, {\n base: ['text-grey-1000', 'p-3', 'w-16'],\n variants: {\n selected: {\n false: [\n 'disabled:bg-white!',\n 'font-normal',\n 'hover:bg-grey-200!',\n 'hover:text-grey-1000!',\n 'text-grey-1000!'\n ]\n }\n }\n})\n\nexport type CalendarTranslationProps = {\n monthNames?: string[]\n weekdayNames?: string[]\n labels?: {\n open: string\n next: string\n previous: string\n nextYear: string\n previousYear: string\n }\n}\n\ntype CalendarProps = DayzedInterface &\n CalendarTranslationProps & {\n refDateToday?: React.RefObject<HTMLButtonElement | null>\n refDateSelected?: React.RefObject<HTMLButtonElement | null>\n setYear: (date: Date) => Promise<void>\n className?: string\n }\n\nconst offsetWeekdayNames = (\n weekdayNames: string[],\n firstDayOfWeek: number\n): string[] => {\n const start = weekdayNames.slice(0, firstDayOfWeek)\n const end = weekdayNames.slice(firstDayOfWeek)\n return [...end, ...start]\n}\n\nexport const Calendar = ({\n className,\n refDateSelected,\n refDateToday,\n firstDayOfWeek = 0,\n monthNames = monthNamesShort,\n weekdayNames = weekdayNamesShort,\n labels = DEFAULT_LABELS,\n date: dateProp,\n minDate,\n maxDate,\n setYear,\n ...rest\n}: CalendarProps) => {\n // `new Date()` as a default parameter runs on every render (impure render,\n // and a server/client hydration divergence near midnight) — capture the\n // fallback once instead.\n const [fallbackDate] = React.useState(() => new Date())\n const date = dateProp ?? fallbackDate\n\n const [showYears, setShowYears] = React.useState<boolean>(false)\n const [currentYear, setCurrentYear] = React.useState<number>(\n date?.getFullYear()\n )\n\n const handleSetYear = (year: number): void => {\n // Copy before setFullYear — mutating the `date` prop in place changes the\n // caller's object.\n const newDate = new Date(date)\n newDate.setFullYear(year)\n setYear(newDate)\n setShowYears(false)\n }\n\n const isAtMinYear = minDate && currentYear - 16 <= minDate.getFullYear()\n const isAtMaxYear = maxDate && currentYear >= maxDate.getFullYear()\n\n const yearList = Array.from({ length: 16 }, (_, i) => {\n const year = currentYear - i\n if (\n (maxDate && year > maxDate.getFullYear()) ||\n (minDate && year < minDate.getFullYear())\n )\n return 0\n return year\n })\n\n const { calendars, getBackProps, getForwardProps, getDateProps } = useDayzed({\n firstDayOfWeek,\n showOutsideDays: true,\n date,\n minDate,\n maxDate,\n ...rest\n })\n\n if (!calendars.length) return null\n\n return (\n <div className={cn('relative', 'w-fit', '-mt-1', className)}>\n <div className=\"absolute top-0 -right-1 flex\">\n <ActionIcon\n label={labels[showYears ? 'previousYear' : 'previous']}\n theme=\"neutral\"\n size=\"md\"\n {...(!showYears && getBackProps({ calendars }))}\n {...(showYears && {\n onClick: () => setCurrentYear(currentYear - 16)\n })}\n disabled={showYears && isAtMinYear}\n >\n <Icon is={ChevronLeft} />\n </ActionIcon>\n <ActionIcon\n label={labels[showYears ? 'nextYear' : 'next']}\n theme=\"neutral\"\n size=\"md\"\n {...(!showYears && getForwardProps({ calendars }))}\n {...(showYears && {\n onClick: () => setCurrentYear(currentYear + 16)\n })}\n disabled={showYears && isAtMaxYear}\n >\n <Icon is={ChevronRight} />\n </ActionIcon>\n </div>\n {showYears && (\n <div className=\"grid grid-cols-4 gap-x-1 gap-y-3 pt-12 [direction:rtl]\">\n {yearList.map((year, i) => {\n const isCurrentYear = year === date.getFullYear()\n // Out-of-range slots render as empty placeholders in a fixed 16-cell\n // grid; several share the same `0` value, so the slot index is their\n // only stable identity.\n // eslint-disable-next-line react/no-array-index-key\n if (!year) return <div key={i} className=\"h-10 w-16\" />\n\n return (\n <StyledButton\n key={year}\n theme={isCurrentYear ? 'primary' : 'neutral'}\n onClick={() => handleSetYear(year)}\n selected={isCurrentYear}\n >\n {year}\n </StyledButton>\n )\n })}\n </div>\n )}\n {!showYears &&\n calendars.map(({ month, year, weeks }) => (\n <div key={`${month}${year}`}>\n <div className=\"mb-4 flex h-10 items-center\">\n <Button\n theme=\"neutral\"\n onClick={() => setShowYears(true)}\n className=\"text-grey-1000 px-0\"\n >\n {monthNames[month]} {year}\n </Button>\n </div>\n <div className=\"mb-3 grid grid-cols-7 gap-x-2 gap-y-1\">\n {offsetWeekdayNames(weekdayNames, firstDayOfWeek).map(\n (weekday) => (\n <Text\n as=\"span\"\n size=\"sm\"\n weight=\"bold\"\n key={`${month}${year}${weekday}`}\n className=\"text-center\"\n >\n {weekday}\n </Text>\n )\n )}\n </div>\n <div className=\"grid grid-cols-7 gap-x-2 gap-y-1\">\n {weeks.map((week, weekIndex) =>\n week.map((dateObj, index) => {\n const key = `${month}${year}${weekIndex}${index}`\n\n if (!dateObj) return <div key={key} />\n\n const { date, selected, today, prevMonth, nextMonth } =\n dateObj\n\n return (\n <Day\n isOutsideMonth={prevMonth || nextMonth}\n isSelected={selected}\n isToday={today}\n key={key}\n ref={\n selected ? refDateSelected : today ? refDateToday : null\n }\n {...getDateProps({ dateObj })}\n type=\"button\"\n >\n {date.getDate()}\n </Day>\n )\n })\n )}\n </div>\n </div>\n ))}\n </div>\n )\n}\n\nCalendar.displayName = 'Calendar'\n"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Carousel.js","names":[],"sources":["../../../src/components/carousel/Carousel.tsx"],"sourcesContent":["import useEmblaCarousel from 'embla-carousel-react'\nimport * as React from 'react'\n\nimport { cn } from '../../styled'\nimport {
|
|
1
|
+
{"version":3,"file":"Carousel.js","names":[],"sources":["../../../src/components/carousel/Carousel.tsx"],"sourcesContent":["import useEmblaCarousel from 'embla-carousel-react'\nimport * as React from 'react'\n\nimport { cn } from '../../styled'\nimport { CarouselArrowNext, CarouselArrowPrevious } from './CarouselArrows'\nimport { CarouselPagination } from './CarouselPagination'\nimport { CarouselSlide } from './CarouselSlide'\nimport { CarouselSlider } from './CarouselSlider'\n\ntype EmblaApi = ReturnType<typeof useEmblaCarousel>[1]\n\ntype CarouselContextValue = {\n emblaRef: React.RefCallback<HTMLDivElement>\n emblaApi: EmblaApi\n selectedIndex: number\n scrollSnaps: number[]\n canScrollPrev: boolean\n canScrollNext: boolean\n scrollPrev: () => void\n scrollNext: () => void\n scrollTo: (index: number) => void\n}\n\nconst CarouselContext = React.createContext<CarouselContextValue | null>(null)\n\ntype CarouselProps = {\n currentSlide?: number\n}\n\nexport const CarouselComponent = ({\n children,\n currentSlide = 0,\n className,\n ...rest\n}: React.PropsWithChildren<\n CarouselProps & React.HTMLAttributes<HTMLDivElement>\n>) => {\n const [emblaRef, emblaApi] = useEmblaCarousel({\n startIndex: currentSlide,\n align: 'center'\n })\n\n const [selectedIndex, setSelectedIndex] = React.useState(currentSlide)\n const [scrollSnaps, setScrollSnaps] = React.useState<number[]>([])\n const [canScrollPrev, setCanScrollPrev] = React.useState(false)\n const [canScrollNext, setCanScrollNext] = React.useState(false)\n\n const scrollPrev = React.useCallback(() => {\n emblaApi?.scrollPrev()\n }, [emblaApi])\n\n const scrollNext = React.useCallback(() => {\n emblaApi?.scrollNext()\n }, [emblaApi])\n\n const scrollTo = React.useCallback(\n (index: number) => {\n emblaApi?.scrollTo(index)\n },\n [emblaApi]\n )\n\n const onSelect = React.useCallback(() => {\n if (!emblaApi) return\n setSelectedIndex(emblaApi.selectedScrollSnap())\n setCanScrollPrev(emblaApi.canScrollPrev())\n setCanScrollNext(emblaApi.canScrollNext())\n }, [emblaApi])\n\n const onInit = React.useCallback(() => {\n if (!emblaApi) return\n setScrollSnaps(emblaApi.scrollSnapList())\n }, [emblaApi])\n\n React.useEffect(() => {\n if (!emblaApi) return\n\n onInit()\n onSelect()\n\n emblaApi.on('reInit', onInit)\n emblaApi.on('reInit', onSelect)\n emblaApi.on('select', onSelect)\n\n return () => {\n emblaApi.off('reInit', onInit)\n emblaApi.off('reInit', onSelect)\n emblaApi.off('select', onSelect)\n }\n }, [emblaApi, onInit, onSelect])\n\n const contextValue = React.useMemo<CarouselContextValue>(\n () => ({\n emblaRef,\n emblaApi,\n selectedIndex,\n scrollSnaps,\n canScrollPrev,\n canScrollNext,\n scrollPrev,\n scrollNext,\n scrollTo\n }),\n [\n emblaRef,\n emblaApi,\n selectedIndex,\n scrollSnaps,\n canScrollPrev,\n canScrollNext,\n scrollPrev,\n scrollNext,\n scrollTo\n ]\n )\n\n return (\n <div className={cn('relative', 'w-full', className)} {...rest}>\n <CarouselContext value={contextValue}>{children}</CarouselContext>\n </div>\n )\n}\n\nexport const useCarousel = () => {\n const context = React.use(CarouselContext)\n if (!context) {\n throw new Error('useCarousel must be used within a Carousel')\n }\n\n return {\n ...context,\n // Alias for backward compatibility\n currentSlide: context.selectedIndex\n }\n}\n\nexport const Carousel = /* @__PURE__ */ Object.assign(CarouselComponent, {\n ArrowNext: CarouselArrowNext,\n ArrowPrevious: CarouselArrowPrevious,\n Pagination: CarouselPagination,\n Slide: CarouselSlide,\n Slider: CarouselSlider\n})\n\nCarouselComponent.displayName = 'Carousel'\n"],"mappings":";;;;;;;;;AAuBA,IAAM,kBAAkB,QAAM,cAA2C,IAAI;AAM7E,IAAa,qBAAqB,EAChC,UACA,eAAe,GACf,WACA,GAAG,WAGC;CACJ,MAAM,CAAC,UAAU,YAAY,iBAAiB;EAC5C,YAAY;EACZ,OAAO;CACT,CAAC;CAED,MAAM,CAAC,eAAe,oBAAoB,QAAM,SAAS,YAAY;CACrE,MAAM,CAAC,aAAa,kBAAkB,QAAM,SAAmB,CAAC,CAAC;CACjE,MAAM,CAAC,eAAe,oBAAoB,QAAM,SAAS,KAAK;CAC9D,MAAM,CAAC,eAAe,oBAAoB,QAAM,SAAS,KAAK;CAE9D,MAAM,aAAa,QAAM,kBAAkB;EACzC,UAAU,WAAW;CACvB,GAAG,CAAC,QAAQ,CAAC;CAEb,MAAM,aAAa,QAAM,kBAAkB;EACzC,UAAU,WAAW;CACvB,GAAG,CAAC,QAAQ,CAAC;CAEb,MAAM,WAAW,QAAM,aACpB,UAAkB;EACjB,UAAU,SAAS,KAAK;CAC1B,GACA,CAAC,QAAQ,CACX;CAEA,MAAM,WAAW,QAAM,kBAAkB;EACvC,IAAI,CAAC,UAAU;EACf,iBAAiB,SAAS,mBAAmB,CAAC;EAC9C,iBAAiB,SAAS,cAAc,CAAC;EACzC,iBAAiB,SAAS,cAAc,CAAC;CAC3C,GAAG,CAAC,QAAQ,CAAC;CAEb,MAAM,SAAS,QAAM,kBAAkB;EACrC,IAAI,CAAC,UAAU;EACf,eAAe,SAAS,eAAe,CAAC;CAC1C,GAAG,CAAC,QAAQ,CAAC;CAEb,QAAM,gBAAgB;EACpB,IAAI,CAAC,UAAU;EAEf,OAAO;EACP,SAAS;EAET,SAAS,GAAG,UAAU,MAAM;EAC5B,SAAS,GAAG,UAAU,QAAQ;EAC9B,SAAS,GAAG,UAAU,QAAQ;EAE9B,aAAa;GACX,SAAS,IAAI,UAAU,MAAM;GAC7B,SAAS,IAAI,UAAU,QAAQ;GAC/B,SAAS,IAAI,UAAU,QAAQ;EACjC;CACF,GAAG;EAAC;EAAU;EAAQ;CAAQ,CAAC;CAE/B,MAAM,eAAe,QAAM,eAClB;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,OACE,oBAAC,OAAD;EAAK,WAAW,GAAG,YAAY,UAAU,SAAS;EAAG,GAAI;YACvD,oBAAC,iBAAD;GAAiB,OAAO;GAAe;EAA0B,CAAA;CAC9D,CAAA;AAET;AAEA,IAAa,oBAAoB;CAC/B,MAAM,UAAU,QAAM,IAAI,eAAe;CACzC,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,4CAA4C;CAG9D,OAAO;EACL,GAAG;EAEH,cAAc,QAAQ;CACxB;AACF;AAEA,IAAa,WAA2B,uBAAO,OAAO,mBAAmB;CACvE,WAAW;CACX,eAAe;CACf,YAAY;CACZ,OAAO;CACP,QAAQ;AACV,CAAC;AAED,kBAAkB,cAAc"}
|
|
@@ -17,8 +17,9 @@ var CheckboxGroupAllItem = ({ onCheckedChange, title = "all", ...rest }) => {
|
|
|
17
17
|
onCheckedChange: handleItemCheckedChange,
|
|
18
18
|
checked: (() => {
|
|
19
19
|
if (!checkedItems.length || !mountedItems.length) return false;
|
|
20
|
-
|
|
21
|
-
if (mountedItems.
|
|
20
|
+
const checkedSet = new Set(checkedItems);
|
|
21
|
+
if (mountedItems.every((mountedItem) => checkedSet.has(mountedItem))) return true;
|
|
22
|
+
if (mountedItems.some((mountedItem) => checkedSet.has(mountedItem))) return "indeterminate";
|
|
22
23
|
return false;
|
|
23
24
|
})(),
|
|
24
25
|
title,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxGroupAllItem.js","names":[],"sources":["../../../src/components/checkbox-group/CheckboxGroupAllItem.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { Checkbox } from '../checkbox/Checkbox'\nimport { CheckboxGroupCheckedContext } from './CheckboxGroupChecked.context'\nimport { CheckboxGroupMountedContext } from './CheckboxGroupMounted.context'\n\ntype CheckboxGroupAllItemProps = Omit<\n React.ComponentProps<typeof Checkbox>,\n 'checked' | 'defaultChecked'\n>\n\nexport const CheckboxGroupAllItem = ({\n onCheckedChange,\n title = 'all',\n ...rest\n}: CheckboxGroupAllItemProps) => {\n const {\n checked: checkedItems,\n handleItemCheckedChange: handleItemCheckedChangeContext\n } = React.use(CheckboxGroupCheckedContext)\n const { mounted: mountedItems } = React.use(CheckboxGroupMountedContext)\n\n const handleItemCheckedChange = (newChecked) => {\n mountedItems.forEach((value) => {\n handleItemCheckedChangeContext(newChecked, value)\n })\n onCheckedChange?.(newChecked)\n }\n\n const isAllChecked = (() => {\n if (!checkedItems.length || !mountedItems.length) return false\n\n if (mountedItems.every((mountedItem) =>
|
|
1
|
+
{"version":3,"file":"CheckboxGroupAllItem.js","names":[],"sources":["../../../src/components/checkbox-group/CheckboxGroupAllItem.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { Checkbox } from '../checkbox/Checkbox'\nimport { CheckboxGroupCheckedContext } from './CheckboxGroupChecked.context'\nimport { CheckboxGroupMountedContext } from './CheckboxGroupMounted.context'\n\ntype CheckboxGroupAllItemProps = Omit<\n React.ComponentProps<typeof Checkbox>,\n 'checked' | 'defaultChecked'\n>\n\nexport const CheckboxGroupAllItem = ({\n onCheckedChange,\n title = 'all',\n ...rest\n}: CheckboxGroupAllItemProps) => {\n const {\n checked: checkedItems,\n handleItemCheckedChange: handleItemCheckedChangeContext\n } = React.use(CheckboxGroupCheckedContext)\n const { mounted: mountedItems } = React.use(CheckboxGroupMountedContext)\n\n const handleItemCheckedChange = (newChecked) => {\n mountedItems.forEach((value) => {\n handleItemCheckedChangeContext(newChecked, value)\n })\n onCheckedChange?.(newChecked)\n }\n\n const isAllChecked = (() => {\n if (!checkedItems.length || !mountedItems.length) return false\n\n // Set lookup keeps the every/some scans O(mounted) instead of O(mounted × checked).\n const checkedSet = new Set(checkedItems)\n\n if (mountedItems.every((mountedItem) => checkedSet.has(mountedItem)))\n return true\n\n if (mountedItems.some((mountedItem) => checkedSet.has(mountedItem)))\n return 'indeterminate'\n\n return false\n })()\n\n return (\n <Checkbox\n onCheckedChange={handleItemCheckedChange}\n checked={isAllChecked}\n title={title}\n {...rest}\n />\n )\n}\n"],"mappings":";;;;;;AAWA,IAAa,wBAAwB,EACnC,iBACA,QAAQ,OACR,GAAG,WAC4B;CAC/B,MAAM,EACJ,SAAS,cACT,yBAAyB,mCACvB,QAAM,IAAI,2BAA2B;CACzC,MAAM,EAAE,SAAS,iBAAiB,QAAM,IAAI,2BAA2B;CAEvE,MAAM,2BAA2B,eAAe;EAC9C,aAAa,SAAS,UAAU;GAC9B,+BAA+B,YAAY,KAAK;EAClD,CAAC;EACD,kBAAkB,UAAU;CAC9B;CAiBA,OACE,oBAAC,UAAD;EACE,iBAAiB;EACjB,gBAlBwB;GAC1B,IAAI,CAAC,aAAa,UAAU,CAAC,aAAa,QAAQ,OAAO;GAGzD,MAAM,aAAa,IAAI,IAAI,YAAY;GAEvC,IAAI,aAAa,OAAO,gBAAgB,WAAW,IAAI,WAAW,CAAC,GACjE,OAAO;GAET,IAAI,aAAa,MAAM,gBAAgB,WAAW,IAAI,WAAW,CAAC,GAChE,OAAO;GAET,OAAO;EACT,EAAA,CAKa;EACF;EACP,GAAI;CACL,CAAA;AAEL"}
|
|
@@ -10,7 +10,7 @@ var generateNewCheckedFn = (currentChecked) => {
|
|
|
10
10
|
const newCheckedSet = new Set(currentChecked);
|
|
11
11
|
if (newItemChecked) newCheckedSet.add(itemValue);
|
|
12
12
|
else newCheckedSet.delete(itemValue);
|
|
13
|
-
return
|
|
13
|
+
return [...newCheckedSet];
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
var CheckboxGroupCheckedProvider = ({ checked: controlledChecked, defaultChecked = [], onCheckedChange, ...rest }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxGroupChecked.context.js","names":[],"sources":["../../../src/components/checkbox-group/CheckboxGroupChecked.context.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport type { CheckboxGroupItemValue } from './CheckboxGroup.types'\n\ntype CheckboxGroupCheckedContextValue = {\n checked: CheckboxGroupItemValue[]\n handleItemCheckedChange: (\n newItemChecked: boolean,\n itemValue: CheckboxGroupItemValue\n ) => void\n}\n\ntype CheckboxGroupCheckedContextProps = {\n checked?: CheckboxGroupCheckedContextValue['checked']\n defaultChecked?: CheckboxGroupCheckedContextValue['checked']\n onCheckedChange?: (\n checked: CheckboxGroupCheckedContextValue['checked']\n ) => void\n}\n\nexport const CheckboxGroupCheckedContext =\n React.createContext<CheckboxGroupCheckedContextValue>({\n checked: [],\n handleItemCheckedChange: () => null\n })\n\nconst generateNewCheckedFn = (\n currentChecked: CheckboxGroupCheckedContextValue['checked']\n) => {\n return (newItemChecked, itemValue) => {\n const newCheckedSet = new Set(currentChecked)\n if (newItemChecked) {\n newCheckedSet.add(itemValue)\n } else {\n newCheckedSet.delete(itemValue)\n }\n const newChecked =
|
|
1
|
+
{"version":3,"file":"CheckboxGroupChecked.context.js","names":[],"sources":["../../../src/components/checkbox-group/CheckboxGroupChecked.context.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport type { CheckboxGroupItemValue } from './CheckboxGroup.types'\n\ntype CheckboxGroupCheckedContextValue = {\n checked: CheckboxGroupItemValue[]\n handleItemCheckedChange: (\n newItemChecked: boolean,\n itemValue: CheckboxGroupItemValue\n ) => void\n}\n\ntype CheckboxGroupCheckedContextProps = {\n checked?: CheckboxGroupCheckedContextValue['checked']\n defaultChecked?: CheckboxGroupCheckedContextValue['checked']\n onCheckedChange?: (\n checked: CheckboxGroupCheckedContextValue['checked']\n ) => void\n}\n\nexport const CheckboxGroupCheckedContext =\n React.createContext<CheckboxGroupCheckedContextValue>({\n checked: [],\n handleItemCheckedChange: () => null\n })\n\nconst generateNewCheckedFn = (\n currentChecked: CheckboxGroupCheckedContextValue['checked']\n) => {\n return (newItemChecked, itemValue) => {\n const newCheckedSet = new Set(currentChecked)\n if (newItemChecked) {\n newCheckedSet.add(itemValue)\n } else {\n newCheckedSet.delete(itemValue)\n }\n const newChecked = [...newCheckedSet]\n return newChecked\n }\n}\n\nexport const CheckboxGroupCheckedProvider = ({\n checked: controlledChecked,\n defaultChecked = [],\n onCheckedChange,\n ...rest\n}: React.PropsWithChildren<CheckboxGroupCheckedContextProps>) => {\n const [checked, setChecked] = React.useState(defaultChecked)\n\n const handleItemControlledCheckedChange = React.useCallback(\n (newItemChecked, itemValue) => {\n if (!controlledChecked) return () => null\n const newCheckedFn = generateNewCheckedFn(controlledChecked)\n const newChecked = newCheckedFn(newItemChecked, itemValue)\n onCheckedChange?.(newChecked)\n },\n [onCheckedChange, controlledChecked]\n )\n\n const handleItemCheckedChange = React.useCallback(\n (newItemChecked, itemValue) => {\n setChecked((prevChecked) => {\n const newCheckedFn = generateNewCheckedFn(prevChecked)\n const newChecked = newCheckedFn(newItemChecked, itemValue)\n onCheckedChange?.(newChecked)\n return newChecked\n })\n },\n [onCheckedChange]\n )\n\n const value = React.useMemo<CheckboxGroupCheckedContextValue>(() => {\n const isControlled = Array.isArray(controlledChecked)\n return {\n checked: isControlled\n ? (controlledChecked as CheckboxGroupCheckedContextValue['checked']) // We're literally JUST checking it above but TS still flags it, wrongly, so casting\n : checked,\n handleItemCheckedChange: isControlled\n ? handleItemControlledCheckedChange\n : handleItemCheckedChange\n }\n }, [\n checked,\n handleItemCheckedChange,\n handleItemControlledCheckedChange,\n controlledChecked\n ])\n\n return <CheckboxGroupCheckedContext value={value} {...rest} />\n}\n"],"mappings":";;;AAoBA,IAAa,8BACX,QAAM,cAAgD;CACpD,SAAS,CAAC;CACV,+BAA+B;AACjC,CAAC;AAEH,IAAM,wBACJ,mBACG;CACH,QAAQ,gBAAgB,cAAc;EACpC,MAAM,gBAAgB,IAAI,IAAI,cAAc;EAC5C,IAAI,gBACF,cAAc,IAAI,SAAS;OAE3B,cAAc,OAAO,SAAS;EAGhC,OAAO,CADa,GAAG,aAChB;CACT;AACF;AAEA,IAAa,gCAAgC,EAC3C,SAAS,mBACT,iBAAiB,CAAC,GAClB,iBACA,GAAG,WAC4D;CAC/D,MAAM,CAAC,SAAS,cAAc,QAAM,SAAS,cAAc;CAE3D,MAAM,oCAAoC,QAAM,aAC7C,gBAAgB,cAAc;EAC7B,IAAI,CAAC,mBAAmB,aAAa;EAErC,MAAM,aADe,qBAAqB,iBACvB,CAAA,CAAa,gBAAgB,SAAS;EACzD,kBAAkB,UAAU;CAC9B,GACA,CAAC,iBAAiB,iBAAiB,CACrC;CAEA,MAAM,0BAA0B,QAAM,aACnC,gBAAgB,cAAc;EAC7B,YAAY,gBAAgB;GAE1B,MAAM,aADe,qBAAqB,WACvB,CAAA,CAAa,gBAAgB,SAAS;GACzD,kBAAkB,UAAU;GAC5B,OAAO;EACT,CAAC;CACH,GACA,CAAC,eAAe,CAClB;CAmBA,OAAO,oBAAC,6BAAD;EAAoC,OAjB7B,QAAM,cAAgD;GAClE,MAAM,eAAe,MAAM,QAAQ,iBAAiB;GACpD,OAAO;IACL,SAAS,eACJ,oBACD;IACJ,yBAAyB,eACrB,oCACA;GACN;EACF,GAAG;GACD;GACA;GACA;GACA;EACF,CAE2C;EAAO,GAAI;CAAO,CAAA;AAC/D"}
|
|
@@ -14,7 +14,7 @@ var CheckboxGroupMountedProvider = (props) => {
|
|
|
14
14
|
const newMountedSet = new Set(prevMounted);
|
|
15
15
|
if (newItemMounted) newMountedSet.add(itemValue);
|
|
16
16
|
else newMountedSet.delete(itemValue);
|
|
17
|
-
return
|
|
17
|
+
return [...newMountedSet];
|
|
18
18
|
});
|
|
19
19
|
}, [handleItemMountedChangeFurtherUpContext]);
|
|
20
20
|
return /* @__PURE__ */ jsx(CheckboxGroupMountedContext, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxGroupMounted.context.js","names":[],"sources":["../../../src/components/checkbox-group/CheckboxGroupMounted.context.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport type { CheckboxGroupItemValue } from './CheckboxGroup.types'\n\ntype CheckboxGroupMountedContextValue = {\n mounted: CheckboxGroupItemValue[]\n handleItemMountedChange: (\n newItemMounted: boolean,\n itemValue: CheckboxGroupItemValue\n ) => void\n}\n\nexport const CheckboxGroupMountedContext =\n React.createContext<CheckboxGroupMountedContextValue>({\n mounted: [],\n handleItemMountedChange: () => null\n })\n\nexport const CheckboxGroupMountedProvider = (props) => {\n const { handleItemMountedChange: handleItemMountedChangeFurtherUpContext } =\n React.use(CheckboxGroupMountedContext)\n\n const [mounted, setMounted] = React.useState<CheckboxGroupItemValue[]>([])\n const handleItemMountedChange = React.useCallback(\n (newItemMounted, itemValue) => {\n handleItemMountedChangeFurtherUpContext?.(newItemMounted, itemValue)\n setMounted((prevMounted) => {\n const newMountedSet = new Set(prevMounted)\n if (newItemMounted) {\n newMountedSet.add(itemValue)\n } else {\n newMountedSet.delete(itemValue)\n }\n const newMounted =
|
|
1
|
+
{"version":3,"file":"CheckboxGroupMounted.context.js","names":[],"sources":["../../../src/components/checkbox-group/CheckboxGroupMounted.context.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport type { CheckboxGroupItemValue } from './CheckboxGroup.types'\n\ntype CheckboxGroupMountedContextValue = {\n mounted: CheckboxGroupItemValue[]\n handleItemMountedChange: (\n newItemMounted: boolean,\n itemValue: CheckboxGroupItemValue\n ) => void\n}\n\nexport const CheckboxGroupMountedContext =\n React.createContext<CheckboxGroupMountedContextValue>({\n mounted: [],\n handleItemMountedChange: () => null\n })\n\nexport const CheckboxGroupMountedProvider = (props) => {\n const { handleItemMountedChange: handleItemMountedChangeFurtherUpContext } =\n React.use(CheckboxGroupMountedContext)\n\n const [mounted, setMounted] = React.useState<CheckboxGroupItemValue[]>([])\n const handleItemMountedChange = React.useCallback(\n (newItemMounted, itemValue) => {\n handleItemMountedChangeFurtherUpContext?.(newItemMounted, itemValue)\n setMounted((prevMounted) => {\n const newMountedSet = new Set(prevMounted)\n if (newItemMounted) {\n newMountedSet.add(itemValue)\n } else {\n newMountedSet.delete(itemValue)\n }\n const newMounted = [...newMountedSet]\n return newMounted\n })\n },\n [handleItemMountedChangeFurtherUpContext]\n )\n\n const value = React.useMemo<CheckboxGroupMountedContextValue>(\n () => ({ mounted, handleItemMountedChange }),\n [mounted, handleItemMountedChange]\n )\n\n return <CheckboxGroupMountedContext value={value} {...props} />\n}\n"],"mappings":";;;AAYA,IAAa,8BACX,QAAM,cAAgD;CACpD,SAAS,CAAC;CACV,+BAA+B;AACjC,CAAC;AAEH,IAAa,gCAAgC,UAAU;CACrD,MAAM,EAAE,yBAAyB,4CAC/B,QAAM,IAAI,2BAA2B;CAEvC,MAAM,CAAC,SAAS,cAAc,QAAM,SAAmC,CAAC,CAAC;CACzE,MAAM,0BAA0B,QAAM,aACnC,gBAAgB,cAAc;EAC7B,0CAA0C,gBAAgB,SAAS;EACnE,YAAY,gBAAgB;GAC1B,MAAM,gBAAgB,IAAI,IAAI,WAAW;GACzC,IAAI,gBACF,cAAc,IAAI,SAAS;QAE3B,cAAc,OAAO,SAAS;GAGhC,OAAO,CADa,GAAG,aAChB;EACT,CAAC;CACH,GACA,CAAC,uCAAuC,CAC1C;CAOA,OAAO,oBAAC,6BAAD;EAAoC,OAL7B,QAAM,eACX;GAAE;GAAS;EAAwB,IAC1C,CAAC,SAAS,uBAAuB,CAGQ;EAAO,GAAI;CAAQ,CAAA;AAChE"}
|
|
@@ -32,14 +32,14 @@ var ChipContent = ({ children, ...rest }) => {
|
|
|
32
32
|
const isSingleChild = childrenArray.length <= 1;
|
|
33
33
|
return /* @__PURE__ */ jsx(StyledChipContent, {
|
|
34
34
|
...rest,
|
|
35
|
-
children: childrenArray.map((child
|
|
35
|
+
children: childrenArray.map((child) => {
|
|
36
36
|
if (!isSingleChild && typeof child === "string") return /* @__PURE__ */ jsx("span", {
|
|
37
37
|
className: "overflow-hidden text-ellipsis whitespace-nowrap",
|
|
38
38
|
children: child
|
|
39
39
|
}, child);
|
|
40
40
|
if (React$1.isValidElement(child) && child.type === Icon) {
|
|
41
41
|
const iconProps = child.props;
|
|
42
|
-
return /* @__PURE__ */ jsx(ChipIcon, { ...iconProps },
|
|
42
|
+
return /* @__PURE__ */ jsx(ChipIcon, { ...iconProps }, child.key);
|
|
43
43
|
}
|
|
44
44
|
return child;
|
|
45
45
|
})
|