@mattermost/compass-ui 0.1.0-alpha.20 → 0.1.0-alpha.21
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/combobox/Combobox.cjs +1 -1
- package/dist/components/combobox/Combobox.cjs.map +1 -1
- package/dist/components/combobox/Combobox.d.ts +12 -0
- package/dist/components/combobox/Combobox.d.ts.map +1 -1
- package/dist/components/combobox/Combobox.js +226 -214
- package/dist/components/combobox/Combobox.js.map +1 -1
- package/dist/components/date-range-picker/DateRangePicker.css +1 -1
- package/dist/components/date-range-picker/DateRangePicker.module.scss.cjs +1 -1
- package/dist/components/date-range-picker/DateRangePicker.module.scss.js +26 -26
- package/dist/components/emoji-popover/EmojiPopover.css +1 -1
- package/dist/components/emoji-popover/EmojiPopover.module.scss.cjs +1 -1
- package/dist/components/emoji-popover/EmojiPopover.module.scss.js +21 -21
- package/dist/components/menu-item/MenuItem.cjs.map +1 -1
- package/dist/components/menu-item/MenuItem.css +1 -1
- package/dist/components/menu-item/MenuItem.d.ts +6 -1
- package/dist/components/menu-item/MenuItem.d.ts.map +1 -1
- package/dist/components/menu-item/MenuItem.js.map +1 -1
- package/dist/components/menu-item/MenuItem.module.scss.cjs +1 -1
- package/dist/components/menu-item/MenuItem.module.scss.js +18 -18
- package/dist/components/popover-menu/PopoverMenu.cjs +1 -1
- package/dist/components/popover-menu/PopoverMenu.cjs.map +1 -1
- package/dist/components/popover-menu/PopoverMenu.css +1 -1
- package/dist/components/popover-menu/PopoverMenu.d.ts +6 -2
- package/dist/components/popover-menu/PopoverMenu.d.ts.map +1 -1
- package/dist/components/popover-menu/PopoverMenu.js +29 -29
- package/dist/components/popover-menu/PopoverMenu.js.map +1 -1
- package/dist/components/popover-menu/PopoverMenu.module.scss.cjs +1 -1
- package/dist/components/popover-menu/PopoverMenu.module.scss.js +13 -12
- package/dist/components/popover-menu/PopoverMenu.module.scss.js.map +1 -1
- package/dist/components/profile-popover/ProfilePopover.css +1 -1
- package/dist/components/profile-popover/ProfilePopover.module.scss.cjs +1 -1
- package/dist/components/profile-popover/ProfilePopover.module.scss.js +33 -33
- package/dist/components/team-avatar/TeamAvatar.cjs +1 -1
- package/dist/components/team-avatar/TeamAvatar.cjs.map +1 -1
- package/dist/components/team-avatar/TeamAvatar.css +1 -1
- package/dist/components/team-avatar/TeamAvatar.d.ts +8 -1
- package/dist/components/team-avatar/TeamAvatar.d.ts.map +1 -1
- package/dist/components/team-avatar/TeamAvatar.js +23 -21
- package/dist/components/team-avatar/TeamAvatar.js.map +1 -1
- package/dist/components/team-avatar/TeamAvatar.module.scss.cjs +1 -1
- package/dist/components/team-avatar/TeamAvatar.module.scss.js +17 -16
- package/dist/components/team-avatar/TeamAvatar.module.scss.js.map +1 -1
- package/dist/components/team-avatar/index.d.ts +1 -1
- package/dist/components/team-avatar/index.d.ts.map +1 -1
- package/dist/components/tile-button/TileButton.cjs +2 -0
- package/dist/components/tile-button/TileButton.cjs.map +1 -0
- package/dist/components/tile-button/TileButton.css +1 -0
- package/dist/components/tile-button/TileButton.d.ts +54 -0
- package/dist/components/tile-button/TileButton.d.ts.map +1 -0
- package/dist/components/tile-button/TileButton.js +74 -0
- package/dist/components/tile-button/TileButton.js.map +1 -0
- package/dist/components/tile-button/TileButton.module.scss.cjs +2 -0
- package/dist/components/tile-button/TileButton.module.scss.cjs.map +1 -0
- package/dist/components/tile-button/TileButton.module.scss.js +12 -0
- package/dist/components/tile-button/TileButton.module.scss.js.map +1 -0
- package/dist/components/{action-button → tile-button}/index.cjs +1 -1
- package/dist/components/tile-button/index.d.ts +3 -0
- package/dist/components/tile-button/index.d.ts.map +1 -0
- package/dist/components/tile-button/index.js +5 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -24
- package/dist/utils/slot.cjs.map +1 -1
- package/dist/utils/slot.d.ts +1 -1
- package/dist/utils/slot.js.map +1 -1
- package/package.json +4 -4
- package/dist/components/action-button/ActionButton.cjs +0 -2
- package/dist/components/action-button/ActionButton.cjs.map +0 -1
- package/dist/components/action-button/ActionButton.css +0 -1
- package/dist/components/action-button/ActionButton.d.ts +0 -54
- package/dist/components/action-button/ActionButton.d.ts.map +0 -1
- package/dist/components/action-button/ActionButton.js +0 -74
- package/dist/components/action-button/ActionButton.js.map +0 -1
- package/dist/components/action-button/ActionButton.module.scss.cjs +0 -2
- package/dist/components/action-button/ActionButton.module.scss.cjs.map +0 -1
- package/dist/components/action-button/ActionButton.module.scss.js +0 -12
- package/dist/components/action-button/ActionButton.module.scss.js.map +0 -1
- package/dist/components/action-button/index.d.ts +0 -3
- package/dist/components/action-button/index.d.ts.map +0 -1
- package/dist/components/action-button/index.js +0 -5
- /package/dist/components/{action-button → tile-button}/index.cjs.map +0 -0
- /package/dist/components/{action-button → tile-button}/index.js.map +0 -0
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { default as r } from "./components/
|
|
1
|
+
import { default as r } from "./components/tile-button/TileButton.js";
|
|
2
2
|
import { default as a } from "./components/admin-console-header/AdminConsoleHeader.js";
|
|
3
3
|
import { default as s } from "./components/admin-panel/AdminPanel.js";
|
|
4
|
-
import { default as
|
|
4
|
+
import { default as l } from "./components/admin-console-footer/AdminConsoleFooter.js";
|
|
5
5
|
import { default as p } from "./components/admin-panel-footer/AdminPanelFooter.js";
|
|
6
6
|
import { default as x } from "./components/admin-panel-header/AdminPanelHeader.js";
|
|
7
7
|
import { default as i } from "./components/attachment-card/AttachmentCard.js";
|
|
8
8
|
import { default as S } from "./components/button/Button.js";
|
|
9
|
-
import { default as
|
|
9
|
+
import { default as c } from "./components/button/Button.module.scss.js";
|
|
10
10
|
import { default as T } from "./components/card-button/CardButton.js";
|
|
11
11
|
import { default as g } from "./components/card-button/CardButtonGroup.js";
|
|
12
12
|
import { default as C } from "./components/channel-info-msg-header/ChannelInfoMsgHeader.js";
|
|
13
|
-
import { default as
|
|
13
|
+
import { default as A } from "./components/channel-sidebar-item/ChannelSidebarItem.js";
|
|
14
14
|
import { default as E } from "./components/checkbox/Checkbox.js";
|
|
15
15
|
import { default as _ } from "./components/chip/Chip.js";
|
|
16
16
|
import { default as N } from "./components/chip/ChipGroup.js";
|
|
@@ -26,15 +26,15 @@ import { default as X } from "./components/error-message/ErrorMessage.js";
|
|
|
26
26
|
import { default as $ } from "./components/field-message/FieldMessage.js";
|
|
27
27
|
import { default as oe } from "./components/feature-discovery-panel/FeatureDiscoveryPanel.js";
|
|
28
28
|
import { default as te } from "./components/global-banner/GlobalBanner.js";
|
|
29
|
-
import { default as fe, IconSlotContext as se, SVG_SIZE_MAP as de, useIconSlotContext as
|
|
29
|
+
import { default as fe, IconSlotContext as se, SVG_SIZE_MAP as de, useIconSlotContext as le } from "./components/icon/Icon.js";
|
|
30
30
|
import { ICON_BUTTON_ICON_SIZES as pe, default as me } from "./components/icon-button/IconButton.js";
|
|
31
31
|
import { default as ne } from "./components/illustration/Illustration.js";
|
|
32
32
|
import { default as Pe } from "./components/image-preview/ImagePreview.js";
|
|
33
|
-
import { default as
|
|
33
|
+
import { default as Me } from "./components/tag/Tag.js";
|
|
34
34
|
import { default as Ie } from "./components/link-preview/LinkPreview.js";
|
|
35
35
|
import { default as ve } from "./components/mention-badge/MentionBadge.js";
|
|
36
36
|
import { default as Be } from "./components/menu-group-heading/MenuGroupHeading.js";
|
|
37
|
-
import { default as
|
|
37
|
+
import { default as he } from "./components/menu-item/MenuItem.js";
|
|
38
38
|
import { default as be } from "./components/message-actions/MessageActions.js";
|
|
39
39
|
import { default as Oe } from "./components/message-header/MessageHeader.js";
|
|
40
40
|
import { default as Ge } from "./components/reactions-row/ReactionsRow.js";
|
|
@@ -50,15 +50,15 @@ import { default as Qe } from "./components/pagination-dots/PaginationDots.js";
|
|
|
50
50
|
import { default as Xe } from "./components/permalink-preview/PermalinkPreview.js";
|
|
51
51
|
import { default as $e } from "./components/pinned-saved-indicators/PinnedSavedIndicators.js";
|
|
52
52
|
import { default as oo, PopoverMenuDivider as ro, PopoverMenuGroup as to, PopoverMenuGroupTitle as ao, PopoverMenuScroll as fo, PopoverMenuTitle as so } from "./components/popover-menu/PopoverMenu.js";
|
|
53
|
-
import { default as
|
|
53
|
+
import { default as uo } from "./components/popover-notice/PopoverNotice.js";
|
|
54
54
|
import { default as mo } from "./components/profile-popover/ProfilePopover.js";
|
|
55
55
|
import { default as no } from "./components/progress-bar/ProgressBar.js";
|
|
56
56
|
import { default as Po } from "./components/radio/Radio.js";
|
|
57
|
-
import { default as
|
|
57
|
+
import { default as Mo } from "./components/right-sidebar-header/RightSidebarHeader.js";
|
|
58
58
|
import { default as Io } from "./components/scrollbar/Scrollbar.js";
|
|
59
59
|
import { default as vo } from "./components/password-input/PasswordInput.js";
|
|
60
60
|
import { default as Bo } from "./components/search-input/SearchInput.js";
|
|
61
|
-
import { default as
|
|
61
|
+
import { default as ho } from "./components/search-tip-banner/SearchTipBanner.js";
|
|
62
62
|
import { default as bo, ShortcutTagGroup as Eo } from "./components/shortcut-tag/ShortcutTag.js";
|
|
63
63
|
import { default as _o } from "./components/section-notice/SectionNotice.js";
|
|
64
64
|
import { default as No } from "./components/select/Select.js";
|
|
@@ -76,15 +76,14 @@ import { default as er } from "./components/tooltip/Tooltip.js";
|
|
|
76
76
|
import { default as rr } from "./components/tour-point/TourPoint.js";
|
|
77
77
|
import { default as ar } from "./components/unread-badge/UnreadBadge.js";
|
|
78
78
|
import { default as sr } from "./components/user-avatar/UserAvatar.js";
|
|
79
|
-
import { default as
|
|
79
|
+
import { default as lr } from "./components/user-avatar-group/UserAvatarGroup.js";
|
|
80
80
|
import { useControllable as pr } from "./hooks/use-controllable.js";
|
|
81
81
|
import { useExitAnimation as xr } from "./hooks/use-exit-animation.js";
|
|
82
82
|
import { useOutsideClose as ir } from "./hooks/use-outside-close.js";
|
|
83
|
-
import { POPOVER_TRANSITION_MS as Sr, usePopoverTransition as
|
|
83
|
+
import { POPOVER_TRANSITION_MS as Sr, usePopoverTransition as Mr } from "./hooks/use-popover-transition.js";
|
|
84
84
|
import { toKebab as Ir } from "./utils/string.js";
|
|
85
85
|
export {
|
|
86
|
-
|
|
87
|
-
u as AdminConsoleFooter,
|
|
86
|
+
l as AdminConsoleFooter,
|
|
88
87
|
a as AdminConsoleHeader,
|
|
89
88
|
s as AdminPanel,
|
|
90
89
|
p as AdminPanelFooter,
|
|
@@ -94,7 +93,7 @@ export {
|
|
|
94
93
|
T as CardButton,
|
|
95
94
|
g as CardButtonGroup,
|
|
96
95
|
C as ChannelInfoMsgHeader,
|
|
97
|
-
|
|
96
|
+
A as ChannelSidebarItem,
|
|
98
97
|
E as Checkbox,
|
|
99
98
|
_ as Chip,
|
|
100
99
|
N as ChipGroup,
|
|
@@ -120,7 +119,7 @@ export {
|
|
|
120
119
|
Ie as LinkPreview,
|
|
121
120
|
ve as MentionBadge,
|
|
122
121
|
Be as MenuGroupHeading,
|
|
123
|
-
|
|
122
|
+
he as MenuItem,
|
|
124
123
|
be as MessageActions,
|
|
125
124
|
Oe as MessageHeader,
|
|
126
125
|
He as MessageSeparator,
|
|
@@ -140,17 +139,17 @@ export {
|
|
|
140
139
|
ao as PopoverMenuGroupTitle,
|
|
141
140
|
fo as PopoverMenuScroll,
|
|
142
141
|
so as PopoverMenuTitle,
|
|
143
|
-
|
|
142
|
+
uo as PopoverNotice,
|
|
144
143
|
mo as ProfilePopover,
|
|
145
144
|
no as ProgressBar,
|
|
146
145
|
Po as Radio,
|
|
147
146
|
we as ReactionButton,
|
|
148
147
|
Ge as ReactionsRow,
|
|
149
|
-
|
|
148
|
+
Mo as RightSidebarHeader,
|
|
150
149
|
de as SVG_SIZE_MAP,
|
|
151
150
|
Io as Scrollbar,
|
|
152
151
|
Bo as SearchInput,
|
|
153
|
-
|
|
152
|
+
ho as SearchTipBanner,
|
|
154
153
|
_o as SectionNotice,
|
|
155
154
|
No as Select,
|
|
156
155
|
bo as ShortcutTag,
|
|
@@ -159,25 +158,26 @@ export {
|
|
|
159
158
|
Do as StatusBadge,
|
|
160
159
|
Uo as Switch,
|
|
161
160
|
ko as Tabs,
|
|
162
|
-
|
|
161
|
+
Me as Tag,
|
|
163
162
|
Zo as TeamAvatar,
|
|
164
163
|
Lo as TextArea,
|
|
165
164
|
Ko as TextInput,
|
|
166
165
|
zo as ThreadFooter,
|
|
167
166
|
Wo as ThreadListItem,
|
|
167
|
+
r as TileButton,
|
|
168
168
|
Yo as Toast,
|
|
169
169
|
er as Tooltip,
|
|
170
170
|
rr as TourPoint,
|
|
171
171
|
ar as UnreadBadge,
|
|
172
172
|
sr as UserAvatar,
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
lr as UserAvatarGroup,
|
|
174
|
+
c as btnStyles,
|
|
175
175
|
ye as modalOverlayStyles,
|
|
176
176
|
Ir as toKebab,
|
|
177
177
|
pr as useControllable,
|
|
178
178
|
xr as useExitAnimation,
|
|
179
|
-
|
|
179
|
+
le as useIconSlotContext,
|
|
180
180
|
ir as useOutsideClose,
|
|
181
|
-
|
|
181
|
+
Mr as usePopoverTransition
|
|
182
182
|
};
|
|
183
183
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/slot.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot.cjs","sources":["../../src/utils/slot.ts"],"sourcesContent":["import {\n Children,\n cloneElement,\n isValidElement,\n type CSSProperties,\n type ReactElement,\n type ReactNode,\n type Ref,\n type RefCallback,\n} from 'react';\nimport { mergeClassNames } from '@/utils/props';\n\ntype PossibleRef<T> = Ref<T> | undefined;\n\n/** Assigns a value to a callback or object ref. */\nfunction setRef<T>(ref: PossibleRef<T>, value: T | null) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref != null) {\n (ref as { current: T | null }).current = value;\n }\n}\n\n/** Composes multiple refs into a single callback ref. */\nexport function composeRefs<T>(...refs: Array<PossibleRef<T>>): RefCallback<T> {\n return (node) => {\n for (const ref of refs) {\n setRef(ref, node);\n }\n };\n}\n\n/**\n * Reads the ref from a React element across React 18 (`element.ref`) and\n * React 19 (`element.props.ref`).\n */\nexport function getElementRef(element: ReactElement): Ref<unknown> | undefined {\n // React 19: ref is a regular prop. React 18: ref is on the element.\n const propsRef = (element.props as { ref?: Ref<unknown> } | null | undefined)\n ?.ref;\n if (propsRef !== undefined) {\n return propsRef;\n }\n return (element as ReactElement & { ref?: Ref<unknown> }).ref;\n}\n\ntype AnyProps = Record<string, unknown>;\n\nfunction isHandlerKey(key: string): boolean {\n return (\n key.length > 2 && key.startsWith('on') && key[2] === key[2]?.toUpperCase()\n );\n}\n\n/**\n * Merges Slot (asChild host) props with the child's props.\n * Child props win by default; event handlers are composed (child first;\n * host skipped when the child called `preventDefault()`); `className` and\n * `style` are merged.\n */\nexport function mergeSlotProps(\n slotProps: AnyProps,\n childProps: AnyProps,\n): AnyProps {\n const override: AnyProps = { ...childProps };\n\n for (const propName of Object.keys(slotProps)) {\n const slotValue = slotProps[propName];\n const childValue = childProps[propName];\n\n if (isHandlerKey(propName)) {\n if (typeof slotValue === 'function' && typeof childValue === 'function') {\n override[propName] = (...args: unknown[]) => {\n const event = args[0] as { defaultPrevented?: boolean } | undefined;\n childValue(...args);\n if (!event?.defaultPrevented) {\n slotValue(...args);\n }\n };\n } else if (typeof slotValue === 'function') {\n override[propName] = slotValue;\n }\n } else if (propName === 'style') {\n override.style = {\n ...(typeof slotValue === 'object' && slotValue != null\n ? (slotValue as CSSProperties)\n : null),\n ...(typeof childValue === 'object' && childValue != null\n ? (childValue as CSSProperties)\n : null),\n };\n } else if (propName === 'className') {\n override.className = mergeClassNames(\n typeof slotValue === 'string' ? slotValue : undefined,\n typeof childValue === 'string' ? childValue : undefined,\n );\n } else if (!(propName in childProps)) {\n override[propName] = slotValue;\n }\n }\n\n return override;\n}\n\nfunction hasRenderableChildren(children: ReactNode): boolean {\n if (children == null || children === false || children === true) {\n return false;\n }\n if (typeof children === 'string') {\n return children.length > 0;\n }\n if (Array.isArray(children)) {\n return children.some(hasRenderableChildren);\n }\n return true;\n}\n\nfunction blockNavigation(event: {\n preventDefault: () => void;\n stopPropagation: () => void;\n}) {\n event.preventDefault();\n event.stopPropagation();\n}\n\nexport interface RenderAsChildOptions {\n /** Single React element to clone (e.g. `<a>` or `<Link>`). */\n child: ReactNode;\n /** Props owned by the host component (className, handlers, aria-*, …). */\n props: AnyProps;\n /** Forwarded ref from the host. */\n ref?: Ref<unknown>;\n /** Anatomy nodes that replace the child's children. */\n content: ReactNode;\n /** When true, apply disabled-link semantics. */\n disabled?: boolean;\n /** BEM disabled class (e.g. `button--disabled`). */\n disabledClassName?: string;\n /**\n * When true, warn in development if the child already has children (they\n * will be replaced). Use for hosts that own their full anatomy\n * (IconButton,
|
|
1
|
+
{"version":3,"file":"slot.cjs","sources":["../../src/utils/slot.ts"],"sourcesContent":["import {\n Children,\n cloneElement,\n isValidElement,\n type CSSProperties,\n type ReactElement,\n type ReactNode,\n type Ref,\n type RefCallback,\n} from 'react';\nimport { mergeClassNames } from '@/utils/props';\n\ntype PossibleRef<T> = Ref<T> | undefined;\n\n/** Assigns a value to a callback or object ref. */\nfunction setRef<T>(ref: PossibleRef<T>, value: T | null) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref != null) {\n (ref as { current: T | null }).current = value;\n }\n}\n\n/** Composes multiple refs into a single callback ref. */\nexport function composeRefs<T>(...refs: Array<PossibleRef<T>>): RefCallback<T> {\n return (node) => {\n for (const ref of refs) {\n setRef(ref, node);\n }\n };\n}\n\n/**\n * Reads the ref from a React element across React 18 (`element.ref`) and\n * React 19 (`element.props.ref`).\n */\nexport function getElementRef(element: ReactElement): Ref<unknown> | undefined {\n // React 19: ref is a regular prop. React 18: ref is on the element.\n const propsRef = (element.props as { ref?: Ref<unknown> } | null | undefined)\n ?.ref;\n if (propsRef !== undefined) {\n return propsRef;\n }\n return (element as ReactElement & { ref?: Ref<unknown> }).ref;\n}\n\ntype AnyProps = Record<string, unknown>;\n\nfunction isHandlerKey(key: string): boolean {\n return (\n key.length > 2 && key.startsWith('on') && key[2] === key[2]?.toUpperCase()\n );\n}\n\n/**\n * Merges Slot (asChild host) props with the child's props.\n * Child props win by default; event handlers are composed (child first;\n * host skipped when the child called `preventDefault()`); `className` and\n * `style` are merged.\n */\nexport function mergeSlotProps(\n slotProps: AnyProps,\n childProps: AnyProps,\n): AnyProps {\n const override: AnyProps = { ...childProps };\n\n for (const propName of Object.keys(slotProps)) {\n const slotValue = slotProps[propName];\n const childValue = childProps[propName];\n\n if (isHandlerKey(propName)) {\n if (typeof slotValue === 'function' && typeof childValue === 'function') {\n override[propName] = (...args: unknown[]) => {\n const event = args[0] as { defaultPrevented?: boolean } | undefined;\n childValue(...args);\n if (!event?.defaultPrevented) {\n slotValue(...args);\n }\n };\n } else if (typeof slotValue === 'function') {\n override[propName] = slotValue;\n }\n } else if (propName === 'style') {\n override.style = {\n ...(typeof slotValue === 'object' && slotValue != null\n ? (slotValue as CSSProperties)\n : null),\n ...(typeof childValue === 'object' && childValue != null\n ? (childValue as CSSProperties)\n : null),\n };\n } else if (propName === 'className') {\n override.className = mergeClassNames(\n typeof slotValue === 'string' ? slotValue : undefined,\n typeof childValue === 'string' ? childValue : undefined,\n );\n } else if (!(propName in childProps)) {\n override[propName] = slotValue;\n }\n }\n\n return override;\n}\n\nfunction hasRenderableChildren(children: ReactNode): boolean {\n if (children == null || children === false || children === true) {\n return false;\n }\n if (typeof children === 'string') {\n return children.length > 0;\n }\n if (Array.isArray(children)) {\n return children.some(hasRenderableChildren);\n }\n return true;\n}\n\nfunction blockNavigation(event: {\n preventDefault: () => void;\n stopPropagation: () => void;\n}) {\n event.preventDefault();\n event.stopPropagation();\n}\n\nexport interface RenderAsChildOptions {\n /** Single React element to clone (e.g. `<a>` or `<Link>`). */\n child: ReactNode;\n /** Props owned by the host component (className, handlers, aria-*, …). */\n props: AnyProps;\n /** Forwarded ref from the host. */\n ref?: Ref<unknown>;\n /** Anatomy nodes that replace the child's children. */\n content: ReactNode;\n /** When true, apply disabled-link semantics. */\n disabled?: boolean;\n /** BEM disabled class (e.g. `button--disabled`). */\n disabledClassName?: string;\n /**\n * When true, warn in development if the child already has children (they\n * will be replaced). Use for hosts that own their full anatomy\n * (IconButton, TileButton). Leave false when the host wraps the child's\n * text (Button label).\n */\n warnOnChildContent?: boolean;\n}\n\n/**\n * Clones a single child element with merged host props, composed refs, and\n * replacement content. Never forwards `type`. When `disabled`, sets\n * `aria-disabled`, the disabled class, and blocks click / auxclick navigation.\n */\nexport function renderAsChild({\n child,\n props,\n ref,\n content,\n disabled = false,\n disabledClassName,\n warnOnChildContent = false,\n}: RenderAsChildOptions): ReactElement | null {\n const warn = process.env.NODE_ENV !== 'production';\n\n let onlyChild: ReactNode = null;\n try {\n onlyChild = Children.only(child);\n } catch {\n onlyChild = null;\n }\n\n if (!isValidElement(onlyChild)) {\n if (warn) {\n console.warn(\n 'asChild expects a single React element child (e.g. <a> or <Link>).',\n );\n }\n return null;\n }\n\n const childProps = onlyChild.props as AnyProps & { children?: ReactNode };\n\n if (\n warn &&\n warnOnChildContent &&\n hasRenderableChildren(childProps.children)\n ) {\n console.warn(\n 'asChild replaces the child element\\'s children with component anatomy. Pass an empty element (e.g. <a href=\"…\" />).',\n );\n }\n\n // Strip `type` — on <a> it means MIME type, not button type.\n const slotProps: AnyProps = { ...props };\n delete slotProps.type;\n\n if (disabled) {\n slotProps['aria-disabled'] = true;\n if (disabledClassName) {\n slotProps.className = mergeClassNames(\n typeof slotProps.className === 'string'\n ? slotProps.className\n : undefined,\n disabledClassName,\n );\n }\n }\n\n const merged = mergeSlotProps(slotProps, childProps);\n\n if (disabled) {\n merged.onClick = blockNavigation;\n merged.onAuxClick = blockNavigation;\n }\n\n const childRef = getElementRef(onlyChild);\n\n return cloneElement(onlyChild, {\n ...merged,\n ref: composeRefs(ref, childRef),\n children: content,\n } as AnyProps);\n}\n"],"names":["setRef","ref","value","composeRefs","refs","node","getElementRef","element","propsRef","_a","isHandlerKey","key","mergeSlotProps","slotProps","childProps","override","propName","slotValue","childValue","args","event","mergeClassNames","hasRenderableChildren","children","blockNavigation","renderAsChild","child","props","content","disabled","disabledClassName","warnOnChildContent","warn","onlyChild","Children","isValidElement","merged","childRef","cloneElement"],"mappings":"kIAeA,SAASA,EAAUC,EAAqBC,EAAiB,CACnD,OAAOD,GAAQ,WACjBA,EAAIC,CAAK,EACAD,GAAO,OACfA,EAA8B,QAAUC,EAE7C,CAGO,SAASC,KAAkBC,EAA6C,CAC7E,OAAQC,GAAS,CACf,UAAWJ,KAAOG,EAChBJ,EAAOC,EAAKI,CAAI,CAEpB,CACF,CAMO,SAASC,EAAcC,EAAiD,OAE7E,MAAMC,GAAYC,EAAAF,EAAQ,QAAR,YAAAE,EACd,IACJ,OAAID,IAAa,OACRA,EAEDD,EAAkD,GAC5D,CAIA,SAASG,EAAaC,EAAsB,OAC1C,OACEA,EAAI,OAAS,GAAKA,EAAI,WAAW,IAAI,GAAKA,EAAI,CAAC,MAAMF,EAAAE,EAAI,CAAC,IAAL,YAAAF,EAAQ,cAEjE,CAQO,SAASG,EACdC,EACAC,EACU,CACV,MAAMC,EAAqB,CAAE,GAAGD,CAAA,EAEhC,UAAWE,KAAY,OAAO,KAAKH,CAAS,EAAG,CAC7C,MAAMI,EAAYJ,EAAUG,CAAQ,EAC9BE,EAAaJ,EAAWE,CAAQ,EAElCN,EAAaM,CAAQ,EACnB,OAAOC,GAAc,YAAc,OAAOC,GAAe,WAC3DH,EAASC,CAAQ,EAAI,IAAIG,IAAoB,CAC3C,MAAMC,EAAQD,EAAK,CAAC,EACpBD,EAAW,GAAGC,CAAI,EACbC,GAAA,MAAAA,EAAO,kBACVH,EAAU,GAAGE,CAAI,CAErB,EACS,OAAOF,GAAc,aAC9BF,EAASC,CAAQ,EAAIC,GAEdD,IAAa,QACtBD,EAAS,MAAQ,CACf,GAAI,OAAOE,GAAc,UAAYA,GAAa,KAC7CA,EACD,KACJ,GAAI,OAAOC,GAAe,UAAY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Ac2B,CAAS,EAExC,OAAOK,EAAAA,aAAaL,EAAW,CAC7B,GAAGG,EACH,IAAKjC,EAAYF,EAAKoC,CAAQ,EAC9B,SAAUT,CAAA,CACC,CACf"}
|
package/dist/utils/slot.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export interface RenderAsChildOptions {
|
|
|
31
31
|
/**
|
|
32
32
|
* When true, warn in development if the child already has children (they
|
|
33
33
|
* will be replaced). Use for hosts that own their full anatomy
|
|
34
|
-
* (IconButton,
|
|
34
|
+
* (IconButton, TileButton). Leave false when the host wraps the child's
|
|
35
35
|
* text (Button label).
|
|
36
36
|
*/
|
|
37
37
|
warnOnChildContent?: boolean;
|
package/dist/utils/slot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot.js","sources":["../../src/utils/slot.ts"],"sourcesContent":["import {\n Children,\n cloneElement,\n isValidElement,\n type CSSProperties,\n type ReactElement,\n type ReactNode,\n type Ref,\n type RefCallback,\n} from 'react';\nimport { mergeClassNames } from '@/utils/props';\n\ntype PossibleRef<T> = Ref<T> | undefined;\n\n/** Assigns a value to a callback or object ref. */\nfunction setRef<T>(ref: PossibleRef<T>, value: T | null) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref != null) {\n (ref as { current: T | null }).current = value;\n }\n}\n\n/** Composes multiple refs into a single callback ref. */\nexport function composeRefs<T>(...refs: Array<PossibleRef<T>>): RefCallback<T> {\n return (node) => {\n for (const ref of refs) {\n setRef(ref, node);\n }\n };\n}\n\n/**\n * Reads the ref from a React element across React 18 (`element.ref`) and\n * React 19 (`element.props.ref`).\n */\nexport function getElementRef(element: ReactElement): Ref<unknown> | undefined {\n // React 19: ref is a regular prop. React 18: ref is on the element.\n const propsRef = (element.props as { ref?: Ref<unknown> } | null | undefined)\n ?.ref;\n if (propsRef !== undefined) {\n return propsRef;\n }\n return (element as ReactElement & { ref?: Ref<unknown> }).ref;\n}\n\ntype AnyProps = Record<string, unknown>;\n\nfunction isHandlerKey(key: string): boolean {\n return (\n key.length > 2 && key.startsWith('on') && key[2] === key[2]?.toUpperCase()\n );\n}\n\n/**\n * Merges Slot (asChild host) props with the child's props.\n * Child props win by default; event handlers are composed (child first;\n * host skipped when the child called `preventDefault()`); `className` and\n * `style` are merged.\n */\nexport function mergeSlotProps(\n slotProps: AnyProps,\n childProps: AnyProps,\n): AnyProps {\n const override: AnyProps = { ...childProps };\n\n for (const propName of Object.keys(slotProps)) {\n const slotValue = slotProps[propName];\n const childValue = childProps[propName];\n\n if (isHandlerKey(propName)) {\n if (typeof slotValue === 'function' && typeof childValue === 'function') {\n override[propName] = (...args: unknown[]) => {\n const event = args[0] as { defaultPrevented?: boolean } | undefined;\n childValue(...args);\n if (!event?.defaultPrevented) {\n slotValue(...args);\n }\n };\n } else if (typeof slotValue === 'function') {\n override[propName] = slotValue;\n }\n } else if (propName === 'style') {\n override.style = {\n ...(typeof slotValue === 'object' && slotValue != null\n ? (slotValue as CSSProperties)\n : null),\n ...(typeof childValue === 'object' && childValue != null\n ? (childValue as CSSProperties)\n : null),\n };\n } else if (propName === 'className') {\n override.className = mergeClassNames(\n typeof slotValue === 'string' ? slotValue : undefined,\n typeof childValue === 'string' ? childValue : undefined,\n );\n } else if (!(propName in childProps)) {\n override[propName] = slotValue;\n }\n }\n\n return override;\n}\n\nfunction hasRenderableChildren(children: ReactNode): boolean {\n if (children == null || children === false || children === true) {\n return false;\n }\n if (typeof children === 'string') {\n return children.length > 0;\n }\n if (Array.isArray(children)) {\n return children.some(hasRenderableChildren);\n }\n return true;\n}\n\nfunction blockNavigation(event: {\n preventDefault: () => void;\n stopPropagation: () => void;\n}) {\n event.preventDefault();\n event.stopPropagation();\n}\n\nexport interface RenderAsChildOptions {\n /** Single React element to clone (e.g. `<a>` or `<Link>`). */\n child: ReactNode;\n /** Props owned by the host component (className, handlers, aria-*, …). */\n props: AnyProps;\n /** Forwarded ref from the host. */\n ref?: Ref<unknown>;\n /** Anatomy nodes that replace the child's children. */\n content: ReactNode;\n /** When true, apply disabled-link semantics. */\n disabled?: boolean;\n /** BEM disabled class (e.g. `button--disabled`). */\n disabledClassName?: string;\n /**\n * When true, warn in development if the child already has children (they\n * will be replaced). Use for hosts that own their full anatomy\n * (IconButton,
|
|
1
|
+
{"version":3,"file":"slot.js","sources":["../../src/utils/slot.ts"],"sourcesContent":["import {\n Children,\n cloneElement,\n isValidElement,\n type CSSProperties,\n type ReactElement,\n type ReactNode,\n type Ref,\n type RefCallback,\n} from 'react';\nimport { mergeClassNames } from '@/utils/props';\n\ntype PossibleRef<T> = Ref<T> | undefined;\n\n/** Assigns a value to a callback or object ref. */\nfunction setRef<T>(ref: PossibleRef<T>, value: T | null) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref != null) {\n (ref as { current: T | null }).current = value;\n }\n}\n\n/** Composes multiple refs into a single callback ref. */\nexport function composeRefs<T>(...refs: Array<PossibleRef<T>>): RefCallback<T> {\n return (node) => {\n for (const ref of refs) {\n setRef(ref, node);\n }\n };\n}\n\n/**\n * Reads the ref from a React element across React 18 (`element.ref`) and\n * React 19 (`element.props.ref`).\n */\nexport function getElementRef(element: ReactElement): Ref<unknown> | undefined {\n // React 19: ref is a regular prop. React 18: ref is on the element.\n const propsRef = (element.props as { ref?: Ref<unknown> } | null | undefined)\n ?.ref;\n if (propsRef !== undefined) {\n return propsRef;\n }\n return (element as ReactElement & { ref?: Ref<unknown> }).ref;\n}\n\ntype AnyProps = Record<string, unknown>;\n\nfunction isHandlerKey(key: string): boolean {\n return (\n key.length > 2 && key.startsWith('on') && key[2] === key[2]?.toUpperCase()\n );\n}\n\n/**\n * Merges Slot (asChild host) props with the child's props.\n * Child props win by default; event handlers are composed (child first;\n * host skipped when the child called `preventDefault()`); `className` and\n * `style` are merged.\n */\nexport function mergeSlotProps(\n slotProps: AnyProps,\n childProps: AnyProps,\n): AnyProps {\n const override: AnyProps = { ...childProps };\n\n for (const propName of Object.keys(slotProps)) {\n const slotValue = slotProps[propName];\n const childValue = childProps[propName];\n\n if (isHandlerKey(propName)) {\n if (typeof slotValue === 'function' && typeof childValue === 'function') {\n override[propName] = (...args: unknown[]) => {\n const event = args[0] as { defaultPrevented?: boolean } | undefined;\n childValue(...args);\n if (!event?.defaultPrevented) {\n slotValue(...args);\n }\n };\n } else if (typeof slotValue === 'function') {\n override[propName] = slotValue;\n }\n } else if (propName === 'style') {\n override.style = {\n ...(typeof slotValue === 'object' && slotValue != null\n ? (slotValue as CSSProperties)\n : null),\n ...(typeof childValue === 'object' && childValue != null\n ? (childValue as CSSProperties)\n : null),\n };\n } else if (propName === 'className') {\n override.className = mergeClassNames(\n typeof slotValue === 'string' ? slotValue : undefined,\n typeof childValue === 'string' ? childValue : undefined,\n );\n } else if (!(propName in childProps)) {\n override[propName] = slotValue;\n }\n }\n\n return override;\n}\n\nfunction hasRenderableChildren(children: ReactNode): boolean {\n if (children == null || children === false || children === true) {\n return false;\n }\n if (typeof children === 'string') {\n return children.length > 0;\n }\n if (Array.isArray(children)) {\n return children.some(hasRenderableChildren);\n }\n return true;\n}\n\nfunction blockNavigation(event: {\n preventDefault: () => void;\n stopPropagation: () => void;\n}) {\n event.preventDefault();\n event.stopPropagation();\n}\n\nexport interface RenderAsChildOptions {\n /** Single React element to clone (e.g. `<a>` or `<Link>`). */\n child: ReactNode;\n /** Props owned by the host component (className, handlers, aria-*, …). */\n props: AnyProps;\n /** Forwarded ref from the host. */\n ref?: Ref<unknown>;\n /** Anatomy nodes that replace the child's children. */\n content: ReactNode;\n /** When true, apply disabled-link semantics. */\n disabled?: boolean;\n /** BEM disabled class (e.g. `button--disabled`). */\n disabledClassName?: string;\n /**\n * When true, warn in development if the child already has children (they\n * will be replaced). Use for hosts that own their full anatomy\n * (IconButton, TileButton). Leave false when the host wraps the child's\n * text (Button label).\n */\n warnOnChildContent?: boolean;\n}\n\n/**\n * Clones a single child element with merged host props, composed refs, and\n * replacement content. Never forwards `type`. When `disabled`, sets\n * `aria-disabled`, the disabled class, and blocks click / auxclick navigation.\n */\nexport function renderAsChild({\n child,\n props,\n ref,\n content,\n disabled = false,\n disabledClassName,\n warnOnChildContent = false,\n}: RenderAsChildOptions): ReactElement | null {\n const warn = process.env.NODE_ENV !== 'production';\n\n let onlyChild: ReactNode = null;\n try {\n onlyChild = Children.only(child);\n } catch {\n onlyChild = null;\n }\n\n if (!isValidElement(onlyChild)) {\n if (warn) {\n console.warn(\n 'asChild expects a single React element child (e.g. <a> or <Link>).',\n );\n }\n return null;\n }\n\n const childProps = onlyChild.props as AnyProps & { children?: ReactNode };\n\n if (\n warn &&\n warnOnChildContent &&\n hasRenderableChildren(childProps.children)\n ) {\n console.warn(\n 'asChild replaces the child element\\'s children with component anatomy. Pass an empty element (e.g. <a href=\"…\" />).',\n );\n }\n\n // Strip `type` — on <a> it means MIME type, not button type.\n const slotProps: AnyProps = { ...props };\n delete slotProps.type;\n\n if (disabled) {\n slotProps['aria-disabled'] = true;\n if (disabledClassName) {\n slotProps.className = mergeClassNames(\n typeof slotProps.className === 'string'\n ? slotProps.className\n : undefined,\n disabledClassName,\n );\n }\n }\n\n const merged = mergeSlotProps(slotProps, childProps);\n\n if (disabled) {\n merged.onClick = blockNavigation;\n merged.onAuxClick = blockNavigation;\n }\n\n const childRef = getElementRef(onlyChild);\n\n return cloneElement(onlyChild, {\n ...merged,\n ref: composeRefs(ref, childRef),\n children: content,\n } as AnyProps);\n}\n"],"names":["setRef","ref","value","composeRefs","refs","node","getElementRef","element","propsRef","_a","isHandlerKey","key","mergeSlotProps","slotProps","childProps","override","propName","slotValue","childValue","args","event","mergeClassNames","hasRenderableChildren","children","blockNavigation","renderAsChild","child","props","content","disabled","disabledClassName","warnOnChildContent","warn","onlyChild","Children","isValidElement","merged","childRef","cloneElement"],"mappings":";;AAeA,SAASA,EAAUC,GAAqBC,GAAiB;AACvD,EAAI,OAAOD,KAAQ,aACjBA,EAAIC,CAAK,IACAD,KAAO,SACfA,EAA8B,UAAUC;AAE7C;AAGO,SAASC,KAAkBC,GA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CACC;AACf;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mattermost/compass-ui",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.21",
|
|
4
4
|
"description": "Compass design system UI components for Mattermost products",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -107,9 +107,6 @@
|
|
|
107
107
|
"utils/string": [
|
|
108
108
|
"./dist/utils/string.d.ts"
|
|
109
109
|
],
|
|
110
|
-
"components/action-button": [
|
|
111
|
-
"./dist/components/action-button/index.d.ts"
|
|
112
|
-
],
|
|
113
110
|
"components/admin-console-footer": [
|
|
114
111
|
"./dist/components/admin-console-footer/index.d.ts"
|
|
115
112
|
],
|
|
@@ -314,6 +311,9 @@
|
|
|
314
311
|
"components/thread-list-item": [
|
|
315
312
|
"./dist/components/thread-list-item/index.d.ts"
|
|
316
313
|
],
|
|
314
|
+
"components/tile-button": [
|
|
315
|
+
"./dist/components/tile-button/index.d.ts"
|
|
316
|
+
],
|
|
317
317
|
"components/toast": [
|
|
318
318
|
"./dist/components/toast/index.d.ts"
|
|
319
319
|
],
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),q=require("react"),s=require("../icon/Icon.cjs"),A=require("../../utils/slot.cjs"),t=require("./ActionButton.module.scss.cjs"),i=q.forwardRef(function(a,o){if(a.asChild){const{icon:m,label:v,destructive:j=!1,className:C,disabled:x,children:N,asChild:S,..._}=a,p=[t.default["action-button"],j?t.default["action-button--destructive"]:"",C??""].filter(Boolean).join(" "),B=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:t.default["action-button__icon"],"aria-hidden":!0,children:e.jsx(s.IconSlotContext.Provider,{value:{size:"20"},children:m})}),e.jsx("span",{className:t.default["action-button__label"],children:v})]});return A.renderAsChild({child:N,props:{..._,className:p},ref:o,content:B,disabled:!!x,disabledClassName:t.default["action-button--disabled"],warnOnChildContent:!0})}const{icon:l,label:c,active:n,destructive:d=!1,className:r,disabled:u,type:b="button",asChild:P,...f}=a,h=[t.default["action-button"],n?t.default["action-button--active"]:"",d?t.default["action-button--destructive"]:"",r??""].filter(Boolean).join(" ");return e.jsxs("button",{ref:o,className:h,type:b,disabled:u,"aria-pressed":n===void 0?void 0:n,...f,children:[e.jsx("span",{className:t.default["action-button__icon"],"aria-hidden":!0,children:e.jsx(s.IconSlotContext.Provider,{value:{size:"20"},children:l})}),e.jsx("span",{className:t.default["action-button__label"],children:c})]})});i.displayName="ActionButton";exports.default=i;
|
|
2
|
-
//# sourceMappingURL=ActionButton.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ActionButton.cjs","sources":["../../../src/components/action-button/ActionButton.tsx"],"sourcesContent":["import {\n forwardRef,\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n type Ref,\n type RefAttributes,\n} from 'react';\nimport { IconSlotContext } from '@/components/icon/Icon';\nimport { renderAsChild } from '@/utils/slot';\nimport styles from './ActionButton.module.scss';\n\ninterface ActionButtonOwnProps {\n /** Pass `<Icon glyph={<SomeIcon />} />` — ActionButton provides the correct size (20) via context. */\n icon: ReactNode;\n /** Visible label. Accepts translated nodes (e.g. `<FormattedMessage/>`). */\n label: ReactNode;\n destructive?: boolean;\n className?: string;\n /**\n * When true, disables the control. On a native `<button>`, sets the `disabled`\n * attribute. With `asChild`, sets `aria-disabled`, applies disabled styles, and\n * blocks click / middle-click navigation (the link stays focusable).\n */\n disabled?: boolean;\n}\n\nexport interface ActionButtonProps\n extends ActionButtonOwnProps, ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * When true, merges ActionButton props onto the single child element instead of\n * rendering a `<button>`. Use with `<a>` or a router `Link`. Default: false.\n */\n asChild?: false;\n /**\n * When set, this is a toggle; maps to `aria-pressed`. Only applies to the native\n * `<button>`; not available with `asChild`.\n */\n active?: boolean;\n}\n\nexport interface ActionButtonAsChildProps\n extends\n ActionButtonOwnProps,\n Omit<HTMLAttributes<HTMLElement>, 'children' | 'color'> {\n /**\n * Merges ActionButton props onto the single child element instead of rendering a\n * `<button>`. The child's own props (`href`, `to`, `target`, …) stay on the\n * child. Do not pass `type` or `active` — they are not available on links.\n * Pass an empty child; ActionButton supplies the icon and label anatomy.\n */\n asChild: true;\n /** Single empty element to render as the ActionButton (e.g. `<a href=\"…\" />`). */\n children: ReactElement;\n}\n\ntype ActionButtonComponent = {\n (\n props: ActionButtonAsChildProps & RefAttributes<HTMLElement>,\n ): ReactElement | null;\n (\n props: ActionButtonProps & RefAttributes<HTMLButtonElement>,\n ): ReactElement | null;\n displayName?: string;\n};\n\n/**\n * Action Buttons surface a small set of high-frequency actions in a fixed context — a\n * profile popover, a channel info panel, a card. They sit close to the content they act on\n * and read as a row of equal-weight choices.\n *\n * Pass `asChild` with a single empty `<a>` or router `Link` child to render a navigational\n * action with Action Button styling (no nested `<button>`).\n */\nconst ActionButton = forwardRef(function ActionButton(\n props: ActionButtonProps | ActionButtonAsChildProps,\n ref: Ref<HTMLButtonElement | HTMLElement>,\n) {\n if (props.asChild) {\n const {\n icon,\n label,\n destructive = false,\n className,\n disabled,\n children,\n asChild,\n ...rest\n } = props;\n void asChild;\n\n const rootClass = [\n styles['action-button'],\n destructive ? styles['action-button--destructive'] : '',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n\n const anatomy = (\n <>\n <span className={styles['action-button__icon']} aria-hidden>\n <IconSlotContext.Provider value={{ size: '20' }}>\n {icon}\n </IconSlotContext.Provider>\n </span>\n <span className={styles['action-button__label']}>{label}</span>\n </>\n );\n\n return renderAsChild({\n child: children,\n props: {\n ...rest,\n className: rootClass,\n },\n ref,\n content: anatomy,\n disabled: Boolean(disabled),\n disabledClassName: styles['action-button--disabled'],\n warnOnChildContent: true,\n });\n }\n\n const {\n icon,\n label,\n active,\n destructive = false,\n className,\n disabled,\n type = 'button',\n asChild,\n ...htmlProps\n } = props;\n void asChild;\n\n const rootClass = [\n styles['action-button'],\n active ? styles['action-button--active'] : '',\n destructive ? styles['action-button--destructive'] : '',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <button\n ref={ref as Ref<HTMLButtonElement>}\n className={rootClass}\n type={type}\n disabled={disabled}\n aria-pressed={active === undefined ? undefined : active}\n {...htmlProps}\n >\n <span className={styles['action-button__icon']} aria-hidden>\n <IconSlotContext.Provider value={{ size: '20' }}>\n {icon}\n </IconSlotContext.Provider>\n </span>\n <span className={styles['action-button__label']}>{label}</span>\n </button>\n );\n}) as ActionButtonComponent;\n\nActionButton.displayName = 'ActionButton';\n\nexport default ActionButton;\n"],"names":["ActionButton","forwardRef","props","ref","icon","label","destructive","className","disabled","children","asChild","rest","rootClass","styles","anatomy","jsxs","Fragment","jsx","IconSlotContext","renderAsChild","active","type","htmlProps"],"mappings":"gRA2EMA,EAAeC,EAAAA,WAAW,SAC9BC,EACAC,EACA,CACA,GAAID,EAAM,QAAS,CACjB,KAAM,CACJ,KAAAE,EACA,MAAAC,EACA,YAAAC,EAAc,GACd,UAAAC,EACA,SAAAC,EACA,SAAAC,EACA,QAAAC,EACA,GAAGC,CAAA,EACDT,EAGEU,EAAY,CAChBC,EAAAA,QAAO,eAAe,EACtBP,EAAcO,EAAAA,QAAO,4BAA4B,EAAI,GACrDN,GAAa,EAAA,EAEZ,OAAO,OAAO,EACd,KAAK,GAAG,EAELO,EACJC,EAAAA,KAAAC,EAAAA,SAAA,CACE,SAAA,CAAAC,MAAC,QAAK,UAAWJ,EAAAA,QAAO,qBAAqB,EAAG,cAAW,GACzD,SAAAI,EAAAA,IAACC,EAAAA,gBAAgB,SAAhB,CAAyB,MAAO,CAAE,KAAM,MACtC,SAAAd,EACH,EACF,QACC,OAAA,CAAK,UAAWS,EAAAA,QAAO,sBAAsB,EAAI,SAAAR,CAAAA,CAAM,CAAA,EAC1D,EAGF,OAAOc,gBAAc,CACnB,MAAOV,EACP,MAAO,CACL,GAAGE,EACH,UAAWC,CAAA,EAEb,IAAAT,EACA,QAASW,EACT,SAAU,EAAQN,EAClB,kBAAmBK,EAAAA,QAAO,yBAAyB,EACnD,mBAAoB,EAAA,CACrB,CACH,CAEA,KAAM,CACJ,KAAAT,EACA,MAAAC,EACA,OAAAe,EACA,YAAAd,EAAc,GACd,UAAAC,EACA,SAAAC,EACA,KAAAa,EAAO,SACP,QAAAX,EACA,GAAGY,CAAA,EACDpB,EAGEU,EAAY,CAChBC,EAAAA,QAAO,eAAe,EACtBO,EAASP,EAAAA,QAAO,uBAAuB,EAAI,GAC3CP,EAAcO,EAAAA,QAAO,4BAA4B,EAAI,GACrDN,GAAa,EAAA,EAEZ,OAAO,OAAO,EACd,KAAK,GAAG,EAEX,OACEQ,EAAAA,KAAC,SAAA,CACC,IAAAZ,EACA,UAAWS,EACX,KAAAS,EACA,SAAAb,EACA,eAAcY,IAAW,OAAY,OAAYA,EAChD,GAAGE,EAEJ,SAAA,CAAAL,MAAC,QAAK,UAAWJ,EAAAA,QAAO,qBAAqB,EAAG,cAAW,GACzD,SAAAI,EAAAA,IAACC,EAAAA,gBAAgB,SAAhB,CAAyB,MAAO,CAAE,KAAM,IAAA,EACtC,WACH,EACF,QACC,OAAA,CAAK,UAAWL,EAAAA,QAAO,sBAAsB,EAAI,SAAAR,CAAA,CAAM,CAAA,CAAA,CAAA,CAG9D,CAAC,EAEDL,EAAa,YAAc"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
._action-button_1nxkv_2{display:flex;flex-direction:column;align-items:center;gap:var(--spacing-xxxs);width:108px;min-width:64px;max-width:100%;padding:var(--spacing-m) 0 var(--spacing-s);border:none;border-radius:var(--radius-s);background-color:rgba(var(--center-channel-color-rgb),.04);--action-button-fg: rgba(var(--center-channel-color-rgb), .64);color:var(--action-button-fg);cursor:pointer;text-decoration:none;transition:background-color var(--duration-quick) var(--ease-transition),color var(--duration-quick) var(--ease-transition),outline-color var(--duration-quick) var(--ease-transition),outline-offset var(--duration-quick) var(--ease-transition);outline:2px solid color-mix(in srgb,var(--focus-ring-color) 0%,transparent);outline-offset:0}._action-button_1nxkv_2:any-link,._action-button_1nxkv_2:hover,._action-button_1nxkv_2:focus,._action-button_1nxkv_2:active,._action-button_1nxkv_2:visited{color:var(--action-button-fg);text-decoration:none}._action-button_1nxkv_2:focus-visible{outline-color:var(--focus-ring-color);outline-offset:3px}._action-button_1nxkv_2:hover:not(:disabled,._action-button--disabled_1nxkv_30){background-color:rgba(var(--center-channel-color-rgb),.08);--action-button-fg: rgba(var(--center-channel-color-rgb), .75)}._action-button_1nxkv_2:active:not(:disabled,._action-button--disabled_1nxkv_30){background-color:rgba(var(--button-bg-rgb),.08);--action-button-fg: var(--link-color)}._action-button_1nxkv_2:is(:disabled,._action-button--disabled_1nxkv_30){opacity:.48;cursor:not-allowed}._action-button--active_1nxkv_42{--action-button-fg: var(--link-color);background-color:rgba(var(--button-bg-rgb),.08)}._action-button--active_1nxkv_42 ._action-button__icon_1nxkv_46,._action-button--active_1nxkv_42 ._action-button__label_1nxkv_47{color:var(--link-color)}._action-button--active_1nxkv_42:hover:not(:disabled,._action-button--disabled_1nxkv_30){background-color:rgba(var(--button-bg-rgb),.12)}._action-button--active_1nxkv_42:active:not(:disabled,._action-button--disabled_1nxkv_30){background-color:rgba(var(--button-bg-rgb),.16)}._action-button--destructive_1nxkv_56{--focus-ring-color: var(--error-text, var(--color-danger));--action-button-fg: var(--error-text, var(--color-danger));background-color:rgba(var(--error-text-color-rgb, var(--color-danger-rgb)),.04)}._action-button--destructive_1nxkv_56:hover:not(:disabled,._action-button--disabled_1nxkv_30){background-color:rgba(var(--error-text-color-rgb, var(--color-danger-rgb)),.08);--action-button-fg: var(--error-text, var(--color-danger))}._action-button--destructive_1nxkv_56:active:not(:disabled,._action-button--disabled_1nxkv_30){background-color:rgba(var(--error-text-color-rgb, var(--color-danger-rgb)),.16);--action-button-fg: var(--error-text, var(--color-danger))}._action-button__icon_1nxkv_46{display:flex;align-items:center;justify-content:center;width:var(--icon-size-20);height:var(--icon-size-20);flex-shrink:0;color:var(--action-button-fg)}._action-button__label_1nxkv_47{font-family:var(--font-family-body);font-size:var(--font-size-50);font-weight:var(--font-weight-semibold);line-height:var(--line-height-50);letter-spacing:.11px;box-sizing:border-box;max-width:100%;padding-inline:var(--action-button-padding-inline, clamp(var(--spacing-xs), 33.33% - 13.33px, var(--spacing-l)));display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;overflow:hidden;overflow-wrap:anywhere;text-wrap:balance;white-space:normal;text-align:center;color:var(--action-button-fg)}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { ButtonHTMLAttributes, HTMLAttributes, ReactElement, ReactNode, RefAttributes } from 'react';
|
|
2
|
-
interface ActionButtonOwnProps {
|
|
3
|
-
/** Pass `<Icon glyph={<SomeIcon />} />` — ActionButton provides the correct size (20) via context. */
|
|
4
|
-
icon: ReactNode;
|
|
5
|
-
/** Visible label. Accepts translated nodes (e.g. `<FormattedMessage/>`). */
|
|
6
|
-
label: ReactNode;
|
|
7
|
-
destructive?: boolean;
|
|
8
|
-
className?: string;
|
|
9
|
-
/**
|
|
10
|
-
* When true, disables the control. On a native `<button>`, sets the `disabled`
|
|
11
|
-
* attribute. With `asChild`, sets `aria-disabled`, applies disabled styles, and
|
|
12
|
-
* blocks click / middle-click navigation (the link stays focusable).
|
|
13
|
-
*/
|
|
14
|
-
disabled?: boolean;
|
|
15
|
-
}
|
|
16
|
-
export interface ActionButtonProps extends ActionButtonOwnProps, ButtonHTMLAttributes<HTMLButtonElement> {
|
|
17
|
-
/**
|
|
18
|
-
* When true, merges ActionButton props onto the single child element instead of
|
|
19
|
-
* rendering a `<button>`. Use with `<a>` or a router `Link`. Default: false.
|
|
20
|
-
*/
|
|
21
|
-
asChild?: false;
|
|
22
|
-
/**
|
|
23
|
-
* When set, this is a toggle; maps to `aria-pressed`. Only applies to the native
|
|
24
|
-
* `<button>`; not available with `asChild`.
|
|
25
|
-
*/
|
|
26
|
-
active?: boolean;
|
|
27
|
-
}
|
|
28
|
-
export interface ActionButtonAsChildProps extends ActionButtonOwnProps, Omit<HTMLAttributes<HTMLElement>, 'children' | 'color'> {
|
|
29
|
-
/**
|
|
30
|
-
* Merges ActionButton props onto the single child element instead of rendering a
|
|
31
|
-
* `<button>`. The child's own props (`href`, `to`, `target`, …) stay on the
|
|
32
|
-
* child. Do not pass `type` or `active` — they are not available on links.
|
|
33
|
-
* Pass an empty child; ActionButton supplies the icon and label anatomy.
|
|
34
|
-
*/
|
|
35
|
-
asChild: true;
|
|
36
|
-
/** Single empty element to render as the ActionButton (e.g. `<a href="…" />`). */
|
|
37
|
-
children: ReactElement;
|
|
38
|
-
}
|
|
39
|
-
type ActionButtonComponent = {
|
|
40
|
-
(props: ActionButtonAsChildProps & RefAttributes<HTMLElement>): ReactElement | null;
|
|
41
|
-
(props: ActionButtonProps & RefAttributes<HTMLButtonElement>): ReactElement | null;
|
|
42
|
-
displayName?: string;
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Action Buttons surface a small set of high-frequency actions in a fixed context — a
|
|
46
|
-
* profile popover, a channel info panel, a card. They sit close to the content they act on
|
|
47
|
-
* and read as a row of equal-weight choices.
|
|
48
|
-
*
|
|
49
|
-
* Pass `asChild` with a single empty `<a>` or router `Link` child to render a navigational
|
|
50
|
-
* action with Action Button styling (no nested `<button>`).
|
|
51
|
-
*/
|
|
52
|
-
declare const ActionButton: ActionButtonComponent;
|
|
53
|
-
export default ActionButton;
|
|
54
|
-
//# sourceMappingURL=ActionButton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ActionButton.d.ts","sourceRoot":"","sources":["../../../src/components/action-button/ActionButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,SAAS,EAEd,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AAKf,UAAU,oBAAoB;IAC5B,sGAAsG;IACtG,IAAI,EAAE,SAAS,CAAC;IAChB,4EAA4E;IAC5E,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,iBACf,SAAQ,oBAAoB,EAAE,oBAAoB,CAAC,iBAAiB,CAAC;IACrE;;;OAGG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,wBACf,SACE,oBAAoB,EACpB,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;IACzD;;;;;OAKG;IACH,OAAO,EAAE,IAAI,CAAC;IACd,kFAAkF;IAClF,QAAQ,EAAE,YAAY,CAAC;CACxB;AAED,KAAK,qBAAqB,GAAG;IAC3B,CACE,KAAK,EAAE,wBAAwB,GAAG,aAAa,CAAC,WAAW,CAAC,GAC3D,YAAY,GAAG,IAAI,CAAC;IACvB,CACE,KAAK,EAAE,iBAAiB,GAAG,aAAa,CAAC,iBAAiB,CAAC,GAC1D,YAAY,GAAG,IAAI,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,YAAY,EAyFZ,qBAAqB,CAAC;AAI5B,eAAe,YAAY,CAAC"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { jsxs as i, Fragment as y, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as A } from "react";
|
|
3
|
-
import { IconSlotContext as s } from "../icon/Icon.js";
|
|
4
|
-
import { renderAsChild as P } from "../../utils/slot.js";
|
|
5
|
-
import t from "./ActionButton.module.scss.js";
|
|
6
|
-
const w = A(function(a, o) {
|
|
7
|
-
if (a.asChild) {
|
|
8
|
-
const {
|
|
9
|
-
icon: f,
|
|
10
|
-
label: v,
|
|
11
|
-
destructive: p = !1,
|
|
12
|
-
className: C,
|
|
13
|
-
disabled: N,
|
|
14
|
-
children: _,
|
|
15
|
-
asChild: F,
|
|
16
|
-
...B
|
|
17
|
-
} = a, j = [
|
|
18
|
-
t["action-button"],
|
|
19
|
-
p ? t["action-button--destructive"] : "",
|
|
20
|
-
C ?? ""
|
|
21
|
-
].filter(Boolean).join(" "), x = /* @__PURE__ */ i(y, { children: [
|
|
22
|
-
/* @__PURE__ */ e("span", { className: t["action-button__icon"], "aria-hidden": !0, children: /* @__PURE__ */ e(s.Provider, { value: { size: "20" }, children: f }) }),
|
|
23
|
-
/* @__PURE__ */ e("span", { className: t["action-button__label"], children: v })
|
|
24
|
-
] });
|
|
25
|
-
return P({
|
|
26
|
-
child: _,
|
|
27
|
-
props: {
|
|
28
|
-
...B,
|
|
29
|
-
className: j
|
|
30
|
-
},
|
|
31
|
-
ref: o,
|
|
32
|
-
content: x,
|
|
33
|
-
disabled: !!N,
|
|
34
|
-
disabledClassName: t["action-button--disabled"],
|
|
35
|
-
warnOnChildContent: !0
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
const {
|
|
39
|
-
icon: l,
|
|
40
|
-
label: c,
|
|
41
|
-
active: n,
|
|
42
|
-
destructive: r = !1,
|
|
43
|
-
className: d,
|
|
44
|
-
disabled: u,
|
|
45
|
-
type: m = "button",
|
|
46
|
-
asChild: g,
|
|
47
|
-
...b
|
|
48
|
-
} = a, h = [
|
|
49
|
-
t["action-button"],
|
|
50
|
-
n ? t["action-button--active"] : "",
|
|
51
|
-
r ? t["action-button--destructive"] : "",
|
|
52
|
-
d ?? ""
|
|
53
|
-
].filter(Boolean).join(" ");
|
|
54
|
-
return /* @__PURE__ */ i(
|
|
55
|
-
"button",
|
|
56
|
-
{
|
|
57
|
-
ref: o,
|
|
58
|
-
className: h,
|
|
59
|
-
type: m,
|
|
60
|
-
disabled: u,
|
|
61
|
-
"aria-pressed": n === void 0 ? void 0 : n,
|
|
62
|
-
...b,
|
|
63
|
-
children: [
|
|
64
|
-
/* @__PURE__ */ e("span", { className: t["action-button__icon"], "aria-hidden": !0, children: /* @__PURE__ */ e(s.Provider, { value: { size: "20" }, children: l }) }),
|
|
65
|
-
/* @__PURE__ */ e("span", { className: t["action-button__label"], children: c })
|
|
66
|
-
]
|
|
67
|
-
}
|
|
68
|
-
);
|
|
69
|
-
});
|
|
70
|
-
w.displayName = "ActionButton";
|
|
71
|
-
export {
|
|
72
|
-
w as default
|
|
73
|
-
};
|
|
74
|
-
//# sourceMappingURL=ActionButton.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ActionButton.js","sources":["../../../src/components/action-button/ActionButton.tsx"],"sourcesContent":["import {\n forwardRef,\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n type Ref,\n type RefAttributes,\n} from 'react';\nimport { IconSlotContext } from '@/components/icon/Icon';\nimport { renderAsChild } from '@/utils/slot';\nimport styles from './ActionButton.module.scss';\n\ninterface ActionButtonOwnProps {\n /** Pass `<Icon glyph={<SomeIcon />} />` — ActionButton provides the correct size (20) via context. */\n icon: ReactNode;\n /** Visible label. Accepts translated nodes (e.g. `<FormattedMessage/>`). */\n label: ReactNode;\n destructive?: boolean;\n className?: string;\n /**\n * When true, disables the control. On a native `<button>`, sets the `disabled`\n * attribute. With `asChild`, sets `aria-disabled`, applies disabled styles, and\n * blocks click / middle-click navigation (the link stays focusable).\n */\n disabled?: boolean;\n}\n\nexport interface ActionButtonProps\n extends ActionButtonOwnProps, ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * When true, merges ActionButton props onto the single child element instead of\n * rendering a `<button>`. Use with `<a>` or a router `Link`. Default: false.\n */\n asChild?: false;\n /**\n * When set, this is a toggle; maps to `aria-pressed`. Only applies to the native\n * `<button>`; not available with `asChild`.\n */\n active?: boolean;\n}\n\nexport interface ActionButtonAsChildProps\n extends\n ActionButtonOwnProps,\n Omit<HTMLAttributes<HTMLElement>, 'children' | 'color'> {\n /**\n * Merges ActionButton props onto the single child element instead of rendering a\n * `<button>`. The child's own props (`href`, `to`, `target`, …) stay on the\n * child. Do not pass `type` or `active` — they are not available on links.\n * Pass an empty child; ActionButton supplies the icon and label anatomy.\n */\n asChild: true;\n /** Single empty element to render as the ActionButton (e.g. `<a href=\"…\" />`). */\n children: ReactElement;\n}\n\ntype ActionButtonComponent = {\n (\n props: ActionButtonAsChildProps & RefAttributes<HTMLElement>,\n ): ReactElement | null;\n (\n props: ActionButtonProps & RefAttributes<HTMLButtonElement>,\n ): ReactElement | null;\n displayName?: string;\n};\n\n/**\n * Action Buttons surface a small set of high-frequency actions in a fixed context — a\n * profile popover, a channel info panel, a card. They sit close to the content they act on\n * and read as a row of equal-weight choices.\n *\n * Pass `asChild` with a single empty `<a>` or router `Link` child to render a navigational\n * action with Action Button styling (no nested `<button>`).\n */\nconst ActionButton = forwardRef(function ActionButton(\n props: ActionButtonProps | ActionButtonAsChildProps,\n ref: Ref<HTMLButtonElement | HTMLElement>,\n) {\n if (props.asChild) {\n const {\n icon,\n label,\n destructive = false,\n className,\n disabled,\n children,\n asChild,\n ...rest\n } = props;\n void asChild;\n\n const rootClass = [\n styles['action-button'],\n destructive ? styles['action-button--destructive'] : '',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n\n const anatomy = (\n <>\n <span className={styles['action-button__icon']} aria-hidden>\n <IconSlotContext.Provider value={{ size: '20' }}>\n {icon}\n </IconSlotContext.Provider>\n </span>\n <span className={styles['action-button__label']}>{label}</span>\n </>\n );\n\n return renderAsChild({\n child: children,\n props: {\n ...rest,\n className: rootClass,\n },\n ref,\n content: anatomy,\n disabled: Boolean(disabled),\n disabledClassName: styles['action-button--disabled'],\n warnOnChildContent: true,\n });\n }\n\n const {\n icon,\n label,\n active,\n destructive = false,\n className,\n disabled,\n type = 'button',\n asChild,\n ...htmlProps\n } = props;\n void asChild;\n\n const rootClass = [\n styles['action-button'],\n active ? styles['action-button--active'] : '',\n destructive ? styles['action-button--destructive'] : '',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <button\n ref={ref as Ref<HTMLButtonElement>}\n className={rootClass}\n type={type}\n disabled={disabled}\n aria-pressed={active === undefined ? undefined : active}\n {...htmlProps}\n >\n <span className={styles['action-button__icon']} aria-hidden>\n <IconSlotContext.Provider value={{ size: '20' }}>\n {icon}\n </IconSlotContext.Provider>\n </span>\n <span className={styles['action-button__label']}>{label}</span>\n </button>\n );\n}) as ActionButtonComponent;\n\nActionButton.displayName = 'ActionButton';\n\nexport default ActionButton;\n"],"names":["ActionButton","forwardRef","props","ref","icon","label","destructive","className","disabled","children","asChild","rest","rootClass","styles","anatomy","jsxs","Fragment","jsx","IconSlotContext","renderAsChild","active","type","htmlProps"],"mappings":";;;;;AA2EA,MAAMA,IAAeC,EAAW,SAC9BC,GACAC,GACA;AACA,MAAID,EAAM,SAAS;AACjB,UAAM;AAAA,MACJ,MAAAE;AAAAA,MACA,OAAAC;AAAAA,MACA,aAAAC,IAAc;AAAA,MACd,WAAAC;AAAAA,MACA,UAAAC;AAAAA,MACA,UAAAC;AAAA,MACA,SAAAC;AAAAA,MACA,GAAGC;AAAA,IAAA,IACDT,GAGEU,IAAY;AAAA,MAChBC,EAAO,eAAe;AAAA,MACtBP,IAAcO,EAAO,4BAA4B,IAAI;AAAA,MACrDN,KAAa;AAAA,IAAA,EAEZ,OAAO,OAAO,EACd,KAAK,GAAG,GAELO,IACJ,gBAAAC,EAAAC,GAAA,EACE,UAAA;AAAA,MAAA,gBAAAC,EAAC,UAAK,WAAWJ,EAAO,qBAAqB,GAAG,eAAW,IACzD,UAAA,gBAAAI,EAACC,EAAgB,UAAhB,EAAyB,OAAO,EAAE,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AAC;AAEDL,EAAa,cAAc;"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./ActionButton.css');const t={"action-button":"_action-button_1nxkv_2","action-button--disabled":"_action-button--disabled_1nxkv_30","action-button--active":"_action-button--active_1nxkv_42","action-button__icon":"_action-button__icon_1nxkv_46","action-button__label":"_action-button__label_1nxkv_47","action-button--destructive":"_action-button--destructive_1nxkv_56"};exports.default=t;
|
|
2
|
-
//# sourceMappingURL=ActionButton.module.scss.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ActionButton.module.scss.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import './ActionButton.css';const t = {
|
|
2
|
-
"action-button": "_action-button_1nxkv_2",
|
|
3
|
-
"action-button--disabled": "_action-button--disabled_1nxkv_30",
|
|
4
|
-
"action-button--active": "_action-button--active_1nxkv_42",
|
|
5
|
-
"action-button__icon": "_action-button__icon_1nxkv_46",
|
|
6
|
-
"action-button__label": "_action-button__label_1nxkv_47",
|
|
7
|
-
"action-button--destructive": "_action-button--destructive_1nxkv_56"
|
|
8
|
-
};
|
|
9
|
-
export {
|
|
10
|
-
t as default
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=ActionButton.module.scss.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ActionButton.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/action-button/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,YAAY,EACV,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,gBAAgB,CAAC"}
|
|
File without changes
|
|
File without changes
|