@mattermost/compass-ui 0.1.0-alpha.14 → 0.1.0-alpha.16
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-button/ActionButton.cjs +1 -1
- package/dist/components/action-button/ActionButton.cjs.map +1 -1
- package/dist/components/action-button/ActionButton.css +1 -1
- package/dist/components/action-button/ActionButton.d.ts +41 -5
- package/dist/components/action-button/ActionButton.d.ts.map +1 -1
- package/dist/components/action-button/ActionButton.js +68 -35
- package/dist/components/action-button/ActionButton.js.map +1 -1
- package/dist/components/action-button/ActionButton.module.scss.cjs +1 -1
- package/dist/components/action-button/ActionButton.module.scss.js +6 -5
- package/dist/components/action-button/ActionButton.module.scss.js.map +1 -1
- package/dist/components/action-button/index.d.ts +1 -1
- package/dist/components/action-button/index.d.ts.map +1 -1
- package/dist/components/admin-console-footer/AdminConsoleFooter.cjs +2 -0
- package/dist/components/admin-console-footer/AdminConsoleFooter.cjs.map +1 -0
- package/dist/components/admin-console-footer/AdminConsoleFooter.css +1 -0
- package/dist/components/admin-console-footer/AdminConsoleFooter.d.ts +27 -0
- package/dist/components/admin-console-footer/AdminConsoleFooter.d.ts.map +1 -0
- package/dist/components/admin-console-footer/AdminConsoleFooter.js +84 -0
- package/dist/components/admin-console-footer/AdminConsoleFooter.js.map +1 -0
- package/dist/components/admin-console-footer/AdminConsoleFooter.module.scss.cjs +2 -0
- package/dist/components/admin-console-footer/AdminConsoleFooter.module.scss.cjs.map +1 -0
- package/dist/components/admin-console-footer/AdminConsoleFooter.module.scss.js +13 -0
- package/dist/components/admin-console-footer/AdminConsoleFooter.module.scss.js.map +1 -0
- package/dist/components/admin-console-footer/index.cjs +2 -0
- package/dist/components/admin-console-footer/index.cjs.map +1 -0
- package/dist/components/admin-console-footer/index.d.ts +3 -0
- package/dist/components/admin-console-footer/index.d.ts.map +1 -0
- package/dist/components/admin-console-footer/index.js +5 -0
- package/dist/components/admin-console-footer/index.js.map +1 -0
- package/dist/components/admin-panel/AdminPanel.cjs +1 -1
- package/dist/components/admin-panel/AdminPanel.cjs.map +1 -1
- package/dist/components/admin-panel/AdminPanel.d.ts +41 -9
- package/dist/components/admin-panel/AdminPanel.d.ts.map +1 -1
- package/dist/components/admin-panel/AdminPanel.js +91 -81
- package/dist/components/admin-panel/AdminPanel.js.map +1 -1
- package/dist/components/admin-panel-footer/AdminPanelFooter.cjs +1 -1
- package/dist/components/admin-panel-footer/AdminPanelFooter.cjs.map +1 -1
- package/dist/components/admin-panel-footer/AdminPanelFooter.css +1 -1
- package/dist/components/admin-panel-footer/AdminPanelFooter.d.ts +18 -21
- package/dist/components/admin-panel-footer/AdminPanelFooter.d.ts.map +1 -1
- package/dist/components/admin-panel-footer/AdminPanelFooter.js +24 -61
- package/dist/components/admin-panel-footer/AdminPanelFooter.js.map +1 -1
- package/dist/components/admin-panel-footer/AdminPanelFooter.module.scss.cjs +1 -1
- package/dist/components/admin-panel-footer/AdminPanelFooter.module.scss.js +7 -9
- package/dist/components/admin-panel-footer/AdminPanelFooter.module.scss.js.map +1 -1
- package/dist/components/admin-panel-footer/index.d.ts +1 -1
- package/dist/components/admin-panel-footer/index.d.ts.map +1 -1
- package/dist/components/admin-panel-header/AdminPanelHeader.cjs.map +1 -1
- package/dist/components/admin-panel-header/AdminPanelHeader.d.ts +3 -2
- package/dist/components/admin-panel-header/AdminPanelHeader.d.ts.map +1 -1
- package/dist/components/admin-panel-header/AdminPanelHeader.js.map +1 -1
- package/dist/components/button/Button.cjs +1 -1
- package/dist/components/button/Button.cjs.map +1 -1
- package/dist/components/button/Button.css +1 -1
- package/dist/components/button/Button.d.ts +37 -6
- package/dist/components/button/Button.d.ts.map +1 -1
- package/dist/components/button/Button.js +106 -44
- package/dist/components/button/Button.js.map +1 -1
- package/dist/components/button/Button.module.scss.cjs +1 -1
- package/dist/components/button/Button.module.scss.js +16 -15
- package/dist/components/button/Button.module.scss.js.map +1 -1
- package/dist/components/button/index.d.ts +1 -1
- package/dist/components/button/index.d.ts.map +1 -1
- package/dist/components/channel-sidebar-item/ChannelSidebarItem.css +1 -1
- package/dist/components/channel-sidebar-item/ChannelSidebarItem.module.scss.cjs +1 -1
- package/dist/components/channel-sidebar-item/ChannelSidebarItem.module.scss.js +22 -22
- package/dist/components/checkbox/Checkbox.css +1 -1
- package/dist/components/checkbox/Checkbox.module.scss.cjs +1 -1
- package/dist/components/checkbox/Checkbox.module.scss.js +10 -10
- package/dist/components/chip/Chip.css +1 -1
- package/dist/components/chip/Chip.module.scss.cjs +1 -1
- package/dist/components/chip/Chip.module.scss.js +12 -12
- package/dist/components/combobox/Combobox.cjs +1 -1
- package/dist/components/combobox/Combobox.cjs.map +1 -1
- package/dist/components/combobox/Combobox.css +1 -1
- package/dist/components/combobox/Combobox.d.ts +14 -0
- package/dist/components/combobox/Combobox.d.ts.map +1 -1
- package/dist/components/combobox/Combobox.js +240 -224
- package/dist/components/combobox/Combobox.js.map +1 -1
- package/dist/components/combobox/Combobox.module.scss.cjs +1 -1
- package/dist/components/combobox/Combobox.module.scss.js +21 -21
- package/dist/components/icon-button/IconButton.cjs +1 -1
- package/dist/components/icon-button/IconButton.cjs.map +1 -1
- package/dist/components/icon-button/IconButton.css +1 -1
- package/dist/components/icon-button/IconButton.d.ts +48 -7
- package/dist/components/icon-button/IconButton.d.ts.map +1 -1
- package/dist/components/icon-button/IconButton.js +136 -62
- package/dist/components/icon-button/IconButton.js.map +1 -1
- package/dist/components/icon-button/IconButton.module.scss.cjs +1 -1
- package/dist/components/icon-button/IconButton.module.scss.js +16 -15
- package/dist/components/icon-button/IconButton.module.scss.js.map +1 -1
- package/dist/components/icon-button/index.d.ts +1 -1
- package/dist/components/icon-button/index.d.ts.map +1 -1
- 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 +20 -0
- 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 +16 -16
- package/dist/components/menu-item/index.d.ts +1 -1
- package/dist/components/menu-item/index.d.ts.map +1 -1
- package/dist/components/radio/Radio.css +1 -1
- package/dist/components/radio/Radio.module.scss.cjs +1 -1
- package/dist/components/radio/Radio.module.scss.js +12 -12
- package/dist/components/right-sidebar-header/RightSidebarHeader.cjs +1 -1
- package/dist/components/right-sidebar-header/RightSidebarHeader.cjs.map +1 -1
- package/dist/components/right-sidebar-header/RightSidebarHeader.d.ts +5 -1
- package/dist/components/right-sidebar-header/RightSidebarHeader.d.ts.map +1 -1
- package/dist/components/right-sidebar-header/RightSidebarHeader.js +60 -48
- package/dist/components/right-sidebar-header/RightSidebarHeader.js.map +1 -1
- package/dist/components/section-notice/SectionNotice.cjs +1 -1
- package/dist/components/section-notice/SectionNotice.cjs.map +1 -1
- package/dist/components/section-notice/SectionNotice.css +1 -1
- package/dist/components/section-notice/SectionNotice.js +17 -17
- package/dist/components/section-notice/SectionNotice.js.map +1 -1
- package/dist/components/section-notice/SectionNotice.module.scss.cjs +1 -1
- package/dist/components/section-notice/SectionNotice.module.scss.js +12 -12
- package/dist/components/select/Select.cjs +1 -1
- package/dist/components/select/Select.cjs.map +1 -1
- package/dist/components/select/Select.css +1 -1
- package/dist/components/select/Select.d.ts +16 -0
- package/dist/components/select/Select.d.ts.map +1 -1
- package/dist/components/select/Select.js +177 -157
- package/dist/components/select/Select.js.map +1 -1
- package/dist/components/select/Select.module.scss.cjs +1 -1
- package/dist/components/select/Select.module.scss.js +20 -20
- package/dist/components/switch/Switch.css +1 -1
- package/dist/components/switch/Switch.module.scss.cjs +1 -1
- package/dist/components/switch/Switch.module.scss.js +9 -9
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +168 -166
- package/dist/index.js.map +1 -1
- package/dist/utils/menuItemProps.cjs +2 -0
- package/dist/utils/menuItemProps.cjs.map +1 -0
- package/dist/utils/menuItemProps.d.ts +5 -0
- package/dist/utils/menuItemProps.d.ts.map +1 -0
- package/dist/utils/menuItemProps.js +12 -0
- package/dist/utils/menuItemProps.js.map +1 -0
- package/dist/utils/slot.cjs +2 -0
- package/dist/utils/slot.cjs.map +1 -0
- package/dist/utils/slot.d.ts +46 -0
- package/dist/utils/slot.d.ts.map +1 -0
- package/dist/utils/slot.js +88 -0
- package/dist/utils/slot.js.map +1 -0
- package/package.json +5 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ReactElement, ReactNode, Ref, RefCallback } from 'react';
|
|
2
|
+
type PossibleRef<T> = Ref<T> | undefined;
|
|
3
|
+
/** Composes multiple refs into a single callback ref. */
|
|
4
|
+
export declare function composeRefs<T>(...refs: Array<PossibleRef<T>>): RefCallback<T>;
|
|
5
|
+
/**
|
|
6
|
+
* Reads the ref from a React element across React 18 (`element.ref`) and
|
|
7
|
+
* React 19 (`element.props.ref`).
|
|
8
|
+
*/
|
|
9
|
+
export declare function getElementRef(element: ReactElement): Ref<unknown> | undefined;
|
|
10
|
+
type AnyProps = Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* Merges Slot (asChild host) props with the child's props.
|
|
13
|
+
* Child props win by default; event handlers are composed (child first;
|
|
14
|
+
* host skipped when the child called `preventDefault()`); `className` and
|
|
15
|
+
* `style` are merged.
|
|
16
|
+
*/
|
|
17
|
+
export declare function mergeSlotProps(slotProps: AnyProps, childProps: AnyProps): AnyProps;
|
|
18
|
+
export interface RenderAsChildOptions {
|
|
19
|
+
/** Single React element to clone (e.g. `<a>` or `<Link>`). */
|
|
20
|
+
child: ReactNode;
|
|
21
|
+
/** Props owned by the host component (className, handlers, aria-*, …). */
|
|
22
|
+
props: AnyProps;
|
|
23
|
+
/** Forwarded ref from the host. */
|
|
24
|
+
ref?: Ref<unknown>;
|
|
25
|
+
/** Anatomy nodes that replace the child's children. */
|
|
26
|
+
content: ReactNode;
|
|
27
|
+
/** When true, apply disabled-link semantics. */
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/** BEM disabled class (e.g. `button--disabled`). */
|
|
30
|
+
disabledClassName?: string;
|
|
31
|
+
/**
|
|
32
|
+
* When true, warn in development if the child already has children (they
|
|
33
|
+
* will be replaced). Use for hosts that own their full anatomy
|
|
34
|
+
* (IconButton, ActionButton). Leave false when the host wraps the child's
|
|
35
|
+
* text (Button label).
|
|
36
|
+
*/
|
|
37
|
+
warnOnChildContent?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Clones a single child element with merged host props, composed refs, and
|
|
41
|
+
* replacement content. Never forwards `type`. When `disabled`, sets
|
|
42
|
+
* `aria-disabled`, the disabled class, and blocks click / auxclick navigation.
|
|
43
|
+
*/
|
|
44
|
+
export declare function renderAsChild({ child, props, ref, content, disabled, disabledClassName, warnOnChildContent, }: RenderAsChildOptions): ReactElement | null;
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=slot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slot.d.ts","sourceRoot":"","sources":["../../src/utils/slot.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,GAAG,EACR,KAAK,WAAW,EACjB,MAAM,OAAO,CAAC;AAGf,KAAK,WAAW,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;AAWzC,yDAAyD;AACzD,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAM7E;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,SAAS,CAQ7E;AAED,KAAK,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAQxC;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,QAAQ,EACnB,UAAU,EAAE,QAAQ,GACnB,QAAQ,CAuCV;AAuBD,MAAM,WAAW,oBAAoB;IACnC,8DAA8D;IAC9D,KAAK,EAAE,SAAS,CAAC;IACjB,0EAA0E;IAC1E,KAAK,EAAE,QAAQ,CAAC;IAChB,mCAAmC;IACnC,GAAG,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACnB,uDAAuD;IACvD,OAAO,EAAE,SAAS,CAAC;IACnB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oDAAoD;IACpD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,KAAK,EACL,GAAG,EACH,OAAO,EACP,QAAgB,EAChB,iBAAiB,EACjB,kBAA0B,GAC3B,EAAE,oBAAoB,GAAG,YAAY,GAAG,IAAI,CA6D5C"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Children as h, isValidElement as g, cloneElement as C } from "react";
|
|
2
|
+
import { mergeClassNames as m } from "./props.js";
|
|
3
|
+
function N(e, t) {
|
|
4
|
+
typeof e == "function" ? e(t) : e != null && (e.current = t);
|
|
5
|
+
}
|
|
6
|
+
function R(...e) {
|
|
7
|
+
return (t) => {
|
|
8
|
+
for (const n of e)
|
|
9
|
+
N(n, t);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function v(e) {
|
|
13
|
+
var n;
|
|
14
|
+
const t = (n = e.props) == null ? void 0 : n.ref;
|
|
15
|
+
return t !== void 0 ? t : e.ref;
|
|
16
|
+
}
|
|
17
|
+
function E(e) {
|
|
18
|
+
var t;
|
|
19
|
+
return e.length > 2 && e.startsWith("on") && e[2] === ((t = e[2]) == null ? void 0 : t.toUpperCase());
|
|
20
|
+
}
|
|
21
|
+
function b(e, t) {
|
|
22
|
+
const n = { ...t };
|
|
23
|
+
for (const r of Object.keys(e)) {
|
|
24
|
+
const o = e[r], l = t[r];
|
|
25
|
+
E(r) ? typeof o == "function" && typeof l == "function" ? n[r] = (...c) => {
|
|
26
|
+
const s = c[0];
|
|
27
|
+
l(...c), s != null && s.defaultPrevented || o(...c);
|
|
28
|
+
} : typeof o == "function" && (n[r] = o) : r === "style" ? n.style = {
|
|
29
|
+
...typeof o == "object" && o != null ? o : null,
|
|
30
|
+
...typeof l == "object" && l != null ? l : null
|
|
31
|
+
} : r === "className" ? n.className = m(
|
|
32
|
+
typeof o == "string" ? o : void 0,
|
|
33
|
+
typeof l == "string" ? l : void 0
|
|
34
|
+
) : r in t || (n[r] = o);
|
|
35
|
+
}
|
|
36
|
+
return n;
|
|
37
|
+
}
|
|
38
|
+
function y(e) {
|
|
39
|
+
return e == null || e === !1 || e === !0 ? !1 : typeof e == "string" ? e.length > 0 : Array.isArray(e) ? e.some(y) : !0;
|
|
40
|
+
}
|
|
41
|
+
function p(e) {
|
|
42
|
+
e.preventDefault(), e.stopPropagation();
|
|
43
|
+
}
|
|
44
|
+
function V({
|
|
45
|
+
child: e,
|
|
46
|
+
props: t,
|
|
47
|
+
ref: n,
|
|
48
|
+
content: r,
|
|
49
|
+
disabled: o = !1,
|
|
50
|
+
disabledClassName: l,
|
|
51
|
+
warnOnChildContent: c = !1
|
|
52
|
+
}) {
|
|
53
|
+
const s = process.env.NODE_ENV !== "production";
|
|
54
|
+
let i = null;
|
|
55
|
+
try {
|
|
56
|
+
i = h.only(e);
|
|
57
|
+
} catch {
|
|
58
|
+
i = null;
|
|
59
|
+
}
|
|
60
|
+
if (!g(i))
|
|
61
|
+
return s && console.warn(
|
|
62
|
+
"asChild expects a single React element child (e.g. <a> or <Link>)."
|
|
63
|
+
), null;
|
|
64
|
+
const u = i.props;
|
|
65
|
+
s && c && y(u.children) && console.warn(
|
|
66
|
+
`asChild replaces the child element's children with component anatomy. Pass an empty element (e.g. <a href="…" />).`
|
|
67
|
+
);
|
|
68
|
+
const f = { ...t };
|
|
69
|
+
delete f.type, o && (f["aria-disabled"] = !0, l && (f.className = m(
|
|
70
|
+
typeof f.className == "string" ? f.className : void 0,
|
|
71
|
+
l
|
|
72
|
+
)));
|
|
73
|
+
const a = b(f, u);
|
|
74
|
+
o && (a.onClick = p, a.onAuxClick = p);
|
|
75
|
+
const d = v(i);
|
|
76
|
+
return C(i, {
|
|
77
|
+
...a,
|
|
78
|
+
ref: R(n, d),
|
|
79
|
+
children: r
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
export {
|
|
83
|
+
R as composeRefs,
|
|
84
|
+
v as getElementRef,
|
|
85
|
+
b as mergeSlotProps,
|
|
86
|
+
V as renderAsChild
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=slot.js.map
|
|
@@ -0,0 +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, ActionButton). 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,GAA6C;AAC7E,SAAO,CAACC,MAAS;AACf,eAAWJ,KAAOG;AAChB,MAAAJ,EAAOC,GAAKI,CAAI;AAAA,EAEpB;AACF;AAMO,SAASC,EAAcC,GAAiD;;AAE7E,QAAMC,KAAYC,IAAAF,EAAQ,UAAR,gBAAAE,EACd;AACJ,SAAID,MAAa,SACRA,IAEDD,EAAkD;AAC5D;AAIA,SAASG,EAAaC,GAAsB;;AAC1C,SACEA,EAAI,SAAS,KAAKA,EAAI,WAAW,IAAI,KAAKA,EAAI,CAAC,QAAMF,IAAAE,EAAI,CAAC,MAAL,gBAAAF,EAAQ;AAEjE;AAQO,SAASG,EACdC,GACAC,GACU;AACV,QAAMC,IAAqB,EAAE,GAAGD,EAAA;AAEhC,aAAWE,KAAY,OAAO,KAAKH,CAAS,GAAG;AAC7C,UAAMI,IAAYJ,EAAUG,CAAQ,GAC9BE,IAAaJ,EAAWE,CAAQ;AAEtC,IAAIN,EAAaM,CAAQ,IACnB,OAAOC,KAAc,cAAc,OAAOC,KAAe,aAC3DH,EAASC,CAAQ,IAAI,IAAIG,MAAoB;AAC3C,YAAMC,IAAQD,EAAK,CAAC;AACpB,MAAAD,EAAW,GAAGC,CAAI,GACbC,KAAA,QAAAA,EAAO,oBACVH,EAAU,GAAGE,CAAI;AAAA,IAErB,IACS,OAAOF,KAAc,eAC9BF,EAASC,CAAQ,IAAIC,KAEdD,MAAa,UACtBD,EAAS,QAAQ;AAAA,MACf,GAAI,OAAOE,KAAc,YAAYA,KAAa,OAC7CA,IACD;AAAA,MACJ,GAAI,OAAOC,KAAe,YAAYA,KAAc,OAC/CA,IACD;AAAA,IAAA,IAEGF,MAAa,cACtBD,EAAS,YAAYM;AAAA,MACnB,OAAOJ,KAAc,WAAWA,IAAY;AAAA,MAC5C,OAAOC,KAAe,WAAWA,IAAa;AAAA,IAAA,IAErCF,KAAYF,MACvBC,EAASC,CAAQ,IAAIC;AAAA,EAEzB;AAEA,SAAOF;AACT;AAEA,SAASO,EAAsBC,GAA8B;AAC3D,SAAIA,KAAY,QAAQA,MAAa,MAASA,MAAa,KAClD,KAEL,OAAOA,KAAa,WACfA,EAAS,SAAS,IAEvB,MAAM,QAAQA,CAAQ,IACjBA,EAAS,KAAKD,CAAqB,IAErC;AACT;AAEA,SAASE,EAAgBJ,GAGtB;AACD,EAAAA,EAAM,eAAA,GACNA,EAAM,gBAAA;AACR;AA6BO,SAASK,EAAc;AAAA,EAC5B,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,KAAA1B;AAAA,EACA,SAAA2B;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,mBAAAC;AAAA,EACA,oBAAAC,IAAqB;AACvB,GAA8C;AAC5C,QAAMC,IAAO,QAAQ,IAAI,aAAa;AAEtC,MAAIC,IAAuB;AAC3B,MAAI;AACF,IAAAA,IAAYC,EAAS,KAAKR,CAAK;AAAA,EACjC,QAAQ;AACN,IAAAO,IAAY;AAAA,EACd;AAEA,MAAI,CAACE,EAAeF,CAAS;AAC3B,WAAID,KACF,QAAQ;AAAA,MACN;AAAA,IAAA,GAGG;AAGT,QAAMlB,IAAamB,EAAU;AAE7B,EACED,KACAD,KACAT,EAAsBR,EAAW,QAAQ,KAEzC,QAAQ;AAAA,IACN;AAAA,EAAA;AAKJ,QAAMD,IAAsB,EAAE,GAAGc,EAAA;AACjC,SAAOd,EAAU,MAEbgB,MACFhB,EAAU,eAAe,IAAI,IACzBiB,MACFjB,EAAU,YAAYQ;AAAA,IACpB,OAAOR,EAAU,aAAc,WAC3BA,EAAU,YACV;AAAA,IACJiB;AAAA,EAAA;AAKN,QAAMM,IAASxB,EAAeC,GAAWC,CAAU;AAEnD,EAAIe,MACFO,EAAO,UAAUZ,GACjBY,EAAO,aAAaZ;AAGtB,QAAMa,IAAW/B,EAAc2B,CAAS;AAExC,SAAOK,EAAaL,GAAW;AAAA,IAC7B,GAAGG;AAAA,IACH,KAAKjC,EAAYF,GAAKoC,CAAQ;AAAA,IAC9B,UAAUT;AAAA,EAAA,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.16",
|
|
4
4
|
"description": "Compass design system UI components for Mattermost products",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
"@vitejs/plugin-react": "^4.3.4",
|
|
82
82
|
"react": "^19.0.0",
|
|
83
83
|
"react-dom": "^19.0.0",
|
|
84
|
+
"react-router-dom": "^6.28.0",
|
|
84
85
|
"sass": "^1.83.4",
|
|
85
86
|
"simplebar-react": "^3.3.2",
|
|
86
87
|
"storybook": "^8.6.14",
|
|
@@ -109,6 +110,9 @@
|
|
|
109
110
|
"components/action-button": [
|
|
110
111
|
"./dist/components/action-button/index.d.ts"
|
|
111
112
|
],
|
|
113
|
+
"components/admin-console-footer": [
|
|
114
|
+
"./dist/components/admin-console-footer/index.d.ts"
|
|
115
|
+
],
|
|
112
116
|
"components/admin-console-header": [
|
|
113
117
|
"./dist/components/admin-console-header/index.d.ts"
|
|
114
118
|
],
|