@mich8060/unified-design-system 0.2.34 → 0.2.36
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/ai/discovery.json +7 -1
- package/dist/ai/examples/admin-users-table-uds.jsonl +5 -0
- package/dist/ai/examples/calendar-events-layout-uds.jsonl +5 -0
- package/dist/ai/examples/dashboard-statistics-uds.jsonl +5 -0
- package/dist/ai/examples/dataset.index.json +42 -0
- package/dist/ai/examples/kanban-board-uds.jsonl +5 -0
- package/dist/ai/examples/settings-preferences-uds.jsonl +5 -0
- package/dist/ai/examples/signin-flow-uds.jsonl +9 -0
- package/dist/ai/examples/training.examples.cjs +1 -1
- package/dist/ai/examples/training.examples.js +1 -1
- package/dist/ai/examples/uds-governed-training.jsonl +5 -0
- package/dist/ai/figma-make.contract.json +11 -1
- package/dist/ai/figma-make.md +53 -7
- package/dist/ai/layout/architecture.json +39 -0
- package/dist/ai/manifest/composition.manifest.cjs +1 -1
- package/dist/ai/manifest/composition.manifest.js +1 -1
- package/dist/ai/manifest/intent-mappings.manifest.cjs +1 -1
- package/dist/ai/manifest/intent-mappings.manifest.js +1 -1
- package/dist/ai/manifest/patterns.manifest.cjs +1 -1
- package/dist/ai/manifest/patterns.manifest.js +1 -1
- package/dist/ai/manifest.json +538 -66
- package/dist/ai/navigation/brand-menus.json +7 -0
- package/dist/ai/policies/policy.engine.cjs +1 -1
- package/dist/ai/policies/policy.engine.js +1 -1
- package/dist/ai/policies/rules/pattern-structure.rules.cjs +1 -0
- package/dist/ai/policies/rules/pattern-structure.rules.js +1 -0
- package/dist/ai/policies/rules/props.rules.cjs +1 -1
- package/dist/ai/policies/rules/props.rules.js +1 -1
- package/dist/ai/prompts/figma-make.prompt.md +7 -0
- package/dist/ai/prompts/system.prompt.md +4 -1
- package/dist/ai/schemas/ai-output.schema.json +1 -0
- package/dist/ai/templates/layouts.json +5 -0
- package/dist/ai/tokens/catalog.json +72 -0
- package/dist/ai/validation/validateAIOutput.cjs +1 -1
- package/dist/ai/validation/validateAIOutput.js +1 -1
- package/dist/app-shell/AppShell.d.ts +4 -0
- package/dist/components/ActionMenu/ActionMenu.cjs +1 -1
- package/dist/components/ActionMenu/ActionMenu.js +1 -1
- package/dist/components/Dropdown/Dropdown.cjs +1 -1
- package/dist/components/Dropdown/Dropdown.js +1 -1
- package/dist/components/Layout/Layout.cjs +1 -0
- package/dist/components/Layout/Layout.js +1 -0
- package/dist/components/Link/Link.cjs +1 -0
- package/dist/components/Link/Link.js +1 -0
- package/dist/components/Menu/Menu.cjs +1 -1
- package/dist/components/Menu/Menu.js +1 -1
- package/dist/components/ProvidersCard/ProvidersCard.cjs +1 -1
- package/dist/components/ProvidersCard/ProvidersCard.js +1 -1
- package/dist/components/SectionHeader/SectionHeader.cjs +1 -1
- package/dist/components/SectionHeader/SectionHeader.js +1 -1
- package/dist/design-system/ai/examples/training.examples.d.ts +1 -0
- package/dist/design-system/ai/manifest/intent-mappings.manifest.d.ts +1 -1
- package/dist/design-system/ai/policies/policy.engine.d.ts +3 -1
- package/dist/design-system/ai/policies/policy.types.d.ts +1 -0
- package/dist/design-system/ai/policies/rules/pattern-structure.rules.d.ts +2 -0
- package/dist/design-system/components/ActionMenu/ActionMenu.d.ts +1 -1
- package/dist/design-system/components/ActionMenu/ActionMenu.types.d.ts +3 -0
- package/dist/design-system/components/Dropdown/Dropdown.d.ts +1 -2
- package/dist/design-system/components/Dropdown/Dropdown.types.d.ts +0 -1
- package/dist/design-system/components/Flex/index.d.ts +2 -2
- package/dist/design-system/components/Layout/Layout.d.ts +16 -0
- package/dist/design-system/components/{Flex/Flex.types.d.ts → Layout/Layout.types.d.ts} +2 -6
- package/dist/design-system/components/Layout/index.d.ts +3 -0
- package/dist/design-system/components/Link/Link.d.ts +4 -0
- package/dist/design-system/components/Link/Link.types.d.ts +8 -0
- package/dist/design-system/components/Link/index.d.ts +3 -0
- package/dist/design-system/constants.d.ts +1 -1
- package/dist/design-system/figma-make/index.d.ts +1 -1
- package/dist/design-system/generated/component-api.d.ts +111 -16
- package/dist/design-system/index.d.ts +2 -1
- package/dist/design-system/version.d.ts +1 -1
- package/dist/figma-make/index.cjs +1 -1
- package/dist/figma-make/index.js +1 -1
- package/dist/generated/component-api.cjs +1 -1
- package/dist/generated/component-api.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/src/app-shell/AppShell.cjs +1 -1
- package/dist/src/app-shell/AppShell.js +1 -1
- package/dist/style.css +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.js +1 -1
- package/package.json +15 -2
- package/dist/components/Flex/Flex.cjs +0 -1
- package/dist/components/Flex/Flex.js +0 -1
- package/dist/design-system/components/Flex/Flex.d.ts +0 -10
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
"contractName": "uds.ai.brand-menus",
|
|
3
3
|
"schemaVersion": "1.0.0",
|
|
4
4
|
"brands": {
|
|
5
|
+
"default": [
|
|
6
|
+
{ "label": "Dashboard", "icon": "Layout" },
|
|
7
|
+
{ "label": "Requests", "icon": "Briefcase" },
|
|
8
|
+
{ "label": "Providers", "icon": "Users" },
|
|
9
|
+
{ "label": "Calendar", "icon": "CalendarBlank" },
|
|
10
|
+
{ "label": "Reporting", "icon": "ChartBar" }
|
|
11
|
+
],
|
|
5
12
|
"comphealth": [
|
|
6
13
|
{ "label": "Dashboard", "icon": "Layout" },
|
|
7
14
|
{ "label": "Schedule", "icon": "CalendarBlank" },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../manifest/governance.manifest.cjs"),t=require("./rules/composition.rules.cjs"),u=require("./rules/action.rules.cjs"),o=require("./rules/spacing.rules.cjs"),l=require("./rules/accessibility.rules.cjs"),s=require("./rules/props.rules.cjs"),a=require("./rules/token-variable.rules.cjs"),f=require("./rules/tailwind.rules.cjs"),_=require("./rules/pattern-structure.rules.cjs"),q=[t.enforceCompositionRule,u.enforcePrimaryActionLimitRule,o.enforceSpacingTokenRule,a.enforceTokenVariableRule,f.enforceTailwindDisallowRule,l.enforceAccessibilityRule,s.enforceCanonicalPropsRule,_.enforcePatternStructureRule];function R(r,n=c.UDSGovernance,e){return q.flatMap(i=>i({tree:r,governanceConfig:n,patternId:e==null?void 0:e.patternId}))}exports.runPolicyEngine=R;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UDSGovernance as i}from"../manifest/governance.manifest.js";import{enforceCompositionRule as
|
|
1
|
+
import{UDSGovernance as i}from"../manifest/governance.manifest.js";import{enforceCompositionRule as t}from"./rules/composition.rules.js";import{enforcePrimaryActionLimitRule as m}from"./rules/action.rules.js";import{enforceSpacingTokenRule as f}from"./rules/spacing.rules.js";import{enforceAccessibilityRule as c}from"./rules/accessibility.rules.js";import{enforceCanonicalPropsRule as l}from"./rules/props.rules.js";import{enforceTokenVariableRule as a}from"./rules/token-variable.rules.js";import{enforceTailwindDisallowRule as u}from"./rules/tailwind.rules.js";import{enforcePatternStructureRule as p}from"./rules/pattern-structure.rules.js";const R=[t,m,f,a,u,c,l,p];function g(e,o=i,r){return R.flatMap(n=>n({tree:e,governanceConfig:o,patternId:r==null?void 0:r.patternId}))}export{g as runPolicyEngine};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../manifest/patterns.manifest.cjs");function u(n){const t=[n.type];for(const r of n.children??[])t.push(...u(r));return t}const d=({tree:n,patternId:t})=>{if(!t)return[];const r=f.PatternRegistry[t];if(!r)return[{severity:"error",code:"RULE_UNKNOWN_PATTERN_ID",message:`Pattern "${t}" is not defined in PatternRegistry.`,path:"audit.patternId"}];const o=[],s=u(n),a=new Set(s);for(const e of r.requiredComponents)a.has(e)||o.push({severity:"error",code:"RULE_PATTERN_REQUIRED_COMPONENT_MISSING",message:`Pattern "${t}" requires component "${e}".`,path:"root",component:e});const p=r.structure.map(e=>e.type);let c=0;for(const e of p){const i=s.indexOf(e,c);if(i!==-1){c=i+1;continue}o.push({severity:"error",code:"RULE_PATTERN_STRUCTURE_MISMATCH",message:`Pattern "${t}" expects "${e}" in canonical structure order.`,path:"root",component:e});break}return o};exports.enforcePatternStructureRule=d;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{PatternRegistry as f}from"../../manifest/patterns.manifest.js";function u(n){const t=[n.type];for(const r of n.children??[])t.push(...u(r));return t}const d=({tree:n,patternId:t})=>{if(!t)return[];const r=f[t];if(!r)return[{severity:"error",code:"RULE_UNKNOWN_PATTERN_ID",message:`Pattern "${t}" is not defined in PatternRegistry.`,path:"audit.patternId"}];const o=[],s=u(n),p=new Set(s);for(const e of r.requiredComponents)p.has(e)||o.push({severity:"error",code:"RULE_PATTERN_REQUIRED_COMPONENT_MISSING",message:`Pattern "${t}" requires component "${e}".`,path:"root",component:e});const a=r.structure.map(e=>e.type);let c=0;for(const e of a){const i=s.indexOf(e,c);if(i!==-1){c=i+1;continue}o.push({severity:"error",code:"RULE_PATTERN_STRUCTURE_MISMATCH",message:`Pattern "${t}" expects "${e}" in canonical structure order.`,path:"root",component:e});break}return o};export{d as enforcePatternStructureRule};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../../manifest/prop-aliases.manifest.cjs"),g=a=>({...l.PropAliasRules.global??{},...l.PropAliasRules.byComponent[a]??{}}),y={Menu:{items:{replacement:"navItems",reason:"Menu uses navItems contract, not Ant-style items."},selectedKeys:{reason:"Menu selection is route-driven via nav item paths and app state."},mode:{replacement:"activeMode",reason:"Menu mode is governed by activeMode light/dark values."}},Flex:{vertical:{replacement:"direction",reason:"Flex direction is governed by row/column direction prop."},justify:{replacement:"justifyContent",reason:"Flex alignment uses justifyContent canonical prop."},align:{replacement:"alignItems",reason:"Flex alignment uses alignItems canonical prop."}},Text:{type:{replacement:"variant",reason:"Text semantics use UDS typography variant tokens."},strong:{replacement:"weight",reason:"Text weight should be controlled by weight prop."}},Button:{type:{replacement:"appearance",reason:"Button style is governed by appearance variants."}},Badge:{status:{replacement:"variant",reason:"Badge uses variant semantic color names, not status."},color:{replacement:"variant",reason:"Badge color intent is governed through variant values."}},Statistics:{title:{replacement:"label",reason:"Statistics title maps to label in UDS contract."},suffix:{replacement:"helperText",reason:"Use helperText/statusLabel/changeText fields for supporting copy."},prefix:{replacement:"helperText",reason:"Use helperText/statusLabel/changeText fields for supporting copy."},valueStyle:{reason:"Styling is token-governed; avoid inline styling props."}}},d=({tree:a})=>{const o=[],r=(e,s)=>{const p=g(e.type),c=y[e.type]??{},u=e.props??{};for(const t of Object.keys(u)){const n=c[t];if(n){const m=n.replacement?` Use "${n.replacement}" instead.`:"";o.push({severity:"error",code:"RULE_FORBIDDEN_PROP",message:`Prop "${t}" is disallowed on ${e.type}. ${n.reason}${m}`,path:`${s}.props.${t}`,component:e.type})}const i=p[t];i&&o.push({severity:"error",code:"RULE_AMBIGUOUS_PROP_ALIAS",message:`Prop "${t}" is ambiguous for ${e.type}. Use canonical prop "${i}".`,path:`${s}.props.${t}`,component:e.type})}(e.children??[]).forEach((t,n)=>r(t,`${s}.children[${n}]`))};return r(a,"root"),o};exports.enforceCanonicalPropsRule=d;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../../manifest/prop-aliases.manifest.cjs"),g=a=>({...l.PropAliasRules.global??{},...l.PropAliasRules.byComponent[a]??{}}),y={Menu:{items:{replacement:"navItems",reason:"Menu uses navItems contract, not Ant-style items."},selectedKeys:{reason:"Menu selection is route-driven via nav item paths and app state."},mode:{replacement:"activeMode",reason:"Menu mode is governed by activeMode light/dark values."}},Flex:{vertical:{replacement:"direction",reason:"Flex direction is governed by row/column direction prop."},justify:{replacement:"justifyContent",reason:"Flex alignment uses justifyContent canonical prop."},align:{replacement:"alignItems",reason:"Flex alignment uses alignItems canonical prop."}},Layout:{vertical:{replacement:"direction",reason:"Layout direction is governed by row/column direction prop."},justify:{replacement:"justifyContent",reason:"Layout alignment uses justifyContent canonical prop."},align:{replacement:"alignItems",reason:"Layout alignment uses alignItems canonical prop."}},Text:{type:{replacement:"variant",reason:"Text semantics use UDS typography variant tokens."},strong:{replacement:"weight",reason:"Text weight should be controlled by weight prop."}},Button:{type:{replacement:"appearance",reason:"Button style is governed by appearance variants."}},Badge:{status:{replacement:"variant",reason:"Badge uses variant semantic color names, not status."},color:{replacement:"variant",reason:"Badge color intent is governed through variant values."}},Statistics:{title:{replacement:"label",reason:"Statistics title maps to label in UDS contract."},suffix:{replacement:"helperText",reason:"Use helperText/statusLabel/changeText fields for supporting copy."},prefix:{replacement:"helperText",reason:"Use helperText/statusLabel/changeText fields for supporting copy."},valueStyle:{reason:"Styling is token-governed; avoid inline styling props."}}},d=({tree:a})=>{const o=[],r=(e,s)=>{const p=g(e.type),c=y[e.type]??{},u=e.props??{};for(const t of Object.keys(u)){const n=c[t];if(n){const m=n.replacement?` Use "${n.replacement}" instead.`:"";o.push({severity:"error",code:"RULE_FORBIDDEN_PROP",message:`Prop "${t}" is disallowed on ${e.type}. ${n.reason}${m}`,path:`${s}.props.${t}`,component:e.type})}const i=p[t];i&&o.push({severity:"error",code:"RULE_AMBIGUOUS_PROP_ALIAS",message:`Prop "${t}" is ambiguous for ${e.type}. Use canonical prop "${i}".`,path:`${s}.props.${t}`,component:e.type})}(e.children??[]).forEach((t,n)=>r(t,`${s}.children[${n}]`))};return r(a,"root"),o};exports.enforceCanonicalPropsRule=d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PropAliasRules as p}from"../../manifest/prop-aliases.manifest.js";const g=a=>({...p.global??{},...p.byComponent[a]??{}}),y={Menu:{items:{replacement:"navItems",reason:"Menu uses navItems contract, not Ant-style items."},selectedKeys:{reason:"Menu selection is route-driven via nav item paths and app state."},mode:{replacement:"activeMode",reason:"Menu mode is governed by activeMode light/dark values."}},Flex:{vertical:{replacement:"direction",reason:"Flex direction is governed by row/column direction prop."},justify:{replacement:"justifyContent",reason:"Flex alignment uses justifyContent canonical prop."},align:{replacement:"alignItems",reason:"Flex alignment uses alignItems canonical prop."}},Text:{type:{replacement:"variant",reason:"Text semantics use UDS typography variant tokens."},strong:{replacement:"weight",reason:"Text weight should be controlled by weight prop."}},Button:{type:{replacement:"appearance",reason:"Button style is governed by appearance variants."}},Badge:{status:{replacement:"variant",reason:"Badge uses variant semantic color names, not status."},color:{replacement:"variant",reason:"Badge color intent is governed through variant values."}},Statistics:{title:{replacement:"label",reason:"Statistics title maps to label in UDS contract."},suffix:{replacement:"helperText",reason:"Use helperText/statusLabel/changeText fields for supporting copy."},prefix:{replacement:"helperText",reason:"Use helperText/statusLabel/changeText fields for supporting copy."},valueStyle:{reason:"Styling is token-governed; avoid inline styling props."}}},v=({tree:a})=>{const o=[],r=(e,s)=>{const l=g(e.type),c=y[e.type]??{},m=e.props??{};for(const t of Object.keys(m)){const n=c[t];if(n){const u=n.replacement?` Use "${n.replacement}" instead.`:"";o.push({severity:"error",code:"RULE_FORBIDDEN_PROP",message:`Prop "${t}" is disallowed on ${e.type}. ${n.reason}${u}`,path:`${s}.props.${t}`,component:e.type})}const i=l[t];i&&o.push({severity:"error",code:"RULE_AMBIGUOUS_PROP_ALIAS",message:`Prop "${t}" is ambiguous for ${e.type}. Use canonical prop "${i}".`,path:`${s}.props.${t}`,component:e.type})}(e.children??[]).forEach((t,n)=>r(t,`${s}.children[${n}]`))};return r(a,"root"),o};export{v as enforceCanonicalPropsRule};
|
|
1
|
+
import{PropAliasRules as p}from"../../manifest/prop-aliases.manifest.js";const g=a=>({...p.global??{},...p.byComponent[a]??{}}),y={Menu:{items:{replacement:"navItems",reason:"Menu uses navItems contract, not Ant-style items."},selectedKeys:{reason:"Menu selection is route-driven via nav item paths and app state."},mode:{replacement:"activeMode",reason:"Menu mode is governed by activeMode light/dark values."}},Flex:{vertical:{replacement:"direction",reason:"Flex direction is governed by row/column direction prop."},justify:{replacement:"justifyContent",reason:"Flex alignment uses justifyContent canonical prop."},align:{replacement:"alignItems",reason:"Flex alignment uses alignItems canonical prop."}},Layout:{vertical:{replacement:"direction",reason:"Layout direction is governed by row/column direction prop."},justify:{replacement:"justifyContent",reason:"Layout alignment uses justifyContent canonical prop."},align:{replacement:"alignItems",reason:"Layout alignment uses alignItems canonical prop."}},Text:{type:{replacement:"variant",reason:"Text semantics use UDS typography variant tokens."},strong:{replacement:"weight",reason:"Text weight should be controlled by weight prop."}},Button:{type:{replacement:"appearance",reason:"Button style is governed by appearance variants."}},Badge:{status:{replacement:"variant",reason:"Badge uses variant semantic color names, not status."},color:{replacement:"variant",reason:"Badge color intent is governed through variant values."}},Statistics:{title:{replacement:"label",reason:"Statistics title maps to label in UDS contract."},suffix:{replacement:"helperText",reason:"Use helperText/statusLabel/changeText fields for supporting copy."},prefix:{replacement:"helperText",reason:"Use helperText/statusLabel/changeText fields for supporting copy."},valueStyle:{reason:"Styling is token-governed; avoid inline styling props."}}},v=({tree:a})=>{const o=[],r=(e,s)=>{const l=g(e.type),c=y[e.type]??{},m=e.props??{};for(const t of Object.keys(m)){const n=c[t];if(n){const u=n.replacement?` Use "${n.replacement}" instead.`:"";o.push({severity:"error",code:"RULE_FORBIDDEN_PROP",message:`Prop "${t}" is disallowed on ${e.type}. ${n.reason}${u}`,path:`${s}.props.${t}`,component:e.type})}const i=l[t];i&&o.push({severity:"error",code:"RULE_AMBIGUOUS_PROP_ALIAS",message:`Prop "${t}" is ambiguous for ${e.type}. Use canonical prop "${i}".`,path:`${s}.props.${t}`,component:e.type})}(e.children??[]).forEach((t,n)=>r(t,`${s}.children[${n}]`))};return r(a,"root"),o};export{v as enforceCanonicalPropsRule};
|
|
@@ -13,10 +13,16 @@ Hard requirements:
|
|
|
13
13
|
- Use canonical prop names only (reject Ant-style aliases like `Menu.items`, `Flex.vertical`, `Button.type`).
|
|
14
14
|
- Default `Container` to `appearance=\"transparent\"` and `padding=\"large\"` (24px) unless a different requirement is explicit.
|
|
15
15
|
- Default `Menu.showSearch` to `false` unless search is explicitly required.
|
|
16
|
+
- In `Menu` account actions, default `accountMenuItems` to:
|
|
17
|
+
1. `Contact` with icon `Phone`
|
|
18
|
+
2. `Feedback` with icon `ChatCenteredText`
|
|
19
|
+
3. `Sign out` with icon `SignOut` (`destructive: true`)
|
|
16
20
|
- Return deterministic JSON only.
|
|
17
21
|
|
|
18
22
|
Preferred flow:
|
|
19
23
|
1. Start from `@mich8060/unified-design-system/ai/templates`.
|
|
24
|
+
1.0 Load `@mich8060/unified-design-system/ai/token-catalog` and `@mich8060/unified-design-system/ai/layout-architecture`.
|
|
25
|
+
1.1 Copy the selected template `patternId` into `audit.patternId` in the output.
|
|
20
26
|
2. Resolve remaining intent decisions using `@mich8060/unified-design-system/ai/manifest.json` -> `intentComponentMappings`.
|
|
21
27
|
3. Load brand menu definitions from `@mich8060/unified-design-system/ai/navigation`.
|
|
22
28
|
4. Fill template slots.
|
|
@@ -58,6 +64,7 @@ Starter scaffold:
|
|
|
58
64
|
},
|
|
59
65
|
"audit": {
|
|
60
66
|
"source": "figma-make",
|
|
67
|
+
"patternId": "AuthForm",
|
|
61
68
|
"notes": "UDS-only generation"
|
|
62
69
|
}
|
|
63
70
|
}
|
|
@@ -6,6 +6,8 @@ Contract discovery order:
|
|
|
6
6
|
- `@mich8060/unified-design-system/ai/schema`
|
|
7
7
|
- `@mich8060/unified-design-system/ai/icons`
|
|
8
8
|
- `@mich8060/unified-design-system/ai/icons.json`
|
|
9
|
+
- `@mich8060/unified-design-system/ai/token-catalog`
|
|
10
|
+
- `@mich8060/unified-design-system/ai/layout-architecture`
|
|
9
11
|
- `@mich8060/unified-design-system/ai/navigation`
|
|
10
12
|
- `@mich8060/unified-design-system/ai/templates`
|
|
11
13
|
|
|
@@ -15,6 +17,7 @@ Hard constraints:
|
|
|
15
17
|
- Use spacing tokens from `ai/manifest/layout.manifest.ts`.
|
|
16
18
|
- Use semantic token intents from `ai/manifest/tokens.intent.manifest.ts`.
|
|
17
19
|
- Resolve UI intents using `ai/manifest/intent-mappings.manifest.ts` before freeform composition.
|
|
20
|
+
- Select a template from `@mich8060/unified-design-system/ai/templates` first and carry its `patternId` into `audit.patternId`.
|
|
18
21
|
- Respect governance limits from `ai/manifest/governance.manifest.ts`.
|
|
19
22
|
- Load icon options from `@mich8060/unified-design-system/ai/icons` (or `@mich8060/unified-design-system/ai/icons.json`) before choosing icons.
|
|
20
23
|
- Use icon names from the icon catalog (`ai/icons/catalog.json`) when adding icons.
|
|
@@ -32,5 +35,5 @@ Output contract:
|
|
|
32
35
|
"governanceVersion": "...",
|
|
33
36
|
"policyVersion": "...",
|
|
34
37
|
"tree": {...},
|
|
35
|
-
"audit": {...}
|
|
38
|
+
"audit": { "patternId": "..." }
|
|
36
39
|
}
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"udsVersion": { "type": "string" },
|
|
48
48
|
"manifestVersion": { "type": "string" },
|
|
49
49
|
"policyVersion": { "type": "string" },
|
|
50
|
+
"patternId": { "type": "string" },
|
|
50
51
|
"componentsUsed": { "type": "array", "items": { "type": "string" } },
|
|
51
52
|
"tokensUsed": { "type": "array", "items": { "type": "string" } },
|
|
52
53
|
"violationsCount": { "type": "number", "minimum": 0 },
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"templates": [
|
|
5
5
|
{
|
|
6
6
|
"id": "auth-form-card",
|
|
7
|
+
"patternId": "AuthForm",
|
|
7
8
|
"intent": "Authentication form with one primary action and optional secondary action.",
|
|
8
9
|
"tags": [
|
|
9
10
|
"form",
|
|
@@ -97,6 +98,7 @@
|
|
|
97
98
|
},
|
|
98
99
|
{
|
|
99
100
|
"id": "dashboard-table-summary",
|
|
101
|
+
"patternId": "DataTablePage",
|
|
100
102
|
"intent": "Summary header with data table and row actions.",
|
|
101
103
|
"tags": [
|
|
102
104
|
"dashboard",
|
|
@@ -171,6 +173,7 @@
|
|
|
171
173
|
},
|
|
172
174
|
{
|
|
173
175
|
"id": "settings-two-column",
|
|
176
|
+
"patternId": "SettingsWorkspace",
|
|
174
177
|
"intent": "Two-column settings page with form area and contextual summary card.",
|
|
175
178
|
"tags": [
|
|
176
179
|
"settings",
|
|
@@ -267,6 +270,7 @@
|
|
|
267
270
|
},
|
|
268
271
|
{
|
|
269
272
|
"id": "modal-confirmation",
|
|
273
|
+
"patternId": "ModalConfirmation",
|
|
270
274
|
"intent": "Confirmation flow in modal with primary and dismissive actions.",
|
|
271
275
|
"tags": [
|
|
272
276
|
"modal",
|
|
@@ -328,6 +332,7 @@
|
|
|
328
332
|
},
|
|
329
333
|
{
|
|
330
334
|
"id": "wizard-steps-form",
|
|
335
|
+
"patternId": "WizardChecklist",
|
|
331
336
|
"intent": "Multi-step form shell with progress indicator and staged actions.",
|
|
332
337
|
"tags": [
|
|
333
338
|
"wizard",
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"contractName": "uds.ai.token-catalog",
|
|
3
|
+
"schemaVersion": "1.0.0",
|
|
4
|
+
"groups": {
|
|
5
|
+
"surface": [
|
|
6
|
+
"--uds-color-neutral-0",
|
|
7
|
+
"--uds-color-neutral-50",
|
|
8
|
+
"--uds-color-neutral-100",
|
|
9
|
+
"--uds-surface-primary",
|
|
10
|
+
"--uds-surface-secondary",
|
|
11
|
+
"--uds-surface-brand-primary"
|
|
12
|
+
],
|
|
13
|
+
"text": [
|
|
14
|
+
"--uds-color-neutral-900",
|
|
15
|
+
"--uds-color-neutral-700",
|
|
16
|
+
"--uds-color-neutral-600",
|
|
17
|
+
"--uds-text-primary",
|
|
18
|
+
"--uds-text-secondary",
|
|
19
|
+
"--uds-text-on-brand"
|
|
20
|
+
],
|
|
21
|
+
"border": [
|
|
22
|
+
"--uds-color-neutral-200",
|
|
23
|
+
"--uds-color-neutral-400",
|
|
24
|
+
"--uds-color-blue-600",
|
|
25
|
+
"--uds-color-red-600",
|
|
26
|
+
"--uds-border-primary",
|
|
27
|
+
"--uds-border-secondary"
|
|
28
|
+
],
|
|
29
|
+
"action": [
|
|
30
|
+
"--uds-color-blue-600",
|
|
31
|
+
"--uds-color-blue-700",
|
|
32
|
+
"--uds-color-red-600",
|
|
33
|
+
"--uds-color-neutral-200"
|
|
34
|
+
],
|
|
35
|
+
"state": [
|
|
36
|
+
"--uds-color-green-600",
|
|
37
|
+
"--uds-color-amber-600",
|
|
38
|
+
"--uds-color-red-600",
|
|
39
|
+
"--uds-color-blue-600"
|
|
40
|
+
],
|
|
41
|
+
"spacing": [
|
|
42
|
+
"--uds-spacing-0",
|
|
43
|
+
"--uds-spacing-2",
|
|
44
|
+
"--uds-spacing-4",
|
|
45
|
+
"--uds-spacing-6",
|
|
46
|
+
"--uds-spacing-8",
|
|
47
|
+
"--uds-spacing-10",
|
|
48
|
+
"--uds-spacing-12",
|
|
49
|
+
"--uds-spacing-14",
|
|
50
|
+
"--uds-spacing-16",
|
|
51
|
+
"--uds-spacing-18",
|
|
52
|
+
"--uds-spacing-24",
|
|
53
|
+
"--uds-spacing-32",
|
|
54
|
+
"--uds-spacing-36",
|
|
55
|
+
"--uds-spacing-40",
|
|
56
|
+
"--uds-spacing-48",
|
|
57
|
+
"--uds-spacing-64",
|
|
58
|
+
"--uds-spacing-80"
|
|
59
|
+
],
|
|
60
|
+
"radius": [
|
|
61
|
+
"--uds-radius-4",
|
|
62
|
+
"--uds-radius-8",
|
|
63
|
+
"--uds-radius-12",
|
|
64
|
+
"--uds-radius-pill"
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
"rules": [
|
|
68
|
+
"Never define custom CSS variables in generated output.",
|
|
69
|
+
"Only use --uds-* variables or hardcoded literals.",
|
|
70
|
+
"Prefer semantic aliases (for example --uds-text-primary) in UI-facing guidance."
|
|
71
|
+
]
|
|
72
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("../manifest/governance.manifest.cjs"),v=require("../policies/policy.engine.cjs"),S=require("./driftDetection.cjs"),l=require("./deterministicFeedback.cjs"),b=require("./schemaValidation.cjs"),c=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),p=t=>typeof t=="string"&&t.trim().length>0?t:void 0;function g(t){const n=c(t)?t:null;if(!n)return;const i=c(n.audit)?n.audit:null,r=p(i==null?void 0:i.patternId);if(r)return r;const o=c(n.tree)?n.tree:null,e=c(o==null?void 0:o.props)?o==null?void 0:o.props:null;return p((e==null?void 0:e.patternId)??(e==null?void 0:e.pattern)??(e==null?void 0:e.layoutPattern))}function A(t,n){const i=c(t)?t:null;if(!i)return[];const r=[{key:"manifestVersion",expected:n.manifestVersion},{key:"governanceVersion",expected:n.governanceVersion},{key:"policyVersion",expected:n.policyVersion}],o=[];for(const e of r){const s=p(i[e.key]);s&&s!==e.expected&&o.push({severity:"error",code:`RULE_VERSION_MISMATCH_${e.key.toUpperCase()}`,message:`${e.key} "${s}" does not match expected "${e.expected}".`,path:e.key})}return o}function D(t,n=y.UDSGovernance){const i=b.validateSchema(t),r=new Date().toISOString(),o=y.getVersionLineage(),e=[...i.violations],s=[];if(e.push(...A(t,n)),i.tree){const k=v.runPolicyEngine(i.tree,n,{patternId:g(t)}),I=S.detectDrift(i.tree);for(const d of[...k,...I])d.severity==="error"?e.push(d):s.push(d)}const a=l.sortAndDedupeViolations(e),V=l.sortAndDedupeViolations(s),m=n.enforcement.strictMode,u=a.length>0,f=m&&u?"fail":"pass",h=u?l.buildDeterministicFeedback(a):void 0;return{status:f,violations:a,warnings:V,deterministicFeedback:h,governanceVersionUsed:n.governanceVersion,manifestVersionUsed:n.manifestVersion,policyVersionUsed:n.policyVersion,timestamp:r,versionLineage:o}}exports.validateAIOutput=D;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UDSGovernance as
|
|
1
|
+
import{UDSGovernance as I,getVersionLineage as v}from"../manifest/governance.manifest.js";import{runPolicyEngine as x}from"../policies/policy.engine.js";import{detectDrift as S}from"./driftDetection.js";import{sortAndDedupeViolations as m,buildDeterministicFeedback as P}from"./deterministicFeedback.js";import{validateSchema as U}from"./schemaValidation.js";const c=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),l=e=>typeof e=="string"&&e.trim().length>0?e:void 0;function A(e){const n=c(e)?e:null;if(!n)return;const o=c(n.audit)?n.audit:null,r=l(o==null?void 0:o.patternId);if(r)return r;const i=c(n.tree)?n.tree:null,t=c(i==null?void 0:i.props)?i==null?void 0:i.props:null;return l((t==null?void 0:t.patternId)??(t==null?void 0:t.pattern)??(t==null?void 0:t.layoutPattern))}function D(e,n){const o=c(e)?e:null;if(!o)return[];const r=[{key:"manifestVersion",expected:n.manifestVersion},{key:"governanceVersion",expected:n.governanceVersion},{key:"policyVersion",expected:n.policyVersion}],i=[];for(const t of r){const s=l(o[t.key]);s&&s!==t.expected&&i.push({severity:"error",code:`RULE_VERSION_MISMATCH_${t.key.toUpperCase()}`,message:`${t.key} "${s}" does not match expected "${t.expected}".`,path:t.key})}return i}function L(e,n=I){const o=U(e),r=new Date().toISOString(),i=v(),t=[...o.violations],s=[];if(t.push(...D(e,n)),o.tree){const h=x(o.tree,n,{patternId:A(e)}),k=S(o.tree);for(const d of[...h,...k])d.severity==="error"?t.push(d):s.push(d)}const a=m(t),f=m(s),y=n.enforcement.strictMode,p=a.length>0,V=y&&p?"fail":"pass",u=p?P(a):void 0;return{status:V,violations:a,warnings:f,deterministicFeedback:u,governanceVersionUsed:n.governanceVersion,manifestVersionUsed:n.manifestVersion,policyVersionUsed:n.policyVersion,timestamp:r,versionLineage:i}}export{L as validateAIOutput};
|
|
@@ -25,6 +25,8 @@ export interface AppShellProps {
|
|
|
25
25
|
layout?: ShellLayoutConfig;
|
|
26
26
|
slots?: AppShellSlots;
|
|
27
27
|
children?: React.ReactNode;
|
|
28
|
+
/** Standalone mode: no navigation/menu spacing (desktop/mobile). */
|
|
29
|
+
standalone?: boolean;
|
|
28
30
|
brand?: string;
|
|
29
31
|
theme?: "light" | "dark";
|
|
30
32
|
className?: string;
|
|
@@ -45,11 +47,13 @@ declare const AppShellMenuSlot: ({ children }: AppShellSectionProps) => import("
|
|
|
45
47
|
declare const AppShellContentSlot: ({ children }: AppShellSectionProps) => import("react/jsx-runtime").JSX.Element;
|
|
46
48
|
declare const AppShellListviewSlot: ({ children }: AppShellSectionProps) => import("react/jsx-runtime").JSX.Element;
|
|
47
49
|
declare const AppShellMainSlot: ({ children }: AppShellSectionProps) => import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
declare const AppShellFooterSlot: ({ children }: AppShellSectionProps) => import("react/jsx-runtime").JSX.Element;
|
|
48
51
|
type AppShellCompound = React.FC<AppShellProps> & {
|
|
49
52
|
Menu: typeof AppShellMenuSlot;
|
|
50
53
|
Content: typeof AppShellContentSlot;
|
|
51
54
|
Listview: typeof AppShellListviewSlot;
|
|
52
55
|
Main: typeof AppShellMainSlot;
|
|
56
|
+
Footer: typeof AppShellFooterSlot;
|
|
53
57
|
};
|
|
54
58
|
export declare const AppShell: AppShellCompound;
|
|
55
59
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),c=require("react"),h=require("../Icon/Icon.cjs"),D=require("../Divider/Divider.cjs"),R=require("../Key/Key.cjs"),O=require("../Toggle/Toggle.cjs");;/* empty css */const a="uds-action-menu";function S({item:r,onItemClick:$}){const[v,m]=c.useState(!1),i=c.useRef(null),o=c.useRef(null),j=()=>{clearTimeout(o.current),m(!0)},x=()=>{o.current=setTimeout(()=>{m(!1)},150)},N=()=>{clearTimeout(o.current)},d=()=>{o.current=setTimeout(()=>{m(!1)},150)};return c.useEffect(()=>()=>{clearTimeout(o.current)},[]),n.jsxs("div",{className:`${a}__item-wrapper`,onMouseEnter:j,onMouseLeave:x,children:[n.jsxs("button",{className:`${a}__item ${a}__item--has-submenu ${r.disabled?`${a}__item--disabled`:""}`,role:"menuitem",disabled:r.disabled,"aria-haspopup":"true","aria-expanded":v,"aria-label":r.label,children:[r.icon&&n.jsx(h.default,{name:r.icon,size:16,appearance:"regular",className:`${a}__item-icon`}),n.jsx("span",{className:`${a}__item-label`,children:r.label}),n.jsx(h.default,{name:"CaretRight",size:12,appearance:"regular",className:`${a}__item-arrow`})]}),v&&r.items&&n.jsx("div",{ref:i,className:`${a}__submenu`,role:"menu","aria-orientation":"vertical",onMouseEnter:N,onMouseLeave:d,children:r.items.map((s,u)=>s.divider?n.jsx("div",{className:`${a}__divider`,children:n.jsx(D.default,{})},`divider-${u}`):s.items&&s.items.length>0?n.jsx(S,{item:s,onItemClick:$},s.id||u):n.jsxs("button",{className:`${a}__item ${s.disabled?`${a}__item--disabled`:""} ${s.active?`${a}__item--active`:""} ${s.destructive?`${a}__item--destructive`:""}`,role:"menuitem",disabled:s.disabled,onClick:f=>$(s,f),"aria-label":s.label,children:[s.icon&&n.jsx(h.default,{name:s.icon,size:16,appearance:"regular",className:`${a}__item-icon`}),n.jsx("span",{className:`${a}__item-label`,children:s.label}),s.shortcut&&n.jsx(R.default,{label:s.shortcut,appearance:"light",className:`${a}__item-shortcut`})]},s.id||u))})]})}function B({trigger:r,items:$=[],placement:v="bottom-start",fullWidth:m=!1,disabled:i=!1,onOpenChange:o,className:j="",menuClassName:x="",...N}){const[d,s]=c.useState(!1),u=c.useRef(null),f=c.useRef(null),k=e=>{var t;e.key==="Escape"&&(b(!1),(t=f.current)==null||t.focus())},b=e=>{s(e),o&&o(e)};c.useEffect(()=>{const e=t=>{u.current&&f.current&&!u.current.contains(t.target)&&!f.current.contains(t.target)&&b(!1)};return d&&(document.addEventListener("mousedown",e),document.addEventListener("keydown",k)),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",k)}},[d]);const L=e=>{var g,_,w,M,y;const t=(g=u.current)==null?void 0:g.querySelectorAll('[role="menuitem"]:not([disabled])');if(!t||t.length===0)return;const l=Array.from(t).findIndex(p=>p===document.activeElement);switch(e.key){case"ArrowDown":{e.preventDefault();const p=l<t.length-1?l+1:0;(_=t[p])==null||_.focus();break}case"ArrowUp":{e.preventDefault();const p=l>0?l-1:t.length-1;(w=t[p])==null||w.focus();break}case"Home":e.preventDefault(),(M=t[0])==null||M.focus();break;case"End":e.preventDefault(),(y=t[t.length-1])==null||y.focus();break;case"Enter":case" ":e.preventDefault(),document.activeElement&&document.activeElement.click();break}},E=()=>{i||b(!d)},C=(e,t)=>{if(e.disabled){t.preventDefault();return}e.onClick&&e.onClick(e,t),b(!1)},T=()=>{var e,t;if(!r)return null;if(c.isValidElement(r)){const l=(e=r.props)==null?void 0:e.onClick,g=c.cloneElement(r,{disabled:i||((t=r.props)==null?void 0:t.disabled),"aria-disabled":i||void 0,onClick:_=>{_.preventDefault(),_.stopPropagation(),!i&&(l&&l(_),E())},"aria-haspopup":"true","aria-expanded":d});return n.jsx("div",{ref:f,className:`${a}__trigger`,children:g})}return n.jsx("div",{ref:f,className:`${a}__trigger`,onClick:E,children:r})},q=()=>({"bottom-start":"bottom-start","bottom-end":"bottom-end","top-start":"top-start","top-end":"top-end","right-start":"right-start","right-end":"right-end","left-start":"left-start","left-end":"left-end"})[v]||"bottom-start",A=[a,d&&`${a}--open`,m&&`${a}--full-width`,i&&`${a}--disabled`,j].filter(Boolean).join(" "),z=[`${a}__menu`,`${a}__menu--${q()}`,m&&`${a}__menu--full-width`,x].filter(Boolean).join(" ");return n.jsxs("div",{className:A,...N,children:[T(),d&&!i&&n.jsx("div",{ref:u,className:z,role:"menu","aria-orientation":"vertical",onKeyDown:L,children:$.map((e,t)=>e.divider?n.jsx("div",{className:`${a}__divider`,children:n.jsx(D.default,{})},`divider-${t}`):e.items&&e.items.length>0?n.jsx(S,{item:e,onItemClick:C},e.id||t):e.type==="toggle"?n.jsxs("div",{className:`${a}__item ${a}__item--toggle ${e.disabled?`${a}__item--disabled`:""}`,role:"menuitemcheckbox","aria-checked":!!e.checked,"aria-label":e.label,children:[e.icon&&n.jsx(h.default,{name:e.icon,size:16,appearance:"regular",className:`${a}__item-icon`}),n.jsx("span",{className:`${a}__item-label`,children:e.label}),n.jsx(O.default,{checked:!!e.checked,size:"small",disabled:e.disabled,onChange:l=>{e.onChange&&e.onChange(l)},className:`${a}__item-toggle`})]},e.id||t):n.jsxs("button",{className:`${a}__item ${e.disabled?`${a}__item--disabled`:""} ${e.active?`${a}__item--active`:""} ${e.destructive?`${a}__item--destructive`:""}`,role:"menuitem",disabled:e.disabled,onClick:l=>C(e,l),"aria-label":e.label,children:[e.icon&&n.jsx(h.default,{name:e.icon,size:16,appearance:"regular",className:`${a}__item-icon`}),n.jsx("span",{className:`${a}__item-label`,children:e.label}),e.shortcut&&n.jsx(R.default,{label:e.shortcut,appearance:"light",className:`${a}__item-shortcut`})]},e.id||t))})]})}exports.default=B;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),l=require("react"),Ee=require("react-dom"),F=require("../Icon/Icon.cjs"),me=require("../Divider/Divider.cjs"),pe=require("../Key/Key.cjs"),Ne=require("../SearchInput/SearchInput.cjs"),ke=require("../Toggle/Toggle.cjs");;/* empty css */const t="uds-action-menu",Le=new Set(["search","autosuggest"]),W=n=>String(n||"").trim().toLowerCase(),Re=n=>typeof(n==null?void 0:n.label)=="string"?n.label:"",fe=n=>{var p,d;const u=[...n];for(;u.length>0&&((p=u[0])!=null&&p.divider);)u.shift();for(;u.length>0&&((d=u[u.length-1])!=null&&d.divider);)u.pop();return u},ge=(n,u)=>{const p=W(u);if(!p)return n;const d=[];for(const h of n){if(h!=null&&h.divider){d.push(h);continue}const v=W(Re(h)),_=Array.isArray(h==null?void 0:h.items)?ge(h.items,u):null,f=Array.isArray(_)&&_.length>0;(v.includes(p)||f)&&d.push(f?{...h,items:fe(_)}:h)}return fe(d)},he=(n,u,p=!1)=>{const d=W(u);if(!d||!n)return n;const h=W(n),v=p?h.startsWith(d)?0:-1:h.indexOf(d);if(v<0)return n;const _=v+d.length,f=n.slice(0,v),R=n.slice(v,_),q=n.slice(_);return o.jsxs(o.Fragment,{children:[f,o.jsx("span",{className:`${t}__match ${p?`${t}__match--weight`:""}`,children:R}),q]})};function _e({item:n,onItemClick:u}){const[p,d]=l.useState(!1),[h,v]=l.useState(!1),_=l.useRef(null),f=l.useRef(null),R=()=>{clearTimeout(f.current),d(!0)},q=()=>{f.current=setTimeout(()=>{d(!1)},150)},G=()=>{clearTimeout(f.current)},U=()=>{f.current=setTimeout(()=>{d(!1)},150)};return l.useEffect(()=>()=>{clearTimeout(f.current)},[]),l.useLayoutEffect(()=>{if(!p||!_.current)return;const s=_.current.getBoundingClientRect(),C=s.right>window.innerWidth-8,M=s.left<8;if(C&&!M){v(!0);return}if(M&&!C){v(!1);return}C&&M&&v(s.right-window.innerWidth>8)},[p]),o.jsxs("div",{className:`${t}__item-wrapper`,onMouseEnter:R,onMouseLeave:q,children:[o.jsxs("button",{className:`${t}__item ${t}__item--has-submenu ${n.disabled?`${t}__item--disabled`:""}`,role:"menuitem",disabled:n.disabled,"aria-haspopup":"true","aria-expanded":p,"aria-label":n.label,children:[n.icon&&o.jsx(F.default,{name:n.icon,size:16,appearance:"regular",className:`${t}__item-icon`}),o.jsx("span",{className:`${t}__item-label`,children:n.label}),o.jsx(F.default,{name:"CaretRight",size:12,appearance:"regular",className:`${t}__item-arrow`})]}),p&&n.items&&o.jsx("div",{ref:_,className:`${t}__submenu ${h?`${t}__submenu--left`:""}`,role:"menu","aria-orientation":"vertical",onMouseEnter:G,onMouseLeave:U,children:n.items.map((s,C)=>s.divider?o.jsx("div",{className:`${t}__divider`,children:o.jsx(me.default,{})},`divider-${C}`):s.items&&s.items.length>0?o.jsx(_e,{item:s,onItemClick:u},s.id||C):o.jsxs("button",{className:`${t}__item ${s.disabled?`${t}__item--disabled`:""} ${s.active?`${t}__item--active`:""} ${s.destructive?`${t}__item--destructive`:""}`,role:"menuitem",disabled:s.disabled,onClick:M=>u(s,M),"aria-label":s.label,children:[s.icon&&o.jsx(F.default,{name:s.icon,size:16,appearance:"regular",className:`${t}__item-icon`}),o.jsx("span",{className:`${t}__item-label`,children:s.label}),s.shortcut&&o.jsx(pe.default,{label:s.shortcut,appearance:"light",className:`${t}__item-shortcut`})]},s.id||C))})]})}function Me({trigger:n,items:u=[],placement:p="bottom-start",variant:d="default",searchPlaceholder:h="Search...",noResultsText:v="No results found",fullWidth:_=!1,disabled:f=!1,onOpenChange:R,className:q="",menuClassName:G="",...U}){const[s,C]=l.useState(!1),[M,$e]=l.useState({}),[I,Y]=l.useState(null),x=l.useRef(null),S=l.useRef(null),T=l.useRef(null),K=l.useRef(null),[Z,ee]=l.useState(""),[be,ve]=l.useState(""),z=d==="search",E=d==="autosuggest",te=Le.has(d),P=z?Z:E?be:"",ne=l.useMemo(()=>te?ge(u,P):u,[te,u,P]),re=e=>{var r;e.key==="Escape"&&(N(!1),(r=S.current)==null||r.focus())},N=e=>{C(e),e||(K.current=null),R&&R(e)};l.useEffect(()=>{const e=r=>{x.current&&S.current&&!x.current.contains(r.target)&&!S.current.contains(r.target)&&N(!1)};return s&&(document.addEventListener("mousedown",e),document.addEventListener("keydown",re)),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",re)}},[s]);const se=()=>{if(!s||!x.current||!S.current)return;const e=S.current.closest(".app-shell__main-content"),r=e instanceof HTMLElement?e:document.body;Y(r);const a=S.current.getBoundingClientRect(),g=x.current.getBoundingClientRect(),j=r===document.body?{top:0,left:0}:r.getBoundingClientRect(),w=r===document.body?0:r.scrollTop,y=r===document.body?0:r.scrollLeft,k=r===document.body?window.innerWidth:r.clientWidth,L=r===document.body?window.innerHeight:r.clientHeight,b=8,c=8,[m="bottom",A="start"]=String(p).split("-"),B=(i,ae)=>{let V=0,Q=0;const ce=a.top-j.top+w,le=a.bottom-j.top+w,ue=a.left-j.left+y,de=a.right-j.left+y;return i==="bottom"&&(V=le+c),i==="top"&&(V=ce-g.height-c),i==="right"&&(Q=de+c),i==="left"&&(Q=ue-g.width-c),(i==="bottom"||i==="top")&&(ae==="end"?Q=de-g.width:Q=ue),(i==="left"||i==="right")&&(ae==="end"?V=le-g.height:V=ce),{top:V,left:Q}},Se=i=>({top:i.top<w+b,bottom:i.top+g.height>w+L-b,left:i.left<y+b,right:i.left+g.width>y+k-b});let $=K.current??m;const H=A;let D=B($,H);if(!K.current){const i=Se(D);$==="bottom"&&i.bottom?($="top",D=B($,H)):$==="top"&&i.top?($="bottom",D=B($,H)):$==="right"&&i.right?($="left",D=B($,H)):$==="left"&&i.left&&($="right",D=B($,H)),K.current=$}let J=D.top,X=D.left;J=Math.max(w+b,Math.min(J,w+L-g.height-b)),X=Math.max(y+b,Math.min(X,y+k-g.width-b));const O={position:r===document.body?"fixed":"absolute",top:`${J}px`,left:`${X}px`,width:_?`${a.width}px`:void 0};$e(i=>i.top===O.top&&i.left===O.left&&i.width===O.width&&i.position===O.position?i:O)};l.useLayoutEffect(()=>{var e;if(s){if(I===null){const r=(e=S.current)==null?void 0:e.closest(".app-shell__main-content");Y(r instanceof HTMLElement?r:document.body)}se()}},[s,p,_,I]),l.useEffect(()=>{if(!s)return;const e=()=>{T.current==null&&(T.current=requestAnimationFrame(()=>{T.current=null,se()}))};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e),T.current!=null&&(cancelAnimationFrame(T.current),T.current=null)}},[s]),l.useEffect(()=>{if(!s){ee("");return}z&&requestAnimationFrame(()=>{var r;const e=(r=x.current)==null?void 0:r.querySelector('input[type="search"]');e==null||e.focus()})},[s,z]);const we=e=>{var j,w,y,k,L,b,c;if(z&&e.target instanceof HTMLInputElement&&e.target.type==="search"&&((j=x.current)==null?void 0:j.contains(e.target))){if(e.key==="ArrowDown"){e.preventDefault();const m=(w=x.current)==null?void 0:w.querySelector('[role="menuitem"]:not([disabled])');m==null||m.focus()}return}const a=(y=x.current)==null?void 0:y.querySelectorAll('[role="menuitem"]:not([disabled])');if(!a||a.length===0)return;const g=Array.from(a).findIndex(m=>m===document.activeElement);switch(e.key){case"ArrowDown":{e.preventDefault();const m=g<a.length-1?g+1:0;(k=a[m])==null||k.focus();break}case"ArrowUp":{e.preventDefault();const m=g>0?g-1:a.length-1;(L=a[m])==null||L.focus();break}case"Home":e.preventDefault(),(b=a[0])==null||b.focus();break;case"End":e.preventDefault(),(c=a[a.length-1])==null||c.focus();break;case"Enter":case" ":e.preventDefault(),document.activeElement&&document.activeElement.click();break}},oe=()=>{f||N(!s)},ie=(e,r)=>{if(e.disabled){r.preventDefault();return}e.onClick&&e.onClick(e,r),N(!1)},ye=()=>z?o.jsx("div",{className:`${t}__search`,children:o.jsx(Ne.SearchInput,{size:"compact",value:Z,onChange:e=>ee(e.target.value),className:`${t}__search-input`,placeholder:h,"aria-label":h})}):null,xe=()=>{var e,r,a,g,j;if(!n)return null;if(l.isValidElement(n)){const w=(e=n.props)==null?void 0:e.onClick,y=(r=n.props)==null?void 0:r.onChange,k=(a=n.props)==null?void 0:a.onFocus,L=(g=n.props)==null?void 0:g.onKeyDown,b=l.cloneElement(n,{disabled:f||((j=n.props)==null?void 0:j.disabled),"aria-disabled":f||void 0,onClick:c=>{f||(E||(c.preventDefault(),c.stopPropagation()),w&&w(c),E?N(!0):oe())},onFocus:c=>{k&&k(c),!(f||!E)&&N(!0)},onChange:c=>{if(y&&y(c),f||!E)return;const m=c==null?void 0:c.target,A=m&&typeof m=="object"&&"value"in m?String(m.value??""):"";ve(A),N(!0)},onKeyDown:c=>{var m;if(L&&L(c),!(f||!E)){if(c.key==="Escape"){N(!1);return}if(c.key==="ArrowDown"){c.preventDefault();const A=(m=x.current)==null?void 0:m.querySelector('[role="menuitem"]:not([disabled])');A==null||A.focus()}}},"aria-haspopup":"true","aria-expanded":s});return o.jsx("div",{ref:S,className:`${t}__trigger`,children:b})}return o.jsx("div",{ref:S,className:`${t}__trigger`,onClick:oe,children:n})},je=[t,s&&`${t}--open`,_&&`${t}--full-width`,f&&`${t}--disabled`,q].filter(Boolean).join(" "),Ce=[`${t}__menu`,`${t}__menu--portal`,d==="search"&&`${t}__menu--search`,_&&`${t}__menu--full-width`,G].filter(Boolean).join(" ");return o.jsxs("div",{className:je,...U,children:[xe(),s&&!f&&I?Ee.createPortal(o.jsxs("div",{ref:x,className:Ce,style:M,role:"menu","aria-orientation":"vertical",onKeyDown:we,children:[ye(),ne.length===0?o.jsx("div",{className:`${t}__empty`,children:v}):null,ne.map((e,r)=>e.divider?o.jsx("div",{className:`${t}__divider`,children:o.jsx(me.default,{})},`divider-${r}`):e.items&&e.items.length>0?o.jsx(_e,{item:e,onItemClick:ie},e.id||r):e.type==="toggle"?o.jsxs("div",{className:`${t}__item ${t}__item--toggle ${e.disabled?`${t}__item--disabled`:""}`,role:"menuitemcheckbox","aria-checked":!!e.checked,"aria-label":e.label,children:[e.icon&&o.jsx(F.default,{name:e.icon,size:16,appearance:"regular",className:`${t}__item-icon`}),o.jsx("span",{className:`${t}__item-label`,children:he(e.label,P,E)}),o.jsx(ke.default,{checked:!!e.checked,size:"small",disabled:e.disabled,onChange:a=>{e.onChange&&e.onChange(a)},className:`${t}__item-toggle`})]},e.id||r):o.jsxs("button",{className:`${t}__item ${e.disabled?`${t}__item--disabled`:""} ${e.active?`${t}__item--active`:""} ${e.destructive?`${t}__item--destructive`:""}`,role:"menuitem",disabled:e.disabled,onClick:a=>ie(e,a),"aria-label":e.label,children:[e.icon&&o.jsx(F.default,{name:e.icon,size:16,appearance:"regular",className:`${t}__item-icon`}),o.jsx("span",{className:`${t}__item-label`,children:he(e.label,P,E)}),e.shortcut&&o.jsx(pe.default,{label:e.shortcut,appearance:"light",className:`${t}__item-shortcut`})]},e.id||r))]}),I):null]})}exports.default=Me;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as A,jsx as i,Fragment as De}from"react/jsx-runtime";import pe,{useState as z,useRef as H,useMemo as Te,useEffect as U,useLayoutEffect as $e}from"react";import{createPortal as xe}from"react-dom";import I from"../Icon/Icon.js";import we from"../Divider/Divider.js";import be from"../Key/Key.js";import{SearchInput as ze}from"../SearchInput/SearchInput.js";import Be from"../Toggle/Toggle.js";/* empty css */const t="uds-action-menu",He=new Set(["search","autosuggest"]),J=n=>String(n||"").trim().toLowerCase(),Ve=n=>typeof(n==null?void 0:n.label)=="string"?n.label:"",ge=n=>{var m,u;const l=[...n];for(;l.length>0&&((m=l[0])!=null&&m.divider);)l.shift();for(;l.length>0&&((u=l[l.length-1])!=null&&u.divider);)l.pop();return l},ve=(n,l)=>{const m=J(l);if(!m)return n;const u=[];for(const f of n){if(f!=null&&f.divider){u.push(f);continue}const w=J(Ve(f)),g=Array.isArray(f==null?void 0:f.items)?ve(f.items,l):null,d=Array.isArray(g)&&g.length>0;(w.includes(m)||d)&&u.push(d?{...f,items:ge(g)}:f)}return ge(u)},_e=(n,l,m=!1)=>{const u=J(l);if(!u||!n)return n;const f=J(n),w=m?f.startsWith(u)?0:-1:f.indexOf(u);if(w<0)return n;const g=w+u.length,d=n.slice(0,w),R=n.slice(w,g),V=n.slice(g);return A(De,{children:[d,i("span",{className:`${t}__match ${m?`${t}__match--weight`:""}`,children:R}),V]})};function ye({item:n,onItemClick:l}){const[m,u]=z(!1),[f,w]=z(!1),g=H(null),d=H(null),R=()=>{clearTimeout(d.current),u(!0)},V=()=>{d.current=setTimeout(()=>{u(!1)},150)},X=()=>{clearTimeout(d.current)},Y=()=>{d.current=setTimeout(()=>{u(!1)},150)};return U(()=>()=>{clearTimeout(d.current)},[]),$e(()=>{if(!m||!g.current)return;const o=g.current.getBoundingClientRect(),N=o.right>window.innerWidth-8,D=o.left<8;if(N&&!D){w(!0);return}if(D&&!N){w(!1);return}N&&D&&w(o.right-window.innerWidth>8)},[m]),A("div",{className:`${t}__item-wrapper`,onMouseEnter:R,onMouseLeave:V,children:[A("button",{className:`${t}__item ${t}__item--has-submenu ${n.disabled?`${t}__item--disabled`:""}`,role:"menuitem",disabled:n.disabled,"aria-haspopup":"true","aria-expanded":m,"aria-label":n.label,children:[n.icon&&i(I,{name:n.icon,size:16,appearance:"regular",className:`${t}__item-icon`}),i("span",{className:`${t}__item-label`,children:n.label}),i(I,{name:"CaretRight",size:12,appearance:"regular",className:`${t}__item-arrow`})]}),m&&n.items&&i("div",{ref:g,className:`${t}__submenu ${f?`${t}__submenu--left`:""}`,role:"menu","aria-orientation":"vertical",onMouseEnter:X,onMouseLeave:Y,children:n.items.map((o,N)=>o.divider?i("div",{className:`${t}__divider`,children:i(we,{})},`divider-${N}`):o.items&&o.items.length>0?i(ye,{item:o,onItemClick:l},o.id||N):A("button",{className:`${t}__item ${o.disabled?`${t}__item--disabled`:""} ${o.active?`${t}__item--active`:""} ${o.destructive?`${t}__item--destructive`:""}`,role:"menuitem",disabled:o.disabled,onClick:D=>l(o,D),"aria-label":o.label,children:[o.icon&&i(I,{name:o.icon,size:16,appearance:"regular",className:`${t}__item-icon`}),i("span",{className:`${t}__item-label`,children:o.label}),o.shortcut&&i(be,{label:o.shortcut,appearance:"light",className:`${t}__item-shortcut`})]},o.id||N))})]})}function Ge({trigger:n,items:l=[],placement:m="bottom-start",variant:u="default",searchPlaceholder:f="Search...",noResultsText:w="No results found",fullWidth:g=!1,disabled:d=!1,onOpenChange:R,className:V="",menuClassName:X="",...Y}){const[o,N]=z(!1),[D,Ce]=z({}),[P,te]=z(null),y=H(null),E=H(null),B=H(null),W=H(null),[ne,re]=z(""),[Ne,Ee]=z(""),O=u==="search",k=u==="autosuggest",oe=He.has(u),G=O?ne:k?Ne:"",ie=Te(()=>oe?ve(l,G):l,[oe,l,G]),ae=e=>{var r;e.key==="Escape"&&(L(!1),(r=E.current)==null||r.focus())},L=e=>{N(e),e||(W.current=null),R&&R(e)};U(()=>{const e=r=>{y.current&&E.current&&!y.current.contains(r.target)&&!E.current.contains(r.target)&&L(!1)};return o&&(document.addEventListener("mousedown",e),document.addEventListener("keydown",ae)),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",ae)}},[o]);const ce=()=>{if(!o||!y.current||!E.current)return;const e=E.current.closest(".app-shell__main-content"),r=e instanceof HTMLElement?e:document.body;te(r);const c=E.current.getBoundingClientRect(),p=y.current.getBoundingClientRect(),C=r===document.body?{top:0,left:0}:r.getBoundingClientRect(),b=r===document.body?0:r.scrollTop,v=r===document.body?0:r.scrollLeft,S=r===document.body?window.innerWidth:r.clientWidth,M=r===document.body?window.innerHeight:r.clientHeight,$=8,s=8,[h="bottom",T="start"]=String(m).split("-"),Q=(a,ue)=>{let K=0,j=0;const de=c.top-C.top+b,fe=c.bottom-C.top+b,he=c.left-C.left+v,me=c.right-C.left+v;return a==="bottom"&&(K=fe+s),a==="top"&&(K=de-p.height-s),a==="right"&&(j=me+s),a==="left"&&(j=he-p.width-s),(a==="bottom"||a==="top")&&(ue==="end"?j=me-p.width:j=he),(a==="left"||a==="right")&&(ue==="end"?K=fe-p.height:K=de),{top:K,left:j}},Re=a=>({top:a.top<b+$,bottom:a.top+p.height>b+M-$,left:a.left<v+$,right:a.left+p.width>v+S-$});let _=W.current??h;const q=T;let x=Q(_,q);if(!W.current){const a=Re(x);_==="bottom"&&a.bottom?(_="top",x=Q(_,q)):_==="top"&&a.top?(_="bottom",x=Q(_,q)):_==="right"&&a.right?(_="left",x=Q(_,q)):_==="left"&&a.left&&(_="right",x=Q(_,q)),W.current=_}let Z=x.top,ee=x.left;Z=Math.max(b+$,Math.min(Z,b+M-p.height-$)),ee=Math.max(v+$,Math.min(ee,v+S-p.width-$));const F={position:r===document.body?"fixed":"absolute",top:`${Z}px`,left:`${ee}px`,width:g?`${c.width}px`:void 0};Ce(a=>a.top===F.top&&a.left===F.left&&a.width===F.width&&a.position===F.position?a:F)};$e(()=>{var e;if(o){if(P===null){const r=(e=E.current)==null?void 0:e.closest(".app-shell__main-content");te(r instanceof HTMLElement?r:document.body)}ce()}},[o,m,g,P]),U(()=>{if(!o)return;const e=()=>{B.current==null&&(B.current=requestAnimationFrame(()=>{B.current=null,ce()}))};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e),B.current!=null&&(cancelAnimationFrame(B.current),B.current=null)}},[o]),U(()=>{if(!o){re("");return}O&&requestAnimationFrame(()=>{var r;const e=(r=y.current)==null?void 0:r.querySelector('input[type="search"]');e==null||e.focus()})},[o,O]);const ke=e=>{var C,b,v,S,M,$,s;if(O&&e.target instanceof HTMLInputElement&&e.target.type==="search"&&((C=y.current)==null?void 0:C.contains(e.target))){if(e.key==="ArrowDown"){e.preventDefault();const h=(b=y.current)==null?void 0:b.querySelector('[role="menuitem"]:not([disabled])');h==null||h.focus()}return}const c=(v=y.current)==null?void 0:v.querySelectorAll('[role="menuitem"]:not([disabled])');if(!c||c.length===0)return;const p=Array.from(c).findIndex(h=>h===document.activeElement);switch(e.key){case"ArrowDown":{e.preventDefault();const h=p<c.length-1?p+1:0;(S=c[h])==null||S.focus();break}case"ArrowUp":{e.preventDefault();const h=p>0?p-1:c.length-1;(M=c[h])==null||M.focus();break}case"Home":e.preventDefault(),($=c[0])==null||$.focus();break;case"End":e.preventDefault(),(s=c[c.length-1])==null||s.focus();break;case"Enter":case" ":e.preventDefault(),document.activeElement&&document.activeElement.click();break}},se=()=>{d||L(!o)},le=(e,r)=>{if(e.disabled){r.preventDefault();return}e.onClick&&e.onClick(e,r),L(!1)},Le=()=>O?i("div",{className:`${t}__search`,children:i(ze,{size:"compact",value:ne,onChange:e=>re(e.target.value),className:`${t}__search-input`,placeholder:f,"aria-label":f})}):null,Se=()=>{var e,r,c,p,C;if(!n)return null;if(pe.isValidElement(n)){const b=(e=n.props)==null?void 0:e.onClick,v=(r=n.props)==null?void 0:r.onChange,S=(c=n.props)==null?void 0:c.onFocus,M=(p=n.props)==null?void 0:p.onKeyDown,$=pe.cloneElement(n,{disabled:d||((C=n.props)==null?void 0:C.disabled),"aria-disabled":d||void 0,onClick:s=>{d||(k||(s.preventDefault(),s.stopPropagation()),b&&b(s),k?L(!0):se())},onFocus:s=>{S&&S(s),!(d||!k)&&L(!0)},onChange:s=>{if(v&&v(s),d||!k)return;const h=s==null?void 0:s.target,T=h&&typeof h=="object"&&"value"in h?String(h.value??""):"";Ee(T),L(!0)},onKeyDown:s=>{var h;if(M&&M(s),!(d||!k)){if(s.key==="Escape"){L(!1);return}if(s.key==="ArrowDown"){s.preventDefault();const T=(h=y.current)==null?void 0:h.querySelector('[role="menuitem"]:not([disabled])');T==null||T.focus()}}},"aria-haspopup":"true","aria-expanded":o});return i("div",{ref:E,className:`${t}__trigger`,children:$})}return i("div",{ref:E,className:`${t}__trigger`,onClick:se,children:n})},Me=[t,o&&`${t}--open`,g&&`${t}--full-width`,d&&`${t}--disabled`,V].filter(Boolean).join(" "),Ae=[`${t}__menu`,`${t}__menu--portal`,u==="search"&&`${t}__menu--search`,g&&`${t}__menu--full-width`,X].filter(Boolean).join(" ");return A("div",{className:Me,...Y,children:[Se(),o&&!d&&P?xe(A("div",{ref:y,className:Ae,style:D,role:"menu","aria-orientation":"vertical",onKeyDown:ke,children:[Le(),ie.length===0?i("div",{className:`${t}__empty`,children:w}):null,ie.map((e,r)=>e.divider?i("div",{className:`${t}__divider`,children:i(we,{})},`divider-${r}`):e.items&&e.items.length>0?i(ye,{item:e,onItemClick:le},e.id||r):e.type==="toggle"?A("div",{className:`${t}__item ${t}__item--toggle ${e.disabled?`${t}__item--disabled`:""}`,role:"menuitemcheckbox","aria-checked":!!e.checked,"aria-label":e.label,children:[e.icon&&i(I,{name:e.icon,size:16,appearance:"regular",className:`${t}__item-icon`}),i("span",{className:`${t}__item-label`,children:_e(e.label,G,k)}),i(Be,{checked:!!e.checked,size:"small",disabled:e.disabled,onChange:c=>{e.onChange&&e.onChange(c)},className:`${t}__item-toggle`})]},e.id||r):A("button",{className:`${t}__item ${e.disabled?`${t}__item--disabled`:""} ${e.active?`${t}__item--active`:""} ${e.destructive?`${t}__item--destructive`:""}`,role:"menuitem",disabled:e.disabled,onClick:c=>le(e,c),"aria-label":e.label,children:[e.icon&&i(I,{name:e.icon,size:16,appearance:"regular",className:`${t}__item-icon`}),i("span",{className:`${t}__item-label`,children:_e(e.label,G,k)}),e.shortcut&&i(be,{label:e.shortcut,appearance:"light",className:`${t}__item-shortcut`})]},e.id||r))]}),P):null]})}export{Ge as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),l=require("react"),q=require("../Icon/Icon.cjs"),y=require("../ActionMenu/ActionMenu.cjs");;/* empty css */const t="uds-dropdown",b={compact:"compact",default:null},g={default:null,focused:"focused",error:"error",disabled:"disabled"};function L({options:m=[],value:n,onChange:r,placeholder:o,size:f="default",state:p="default",placement:v="bottom-start",id:S,className:h="",disabled:a=!1,...j}){const[c,w]=l.useState(!1),x=l.useId(),C=S||`dropdown-${x}`,u=l.useMemo(()=>m.map(e=>typeof e=="string"?{value:e,label:e}:e),[m]),$=a?"disabled":p==="default"&&c?"focused":p,i=u.find(e=>e.value===n),d=typeof o=="string"&&o.trim().length>0?o.trim():"Select an option",M=i?i.label:d,N=l.useMemo(()=>u.map(e=>({id:e.value,label:e.label,active:e.value===n,onClick:()=>{r&&!a&&r(e.value)}})),[u,n,r,a]),I=[t,b[f]&&`${t}--${b[f]}`,g[$]&&`${t}--${g[$]}`,c&&`${t}--open`,h].filter(Boolean).join(" "),_={...j};delete _.label;const O=s.jsxs("button",{type:"button",id:C,className:`${t}__trigger`,disabled:a,"aria-label":d,..._,children:[s.jsx("span",{className:`${t}__value ${i?"":`${t}__value--placeholder`}`,children:M}),s.jsx(q.default,{name:"CaretDown",size:16,appearance:"regular",className:`${t}__icon ${c?`${t}__icon--open`:""}`})]});return s.jsx("div",{className:`${t}-outer`,children:s.jsx(y.default,{trigger:O,items:N,variant:"search",searchPlaceholder:`Search ${d.toLowerCase()}`,placement:v,fullWidth:!0,disabled:a,onOpenChange:w,className:I,menuClassName:`${t}__menu`})})}const k=l.memo(L);exports.default=k;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as s,jsxs as
|
|
1
|
+
import{jsx as s,jsxs as M}from"react/jsx-runtime";import j,{useState as k,useId as A,useMemo as _}from"react";import B from"../Icon/Icon.js";import D from"../ActionMenu/ActionMenu.js";/* empty css */const a="uds-dropdown",b={compact:"compact",default:null},g={default:null,focused:"focused",error:"error",disabled:"disabled"};function z({options:d=[],value:o,onChange:l,placeholder:r,size:m="default",state:p="default",placement:h="bottom-start",id:v,className:w="",disabled:t=!1,...C}){const[n,N]=k(!1),S=A(),I=v||`dropdown-${S}`,c=_(()=>d.map(e=>typeof e=="string"?{value:e,label:e}:e),[d]),f=t?"disabled":p==="default"&&n?"focused":p,i=c.find(e=>e.value===o),u=typeof r=="string"&&r.trim().length>0?r.trim():"Select an option",O=i?i.label:u,x=_(()=>c.map(e=>({id:e.value,label:e.label,active:e.value===o,onClick:()=>{l&&!t&&l(e.value)}})),[c,o,l,t]),y=[a,b[m]&&`${a}--${b[m]}`,g[f]&&`${a}--${g[f]}`,n&&`${a}--open`,w].filter(Boolean).join(" "),$={...C};delete $.label;const L=M("button",{type:"button",id:I,className:`${a}__trigger`,disabled:t,"aria-label":u,...$,children:[s("span",{className:`${a}__value ${i?"":`${a}__value--placeholder`}`,children:O}),s(B,{name:"CaretDown",size:16,appearance:"regular",className:`${a}__icon ${n?`${a}__icon--open`:""}`})]});return s("div",{className:`${a}-outer`,children:s(D,{trigger:L,items:x,variant:"search",searchPlaceholder:`Search ${u.toLowerCase()}`,placement:h,fullWidth:!0,disabled:t,onOpenChange:N,className:y,menuClassName:`${a}__menu`})})}const q=j.memo(z);export{q as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("react/jsx-runtime"),g=require("react");;/* empty css */const P=new Set(["0","2","4","6","8","10","12","14","16","18","24","32","48","64","80"]);function N(e){return e===!0?"wrap":e===!1||e==null?"nowrap":e}function i(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function _(e){return e==="equal"||e==="right"||e==="left"?e:e==="2 Equal Column"?"equal":e==="Content Right"?"right":e==="Content Left"?"left":"full"}function B(e){var n;if(e==null)return;const t=String(e).trim();if(t==="auto")return;const r=((n=t.match(/^spacing-(\d+)$/))==null?void 0:n[1])??t;return P.has(r)?`var(--uds-spacing-${r})`:e}function C(e){if(typeof e!="number"||!Number.isFinite(e))return;const t=Math.floor(e);return t>0?t:void 0}const E=g.forwardRef(function({as:t="div",direction:r="row",justifyContent:n,alignItems:u,appearance:a="full",itemsPerRow:c,wrap:h=!1,gap:d,fullWidth:m=!1,inline:S=!1,className:v,style:o,children:R,...L},$){const p=C(c),x=r==="row"&&p!==void 0,b=N(x?!0:h),j=String(d).trim()==="auto",q=_(a),z=["uds-flex",`uds-flex--direction-${r}`,`uds-flex--appearance-${i(q)}`,n&&`uds-flex--justify-${i(n)}`,u&&`uds-flex--align-${i(u)}`,`uds-flex--wrap-${i(b)}`,S&&"uds-flex--inline",m&&"uds-flex--full-width",m&&"uds-flex--span",x&&"uds-flex--items-per-row",j&&"uds-flex--gap-auto",v].filter(Boolean).join(" "),l={},A=B(d),G=(o==null?void 0:o.gap)!=null;return d!=null&&!G&&(l.gap=A),x&&(l["--uds-flex-items-per-row"]=String(p)),m&&(o==null?void 0:o.width)==null&&(l.width="100%"),F.jsx(t,{ref:$,className:z,style:{...l,...o},...L,children:R})}),s=g.forwardRef(function({as:t="div",className:r,children:n,...u},a){const c=["uds-flex__full",r].filter(Boolean).join(" ");return F.jsx(t,{ref:a,className:c,...u,children:n})}),f=E;f.Fill=s;f.Full=s;const w=f;w.Fill=s;w.Full=s;exports.Flex=w;exports.Layout=f;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as p}from"react/jsx-runtime";import h from"react";/* empty css */const _=new Set(["0","2","4","6","8","10","12","14","16","18","24","32","48","64","80"]);function j(r){return r===!0?"wrap":r===!1||r==null?"nowrap":r}function u(r){return r.trim().toLowerCase().replace(/\s+/g,"-")}function q(r){return r==="equal"||r==="right"||r==="left"?r:r==="2 Equal Column"?"equal":r==="Content Right"?"right":r==="Content Left"?"left":"full"}function B(r){var e;if(r==null)return;const t=String(r).trim();if(t==="auto")return;const o=((e=t.match(/^spacing-(\d+)$/))==null?void 0:e[1])??t;return _.has(o)?`var(--uds-spacing-${o})`:r}function C(r){if(typeof r!="number"||!Number.isFinite(r))return;const t=Math.floor(r);return t>0?t:void 0}const E=h.forwardRef(function({as:t="div",direction:o="row",justifyContent:e,alignItems:l,appearance:f="full",itemsPerRow:a,wrap:g=!1,gap:c,fullWidth:d=!1,inline:v=!1,className:S,style:n,children:R,...$},z){const w=C(a),m=o==="row"&&w!==void 0,A=j(m?!0:g),G=String(c).trim()==="auto",L=q(f),b=["uds-flex",`uds-flex--direction-${o}`,`uds-flex--appearance-${u(L)}`,e&&`uds-flex--justify-${u(e)}`,l&&`uds-flex--align-${u(l)}`,`uds-flex--wrap-${u(A)}`,v&&"uds-flex--inline",d&&"uds-flex--full-width",d&&"uds-flex--span",m&&"uds-flex--items-per-row",G&&"uds-flex--gap-auto",S].filter(Boolean).join(" "),i={},N=B(c),P=(n==null?void 0:n.gap)!=null;return c!=null&&!P&&(i.gap=N),m&&(i["--uds-flex-items-per-row"]=String(w)),d&&(n==null?void 0:n.width)==null&&(i.width="100%"),p(t,{ref:z,className:b,style:{...i,...n},...$,children:R})}),s=h.forwardRef(function({as:t="div",className:o,children:e,...l},f){const a=["uds-flex__full",o].filter(Boolean).join(" ");return p(t,{ref:f,className:a,...l,children:e})}),x=E;x.Fill=s;x.Full=s;const F=x;F.Fill=s;F.Full=s;export{F as Flex,x as Layout};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react/jsx-runtime");;/* empty css */const r="uds-link";function $({appearance:i="primary",underline:s="always",disabled:e=!1,className:l="",target:t,rel:a,href:u,onClick:n,tabIndex:c,children:f,...p}){const d=[r,`${r}--${i}`,`${r}--underline-${s}`,e&&`${r}--disabled`,l].filter(Boolean).join(" "),m=t==="_blank"?[a,"noopener","noreferrer"].filter(Boolean).join(" "):a,j=o=>{if(e){o.preventDefault(),o.stopPropagation();return}n==null||n(o)};return S.jsx("a",{className:d,href:e?void 0:u,target:t,rel:m||void 0,"aria-disabled":e||void 0,tabIndex:e?-1:c,onClick:j,...p,children:f})}exports.Link=$;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as $}from"react/jsx-runtime";/* empty css */const r="uds-link";function B({appearance:t="primary",underline:l="always",disabled:o=!1,className:s="",target:a,rel:i,href:f,onClick:n,tabIndex:p,children:c,...m}){const u=[r,`${r}--${t}`,`${r}--underline-${l}`,o&&`${r}--disabled`,s].filter(Boolean).join(" "),d=a==="_blank"?[i,"noopener","noreferrer"].filter(Boolean).join(" "):i;return $("a",{className:u,href:o?void 0:f,target:a,rel:d||void 0,"aria-disabled":o||void 0,tabIndex:o?-1:p,onClick:e=>{if(o){e.preventDefault(),e.stopPropagation();return}n==null||n(e)},...m,children:c})}export{B as Link};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react/jsx-runtime"),t=require("react");;/* empty css */const I=require("react-router-dom"),h=require("../Icon/Icon.cjs"),ce=require("../Avatar/Avatar.cjs"),j=require("../Button/Button.cjs"),oe=require("../TextInput/TextInput.cjs"),B=require("../Branding/Branding.cjs"),ue=require("../Dropdown/Dropdown.cjs"),de=require("../Toggle/Toggle.cjs"),me=require("../ActionMenu/ActionMenu.cjs"),_e=require("../Text/Text.cjs"),F=n=>{if(!n)return"/";const l=n.replace(/\/+$/,"");return l.length===0?"/":l},u=(n,l)=>{const f=F(n),b=F(l);return f===b||f.startsWith(`${b}/`)},pe=n=>n.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),he=n=>{if(typeof n!="object"||n===null)return!1;const l=n;return typeof l.label=="string"&&typeof l.path=="string"},fe=n=>{if(typeof n!="object"||n===null)return!1;const l=n;return!(typeof l.label!="string"||typeof l.icon!="string"||l.path!==void 0&&typeof l.path!="string"||l.children!==void 0&&(!Array.isArray(l.children)||!l.children.every(he)))},be=n=>n==="dark"?"dark":"light";function G({title:n,className:l="",navItems:f=[],brands:b=[],activeBrand:S,onBrandChange:$,activeMode:J,onModeChange:v,showBrand:U=!0,showSearch:V=!1,showBrandSwitcher:W=!0,showNav:H=!0,showModeToggle:K=!0,showUser:Q=!0,userName:C="Jane Doe",userInitials:X="JD",userAvatarSrc:Y,accountMenuItems:A=[],identity:Z="design-system",defaultExpanded:ee=!0}){var R;const y=t.useContext(I.UNSAFE_LocationContext),M=!!y,c=((R=y==null?void 0:y.location)==null?void 0:R.pathname)??(typeof window<"u"?window.location.pathname:"/"),[D,q]=t.useState({}),[r,T]=t.useState(ee),[N,ae]=t.useState(24),d=t.useMemo(()=>f.filter(fe),[f]),z=t.useMemo(()=>b.filter(e=>typeof e=="string"),[b]),ne=typeof n=="string"?n:"Menu",w=typeof S=="string"?S:z[0],L=w==="default"?"design-system":w??Z,_=be(J),se=t.useMemo(()=>Array.isArray(A)?A:[],[A]);t.useEffect(()=>{if(d.length<=N)return;const e=()=>ae(d.length);if(typeof requestIdleCallback=="function"){const o=requestIdleCallback(e);return()=>cancelIdleCallback(o)}const s=window.setTimeout(e,50);return()=>window.clearTimeout(s)},[d.length,N]),t.useEffect(()=>{const e=d.filter(s=>Array.isArray(s.children)&&s.children.some(o=>c===o.path)).map(s=>s.label);e.length!==0&&q(s=>{let o=!1;const m={...s};return e.forEach(g=>{m[g]||(m[g]=!0,o=!0)}),o?m:s})},[d,c]);const P=t.useCallback(e=>{q(s=>({...s,[e]:!s[e]}))},[]),te=t.useCallback(()=>T(e=>!e),[]),p=t.useCallback(()=>T(!0),[]),le=t.useCallback(e=>{r||(e.preventDefault(),e.stopPropagation(),p())},[p,r]),E=t.useCallback(e=>{if(!r){p(),q(s=>({...s,[e]:!0}));return}P(e)},[p,r,P]),x=t.useCallback(()=>{r||p()},[p,r]),O=t.useCallback(e=>v==null?void 0:v(e),[v]),re=t.useMemo(()=>d.slice(0,N).map(e=>{const s=e.children??[],o=s.length>0,m=D[e.label],g=r&&m,ie=o&&s.some(k=>u(c,k.path));if(o){const k=`uds-menu-accordion-${pe(e.label)}`;return a.jsxs("div",{className:`uds-menu_nav__item uds-menu_nav__item--accordion${m?" uds-menu_nav__item--open":""}${ie?" uds-menu_nav__item--active":""}`,children:[a.jsxs("button",{type:"button",className:"uds-menu_nav__item-link",onClick:()=>E(e.label),title:e.label,"aria-expanded":g,"aria-controls":k,children:[a.jsx("span",{className:"uds-menu_nav__item-icon",children:a.jsx(h.default,{name:e.icon,size:24,appearance:"duotone"})}),a.jsx("div",{className:"uds-menu_nav__item-label",children:e.label}),a.jsx("span",{className:`uds-menu_nav__item-caret${m?" uds-menu_nav__item-caret--open":""}`,children:a.jsx(h.default,{name:"CaretDown",size:16})})]}),g?a.jsx("div",{id:k,className:"uds-menu_nav__children uds-menu_nav__children--open",children:s.map(i=>M?a.jsx(I.Link,{className:`uds-menu_nav__child-link${u(c,i.path)?" uds-menu_nav__child-link--active":""}`,to:i.path,onClick:x,title:i.label,"aria-current":u(c,i.path)?"page":void 0,children:i.label},i.path):a.jsx("a",{className:`uds-menu_nav__child-link${u(c,i.path)?" uds-menu_nav__child-link--active":""}`,href:i.path,onClick:x,title:i.label,"aria-current":u(c,i.path)?"page":void 0,children:i.label},i.path))}):null]},e.label)}return a.jsx("div",{className:`uds-menu_nav__item${typeof e.path=="string"&&u(c,e.path)?" uds-menu_nav__item--active":""}`,children:M?a.jsxs(I.Link,{className:"uds-menu_nav__item-link",to:e.path??"/",onClick:x,title:e.label,"aria-current":typeof e.path=="string"&&u(c,e.path)?"page":void 0,children:[a.jsx("span",{className:"uds-menu_nav__item-icon",children:a.jsx(h.default,{name:e.icon,size:24,appearance:"duotone"})}),a.jsx("div",{className:"uds-menu_nav__item-label",children:e.label})]}):a.jsxs("a",{className:"uds-menu_nav__item-link",href:e.path??"/",onClick:x,title:e.label,"aria-current":typeof e.path=="string"&&u(c,e.path)?"page":void 0,children:[a.jsx("span",{className:"uds-menu_nav__item-icon",children:a.jsx(h.default,{name:e.icon,size:24,appearance:"duotone"})}),a.jsx("div",{className:"uds-menu_nav__item-label",children:e.label})]})},e.path??e.label)}),[d,N,D,r,E,x,M,c]);return a.jsxs("aside",{className:`uds-menu${r?" uds-menu--expanded":""} ${l}`,"aria-label":ne,onClickCapture:le,children:[U&&a.jsxs("div",{className:"uds-menu_brand",children:[a.jsx(j.default,{appearance:"text",icon:"List",size:"default",label:r?"Collapse menu":"Expand menu",layout:"icon-only","aria-label":r?"Collapse menu":"Expand menu",className:"uds-menu_brand__toggle",onClick:te}),a.jsx("div",{className:"uds-menu_brand__symbol",children:a.jsx(B.default,{brand:L,symbol:!0})}),a.jsx("div",{className:"uds-menu_brand__full",children:a.jsx(B.default,{brand:L})})]}),V&&a.jsxs("div",{className:"uds-menu_search",children:[a.jsx(j.default,{appearance:"text",icon:"MagnifyingGlass",label:"Search",layout:"icon-only","aria-label":"Search",className:"uds-menu_search__button"}),a.jsx("div",{className:"uds-menu_search__field",children:a.jsx(oe.default,{type:"text",placeholder:"Search",icon:"MagnifyingGlass",iconPosition:"right",className:"uds-menu_search__input",size:"compact"})})]}),W&&z.length>0&&$&&a.jsxs("div",{className:"uds-menu_brands",children:[a.jsx(j.default,{appearance:"text",icon:"PlusCircle",label:"Brand",layout:"icon-only","aria-label":"Switch brand",className:"uds-menu_brands__button"}),a.jsx("div",{className:"uds-menu_brands__dropdown",children:a.jsx(ue.default,{options:z.map(e=>({value:e,label:e})),value:w,onChange:e=>{typeof e=="string"&&$(e)},placeholder:"Select brand",placement:"bottom-start",size:"compact"})})]}),H&&a.jsx("nav",{className:"uds-menu_nav",children:re}),K&&v&&a.jsx("div",{className:"uds-menu_footer",children:a.jsxs("div",{className:"uds-menu_mode",children:[a.jsx(j.default,{appearance:"text",icon:_==="light"?"Sun":"Moon",label:_==="light"?"Light mode":"Dark mode",layout:"icon-only",size:"default","aria-label":"Toggle light/dark mode",className:"uds-menu_mode__button",onClick:()=>O(_==="light"?"dark":"light")}),a.jsxs("div",{className:"uds-menu_mode__controls",children:[a.jsx(h.default,{name:_==="light"?"Sun":"Moon",size:20,appearance:"duotone"}),a.jsx("span",{className:"uds-menu_mode__label",children:_==="light"?"Light":"Dark"}),a.jsx(de.default,{checked:_==="dark",onChange:e=>O(e?"dark":"light"),className:"uds-menu_mode__toggle"})]})]})}),Q&&a.jsxs("div",{className:"uds-menu_account",children:[a.jsx(ce.default,{src:Y,initials:X,alt:C?`${C} avatar`:"User avatar",size:"default"}),r&&a.jsxs(a.Fragment,{children:[a.jsx(_e.Text,{as:"p",variant:"body-16",weight:"semibold",leading:"regular",className:"uds-menu_account__name",children:C}),a.jsx(me.default,{placement:"top-start",items:se,trigger:a.jsx(j.default,{appearance:"text",icon:a.jsx(h.default,{name:"DotsThreeVertical",appearance:"bold"}),label:"Account Menu",layout:"icon-only","aria-label":"Account menu"})})]})]})]})}G.defaultProps={title:"Menu"};const ve=t.memo(G);exports.default=ve;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as i,jsx as n,Fragment as
|
|
1
|
+
import{jsxs as i,jsx as n,Fragment as pe}from"react/jsx-runtime";import W,{useState as L,useMemo as M,useEffect as G,useCallback as p}from"react";/* empty css */import{UNSAFE_LocationContext as _e,Link as J}from"react-router-dom";import f from"../Icon/Icon.js";import he from"../Avatar/Avatar.js";import k from"../Button/Button.js";import fe from"../TextInput/TextInput.js";import U from"../Branding/Branding.js";import ve from"../Dropdown/Dropdown.js";import be from"../Toggle/Toggle.js";import ge from"../ActionMenu/ActionMenu.js";import{Text as ye}from"../Text/Text.js";const V=a=>{if(!a)return"/";const s=a.replace(/\/+$/,"");return s.length===0?"/":s},d=(a,s)=>{const v=V(a),b=V(s);return v===b||v.startsWith(`${b}/`)},Ne=a=>a.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),ke=a=>{if(typeof a!="object"||a===null)return!1;const s=a;return typeof s.label=="string"&&typeof s.path=="string"},Ce=a=>{if(typeof a!="object"||a===null)return!1;const s=a;return!(typeof s.label!="string"||typeof s.icon!="string"||s.path!==void 0&&typeof s.path!="string"||s.children!==void 0&&(!Array.isArray(s.children)||!s.children.every(ke)))},Ae=a=>a==="dark"?"dark":"light";function H({title:a,className:s="",navItems:v=[],brands:b=[],activeBrand:P,onBrandChange:T,activeMode:K,onModeChange:g,showBrand:Q=!0,showSearch:X=!1,showBrandSwitcher:Y=!0,showNav:Z=!0,showModeToggle:ee=!0,showUser:ne=!0,userName:z="Jane Doe",userInitials:ae="JD",userAvatarSrc:te,accountMenuItems:w=[],identity:se="design-system",defaultExpanded:le=!0}){var F;const C=W.useContext(_e),I=!!C,o=((F=C==null?void 0:C.location)==null?void 0:F.pathname)??(typeof window<"u"?window.location.pathname:"/"),[E,$]=L({}),[l,j]=L(le),[A,re]=L(24),u=M(()=>v.filter(Ce),[v]),D=M(()=>b.filter(e=>typeof e=="string"),[b]),ie=typeof a=="string"?a:"Menu",S=typeof P=="string"?P:D[0],B=S==="default"?"design-system":S??se,_=Ae(K),oe=M(()=>Array.isArray(w)?w:[],[w]);G(()=>{if(u.length<=A)return;const e=()=>re(u.length);if(typeof requestIdleCallback=="function"){const c=requestIdleCallback(e);return()=>cancelIdleCallback(c)}const t=window.setTimeout(e,50);return()=>window.clearTimeout(t)},[u.length,A]),G(()=>{const e=u.filter(t=>Array.isArray(t.children)&&t.children.some(c=>o===c.path)).map(t=>t.label);e.length!==0&&$(t=>{let c=!1;const m={...t};return e.forEach(N=>{m[N]||(m[N]=!0,c=!0)}),c?m:t})},[u,o]);const O=p(e=>{$(t=>({...t,[e]:!t[e]}))},[]),ce=p(()=>j(e=>!e),[]),h=p(()=>j(!0),[]),de=p(e=>{l||(e.preventDefault(),e.stopPropagation(),h())},[h,l]),R=p(e=>{if(!l){h(),$(t=>({...t,[e]:!0}));return}O(e)},[h,l,O]),y=p(()=>{l||h()},[h,l]),q=p(e=>g==null?void 0:g(e),[g]),ue=M(()=>u.slice(0,A).map(e=>{const t=e.children??[],c=t.length>0,m=E[e.label],N=l&&m,me=c&&t.some(x=>d(o,x.path));if(c){const x=`uds-menu-accordion-${Ne(e.label)}`;return i("div",{className:`uds-menu_nav__item uds-menu_nav__item--accordion${m?" uds-menu_nav__item--open":""}${me?" uds-menu_nav__item--active":""}`,children:[i("button",{type:"button",className:"uds-menu_nav__item-link",onClick:()=>R(e.label),title:e.label,"aria-expanded":N,"aria-controls":x,children:[n("span",{className:"uds-menu_nav__item-icon",children:n(f,{name:e.icon,size:24,appearance:"duotone"})}),n("div",{className:"uds-menu_nav__item-label",children:e.label}),n("span",{className:`uds-menu_nav__item-caret${m?" uds-menu_nav__item-caret--open":""}`,children:n(f,{name:"CaretDown",size:16})})]}),N?n("div",{id:x,className:"uds-menu_nav__children uds-menu_nav__children--open",children:t.map(r=>I?n(J,{className:`uds-menu_nav__child-link${d(o,r.path)?" uds-menu_nav__child-link--active":""}`,to:r.path,onClick:y,title:r.label,"aria-current":d(o,r.path)?"page":void 0,children:r.label},r.path):n("a",{className:`uds-menu_nav__child-link${d(o,r.path)?" uds-menu_nav__child-link--active":""}`,href:r.path,onClick:y,title:r.label,"aria-current":d(o,r.path)?"page":void 0,children:r.label},r.path))}):null]},e.label)}return n("div",{className:`uds-menu_nav__item${typeof e.path=="string"&&d(o,e.path)?" uds-menu_nav__item--active":""}`,children:I?i(J,{className:"uds-menu_nav__item-link",to:e.path??"/",onClick:y,title:e.label,"aria-current":typeof e.path=="string"&&d(o,e.path)?"page":void 0,children:[n("span",{className:"uds-menu_nav__item-icon",children:n(f,{name:e.icon,size:24,appearance:"duotone"})}),n("div",{className:"uds-menu_nav__item-label",children:e.label})]}):i("a",{className:"uds-menu_nav__item-link",href:e.path??"/",onClick:y,title:e.label,"aria-current":typeof e.path=="string"&&d(o,e.path)?"page":void 0,children:[n("span",{className:"uds-menu_nav__item-icon",children:n(f,{name:e.icon,size:24,appearance:"duotone"})}),n("div",{className:"uds-menu_nav__item-label",children:e.label})]})},e.path??e.label)}),[u,A,E,l,R,y,I,o]);return i("aside",{className:`uds-menu${l?" uds-menu--expanded":""} ${s}`,"aria-label":ie,onClickCapture:de,children:[Q&&i("div",{className:"uds-menu_brand",children:[n(k,{appearance:"text",icon:"List",size:"default",label:l?"Collapse menu":"Expand menu",layout:"icon-only","aria-label":l?"Collapse menu":"Expand menu",className:"uds-menu_brand__toggle",onClick:ce}),n("div",{className:"uds-menu_brand__symbol",children:n(U,{brand:B,symbol:!0})}),n("div",{className:"uds-menu_brand__full",children:n(U,{brand:B})})]}),X&&i("div",{className:"uds-menu_search",children:[n(k,{appearance:"text",icon:"MagnifyingGlass",label:"Search",layout:"icon-only","aria-label":"Search",className:"uds-menu_search__button"}),n("div",{className:"uds-menu_search__field",children:n(fe,{type:"text",placeholder:"Search",icon:"MagnifyingGlass",iconPosition:"right",className:"uds-menu_search__input",size:"compact"})})]}),Y&&D.length>0&&T&&i("div",{className:"uds-menu_brands",children:[n(k,{appearance:"text",icon:"PlusCircle",label:"Brand",layout:"icon-only","aria-label":"Switch brand",className:"uds-menu_brands__button"}),n("div",{className:"uds-menu_brands__dropdown",children:n(ve,{options:D.map(e=>({value:e,label:e})),value:S,onChange:e=>{typeof e=="string"&&T(e)},placeholder:"Select brand",placement:"bottom-start",size:"compact"})})]}),Z&&n("nav",{className:"uds-menu_nav",children:ue}),ee&&g&&n("div",{className:"uds-menu_footer",children:i("div",{className:"uds-menu_mode",children:[n(k,{appearance:"text",icon:_==="light"?"Sun":"Moon",label:_==="light"?"Light mode":"Dark mode",layout:"icon-only",size:"default","aria-label":"Toggle light/dark mode",className:"uds-menu_mode__button",onClick:()=>q(_==="light"?"dark":"light")}),i("div",{className:"uds-menu_mode__controls",children:[n(f,{name:_==="light"?"Sun":"Moon",size:20,appearance:"duotone"}),n("span",{className:"uds-menu_mode__label",children:_==="light"?"Light":"Dark"}),n(be,{checked:_==="dark",onChange:e=>q(e?"dark":"light"),className:"uds-menu_mode__toggle"})]})]})}),ne&&i("div",{className:"uds-menu_account",children:[n(he,{src:te,initials:ae,alt:z?`${z} avatar`:"User avatar",size:"default"}),l&&i(pe,{children:[n(ye,{as:"p",variant:"body-16",weight:"semibold",leading:"regular",className:"uds-menu_account__name",children:z}),n(ge,{placement:"top-start",items:oe,trigger:n(k,{appearance:"text",icon:n(f,{name:"DotsThreeVertical",appearance:"bold"}),label:"Account Menu",layout:"icon-only","aria-label":"Account menu"})})]})]})]})}H.defaultProps={title:"Menu"};const Be=W.memo(H);export{Be as default};
|