@langchain/macaw-components 1.0.0-beta.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/_chunks/{ErrorState-CmPX01HV.js → ErrorState-BY6VBCRB.js} +2 -2
- package/dist/_chunks/{ErrorState-CmPX01HV.js.map → ErrorState-BY6VBCRB.js.map} +1 -1
- package/dist/_chunks/{LoadingIndicator-DujSAzqj.js → LoadingIndicator-Itl4c0WV.js} +10 -10
- package/dist/_chunks/LoadingIndicator-Itl4c0WV.js.map +1 -0
- package/dist/base.css +19 -6
- package/dist/catalog.json +493 -480
- package/dist/components/BarChart/AnimatedBar.js +1 -1
- package/dist/components/BarChart/AnimatedBar.js.map +1 -1
- package/dist/components/BarChart/BarChartPlot.js +1 -1
- package/dist/components/BarChart/BarChartPlot.js.map +1 -1
- package/dist/components/Button/constants.js +4 -4
- package/dist/components/Button/constants.js.map +1 -1
- package/dist/components/ChartLegend/ChartLegend.js +1 -1
- package/dist/components/ChartLegend/ChartLegend.js.map +1 -1
- package/dist/components/ChartLegend/ChartLegendItemRenderer.js +2 -2
- package/dist/components/ChartLegend/ChartLegendItemRenderer.js.map +1 -1
- package/dist/components/ChartTooltip/ChartTooltip.js +2 -2
- package/dist/components/ChartTooltip/ChartTooltip.js.map +1 -1
- package/dist/components/Checkbox/constants.d.ts +1 -1
- package/dist/components/Checkbox/constants.js +1 -1
- package/dist/components/Checkbox/constants.js.map +1 -1
- package/dist/components/Code/CodeLite.js +2 -2
- package/dist/components/Code/CodeLite.js.map +1 -1
- package/dist/components/Code/JsonHighlighterExtension.js +1 -1
- package/dist/components/Code/JsonHighlighterExtension.js.map +1 -1
- package/dist/components/Command/Command.js +1 -1
- package/dist/components/Command/Command.js.map +1 -1
- package/dist/components/Command/CommandMenu.js +2 -2
- package/dist/components/Command/CommandMenu.js.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.js +2 -2
- package/dist/components/ContextMenu/ContextMenu.js.map +1 -1
- package/dist/components/CopyButton/CopyButton.d.ts +3 -2
- package/dist/components/CopyButton/CopyButton.js +5 -0
- package/dist/components/CopyButton/CopyButton.js.map +1 -1
- package/dist/components/Dialog/index.d.ts +3 -2
- package/dist/components/Dialog/index.js +44 -17
- package/dist/components/Dialog/index.js.map +1 -1
- package/dist/components/DonutChart/DonutChart.js +1 -1
- package/dist/components/DonutChart/DonutChart.js.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.js +3 -3
- package/dist/components/DropdownMenu/DropdownMenu.js.map +1 -1
- package/dist/components/ErrorState/ErrorState.js +1 -1
- package/dist/components/ErrorState/index.js +1 -1
- package/dist/components/GroupedTabs/GroupedTabs.d.ts +3 -2
- package/dist/components/GroupedTabs/GroupedTabs.js +3 -1
- package/dist/components/GroupedTabs/GroupedTabs.js.map +1 -1
- package/dist/components/Input/Input.js +7 -6
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/Input/inputStyles.js +5 -5
- package/dist/components/Input/inputStyles.js.map +1 -1
- package/dist/components/Link/Link.js +3 -3
- package/dist/components/Link/Link.js.map +1 -1
- package/dist/components/Pane/Pane.d.ts +3 -2
- package/dist/components/Pane/Pane.js +107 -101
- package/dist/components/Pane/Pane.js.map +1 -1
- package/dist/components/Popover/Popover.js +15 -4
- package/dist/components/Popover/Popover.js.map +1 -1
- package/dist/components/Popover/constants.d.ts +1 -1
- package/dist/components/Popover/constants.js +1 -1
- package/dist/components/Popover/constants.js.map +1 -1
- package/dist/components/RadioButton/constants.d.ts +1 -1
- package/dist/components/RadioButton/constants.js +1 -1
- package/dist/components/RadioButton/constants.js.map +1 -1
- package/dist/components/RadioGroup/RadioGroupItem.js +1 -1
- package/dist/components/RadioGroup/RadioGroupItem.js.map +1 -1
- package/dist/components/SankeyChart/AnimatedSankeyLink.js +1 -1
- package/dist/components/SankeyChart/AnimatedSankeyLink.js.map +1 -1
- package/dist/components/SankeyChart/AnimatedSankeyNode.js +1 -1
- package/dist/components/SankeyChart/AnimatedSankeyNode.js.map +1 -1
- package/dist/components/Select/Select.d.ts +2 -1
- package/dist/components/Select/Select.js +5 -3
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Select/SelectPrimitive.js +6 -4
- package/dist/components/Select/SelectPrimitive.js.map +1 -1
- package/dist/components/Slider/Slider.js +1 -1
- package/dist/components/Slider/Slider.js.map +1 -1
- package/dist/components/SplitViewPane/SplitViewPane.js +1 -1
- package/dist/components/SplitViewPane/SplitViewPane.js.map +1 -1
- package/dist/components/Switch/Switch.js +1 -1
- package/dist/components/Switch/Switch.js.map +1 -1
- package/dist/components/Tabs/index.d.ts +3 -2
- package/dist/components/Tabs/index.js +5 -3
- package/dist/components/Tabs/index.js.map +1 -1
- package/dist/components/Textarea/Textarea.js +9 -9
- package/dist/components/Textarea/Textarea.js.map +1 -1
- package/dist/components/ThinkingState/LoadingIndicator.js +1 -1
- package/dist/components/ThinkingState/ThinkingState.js +1 -1
- package/dist/components/ThinkingState/index.js +1 -1
- package/dist/components/Toast/index.js +2 -2
- package/dist/components/Toast/index.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.js +1 -1
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/Typeahead/TypeaheadParts.js +1 -1
- package/dist/components/Typeahead/TypeaheadParts.js.map +1 -1
- package/dist/components/Typeahead/TypeaheadView.js +9 -9
- package/dist/components/Typeahead/TypeaheadView.js.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components.css +2 -105
- package/dist/index.js +1 -1
- package/dist/utilities.css +2 -2
- package/dist/utils/ModalLayerContext.d.ts +23 -0
- package/dist/utils/ModalLayerContext.js +92 -0
- package/dist/utils/ModalLayerContext.js.map +1 -0
- package/dist/utils/cn.js +21 -11
- package/dist/utils/cn.js.map +1 -1
- package/dist/utils/dataAttributes.d.ts +9 -0
- package/dist/utils/dataAttributes.js +13 -0
- package/dist/utils/dataAttributes.js.map +1 -0
- package/docs/DESIGN.md +33 -3
- package/docs/STYLES.md +96 -46
- package/package.json +10 -9
- package/tailwind.preset.cjs +292 -332
- package/dist/_chunks/LoadingIndicator-DujSAzqj.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonHighlighterExtension.js","names":[],"sources":["../../../src/components/Code/JsonHighlighterExtension.ts"],"sourcesContent":["import type { Extension } from '@codemirror/state';\nimport type {\n Decoration,\n DecorationSet,\n EditorView,\n ViewUpdate,\n} from '@codemirror/view';\nimport type { SyntaxNodeRef } from '@lezer/common';\n\nimport type { CMBundle } from '../../utils/lazy-codemirror-loader';\n\ntype NodeInfo = { from: number; to: number; name: string };\ntype DecoratedRange = { from: number; to: number; decoration: Decoration };\n\ntype PathSegment = {\n type: 'property' | 'index' | 'wildcard';\n value: string | number;\n};\n\n/** Highlights JSON values referenced by variable mappings. */\nexport function createJsonHighlighterExtension(\n cm: CMBundle,\n variableMapping: Record<string, string | null>,\n dataType: 'input' | 'output' | 'referenceOutput',\n activeVariable: string | null\n): Extension {\n const { Decoration, ViewPlugin, syntaxTree } = cm;\n return ViewPlugin.fromClass(\n class {\n decorations: DecorationSet;\n\n constructor(view: EditorView) {\n this.decorations = this.getDecorations(view);\n }\n\n getDecorations(view: EditorView): DecorationSet {\n // Match the full data type or a path nested beneath it.\n const relevantMappings = Object.entries(variableMapping).filter(\n ([, path]) => path === dataType || path?.startsWith(`${dataType}.`)\n );\n\n if (relevantMappings.length === 0) {\n return Decoration.none;\n }\n\n const ranges: DecoratedRange[] = [];\n\n for (const [variableName, path] of relevantMappings) {\n if (!path) continue;\n\n const isActiveVariable = activeVariable === variableName;\n\n const highlightClass = isActiveVariable\n ? 'bg-yellow-200 dark:bg-yellow-800'\n : 'bg-green-100 dark:bg-green-950';\n\n if (path === dataType) {\n this.addDecoration(\n ranges,\n 0,\n view.state.doc.length,\n highlightClass\n );\n continue;\n }\n\n // Strip the data type and separator from the stored path.\n const actualPath = path.substring(dataType.length + 1);\n const pathSegments = this.parseJsonPath(actualPath);\n\n this.findMatchingNodes(view, pathSegments, ranges, highlightClass);\n }\n\n return Decoration.set(\n ranges.map(({ from, to, decoration }) =>\n Decoration.mark({\n class: decoration.spec.class as string,\n }).range(from, to)\n )\n );\n }\n\n /** Parses property, array-index, and wildcard path segments. */\n parseJsonPath(path: string): PathSegment[] {\n const segments: PathSegment[] = [];\n let currentSegment = '';\n let inBracket = false;\n\n for (let i = 0; i < path.length; i++) {\n const char = path[i];\n\n if (char === '.' && !inBracket) {\n if (currentSegment) {\n segments.push({ type: 'property', value: currentSegment });\n currentSegment = '';\n }\n } else if (char === '[') {\n if (currentSegment) {\n segments.push({ type: 'property', value: currentSegment });\n currentSegment = '';\n }\n inBracket = true;\n } else if (char === ']' && inBracket) {\n if (currentSegment) {\n if (currentSegment === '*') {\n segments.push({ type: 'wildcard', value: '*' });\n } else {\n const index = parseInt(currentSegment, 10);\n segments.push({\n type: 'index',\n value: isNaN(index) ? currentSegment : index,\n });\n }\n currentSegment = '';\n }\n inBracket = false;\n } else {\n currentSegment += char;\n }\n }\n\n if (currentSegment) {\n const numericIndex = parseInt(currentSegment, 10);\n if (currentSegment === '*') {\n segments.push({ type: 'wildcard', value: '*' });\n } else if (\n !isNaN(numericIndex) &&\n numericIndex.toString() === currentSegment\n ) {\n segments.push({ type: 'index', value: numericIndex });\n } else {\n segments.push({ type: 'property', value: currentSegment });\n }\n }\n\n return segments;\n }\n\n findMatchingNodes(\n view: EditorView,\n pathSegments: PathSegment[],\n ranges: DecoratedRange[],\n highlightClass: string,\n currentDepth = 0,\n parentFrom = 0,\n parentTo = view.state.doc.length\n ): void {\n const currentSegment = pathSegments[currentDepth];\n if (!currentSegment) return;\n\n const tree = syntaxTree(view.state);\n\n tree.iterate({\n from: parentFrom,\n to: parentTo,\n enter: (node) => {\n if (\n currentSegment.type === 'property' &&\n node.name === 'Property'\n ) {\n const { keyNode, valueNode } = this.extractPropertyNodes(node);\n\n if (!keyNode) return;\n\n const keyName = this.extractKeyName(view, keyNode);\n\n if (keyName !== currentSegment.value) return;\n\n if (currentDepth === pathSegments.length - 1 && valueNode) {\n this.addDecoration(\n ranges,\n valueNode.from,\n valueNode.to,\n highlightClass\n );\n } else if (currentDepth < pathSegments.length - 1 && valueNode) {\n if (valueNode.name === 'Object' || valueNode.name === 'Array') {\n this.findMatchingNodes(\n view,\n pathSegments,\n ranges,\n highlightClass,\n currentDepth + 1,\n valueNode.from,\n valueNode.to\n );\n }\n }\n } else if (\n (currentSegment.type === 'index' ||\n currentSegment.type === 'wildcard') &&\n node.name === 'Array'\n ) {\n const elements = this.extractArrayElements(node);\n if (currentSegment.type === 'index') {\n const targetIndex = currentSegment.value as number;\n\n // Negative indices address elements from the end of the array.\n const resolvedIndex =\n targetIndex >= 0\n ? targetIndex\n : elements.length + targetIndex;\n\n if (resolvedIndex < 0 || resolvedIndex >= elements.length) {\n return;\n }\n\n const targetElement = elements[resolvedIndex];\n\n if (currentDepth === pathSegments.length - 1) {\n this.addDecoration(\n ranges,\n targetElement.from,\n targetElement.to,\n highlightClass\n );\n } else if (currentDepth < pathSegments.length - 1) {\n this.findMatchingNodes(\n view,\n pathSegments,\n ranges,\n highlightClass,\n currentDepth + 1,\n targetElement.from,\n targetElement.to\n );\n }\n } else if (currentSegment.type === 'wildcard') {\n elements.forEach((element) => {\n if (currentDepth === pathSegments.length - 1) {\n this.addDecoration(\n ranges,\n element.from,\n element.to,\n highlightClass\n );\n } else if (currentDepth < pathSegments.length - 1) {\n this.findMatchingNodes(\n view,\n pathSegments,\n ranges,\n highlightClass,\n currentDepth + 1,\n element.from,\n element.to\n );\n }\n });\n }\n }\n },\n });\n }\n\n private extractArrayElements(arrayNode: SyntaxNodeRef): NodeInfo[] {\n const elements: NodeInfo[] = [];\n\n const cursor = arrayNode.node.cursor();\n\n if (cursor.firstChild()) {\n if (cursor.nextSibling()) {\n do {\n if (\n cursor.name === 'Expression' ||\n cursor.name === 'Number' ||\n cursor.name === 'String' ||\n cursor.name === 'True' ||\n cursor.name === 'False' ||\n cursor.name === 'Null' ||\n cursor.name === 'Array' ||\n cursor.name === 'Object'\n ) {\n elements.push({\n from: cursor.from,\n to: cursor.to,\n name: cursor.name,\n });\n }\n } while (cursor.nextSibling());\n }\n }\n\n return elements;\n }\n\n private extractPropertyNodes(node: SyntaxNodeRef): {\n keyNode?: NodeInfo;\n valueNode?: NodeInfo;\n } {\n let keyNode: NodeInfo | undefined;\n let valueNode: NodeInfo | undefined;\n\n const cursor = node.node.cursor();\n if (cursor.firstChild()) {\n do {\n if (cursor.name === 'PropertyName') {\n keyNode = {\n from: cursor.from,\n to: cursor.to,\n name: cursor.name,\n };\n } else if (\n cursor.name === 'Expression' ||\n cursor.name === 'Number' ||\n cursor.name === 'String' ||\n cursor.name === 'True' ||\n cursor.name === 'False' ||\n cursor.name === 'Null' ||\n cursor.name === 'Array' ||\n cursor.name === 'Object'\n ) {\n valueNode = {\n from: cursor.from,\n to: cursor.to,\n name: cursor.name,\n };\n }\n } while (cursor.nextSibling());\n }\n\n return { keyNode, valueNode };\n }\n\n private extractKeyName(view: EditorView, keyNode: NodeInfo): string {\n const keyText = view.state.doc.sliceString(keyNode.from, keyNode.to);\n return keyText.replace(/^[\"'](.*)[\"']$/, '$1');\n }\n\n private addDecoration(\n ranges: DecoratedRange[],\n from: number,\n to: number,\n highlightClass: string\n ): void {\n const decoration = Decoration.mark({\n class: highlightClass,\n });\n\n ranges.push({\n from,\n to,\n decoration,\n });\n }\n\n update(update: ViewUpdate) {\n if (update.docChanged || update.viewportChanged) {\n this.decorations = this.getDecorations(update.view);\n }\n }\n },\n {\n decorations: (v) => v.decorations,\n }\n );\n}\n"],"mappings":";;AAoBA,SAAgB,+BACd,IACA,iBACA,UACA,gBACW;CACX,MAAM,EAAE,YAAY,YAAY,eAAe;CAC/C,OAAO,WAAW,UAChB,MAAM;EACJ;EAEA,YAAY,MAAkB;GAC5B,KAAK,cAAc,KAAK,eAAe,IAAI;EAC7C;EAEA,eAAe,MAAiC;GAE9C,M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AO;KACb,IAAI,OAAO;KACX,MAAM,OAAO;IACf;SACK,IACL,OAAO,SAAS,gBAChB,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS,UAChB,OAAO,SAAS,WAChB,OAAO,SAAS,UAChB,OAAO,SAAS,WAChB,OAAO,SAAS,UAEhB,YAAY;KACV,MAAM,OAAO;KACb,IAAI,OAAO;KACX,MAAM,OAAO;IACf;UAEK,OAAO,YAAY;GAG9B,OAAO;IAAE;IAAS;GAAU;EAC9B;EAEA,eAAuB,MAAkB,SAA2B;GAElE,OADgB,KAAK,MAAM,IAAI,YAAY,QAAQ,MAAM,QAAQ,EAC1D,CAAA,CAAQ,QAAQ,kBAAkB,IAAI;EAC/C;EAEA,cACE,QACA,MACA,IACA,gBACM;GACN,MAAM,aAAa,WAAW,KAAK,EACjC,OAAO,eACT,CAAC;GAED,OAAO,KAAK;IACV;IACA;IACA;GACF,CAAC;EACH;EAEA,OAAO,QAAoB;GACzB,IAAI,OAAO,cAAc,OAAO,iBAC9B,KAAK,cAAc,KAAK,eAAe,OAAO,IAAI;EAEtD;CACF,GACA,EACE,cAAc,MAAM,EAAE,YACxB,CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"JsonHighlighterExtension.js","names":[],"sources":["../../../src/components/Code/JsonHighlighterExtension.ts"],"sourcesContent":["import type { Extension } from '@codemirror/state';\nimport type {\n Decoration,\n DecorationSet,\n EditorView,\n ViewUpdate,\n} from '@codemirror/view';\nimport type { SyntaxNodeRef } from '@lezer/common';\n\nimport type { CMBundle } from '../../utils/lazy-codemirror-loader';\n\ntype NodeInfo = { from: number; to: number; name: string };\ntype DecoratedRange = { from: number; to: number; decoration: Decoration };\n\ntype PathSegment = {\n type: 'property' | 'index' | 'wildcard';\n value: string | number;\n};\n\n/** Highlights JSON values referenced by variable mappings. */\nexport function createJsonHighlighterExtension(\n cm: CMBundle,\n variableMapping: Record<string, string | null>,\n dataType: 'input' | 'output' | 'referenceOutput',\n activeVariable: string | null\n): Extension {\n const { Decoration, ViewPlugin, syntaxTree } = cm;\n return ViewPlugin.fromClass(\n class {\n decorations: DecorationSet;\n\n constructor(view: EditorView) {\n this.decorations = this.getDecorations(view);\n }\n\n getDecorations(view: EditorView): DecorationSet {\n // Match the full data type or a path nested beneath it.\n const relevantMappings = Object.entries(variableMapping).filter(\n ([, path]) => path === dataType || path?.startsWith(`${dataType}.`)\n );\n\n if (relevantMappings.length === 0) {\n return Decoration.none;\n }\n\n const ranges: DecoratedRange[] = [];\n\n for (const [variableName, path] of relevantMappings) {\n if (!path) continue;\n\n const isActiveVariable = activeVariable === variableName;\n\n const highlightClass = isActiveVariable\n ? 'bg-warning-subtle dark:bg-warning'\n : 'bg-success-subtle dark:bg-success';\n\n if (path === dataType) {\n this.addDecoration(\n ranges,\n 0,\n view.state.doc.length,\n highlightClass\n );\n continue;\n }\n\n // Strip the data type and separator from the stored path.\n const actualPath = path.substring(dataType.length + 1);\n const pathSegments = this.parseJsonPath(actualPath);\n\n this.findMatchingNodes(view, pathSegments, ranges, highlightClass);\n }\n\n return Decoration.set(\n ranges.map(({ from, to, decoration }) =>\n Decoration.mark({\n class: decoration.spec.class as string,\n }).range(from, to)\n )\n );\n }\n\n /** Parses property, array-index, and wildcard path segments. */\n parseJsonPath(path: string): PathSegment[] {\n const segments: PathSegment[] = [];\n let currentSegment = '';\n let inBracket = false;\n\n for (let i = 0; i < path.length; i++) {\n const char = path[i];\n\n if (char === '.' && !inBracket) {\n if (currentSegment) {\n segments.push({ type: 'property', value: currentSegment });\n currentSegment = '';\n }\n } else if (char === '[') {\n if (currentSegment) {\n segments.push({ type: 'property', value: currentSegment });\n currentSegment = '';\n }\n inBracket = true;\n } else if (char === ']' && inBracket) {\n if (currentSegment) {\n if (currentSegment === '*') {\n segments.push({ type: 'wildcard', value: '*' });\n } else {\n const index = parseInt(currentSegment, 10);\n segments.push({\n type: 'index',\n value: isNaN(index) ? currentSegment : index,\n });\n }\n currentSegment = '';\n }\n inBracket = false;\n } else {\n currentSegment += char;\n }\n }\n\n if (currentSegment) {\n const numericIndex = parseInt(currentSegment, 10);\n if (currentSegment === '*') {\n segments.push({ type: 'wildcard', value: '*' });\n } else if (\n !isNaN(numericIndex) &&\n numericIndex.toString() === currentSegment\n ) {\n segments.push({ type: 'index', value: numericIndex });\n } else {\n segments.push({ type: 'property', value: currentSegment });\n }\n }\n\n return segments;\n }\n\n findMatchingNodes(\n view: EditorView,\n pathSegments: PathSegment[],\n ranges: DecoratedRange[],\n highlightClass: string,\n currentDepth = 0,\n parentFrom = 0,\n parentTo = view.state.doc.length\n ): void {\n const currentSegment = pathSegments[currentDepth];\n if (!currentSegment) return;\n\n const tree = syntaxTree(view.state);\n\n tree.iterate({\n from: parentFrom,\n to: parentTo,\n enter: (node) => {\n if (\n currentSegment.type === 'property' &&\n node.name === 'Property'\n ) {\n const { keyNode, valueNode } = this.extractPropertyNodes(node);\n\n if (!keyNode) return;\n\n const keyName = this.extractKeyName(view, keyNode);\n\n if (keyName !== currentSegment.value) return;\n\n if (currentDepth === pathSegments.length - 1 && valueNode) {\n this.addDecoration(\n ranges,\n valueNode.from,\n valueNode.to,\n highlightClass\n );\n } else if (currentDepth < pathSegments.length - 1 && valueNode) {\n if (valueNode.name === 'Object' || valueNode.name === 'Array') {\n this.findMatchingNodes(\n view,\n pathSegments,\n ranges,\n highlightClass,\n currentDepth + 1,\n valueNode.from,\n valueNode.to\n );\n }\n }\n } else if (\n (currentSegment.type === 'index' ||\n currentSegment.type === 'wildcard') &&\n node.name === 'Array'\n ) {\n const elements = this.extractArrayElements(node);\n if (currentSegment.type === 'index') {\n const targetIndex = currentSegment.value as number;\n\n // Negative indices address elements from the end of the array.\n const resolvedIndex =\n targetIndex >= 0\n ? targetIndex\n : elements.length + targetIndex;\n\n if (resolvedIndex < 0 || resolvedIndex >= elements.length) {\n return;\n }\n\n const targetElement = elements[resolvedIndex];\n\n if (currentDepth === pathSegments.length - 1) {\n this.addDecoration(\n ranges,\n targetElement.from,\n targetElement.to,\n highlightClass\n );\n } else if (currentDepth < pathSegments.length - 1) {\n this.findMatchingNodes(\n view,\n pathSegments,\n ranges,\n highlightClass,\n currentDepth + 1,\n targetElement.from,\n targetElement.to\n );\n }\n } else if (currentSegment.type === 'wildcard') {\n elements.forEach((element) => {\n if (currentDepth === pathSegments.length - 1) {\n this.addDecoration(\n ranges,\n element.from,\n element.to,\n highlightClass\n );\n } else if (currentDepth < pathSegments.length - 1) {\n this.findMatchingNodes(\n view,\n pathSegments,\n ranges,\n highlightClass,\n currentDepth + 1,\n element.from,\n element.to\n );\n }\n });\n }\n }\n },\n });\n }\n\n private extractArrayElements(arrayNode: SyntaxNodeRef): NodeInfo[] {\n const elements: NodeInfo[] = [];\n\n const cursor = arrayNode.node.cursor();\n\n if (cursor.firstChild()) {\n if (cursor.nextSibling()) {\n do {\n if (\n cursor.name === 'Expression' ||\n cursor.name === 'Number' ||\n cursor.name === 'String' ||\n cursor.name === 'True' ||\n cursor.name === 'False' ||\n cursor.name === 'Null' ||\n cursor.name === 'Array' ||\n cursor.name === 'Object'\n ) {\n elements.push({\n from: cursor.from,\n to: cursor.to,\n name: cursor.name,\n });\n }\n } while (cursor.nextSibling());\n }\n }\n\n return elements;\n }\n\n private extractPropertyNodes(node: SyntaxNodeRef): {\n keyNode?: NodeInfo;\n valueNode?: NodeInfo;\n } {\n let keyNode: NodeInfo | undefined;\n let valueNode: NodeInfo | undefined;\n\n const cursor = node.node.cursor();\n if (cursor.firstChild()) {\n do {\n if (cursor.name === 'PropertyName') {\n keyNode = {\n from: cursor.from,\n to: cursor.to,\n name: cursor.name,\n };\n } else if (\n cursor.name === 'Expression' ||\n cursor.name === 'Number' ||\n cursor.name === 'String' ||\n cursor.name === 'True' ||\n cursor.name === 'False' ||\n cursor.name === 'Null' ||\n cursor.name === 'Array' ||\n cursor.name === 'Object'\n ) {\n valueNode = {\n from: cursor.from,\n to: cursor.to,\n name: cursor.name,\n };\n }\n } while (cursor.nextSibling());\n }\n\n return { keyNode, valueNode };\n }\n\n private extractKeyName(view: EditorView, keyNode: NodeInfo): string {\n const keyText = view.state.doc.sliceString(keyNode.from, keyNode.to);\n return keyText.replace(/^[\"'](.*)[\"']$/, '$1');\n }\n\n private addDecoration(\n ranges: DecoratedRange[],\n from: number,\n to: number,\n highlightClass: string\n ): void {\n const decoration = Decoration.mark({\n class: highlightClass,\n });\n\n ranges.push({\n from,\n to,\n decoration,\n });\n }\n\n update(update: ViewUpdate) {\n if (update.docChanged || update.viewportChanged) {\n this.decorations = this.getDecorations(update.view);\n }\n }\n },\n {\n decorations: (v) => v.decorations,\n }\n );\n}\n"],"mappings":";;AAoBA,SAAgB,+BACd,IACA,iBACA,UACA,gBACW;CACX,MAAM,EAAE,YAAY,YAAY,eAAe;CAC/C,OAAO,WAAW,UAChB,MAAM;EACJ;EAEA,YAAY,MAAkB;GAC5B,KAAK,cAAc,KAAK,eAAe,IAAI;EAC7C;EAEA,eAAe,MAAiC;GAE9C,MAAM,mBAAmB,OAAO,QAAQ,eAAe,CAAC,CAAC,QACtD,GAAG,UAAU,SAAS,YAAY,MAAM,WAAW,GAAG,SAAS,EAAE,CACpE;GAEA,IAAI,iBAAiB,WAAW,GAC9B,OAAO,WAAW;GAGpB,MAAM,SAA2B,CAAC;GAElC,KAAK,MAAM,CAAC,cAAc,SAAS,kBAAkB;IACnD,IAAI,CAAC,MAAM;IAIX,MAAM,iBAFmB,mBAAmB,eAGxC,sCACA;IAEJ,IAAI,SAAS,UAAU;KACrB,KAAK,cACH,QACA,GACA,KAAK,MAAM,IAAI,QACf,cACF;KACA;IACF;IAGA,MAAM,aAAa,KAAK,UAAU,SAAS,SAAS,CAAC;IACrD,MAAM,eAAe,KAAK,cAAc,UAAU;IAElD,KAAK,kBAAkB,MAAM,cAAc,QAAQ,cAAc;GACnE;GAEA,OAAO,WAAW,IAChB,OAAO,KAAK,EAAE,MAAM,IAAI,iBACtB,WAAW,KAAK,EACd,OAAO,WAAW,KAAK,MACzB,CAAC,CA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iBAC9B,KAAK,cAAc,KAAK,eAAe,OAAO,IAAI;EAEtD;CACF,GACA,EACE,cAAc,MAAM,EAAE,YACxB,CACF;AACF"}
|
|
@@ -73,7 +73,7 @@ var COMMAND_ITEM_SIZE_CLASSES = {
|
|
|
73
73
|
};
|
|
74
74
|
var CommandItem = forwardRef(({ className, size = "md", ...props }, ref) => /* @__PURE__ */ jsx(Command$1.Item, {
|
|
75
75
|
ref,
|
|
76
|
-
className: cn("relative flex cursor-pointer select-none items-center rounded-sm px-space-2 outline-
|
|
76
|
+
className: cn("relative flex cursor-pointer select-none items-center rounded-sm px-space-2 outline-hidden hover:bg-elevated-hover aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-selected:bg-elevated-hover", OPTION_ROW_SIZES[size].minHeightClassName, COMMAND_ITEM_SIZE_CLASSES[size], className),
|
|
77
77
|
...props
|
|
78
78
|
}));
|
|
79
79
|
CommandItem.displayName = Command$1.Item.displayName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Command.js","names":[],"sources":["../../../src/components/Command/Command.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, ElementRef, ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nimport { Command as CommandPrimitive } from 'cmdk';\n\nimport { cn } from '../../utils/cn';\nimport {\n OPTION_ROW_SIZES,\n type OptionRowSize,\n} from '../../utils/componentSizes';\nimport {\n DECORATOR_CLASSES,\n getInputContainerClasses,\n getInputElementClasses,\n} from '../Input/inputStyles';\nimport type { InputSize, InputVariant } from '../Input/inputStyles';\n\nexport const Command = forwardRef<\n ElementRef<typeof CommandPrimitive>,\n ComponentPropsWithoutRef<typeof CommandPrimitive>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive\n ref={ref}\n className={cn(\n 'flex h-full w-full flex-col overflow-hidden rounded-md bg-popover',\n className\n )}\n {...props}\n />\n));\nCommand.displayName = CommandPrimitive.displayName;\n\nexport interface CommandInputProps extends Omit<\n ComponentPropsWithoutRef<typeof CommandPrimitive.Input>,\n 'size'\n> {\n /** Left side decorator (icon or element) */\n leftDecorator?: ReactNode;\n /** Right side decorator (icon or element) */\n rightDecorator?: ReactNode;\n /** Size variant — uses shared Input styling */\n size?: InputSize;\n /** Visual variant — uses shared Input styling */\n variant?: InputVariant;\n}\n\nexport const CommandInput = forwardRef<\n ElementRef<typeof CommandPrimitive.Input>,\n CommandInputProps\n>(\n (\n {\n className,\n leftDecorator,\n rightDecorator,\n size = 'lg',\n variant = 'outlined',\n ...props\n },\n ref\n ) => {\n const containerClasses = getInputContainerClasses({\n size,\n variant,\n disabled: props.disabled,\n className,\n });\n\n const inputClasses = getInputElementClasses({\n size,\n disabled: props.disabled,\n });\n\n return (\n <div className={containerClasses} {...{ 'cmdk-input-wrapper': '' }}>\n {leftDecorator && (\n <div className={DECORATOR_CLASSES}>{leftDecorator}</div>\n )}\n <CommandPrimitive.Input ref={ref} className={inputClasses} {...props} />\n {rightDecorator && (\n <div className={DECORATOR_CLASSES}>{rightDecorator}</div>\n )}\n </div>\n );\n }\n);\n\nCommandInput.displayName = CommandPrimitive.Input.displayName;\n\nexport const CommandList = forwardRef<\n ElementRef<typeof CommandPrimitive.List>,\n ComponentPropsWithoutRef<typeof CommandPrimitive.List>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.List\n ref={ref}\n className={cn('max-h-[300px] overflow-y-auto overflow-x-hidden', className)}\n {...props}\n />\n));\n\nCommandList.displayName = CommandPrimitive.List.displayName;\n\nexport const CommandEmpty = forwardRef<\n ElementRef<typeof CommandPrimitive.Empty>,\n ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>\n>((props, ref) => (\n <CommandPrimitive.Empty\n ref={ref}\n className=\"py-space-5 text-center\"\n {...props}\n />\n));\n\nCommandEmpty.displayName = CommandPrimitive.Empty.displayName;\n\nexport const CommandGroup = forwardRef<\n ElementRef<typeof CommandPrimitive.Group>,\n ComponentPropsWithoutRef<typeof CommandPrimitive.Group>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.Group\n ref={ref}\n className={cn(\n 'overflow-hidden',\n '[&_[cmdk-group-heading]]:px-space-2 [&_[cmdk-group-heading]]:py-space-2 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-semibold [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:text-tertiary',\n className\n )}\n {...props}\n />\n));\n\nCommandGroup.displayName = CommandPrimitive.Group.displayName;\n\nexport const CommandSeparator = forwardRef<\n ElementRef<typeof CommandPrimitive.Separator>,\n ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.Separator\n ref={ref}\n className={cn('bg-border -mx-space-1 h-px', className)}\n {...props}\n />\n));\nCommandSeparator.displayName = CommandPrimitive.Separator.displayName;\n\ninterface CommandItemProps extends ComponentPropsWithoutRef<\n typeof CommandPrimitive.Item\n> {\n /**\n * Controls minimum row height and default label typography.\n * Rich or multiline content grows intrinsically.\n */\n size?: OptionRowSize;\n}\n\nconst COMMAND_ITEM_SIZE_CLASSES = {\n sm: 'py-space-1 text-xs leading-4',\n md: 'py-space-1 text-sm',\n} satisfies Record<OptionRowSize, string>;\n\nexport const CommandItem = forwardRef<\n ElementRef<typeof CommandPrimitive.Item>,\n CommandItemProps\n>(({ className, size = 'md', ...props }, ref) => (\n <CommandPrimitive.Item\n ref={ref}\n className={cn(\n 'relative flex cursor-pointer select-none items-center rounded-sm px-space-2 outline-
|
|
1
|
+
{"version":3,"file":"Command.js","names":[],"sources":["../../../src/components/Command/Command.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, ElementRef, ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nimport { Command as CommandPrimitive } from 'cmdk';\n\nimport { cn } from '../../utils/cn';\nimport {\n OPTION_ROW_SIZES,\n type OptionRowSize,\n} from '../../utils/componentSizes';\nimport {\n DECORATOR_CLASSES,\n getInputContainerClasses,\n getInputElementClasses,\n} from '../Input/inputStyles';\nimport type { InputSize, InputVariant } from '../Input/inputStyles';\n\nexport const Command = forwardRef<\n ElementRef<typeof CommandPrimitive>,\n ComponentPropsWithoutRef<typeof CommandPrimitive>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive\n ref={ref}\n className={cn(\n 'flex h-full w-full flex-col overflow-hidden rounded-md bg-popover',\n className\n )}\n {...props}\n />\n));\nCommand.displayName = CommandPrimitive.displayName;\n\nexport interface CommandInputProps extends Omit<\n ComponentPropsWithoutRef<typeof CommandPrimitive.Input>,\n 'size'\n> {\n /** Left side decorator (icon or element) */\n leftDecorator?: ReactNode;\n /** Right side decorator (icon or element) */\n rightDecorator?: ReactNode;\n /** Size variant — uses shared Input styling */\n size?: InputSize;\n /** Visual variant — uses shared Input styling */\n variant?: InputVariant;\n}\n\nexport const CommandInput = forwardRef<\n ElementRef<typeof CommandPrimitive.Input>,\n CommandInputProps\n>(\n (\n {\n className,\n leftDecorator,\n rightDecorator,\n size = 'lg',\n variant = 'outlined',\n ...props\n },\n ref\n ) => {\n const containerClasses = getInputContainerClasses({\n size,\n variant,\n disabled: props.disabled,\n className,\n });\n\n const inputClasses = getInputElementClasses({\n size,\n disabled: props.disabled,\n });\n\n return (\n <div className={containerClasses} {...{ 'cmdk-input-wrapper': '' }}>\n {leftDecorator && (\n <div className={DECORATOR_CLASSES}>{leftDecorator}</div>\n )}\n <CommandPrimitive.Input ref={ref} className={inputClasses} {...props} />\n {rightDecorator && (\n <div className={DECORATOR_CLASSES}>{rightDecorator}</div>\n )}\n </div>\n );\n }\n);\n\nCommandInput.displayName = CommandPrimitive.Input.displayName;\n\nexport const CommandList = forwardRef<\n ElementRef<typeof CommandPrimitive.List>,\n ComponentPropsWithoutRef<typeof CommandPrimitive.List>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.List\n ref={ref}\n className={cn('max-h-[300px] overflow-y-auto overflow-x-hidden', className)}\n {...props}\n />\n));\n\nCommandList.displayName = CommandPrimitive.List.displayName;\n\nexport const CommandEmpty = forwardRef<\n ElementRef<typeof CommandPrimitive.Empty>,\n ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>\n>((props, ref) => (\n <CommandPrimitive.Empty\n ref={ref}\n className=\"py-space-5 text-center\"\n {...props}\n />\n));\n\nCommandEmpty.displayName = CommandPrimitive.Empty.displayName;\n\nexport const CommandGroup = forwardRef<\n ElementRef<typeof CommandPrimitive.Group>,\n ComponentPropsWithoutRef<typeof CommandPrimitive.Group>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.Group\n ref={ref}\n className={cn(\n 'overflow-hidden',\n '[&_[cmdk-group-heading]]:px-space-2 [&_[cmdk-group-heading]]:py-space-2 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-semibold [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:text-tertiary',\n className\n )}\n {...props}\n />\n));\n\nCommandGroup.displayName = CommandPrimitive.Group.displayName;\n\nexport const CommandSeparator = forwardRef<\n ElementRef<typeof CommandPrimitive.Separator>,\n ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.Separator\n ref={ref}\n className={cn('bg-border -mx-space-1 h-px', className)}\n {...props}\n />\n));\nCommandSeparator.displayName = CommandPrimitive.Separator.displayName;\n\ninterface CommandItemProps extends ComponentPropsWithoutRef<\n typeof CommandPrimitive.Item\n> {\n /**\n * Controls minimum row height and default label typography.\n * Rich or multiline content grows intrinsically.\n */\n size?: OptionRowSize;\n}\n\nconst COMMAND_ITEM_SIZE_CLASSES = {\n sm: 'py-space-1 text-xs leading-4',\n md: 'py-space-1 text-sm',\n} satisfies Record<OptionRowSize, string>;\n\nexport const CommandItem = forwardRef<\n ElementRef<typeof CommandPrimitive.Item>,\n CommandItemProps\n>(({ className, size = 'md', ...props }, ref) => (\n <CommandPrimitive.Item\n ref={ref}\n className={cn(\n 'relative flex cursor-pointer select-none items-center rounded-sm px-space-2 outline-hidden hover:bg-elevated-hover aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-selected:bg-elevated-hover',\n OPTION_ROW_SIZES[size].minHeightClassName,\n COMMAND_ITEM_SIZE_CLASSES[size],\n className\n )}\n {...props}\n />\n));\n\nCommandItem.displayName = CommandPrimitive.Item.displayName;\n"],"mappings":";;;;;;;AAiBA,IAAa,UAAU,YAGpB,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,WAAD;CACO;CACL,WAAW,GACT,qEACA,SACF;CACA,GAAI;AACL,CAAA,CACF;AACD,QAAQ,cAAc,UAAiB;AAgBvC,IAAa,eAAe,YAKxB,EACE,WACA,eACA,gBACA,OAAO,MACP,UAAU,YACV,GAAG,SAEL,QACG;CACH,MAAM,mBAAmB,yBAAyB;EAChD;EACA;EACA,UAAU,MAAM;EAChB;CACF,CAAC;CAED,MAAM,eAAe,uBAAuB;EAC1C;EACA,UAAU,MAAM;CAClB,CAAC;CAED,OACE,qBAAC,OAAD;EAAK,WAAW;EAAwB,sBAAsB;EAA9D,UAAA;GACG,iBACC,oBAAC,OAAD;IAAK,WAAA;IAA+B,UAAA;GAAmB,CAAA;GAEzD,oBAAC,UAAiB,OAAlB;IAA6B;IAAK,WAAW;IAAc,GAAI;GAAQ,CAAA;GACtE,kBACC,oBAAC,OAAD;IAAK,WAAA;IAA+B,UAAA;GAAoB,CAAA;EAEvD;;AAET,CACF;AAEA,aAAa,cAAc,UAAiB,MAAM;AAElD,IAAa,cAAc,YAGxB,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,UAAiB,MAAlB;CACO;CACL,WAAW,GAAG,mDAAmD,SAAS;CAC1E,GAAI;AACL,CAAA,CACF;AAED,YAAY,cAAc,UAAiB,KAAK;AAEhD,IAAa,eAAe,YAGzB,OAAO,QACR,oBAAC,UAAiB,OAAlB;CACO;CACL,WAAU;CACV,GAAI;AACL,CAAA,CACF;AAED,aAAa,cAAc,UAAiB,MAAM;AAElD,IAAa,eAAe,YAGzB,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,UAAiB,OAAlB;CACO;CACL,WAAW,GACT,mBACA,6NACA,SACF;CACA,GAAI;AACL,CAAA,CACF;AAED,aAAa,cAAc,UAAiB,MAAM;AAElD,IAAa,mBAAmB,YAG7B,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,UAAiB,WAAlB;CACO;CACL,WAAW,GAAG,8BAA8B,SAAS;CACrD,GAAI;AACL,CAAA,CACF;AACD,iBAAiB,cAAc,UAAiB,UAAU;AAY1D,IAAM,4BAA4B;CAChC,IAAI;CACJ,IAAI;AACN;AAEA,IAAa,cAAc,YAGxB,EAAE,WAAW,OAAO,MAAM,GAAG,SAAS,QACvC,oBAAC,UAAiB,MAAlB;CACO;CACL,WAAW,GACT,iNACA,iBAAiB,KAAK,CAAC,oBACvB,0BAA0B,OAC1B,SACF;CACA,GAAI;AACL,CAAA,CACF;AAED,YAAY,cAAc,UAAiB,KAAK"}
|
|
@@ -69,7 +69,7 @@ function CommandMenu({ items, groups, onSelect, value, placeholder = "Search..."
|
|
|
69
69
|
}, item.value);
|
|
70
70
|
});
|
|
71
71
|
return /* @__PURE__ */ jsxs(Command, {
|
|
72
|
-
className: cn("flex flex-col gap-1.5 p-space-1 outline-
|
|
72
|
+
className: cn("flex flex-col gap-1.5 p-space-1 outline-hidden", className),
|
|
73
73
|
shouldFilter: disableFilter ? false : void 0,
|
|
74
74
|
tabIndex: hideSearch ? 0 : -1,
|
|
75
75
|
children: [!hideSearch && /* @__PURE__ */ jsx(CommandInput, {
|
|
@@ -83,7 +83,7 @@ function CommandMenu({ items, groups, onSelect, value, placeholder = "Search..."
|
|
|
83
83
|
}),
|
|
84
84
|
onValueChange: onSearchChange
|
|
85
85
|
}), /* @__PURE__ */ jsxs(CommandList, {
|
|
86
|
-
className: "outline-
|
|
86
|
+
className: "outline-hidden",
|
|
87
87
|
onScroll: handleScroll,
|
|
88
88
|
children: [
|
|
89
89
|
!loading && /* @__PURE__ */ jsx(CommandEmpty, { children: /* @__PURE__ */ jsx(Text, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandMenu.js","names":[],"sources":["../../../src/components/Command/CommandMenu.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { Fragment, useCallback, useEffect, useRef, useState } from 'react';\n\nimport { MagnifyingGlassIcon } from '@phosphor-icons/react/dist/ssr/MagnifyingGlass';\n\nimport { CheckIcon } from '../../icons/PaddedPhosphorIcons';\nimport { cn } from '../../utils/cn';\nimport {\n OPTION_ROW_SIZES,\n type OptionRowSize,\n} from '../../utils/componentSizes';\nimport { Icon } from '../Icon';\nimport type { InputSize, InputVariant } from '../Input/inputStyles';\nimport { Text } from '../Text';\nimport { Tooltip } from '../Tooltip';\nimport {\n Command,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n CommandSeparator,\n} from './Command';\n\nexport interface CommandMenuItem {\n /** Unique value used for selection and filtering */\n value: string;\n /** Display label (defaults to value if not provided) */\n label?: string;\n /** Secondary description text displayed below the label */\n description?: string;\n /** Element displayed on the right side of the item (e.g. badge, shortcut) */\n rightDecorator?: ReactNode;\n /** Whether this item is disabled */\n disabled?: boolean;\n /** Extra search terms for filtering */\n keywords?: string[];\n}\n\nexport interface CommandMenuGroup {\n /** Optional heading displayed above the group */\n heading?: string;\n /** Items in this group */\n items: CommandMenuItem[];\n}\n\ninterface CommandMenuBaseProps {\n /** Callback when an item is selected */\n onSelect: (value: string) => void;\n /** The currently selected value. When set, a check icon is shown next to the selected item. */\n value?: string;\n /** Placeholder text for the search input */\n placeholder?: string;\n /** Text shown when no items match the search */\n emptyText?: string;\n /** Hide the search input (default: false, search is visible) */\n hideSearch?: boolean;\n /** Show the leading selected-indicator slot in the default item layout (default: true). Set false for action menus that track no selection so labels sit flush-left. */\n showSelectedIndicator?: boolean;\n /** Disable client-side filtering by cmdk (default: false). Set true for server-side filtering. */\n disableFilter?: boolean;\n /** Callback when the search input value changes. Useful for server-side filtering. */\n onSearchChange?: (query: string) => void;\n /** Custom render function for each item */\n renderItem?: (item: CommandMenuItem, isSelected: boolean) => ReactNode;\n /** Size variant for the search input */\n inputSize?: InputSize;\n /**\n * Controls minimum row height and default label typography.\n * Descriptions and custom content may grow beyond the minimum height.\n */\n itemRowSize?: OptionRowSize;\n /** Visual variant for the search input */\n inputVariant?: InputVariant;\n /** Additional class name for the Command root */\n className?: string;\n /** Whether more items are currently being loaded */\n loading?: boolean;\n /** Number of skeleton rows to show while loading (default: 5) */\n loadingRows?: number;\n /** Callback when the user scrolls near the end of the list. Use for infinite loading. */\n onEndReached?: () => void;\n /** Distance in pixels from the bottom to trigger onEndReached (default: 50) */\n endReachedThresholdPx?: number;\n}\n\nexport type CommandMenuProps = CommandMenuBaseProps &\n (\n | { /** Flat list of items */ items: CommandMenuItem[]; groups?: never }\n | {\n /** Grouped items with optional headings */ groups: CommandMenuGroup[];\n items?: never;\n }\n );\n\nfunction TruncatedLabel({ text, size }: { text: string; size: OptionRowSize }) {\n const textRef = useRef<HTMLElement>(null);\n const [isTruncated, setIsTruncated] = useState(false);\n\n useEffect(() => {\n const el = textRef.current;\n if (el) {\n setIsTruncated(el.scrollWidth > el.clientWidth);\n }\n }, [text, size]);\n\n return (\n <Tooltip title={isTruncated ? text : undefined}>\n <Text\n ref={textRef}\n as=\"span\"\n variant={size}\n className={cn(\n 'truncate tracking-normal',\n size === 'sm' ? 'leading-4' : 'leading-5'\n )}\n >\n {text}\n </Text>\n </Tooltip>\n );\n}\n\nexport function CommandMenu({\n items,\n groups,\n onSelect,\n value,\n placeholder = 'Search...',\n emptyText = 'No results found.',\n hideSearch,\n showSelectedIndicator = true,\n disableFilter,\n onSearchChange,\n renderItem,\n inputSize = 'sm',\n itemRowSize = 'md',\n inputVariant = 'plain',\n className,\n loading = false,\n loadingRows = 5,\n onEndReached,\n endReachedThresholdPx = 50,\n}: CommandMenuProps) {\n const handleScroll = useCallback(\n (e: React.UIEvent<HTMLDivElement>) => {\n if (!onEndReached) return;\n const { scrollTop, scrollHeight, clientHeight } = e.currentTarget;\n if (scrollHeight - scrollTop - clientHeight <= endReachedThresholdPx) {\n onEndReached();\n }\n },\n [onEndReached, endReachedThresholdPx]\n );\n\n const renderItems = (menuItems: CommandMenuItem[]) =>\n menuItems.map((item) => {\n const isSelected = item.value === value;\n const label = item.label ?? item.value;\n return (\n <CommandItem\n key={item.value}\n value={item.value}\n keywords={\n item.label ? [item.label, ...(item.keywords ?? [])] : item.keywords\n }\n disabled={item.disabled}\n onSelect={() => onSelect(item.value)}\n size={itemRowSize}\n className={cn(\n 'gap-space-2',\n hideSearch &&\n 'after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] aria-selected:after:border-2 aria-selected:after:border-focus'\n )}\n >\n {renderItem ? (\n renderItem(item, isSelected)\n ) : (\n <>\n {showSelectedIndicator && (\n <Icon\n icon={CheckIcon}\n size=\"md\"\n className={cn(\n 'shrink-0',\n isSelected ? 'opacity-100' : 'opacity-0'\n )}\n />\n )}\n <div className=\"flex min-w-0 flex-1 flex-col\">\n <TruncatedLabel text={label} size={itemRowSize} />\n {item.description && (\n <Text\n as=\"span\"\n variant=\"xs\"\n className=\"truncate text-tertiary\"\n >\n {item.description}\n </Text>\n )}\n </div>\n {item.rightDecorator && (\n <div className=\"ml-auto shrink-0\">{item.rightDecorator}</div>\n )}\n </>\n )}\n </CommandItem>\n );\n });\n\n return (\n <Command\n className={cn('flex flex-col gap-1.5 p-space-1 outline-none', className)}\n shouldFilter={disableFilter ? false : undefined}\n tabIndex={hideSearch ? 0 : -1}\n >\n {!hideSearch && (\n <CommandInput\n placeholder={placeholder}\n size={inputSize}\n variant={inputVariant}\n leftDecorator={\n <MagnifyingGlassIcon aria-hidden size={16} weight=\"regular\" />\n }\n onValueChange={onSearchChange}\n />\n )}\n <CommandList className=\"outline-none\" onScroll={handleScroll}>\n {!loading && (\n <CommandEmpty>\n <Text variant=\"sm\">{emptyText}</Text>\n </CommandEmpty>\n )}\n {items && renderItems(items)}\n {groups?.map((group, i) => (\n <Fragment key={group.heading ?? i}>\n {i > 0 && <CommandSeparator />}\n <CommandGroup heading={group.heading}>\n {renderItems(group.items)}\n </CommandGroup>\n </Fragment>\n ))}\n {loading && (\n <div className=\"flex flex-col gap-space-1 px-space-2 py-space-1\">\n {Array.from({ length: loadingRows }, (_, i) => (\n <div\n key={i}\n className={cn(\n 'animate-pulse rounded-md bg-tertiary',\n OPTION_ROW_SIZES[itemRowSize].minHeightClassName\n )}\n />\n ))}\n </div>\n )}\n </CommandList>\n </Command>\n );\n}\n"],"mappings":";;;;;;;;;;;AAgGA,SAAS,eAAe,EAAE,MAAM,QAA+C;CAC7E,MAAM,UAAU,OAAoB,IAAI;CACxC,MAAM,CAAC,aAAa,kBAAkB,SAAS,KAAK;CAEpD,gBAAgB;EACd,MAAM,KAAK,QAAQ;EACnB,IAAI,IACF,eAAe,GAAG,cAAc,GAAG,WAAW;CAElD,GAAG,CAAC,MAAM,IAAI,CAAC;CAEf,OACE,oBAAC,SAAD;EAAS,OAAO,cAAc,OAAO,KAAA;EACnC,UAAA,oBAAC,MAAD;GACE,KAAK;GACL,IAAG;GACH,SAAS;GACT,WAAW,GACT,4BACA,SAAS,OAAO,cAAc,WAChC;GAEC,UAAA;EACG,CAAA;CACC,CAAA;AAEb;AAEA,SAAgB,YAAY,EAC1B,OACA,QACA,UACA,OACA,cAAc,aACd,YAAY,qBACZ,YACA,wBAAwB,MACxB,eACA,gBACA,YACA,YAAY,MACZ,cAAc,MACd,eAAe,SACf,WACA,UAAU,OACV,cAAc,GACd,cACA,wBAAwB,MACL;CACnB,MAAM,eAAe,aAClB,MAAqC;EACpC,IAAI,CAAC,cAAc;EACnB,MAAM,EAAE,WAAW,cAAc,iBAAiB,EAAE;EACpD,IAAI,eAAe,YAAY,gBAAgB,uBAC7C,aAAa;CAEjB,GACA,CAAC,cAAc,qBAAqB,CACtC;CAEA,MAAM,eAAe,cACnB,UAAU,KAAK,SAAS;EACtB,MAAM,aAAa,KAAK,UAAU;EAClC,MAAM,QAAQ,KA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ACnB,qBAAC,UAAD,EAAA,UAAA,CACG,IAAI,KAAK,oBAAC,kBAAD,CAAmB,CAAA,GAC7B,oBAAC,cAAD;KAAc,SAAS,MAAM;KAC1B,UAAA,YAAY,MAAM,KAAK;IACZ,CAAA,CACN,EAAA,GALK,MAAM,WAAW,CAKtB,CACX;IACA,WACC,oBAAC,OAAD;KAAK,WAAU;KACZ,UAAA,MAAM,KAAK,EAAE,QAAQ,YAAY,IAAI,GAAG,MACvC,oBAAC,OAAD,EAEE,WAAW,GACT,wCACA,iBAAiB,YAAY,CAAC,kBAChC,EACD,GALM,CAKN,CACF;IACE,CAAA;GAEI;EACN,CAAA,CAAA;;AAEb"}
|
|
1
|
+
{"version":3,"file":"CommandMenu.js","names":[],"sources":["../../../src/components/Command/CommandMenu.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { Fragment, useCallback, useEffect, useRef, useState } from 'react';\n\nimport { MagnifyingGlassIcon } from '@phosphor-icons/react/dist/ssr/MagnifyingGlass';\n\nimport { CheckIcon } from '../../icons/PaddedPhosphorIcons';\nimport { cn } from '../../utils/cn';\nimport {\n OPTION_ROW_SIZES,\n type OptionRowSize,\n} from '../../utils/componentSizes';\nimport { Icon } from '../Icon';\nimport type { InputSize, InputVariant } from '../Input/inputStyles';\nimport { Text } from '../Text';\nimport { Tooltip } from '../Tooltip';\nimport {\n Command,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n CommandSeparator,\n} from './Command';\n\nexport interface CommandMenuItem {\n /** Unique value used for selection and filtering */\n value: string;\n /** Display label (defaults to value if not provided) */\n label?: string;\n /** Secondary description text displayed below the label */\n description?: string;\n /** Element displayed on the right side of the item (e.g. badge, shortcut) */\n rightDecorator?: ReactNode;\n /** Whether this item is disabled */\n disabled?: boolean;\n /** Extra search terms for filtering */\n keywords?: string[];\n}\n\nexport interface CommandMenuGroup {\n /** Optional heading displayed above the group */\n heading?: string;\n /** Items in this group */\n items: CommandMenuItem[];\n}\n\ninterface CommandMenuBaseProps {\n /** Callback when an item is selected */\n onSelect: (value: string) => void;\n /** The currently selected value. When set, a check icon is shown next to the selected item. */\n value?: string;\n /** Placeholder text for the search input */\n placeholder?: string;\n /** Text shown when no items match the search */\n emptyText?: string;\n /** Hide the search input (default: false, search is visible) */\n hideSearch?: boolean;\n /** Show the leading selected-indicator slot in the default item layout (default: true). Set false for action menus that track no selection so labels sit flush-left. */\n showSelectedIndicator?: boolean;\n /** Disable client-side filtering by cmdk (default: false). Set true for server-side filtering. */\n disableFilter?: boolean;\n /** Callback when the search input value changes. Useful for server-side filtering. */\n onSearchChange?: (query: string) => void;\n /** Custom render function for each item */\n renderItem?: (item: CommandMenuItem, isSelected: boolean) => ReactNode;\n /** Size variant for the search input */\n inputSize?: InputSize;\n /**\n * Controls minimum row height and default label typography.\n * Descriptions and custom content may grow beyond the minimum height.\n */\n itemRowSize?: OptionRowSize;\n /** Visual variant for the search input */\n inputVariant?: InputVariant;\n /** Additional class name for the Command root */\n className?: string;\n /** Whether more items are currently being loaded */\n loading?: boolean;\n /** Number of skeleton rows to show while loading (default: 5) */\n loadingRows?: number;\n /** Callback when the user scrolls near the end of the list. Use for infinite loading. */\n onEndReached?: () => void;\n /** Distance in pixels from the bottom to trigger onEndReached (default: 50) */\n endReachedThresholdPx?: number;\n}\n\nexport type CommandMenuProps = CommandMenuBaseProps &\n (\n | { /** Flat list of items */ items: CommandMenuItem[]; groups?: never }\n | {\n /** Grouped items with optional headings */ groups: CommandMenuGroup[];\n items?: never;\n }\n );\n\nfunction TruncatedLabel({ text, size }: { text: string; size: OptionRowSize }) {\n const textRef = useRef<HTMLElement>(null);\n const [isTruncated, setIsTruncated] = useState(false);\n\n useEffect(() => {\n const el = textRef.current;\n if (el) {\n setIsTruncated(el.scrollWidth > el.clientWidth);\n }\n }, [text, size]);\n\n return (\n <Tooltip title={isTruncated ? text : undefined}>\n <Text\n ref={textRef}\n as=\"span\"\n variant={size}\n className={cn(\n 'truncate tracking-normal',\n size === 'sm' ? 'leading-4' : 'leading-5'\n )}\n >\n {text}\n </Text>\n </Tooltip>\n );\n}\n\nexport function CommandMenu({\n items,\n groups,\n onSelect,\n value,\n placeholder = 'Search...',\n emptyText = 'No results found.',\n hideSearch,\n showSelectedIndicator = true,\n disableFilter,\n onSearchChange,\n renderItem,\n inputSize = 'sm',\n itemRowSize = 'md',\n inputVariant = 'plain',\n className,\n loading = false,\n loadingRows = 5,\n onEndReached,\n endReachedThresholdPx = 50,\n}: CommandMenuProps) {\n const handleScroll = useCallback(\n (e: React.UIEvent<HTMLDivElement>) => {\n if (!onEndReached) return;\n const { scrollTop, scrollHeight, clientHeight } = e.currentTarget;\n if (scrollHeight - scrollTop - clientHeight <= endReachedThresholdPx) {\n onEndReached();\n }\n },\n [onEndReached, endReachedThresholdPx]\n );\n\n const renderItems = (menuItems: CommandMenuItem[]) =>\n menuItems.map((item) => {\n const isSelected = item.value === value;\n const label = item.label ?? item.value;\n return (\n <CommandItem\n key={item.value}\n value={item.value}\n keywords={\n item.label ? [item.label, ...(item.keywords ?? [])] : item.keywords\n }\n disabled={item.disabled}\n onSelect={() => onSelect(item.value)}\n size={itemRowSize}\n className={cn(\n 'gap-space-2',\n hideSearch &&\n 'after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] aria-selected:after:border-2 aria-selected:after:border-focus'\n )}\n >\n {renderItem ? (\n renderItem(item, isSelected)\n ) : (\n <>\n {showSelectedIndicator && (\n <Icon\n icon={CheckIcon}\n size=\"md\"\n className={cn(\n 'shrink-0',\n isSelected ? 'opacity-100' : 'opacity-0'\n )}\n />\n )}\n <div className=\"flex min-w-0 flex-1 flex-col\">\n <TruncatedLabel text={label} size={itemRowSize} />\n {item.description && (\n <Text\n as=\"span\"\n variant=\"xs\"\n className=\"truncate text-tertiary\"\n >\n {item.description}\n </Text>\n )}\n </div>\n {item.rightDecorator && (\n <div className=\"ml-auto shrink-0\">{item.rightDecorator}</div>\n )}\n </>\n )}\n </CommandItem>\n );\n });\n\n return (\n <Command\n className={cn(\n 'flex flex-col gap-1.5 p-space-1 outline-hidden',\n className\n )}\n shouldFilter={disableFilter ? false : undefined}\n tabIndex={hideSearch ? 0 : -1}\n >\n {!hideSearch && (\n <CommandInput\n placeholder={placeholder}\n size={inputSize}\n variant={inputVariant}\n leftDecorator={\n <MagnifyingGlassIcon aria-hidden size={16} weight=\"regular\" />\n }\n onValueChange={onSearchChange}\n />\n )}\n <CommandList className=\"outline-hidden\" onScroll={handleScroll}>\n {!loading && (\n <CommandEmpty>\n <Text variant=\"sm\">{emptyText}</Text>\n </CommandEmpty>\n )}\n {items && renderItems(items)}\n {groups?.map((group, i) => (\n <Fragment key={group.heading ?? i}>\n {i > 0 && <CommandSeparator />}\n <CommandGroup heading={group.heading}>\n {renderItems(group.items)}\n </CommandGroup>\n </Fragment>\n ))}\n {loading && (\n <div className=\"flex flex-col gap-space-1 px-space-2 py-space-1\">\n {Array.from({ length: loadingRows }, (_, i) => (\n <div\n key={i}\n className={cn(\n 'animate-pulse rounded-md bg-tertiary',\n OPTION_ROW_SIZES[itemRowSize].minHeightClassName\n )}\n />\n ))}\n </div>\n )}\n </CommandList>\n </Command>\n );\n}\n"],"mappings":";;;;;;;;;;;AAgGA,SAAS,eAAe,EAAE,MAAM,QAA+C;CAC7E,MAAM,UAAU,OAAoB,IAAI;CACxC,MAAM,CAAC,aAAa,kBAAkB,SAAS,KAAK;CAEpD,gBAAgB;EACd,MAAM,KAAK,QAAQ;EACnB,IAAI,IACF,eAAe,GAAG,cAAc,GAAG,WAAW;CAElD,GAAG,CAAC,MAAM,IAAI,CAAC;CAEf,OACE,oBAAC,SAAD;EAAS,OAAO,cAAc,OAAO,KAAA;EACnC,UAAA,oBAAC,MAAD;GACE,KAAK;GACL,IAAG;GACH,SAAS;GACT,WAAW,GACT,4BACA,SAAS,OAAO,cAAc,WAChC;GAEC,UAAA;EACG,CAAA;CACC,CAAA;AAEb;AAEA,SAAgB,YAAY,EAC1B,OACA,QACA,UACA,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AQ,KAAA;EACtC,UAAU,aAAa,IAAI;EAN7B,UAAA,CAQG,CAAC,cACA,oBAAC,cAAD;GACe;GACb,MAAM;GACN,SAAS;GACT,eACE,oBAAC,qBAAD;IAAqB,eAAA;IAAY,MAAM;IAAI,QAAO;GAAW,CAAA;GAE/D,eAAe;EAChB,CAAA,GAEH,qBAAC,aAAD;GAAa,WAAU;GAAiB,UAAU;GAAlD,UAAA;IACG,CAAC,WACA,oBAAC,cAAD,EAAA,UACE,oBAAC,MAAD;KAAM,SAAQ;KAAM,UAAA;IAAgB,CAAA,EACxB,CAAA;IAEf,SAAS,YAAY,KAAK;IAC1B,QAAQ,KAAK,OAAO,MACnB,qBAAC,UAAD,EAAA,UAAA,CACG,IAAI,KAAK,oBAAC,kBAAD,CAAmB,CAAA,GAC7B,oBAAC,cAAD;KAAc,SAAS,MAAM;KAC1B,UAAA,YAAY,MAAM,KAAK;IACZ,CAAA,CACN,EAAA,GALK,MAAM,WAAW,CAKtB,CACX;IACA,WACC,oBAAC,OAAD;KAAK,WAAU;KACZ,UAAA,MAAM,KAAK,EAAE,QAAQ,YAAY,IAAI,GAAG,MACvC,oBAAC,OAAD,EAEE,WAAW,GACT,wCACA,iBAAiB,YAAY,CAAC,kBAChC,EACD,GALM,CAKN,CACF;IACE,CAAA;GAEI;EACN,CAAA,CAAA;;AAEb"}
|
|
@@ -13,7 +13,7 @@ var ContextMenuContent = React$1.forwardRef(({ className, children, ...props },
|
|
|
13
13
|
const zIndex = useZIndex(zIndices.popover);
|
|
14
14
|
return /* @__PURE__ */ jsx(ContextMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(ContextMenuPrimitive.Content, {
|
|
15
15
|
ref,
|
|
16
|
-
className: cn("min-w-[8rem] overflow-hidden rounded-md border border-default bg-
|
|
16
|
+
className: cn("min-w-[8rem] overflow-hidden rounded-md border border-default bg-popover p-space-1 text-primary shadow-md", className),
|
|
17
17
|
...props,
|
|
18
18
|
style: {
|
|
19
19
|
zIndex,
|
|
@@ -28,7 +28,7 @@ var ContextMenuContent = React$1.forwardRef(({ className, children, ...props },
|
|
|
28
28
|
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName;
|
|
29
29
|
var ContextMenuItem = React$1.forwardRef(({ className, inset, size = "md", ...props }, ref) => /* @__PURE__ */ jsx(ContextMenuPrimitive.Item, {
|
|
30
30
|
ref,
|
|
31
|
-
className: cn("flex w-full cursor-default select-none items-center rounded-sm px-space-2 py-space-1 text-primary outline-
|
|
31
|
+
className: cn("flex w-full cursor-default select-none items-center rounded-sm px-space-2 py-space-1 text-primary outline-hidden transition-colors focus:bg-elevated-hover data-[disabled]:pointer-events-none data-[highlighted]:bg-elevated-hover data-[disabled]:opacity-50", OPTION_ROW_SIZES[size].minHeightClassName, size === "sm" ? "text-xs leading-4" : "text-sm", inset ? "pl-space-8" : void 0, className),
|
|
32
32
|
...props
|
|
33
33
|
}));
|
|
34
34
|
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenu.js","names":[],"sources":["../../../src/components/ContextMenu/ContextMenu.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport * as ContextMenuPrimitive from '@radix-ui/react-context-menu';\n\nimport { cn } from '../../utils/cn';\nimport {\n OPTION_ROW_SIZES,\n type OptionRowSize,\n} from '../../utils/componentSizes';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\n\nexport const ContextMenu = ContextMenuPrimitive.Root;\n\nexport const ContextMenuTrigger = ContextMenuPrimitive.Trigger;\n\nexport const ContextMenuContent = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>\n>(({ className, children, ...props }, ref) => {\n const zIndex = useZIndex(zIndices.popover);\n\n return (\n <ContextMenuPrimitive.Portal>\n <ContextMenuPrimitive.Content\n ref={ref}\n className={cn(\n 'min-w-[8rem] overflow-hidden rounded-md border border-default bg-
|
|
1
|
+
{"version":3,"file":"ContextMenu.js","names":[],"sources":["../../../src/components/ContextMenu/ContextMenu.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport * as ContextMenuPrimitive from '@radix-ui/react-context-menu';\n\nimport { cn } from '../../utils/cn';\nimport {\n OPTION_ROW_SIZES,\n type OptionRowSize,\n} from '../../utils/componentSizes';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\n\nexport const ContextMenu = ContextMenuPrimitive.Root;\n\nexport const ContextMenuTrigger = ContextMenuPrimitive.Trigger;\n\nexport const ContextMenuContent = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>\n>(({ className, children, ...props }, ref) => {\n const zIndex = useZIndex(zIndices.popover);\n\n return (\n <ContextMenuPrimitive.Portal>\n <ContextMenuPrimitive.Content\n ref={ref}\n className={cn(\n 'min-w-[8rem] overflow-hidden rounded-md border border-default bg-popover p-space-1 text-primary shadow-md',\n className\n )}\n {...props}\n style={{ zIndex, ...props.style }}\n >\n <ZIndexProvider value={zIndex}>{children}</ZIndexProvider>\n </ContextMenuPrimitive.Content>\n </ContextMenuPrimitive.Portal>\n );\n});\nContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName;\n\nexport const ContextMenuItem = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {\n inset?: boolean;\n /**\n * Controls minimum row height and default label typography.\n * Rich or multiline content grows intrinsically.\n */\n size?: OptionRowSize;\n }\n>(({ className, inset, size = 'md', ...props }, ref) => (\n <ContextMenuPrimitive.Item\n ref={ref}\n className={cn(\n 'flex w-full cursor-default select-none items-center rounded-sm px-space-2 py-space-1 text-primary outline-hidden transition-colors focus:bg-elevated-hover data-[disabled]:pointer-events-none data-[highlighted]:bg-elevated-hover data-[disabled]:opacity-50',\n OPTION_ROW_SIZES[size].minHeightClassName,\n size === 'sm' ? 'text-xs leading-4' : 'text-sm',\n inset ? 'pl-space-8' : undefined,\n className\n )}\n {...props}\n />\n));\nContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName;\n\nexport const ContextMenuSeparator = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <ContextMenuPrimitive.Separator\n ref={ref}\n className={cn('-mx-space-1 my-space-1 border-b border-subtle', className)}\n {...props}\n />\n));\nContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName;\n"],"mappings":";;;;;;;;;AAaA,IAAa,cAAc,qBAAqB;AAEhD,IAAa,qBAAqB,qBAAqB;AAEvD,IAAa,qBAAqB,QAAM,YAGrC,EAAE,WAAW,UAAU,GAAG,SAAS,QAAQ;CAC5C,MAAM,SAAS,UAAU,SAAS,OAAO;CAEzC,OACE,oBAAC,qBAAqB,QAAtB,EAAA,UACE,oBAAC,qBAAqB,SAAtB;EACO;EACL,WAAW,GACT,6GACA,SACF;EACA,GAAI;EACJ,OAAO;GAAE;GAAQ,GAAG,MAAM;EAAM;EAEhC,UAAA,oBAAC,gBAAD;GAAgB,OAAO;GAAS;EAAyB,CAAA;CAC7B,CAAA,EACH,CAAA;AAEjC,CAAC;AACD,mBAAmB,cAAc,qBAAqB,QAAQ;AAE9D,IAAa,kBAAkB,QAAM,YAUlC,EAAE,WAAW,OAAO,OAAO,MAAM,GAAG,SAAS,QAC9C,oBAAC,qBAAqB,MAAtB;CACO;CACL,WAAW,GACT,kQACA,iBAAiB,KAAK,CAAC,oBACvB,SAAS,OAAO,sBAAsB,WACtC,QAAQ,eAAe,KAAA,GACvB,SACF;CACA,GAAI;AACL,CAAA,CACF;AACD,gBAAgB,cAAc,qBAAqB,KAAK;AAExD,IAAa,uBAAuB,QAAM,YAGvC,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,qBAAqB,WAAtB;CACO;CACL,WAAW,GAAG,iDAAiD,SAAS;CACxE,GAAI;AACL,CAAA,CACF;AACD,qBAAqB,cAAc,qBAAqB,UAAU"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
+
import { type DataAttributes } from '../../utils/dataAttributes.js';
|
|
2
3
|
import { type IconButtonProps } from '../IconButton/index.js';
|
|
3
|
-
export interface CopyButtonProps {
|
|
4
|
+
export interface CopyButtonProps extends DataAttributes {
|
|
4
5
|
copy: string;
|
|
5
6
|
variant?: 'full' | 'icon';
|
|
6
7
|
className?: string;
|
|
@@ -9,7 +10,7 @@ export interface CopyButtonProps {
|
|
|
9
10
|
onCopy?: () => void;
|
|
10
11
|
}
|
|
11
12
|
export declare function CopyButton(props: CopyButtonProps): import("react").JSX.Element;
|
|
12
|
-
export interface CopyIconButtonProps {
|
|
13
|
+
export interface CopyIconButtonProps extends DataAttributes {
|
|
13
14
|
copy: string;
|
|
14
15
|
className?: string;
|
|
15
16
|
iconClassName?: string;
|
|
@@ -2,6 +2,7 @@ import { Text } from "../Text/Text.js";
|
|
|
2
2
|
import { Button } from "../Button/Button.js";
|
|
3
3
|
import { IconButton } from "../IconButton/IconButton.js";
|
|
4
4
|
import { CheckIcon } from "../../icons/PaddedPhosphorIcons.js";
|
|
5
|
+
import { pickDataAttributes } from "../../utils/dataAttributes.js";
|
|
5
6
|
import { useCopy } from "./useCopy.js";
|
|
6
7
|
import { useState } from "react";
|
|
7
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -9,7 +10,9 @@ import { CopySimpleIcon } from "@phosphor-icons/react/dist/ssr/CopySimple";
|
|
|
9
10
|
//#region packages/components/src/components/CopyButton/CopyButton.tsx
|
|
10
11
|
function CopyButton(props) {
|
|
11
12
|
const { copied, onCopy } = useCopy({ copy: props.copy });
|
|
13
|
+
const dataAttributes = pickDataAttributes(props);
|
|
12
14
|
if (props.variant === "icon") return /* @__PURE__ */ jsx(CopyIconButton, {
|
|
15
|
+
...dataAttributes,
|
|
13
16
|
copy: props.copy,
|
|
14
17
|
copyText: props.copyText,
|
|
15
18
|
className: props.className,
|
|
@@ -18,6 +21,7 @@ function CopyButton(props) {
|
|
|
18
21
|
});
|
|
19
22
|
const CopyStatusIcon = copied ? CheckIcon : CopySimpleIcon;
|
|
20
23
|
return /* @__PURE__ */ jsx(Button, {
|
|
24
|
+
...dataAttributes,
|
|
21
25
|
size: "sm",
|
|
22
26
|
color: "secondary",
|
|
23
27
|
variant: "outlined",
|
|
@@ -90,6 +94,7 @@ function CopyIconButton(props) {
|
|
|
90
94
|
const copyLabel = getCopyLabel(props.copyText, props.label);
|
|
91
95
|
const tooltipTitle = props.copyText ?? copyLabel;
|
|
92
96
|
return /* @__PURE__ */ jsx(IconButton, {
|
|
97
|
+
...pickDataAttributes(props),
|
|
93
98
|
onClick: (e) => {
|
|
94
99
|
e.stopPropagation();
|
|
95
100
|
onCopy();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopyButton.js","names":[],"sources":["../../../src/components/CopyButton/CopyButton.tsx"],"sourcesContent":["import { type ReactNode, useState } from 'react';\n\nimport { CopySimpleIcon } from '@phosphor-icons/react/dist/ssr/CopySimple';\n\nimport { CheckIcon } from '../../icons/PaddedPhosphorIcons';\nimport { Button } from '../Button';\nimport { IconButton, type IconButtonProps } from '../IconButton';\nimport { Text } from '../Text';\nimport { useCopy } from './useCopy';\n\nexport interface CopyButtonProps {\n copy: string;\n variant?: 'full' | 'icon';\n className?: string;\n copyText?: string;\n disabled?: boolean;\n onCopy?: () => void;\n}\n\nexport function CopyButton(props: CopyButtonProps) {\n const { copied, onCopy } = useCopy({ copy: props.copy });\n\n if (props.variant === 'icon') {\n return (\n <CopyIconButton\n copy={props.copy}\n copyText={props.copyText}\n className={props.className}\n disabled={props.disabled}\n onCopy={props.onCopy}\n />\n );\n }\n\n const CopyStatusIcon = copied ? CheckIcon : CopySimpleIcon;\n\n return (\n <Button\n size=\"sm\"\n color=\"secondary\"\n variant=\"outlined\"\n aria-label={copied ? 'Copied' : (props.copyText ?? 'Copy')}\n onClick={(event) => {\n event.stopPropagation();\n onCopy();\n props.onCopy?.();\n }}\n className={props.className}\n disabled={props.disabled}\n >\n <span className=\"grid\">\n {/* Both states rendered invisibly so the grid cell is always wide enough for either */}\n <Text\n as=\"span\"\n variant=\"sm\"\n weight=\"normal\"\n className=\"invisible col-start-1 row-start-1 flex items-center gap-1 whitespace-nowrap\"\n aria-hidden\n >\n <span aria-hidden className=\"inline-flex size-4 shrink-0\">\n <CopySimpleIcon size=\"100%\" weight=\"regular\" />\n </span>\n {props.copyText ?? 'Copy'}\n </Text>\n <Text\n as=\"span\"\n variant=\"sm\"\n weight=\"normal\"\n className=\"invisible col-start-1 row-start-1 flex items-center gap-1 whitespace-nowrap\"\n aria-hidden\n >\n <span aria-hidden className=\"inline-flex size-4 shrink-0\">\n <CheckIcon size=\"100%\" weight=\"regular\" />\n </span>\n Copied\n </Text>\n <Text\n as=\"span\"\n variant=\"sm\"\n weight=\"normal\"\n className=\"col-start-1 row-start-1 flex items-center justify-center gap-1 whitespace-nowrap\"\n >\n <span aria-hidden className=\"inline-flex size-4 shrink-0\">\n <CopyStatusIcon size=\"100%\" weight=\"regular\" />\n </span>\n {copied ? 'Copied' : (props.copyText ?? 'Copy')}\n </Text>\n </span>\n </Button>\n );\n}\n\nexport interface CopyIconButtonProps {\n copy: string;\n className?: string;\n iconClassName?: string;\n copyText?: ReactNode;\n label?: string;\n disabled?: boolean;\n color?: IconButtonProps['color'];\n size?: IconButtonProps['size'];\n variant?: IconButtonProps['variant'];\n onCopy?: () => void;\n}\n\nfunction getCopyLabel(copyText: ReactNode, label?: string) {\n if (label) return label;\n return typeof copyText === 'string' ? copyText : 'Copy';\n}\n\nexport function CopyIconButton(props: CopyIconButtonProps) {\n const { copied, onCopy } = useCopy({ copy: props.copy });\n const [tooltipOpen, setTooltipOpen] = useState(false);\n const copyLabel = getCopyLabel(props.copyText, props.label);\n const tooltipTitle = props.copyText ?? copyLabel;\n\n return (\n <IconButton\n onClick={(e) => {\n e.stopPropagation();\n onCopy();\n props.onCopy?.();\n }}\n disabled={props.disabled}\n icon={copied ? CheckIcon : CopySimpleIcon}\n label={copied ? 'Copied' : copyLabel}\n tooltipProps={{\n title: copied ? 'Copied' : tooltipTitle,\n side: 'top',\n open: tooltipOpen,\n onOpenChange: (open) => {\n if (open) setTooltipOpen(true);\n },\n }}\n variant={props.variant ?? 'plain'}\n color={props.color ?? 'secondary'}\n size={props.size ?? 'sm'}\n className={props.className}\n iconClassName={props.iconClassName}\n onMouseLeave={() => setTooltipOpen(false)}\n onBlur={() => setTooltipOpen(false)}\n />\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"CopyButton.js","names":[],"sources":["../../../src/components/CopyButton/CopyButton.tsx"],"sourcesContent":["import { type ReactNode, useState } from 'react';\n\nimport { CopySimpleIcon } from '@phosphor-icons/react/dist/ssr/CopySimple';\n\nimport { CheckIcon } from '../../icons/PaddedPhosphorIcons';\nimport {\n type DataAttributes,\n pickDataAttributes,\n} from '../../utils/dataAttributes';\nimport { Button } from '../Button';\nimport { IconButton, type IconButtonProps } from '../IconButton';\nimport { Text } from '../Text';\nimport { useCopy } from './useCopy';\n\nexport interface CopyButtonProps extends DataAttributes {\n copy: string;\n variant?: 'full' | 'icon';\n className?: string;\n copyText?: string;\n disabled?: boolean;\n onCopy?: () => void;\n}\n\nexport function CopyButton(props: CopyButtonProps) {\n const { copied, onCopy } = useCopy({ copy: props.copy });\n const dataAttributes = pickDataAttributes(props);\n\n if (props.variant === 'icon') {\n return (\n <CopyIconButton\n {...dataAttributes}\n copy={props.copy}\n copyText={props.copyText}\n className={props.className}\n disabled={props.disabled}\n onCopy={props.onCopy}\n />\n );\n }\n\n const CopyStatusIcon = copied ? CheckIcon : CopySimpleIcon;\n\n return (\n <Button\n {...dataAttributes}\n size=\"sm\"\n color=\"secondary\"\n variant=\"outlined\"\n aria-label={copied ? 'Copied' : (props.copyText ?? 'Copy')}\n onClick={(event) => {\n event.stopPropagation();\n onCopy();\n props.onCopy?.();\n }}\n className={props.className}\n disabled={props.disabled}\n >\n <span className=\"grid\">\n {/* Both states rendered invisibly so the grid cell is always wide enough for either */}\n <Text\n as=\"span\"\n variant=\"sm\"\n weight=\"normal\"\n className=\"invisible col-start-1 row-start-1 flex items-center gap-1 whitespace-nowrap\"\n aria-hidden\n >\n <span aria-hidden className=\"inline-flex size-4 shrink-0\">\n <CopySimpleIcon size=\"100%\" weight=\"regular\" />\n </span>\n {props.copyText ?? 'Copy'}\n </Text>\n <Text\n as=\"span\"\n variant=\"sm\"\n weight=\"normal\"\n className=\"invisible col-start-1 row-start-1 flex items-center gap-1 whitespace-nowrap\"\n aria-hidden\n >\n <span aria-hidden className=\"inline-flex size-4 shrink-0\">\n <CheckIcon size=\"100%\" weight=\"regular\" />\n </span>\n Copied\n </Text>\n <Text\n as=\"span\"\n variant=\"sm\"\n weight=\"normal\"\n className=\"col-start-1 row-start-1 flex items-center justify-center gap-1 whitespace-nowrap\"\n >\n <span aria-hidden className=\"inline-flex size-4 shrink-0\">\n <CopyStatusIcon size=\"100%\" weight=\"regular\" />\n </span>\n {copied ? 'Copied' : (props.copyText ?? 'Copy')}\n </Text>\n </span>\n </Button>\n );\n}\n\nexport interface CopyIconButtonProps extends DataAttributes {\n copy: string;\n className?: string;\n iconClassName?: string;\n copyText?: ReactNode;\n label?: string;\n disabled?: boolean;\n color?: IconButtonProps['color'];\n size?: IconButtonProps['size'];\n variant?: IconButtonProps['variant'];\n onCopy?: () => void;\n}\n\nfunction getCopyLabel(copyText: ReactNode, label?: string) {\n if (label) return label;\n return typeof copyText === 'string' ? copyText : 'Copy';\n}\n\nexport function CopyIconButton(props: CopyIconButtonProps) {\n const { copied, onCopy } = useCopy({ copy: props.copy });\n const [tooltipOpen, setTooltipOpen] = useState(false);\n const copyLabel = getCopyLabel(props.copyText, props.label);\n const tooltipTitle = props.copyText ?? copyLabel;\n\n return (\n <IconButton\n {...pickDataAttributes(props)}\n onClick={(e) => {\n e.stopPropagation();\n onCopy();\n props.onCopy?.();\n }}\n disabled={props.disabled}\n icon={copied ? CheckIcon : CopySimpleIcon}\n label={copied ? 'Copied' : copyLabel}\n tooltipProps={{\n title: copied ? 'Copied' : tooltipTitle,\n side: 'top',\n open: tooltipOpen,\n onOpenChange: (open) => {\n if (open) setTooltipOpen(true);\n },\n }}\n variant={props.variant ?? 'plain'}\n color={props.color ?? 'secondary'}\n size={props.size ?? 'sm'}\n className={props.className}\n iconClassName={props.iconClassName}\n onMouseLeave={() => setTooltipOpen(false)}\n onBlur={() => setTooltipOpen(false)}\n />\n );\n}\n"],"mappings":";;;;;;;;;;AAuBA,SAAgB,WAAW,OAAwB;CACjD,MAAM,EAAE,QAAQ,WAAW,QAAQ,EAAE,MAAM,MAAM,KAAK,CAAC;CACvD,MAAM,iBAAiB,mBAAmB,KAAK;CAE/C,IAAI,MAAM,YAAY,QACpB,OACE,oBAAC,gBAAD;EACE,GAAI;EACJ,MAAM,MAAM;EACZ,UAAU,MAAM;EAChB,WAAW,MAAM;EACjB,UAAU,MAAM;EAChB,QAAQ,MAAM;CACf,CAAA;CAIL,MAAM,iBAAiB,SAAS,YAAY;CAE5C,OACE,oBAAC,QAAD;EACE,GAAI;EACJ,MAAK;EACL,OAAM;EACN,SAAQ;EACR,cAAY,SAAS,WAAY,MAAM,YAAY;EACnD,UAAU,UAAU;GAClB,MAAM,gBAAgB;GACtB,OAAO;GACP,MAAM,SAAS;EACjB;EACA,WAAW,MAAM;EACjB,UAAU,MAAM;EAEhB,UAAA,qBAAC,QAAD;GAAM,WAAU;GAAhB,UAAA;IAEE,qBAAC,MAAD;KACE,IAAG;KACH,SAAQ;KACR,QAAO;KACP,WAAU;KACV,eAAA;KALF,UAAA,CAOE,oB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ACF;EACA,SAAS,MAAM,WAAW;EAC1B,OAAO,MAAM,SAAS;EACtB,MAAM,MAAM,QAAQ;EACpB,WAAW,MAAM;EACjB,eAAe,MAAM;EACrB,oBAAoB,eAAe,KAAK;EACxC,cAAc,eAAe,KAAK;CACnC,CAAA;AAEL"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type ComponentPropsWithoutRef, type KeyboardEvent as ReactKeyboardEvent, type ReactNode } from 'react';
|
|
2
2
|
import { DialogClose as RadixDialogClose, DialogDescription as RadixDialogDescription, DialogTitle as RadixDialogTitle, type DialogContentProps as RadixDialogContentProps } from '@radix-ui/react-dialog';
|
|
3
|
+
import { type DataAttributes } from '../../utils/dataAttributes.js';
|
|
4
|
+
export { ModalProvider } from '../../utils/ModalLayerContext.js';
|
|
3
5
|
import type { IconComponent } from '../Icon/index.js';
|
|
4
6
|
/**
|
|
5
7
|
* Exposes the modal DialogContent DOM node to descendants so portaled overlays
|
|
@@ -20,7 +22,7 @@ export type DialogCloseProps = ComponentPropsWithoutRef<typeof RadixDialogClose>
|
|
|
20
22
|
/** Closes the nearest dialog and supports custom controls through `asChild`. */
|
|
21
23
|
export declare const DialogClose: import("react").ForwardRefExoticComponent<Omit<import("@radix-ui/react-dialog").DialogCloseProps & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
22
24
|
type TitleIconIntent = 'error' | 'warning' | 'info';
|
|
23
|
-
interface DialogContentProps {
|
|
25
|
+
interface DialogContentProps extends DataAttributes {
|
|
24
26
|
title?: ReactNode;
|
|
25
27
|
description?: ReactNode;
|
|
26
28
|
/** Icon component to display in the title area, inside a colored circular container */
|
|
@@ -46,4 +48,3 @@ export declare function Dialog({ open, onOpenChange, children, className, onEsca
|
|
|
46
48
|
onEscapeKeyDown?: (e: ReactKeyboardEvent) => void;
|
|
47
49
|
}): import("react").JSX.Element;
|
|
48
50
|
export declare const DialogContent: import("react").ForwardRefExoticComponent<DialogContentProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
49
|
-
export {};
|
|
@@ -6,7 +6,9 @@ import { ZIndexProvider } from "../../utils/ZIndexContext.js";
|
|
|
6
6
|
import { Icon } from "../Icon/Icon.js";
|
|
7
7
|
import { IconButton } from "../IconButton/IconButton.js";
|
|
8
8
|
import { XIcon } from "../../icons/PaddedPhosphorIcons.js";
|
|
9
|
+
import { pickDataAttributes } from "../../utils/dataAttributes.js";
|
|
9
10
|
import { mergeRefs } from "../../utils/merge-refs.js";
|
|
11
|
+
import { ModalLayerProvider, ModalProvider, useCurrentModalLayer, useModalLayer } from "../../utils/ModalLayerContext.js";
|
|
10
12
|
import { createContext, forwardRef, useContext, useState } from "react";
|
|
11
13
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
14
|
import { Dialog as Dialog$1, DialogClose as DialogClose$1, DialogContent as DialogContent$1, DialogDescription as DialogDescription$1, DialogOverlay, DialogPortal, DialogTitle as DialogTitle$1 } from "@radix-ui/react-dialog";
|
|
@@ -40,36 +42,61 @@ var DialogClose = forwardRef((props, ref) => /* @__PURE__ */ jsx(DialogClose$1,
|
|
|
40
42
|
...props
|
|
41
43
|
}));
|
|
42
44
|
DialogClose.displayName = "DialogClose";
|
|
45
|
+
var DialogEscapeContext = createContext(void 0);
|
|
43
46
|
function Dialog({ open, onOpenChange, children, className, onEscapeKeyDown }) {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
const layer = useModalLayer(open);
|
|
48
|
+
const zIndex = useZIndex(layer.zIndex ?? zIndices.dialogOverlay);
|
|
49
|
+
return /* @__PURE__ */ jsx(ModalLayerProvider, {
|
|
50
|
+
layer,
|
|
51
|
+
children: /* @__PURE__ */ jsx(DialogEscapeContext.Provider, {
|
|
52
|
+
value: onEscapeKeyDown,
|
|
53
|
+
children: /* @__PURE__ */ jsx(ZIndexProvider, {
|
|
54
|
+
value: zIndex,
|
|
55
|
+
children: /* @__PURE__ */ jsx(Dialog$1, {
|
|
56
|
+
modal: true,
|
|
57
|
+
open: open && !layer.suspended,
|
|
58
|
+
onOpenChange,
|
|
59
|
+
children: /* @__PURE__ */ jsxs(DialogPortal, {
|
|
60
|
+
forceMount: open || void 0,
|
|
61
|
+
children: [/* @__PURE__ */ jsx(DialogOverlay, {
|
|
62
|
+
forceMount: open || void 0,
|
|
63
|
+
className: cn("fixed inset-0 bg-overlay", "data-[state=open]:animate-overlay-in data-[state=closed]:animate-overlay-out motion-reduce:animate-none", className),
|
|
64
|
+
style: {
|
|
65
|
+
zIndex,
|
|
66
|
+
...layer.backdropStyle,
|
|
67
|
+
display: layer.suspended ? "none" : void 0
|
|
68
|
+
}
|
|
69
|
+
}), children]
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
})
|
|
57
74
|
});
|
|
58
75
|
}
|
|
59
|
-
var DialogContent = forwardRef(({ title, description, titleIcon: TitleIcon, titleIconIntent = "info", showClose = true, children, className, childrenClassName, onPointerDownOutside, onInteractOutside, onOpenAutoFocus, onCloseAutoFocus, onEscapeKeyDown, onKeyDown }, ref) => {
|
|
76
|
+
var DialogContent = forwardRef(({ title, description, titleIcon: TitleIcon, titleIconIntent = "info", showClose = true, children, className, childrenClassName, onPointerDownOutside, onInteractOutside, onOpenAutoFocus, onCloseAutoFocus, onEscapeKeyDown, onKeyDown, ...rest }, ref) => {
|
|
60
77
|
const dialogZIndex = useZIndex(zIndices.dialogContent);
|
|
78
|
+
const layer = useCurrentModalLayer();
|
|
79
|
+
const onDialogEscape = useContext(DialogEscapeContext);
|
|
61
80
|
const hasHeader = Boolean(title || description || showClose);
|
|
62
81
|
const [contentNode, setContentNode] = useState(null);
|
|
63
82
|
return /* @__PURE__ */ jsx(DialogContent$1, {
|
|
83
|
+
forceMount: layer?.open || void 0,
|
|
84
|
+
...pickDataAttributes(rest),
|
|
64
85
|
ref: mergeRefs([ref, setContentNode]),
|
|
65
86
|
className: cn("fixed left-[50%] top-[50%] flex max-h-[calc(100vh-2rem)] w-[37.5rem] translate-x-[-50%] translate-y-[-50%] flex-col rounded-lg bg-background", "fade-in", "data-[state=closed]:fade-out", className),
|
|
66
|
-
style: {
|
|
87
|
+
style: {
|
|
88
|
+
zIndex: dialogZIndex,
|
|
89
|
+
display: layer?.suspended ? "none" : void 0
|
|
90
|
+
},
|
|
67
91
|
onPointerDownOutside,
|
|
68
92
|
onInteractOutside,
|
|
69
93
|
onOpenAutoFocus,
|
|
70
94
|
onCloseAutoFocus,
|
|
71
95
|
onEscapeKeyDown,
|
|
72
|
-
onKeyDown
|
|
96
|
+
onKeyDown: (event) => {
|
|
97
|
+
onKeyDown?.(event);
|
|
98
|
+
if (event.key === "Escape") onDialogEscape?.(event);
|
|
99
|
+
},
|
|
73
100
|
children: /* @__PURE__ */ jsx(ZIndexProvider, {
|
|
74
101
|
value: dialogZIndex,
|
|
75
102
|
children: /* @__PURE__ */ jsxs(DialogContainerContext.Provider, {
|
|
@@ -125,6 +152,6 @@ var DialogContent = forwardRef(({ title, description, titleIcon: TitleIcon, titl
|
|
|
125
152
|
});
|
|
126
153
|
DialogContent.displayName = "DialogContent";
|
|
127
154
|
//#endregion
|
|
128
|
-
export { Dialog, DialogClose, DialogContainerContext, DialogContent, DialogDescription, DialogTitle, useDialogContainer };
|
|
155
|
+
export { Dialog, DialogClose, DialogContainerContext, DialogContent, DialogDescription, DialogTitle, ModalProvider, useDialogContainer };
|
|
129
156
|
|
|
130
157
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Dialog/index.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type KeyboardEvent as ReactKeyboardEvent,\n type ReactNode,\n createContext,\n forwardRef,\n useContext,\n useState,\n} from 'react';\n\nimport {\n DialogClose as RadixDialogClose,\n DialogDescription as RadixDialogDescription,\n DialogOverlay,\n DialogPortal,\n DialogTitle as RadixDialogTitle,\n Dialog as RadixDialog,\n DialogContent as RadixDialogContent,\n type DialogContentProps as RadixDialogContentProps,\n} from '@radix-ui/react-dialog';\n\nimport { XIcon } from '../../icons/PaddedPhosphorIcons';\nimport { cn } from '../../utils/cn';\nimport { mergeRefs } from '../../utils/merge-refs';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\nimport { Icon } from '../Icon';\nimport type { IconComponent } from '../Icon';\nimport { IconButton } from '../IconButton';\nimport { Text } from '../Text';\n\n/**\n * Exposes the modal DialogContent DOM node to descendants so portaled overlays\n * (e.g. Typeahead's Popover) can render inside the dialog. A modal Dialog sets\n * `pointer-events: none` outside DialogContent, so overlays portaled to\n * `document.body` become mouse-inert; portaling into this node keeps them\n * interactive. Null when not inside a Dialog.\n */\n// eslint-disable-next-line react-refresh/only-export-components\nexport const DialogContainerContext = createContext<HTMLElement | null>(null);\n\n// eslint-disable-next-line react-refresh/only-export-components\nexport function useDialogContainer(): HTMLElement | null {\n return useContext(DialogContainerContext);\n}\n\nexport type DialogTitleProps = ComponentPropsWithoutRef<\n typeof RadixDialogTitle\n>;\n\n/** Associates a custom-composed heading with the dialog content. */\nexport const DialogTitle = forwardRef<\n ComponentRef<typeof RadixDialogTitle>,\n DialogTitleProps\n>((props, ref) => <RadixDialogTitle ref={ref} {...props} />);\nDialogTitle.displayName = 'DialogTitle';\n\nexport type DialogDescriptionProps = ComponentPropsWithoutRef<\n typeof RadixDialogDescription\n>;\n\n/** Associates supporting copy with the dialog content. */\nexport const DialogDescription = forwardRef<\n ComponentRef<typeof RadixDialogDescription>,\n DialogDescriptionProps\n>((props, ref) => <RadixDialogDescription ref={ref} {...props} />);\nDialogDescription.displayName = 'DialogDescription';\n\nexport type DialogCloseProps = ComponentPropsWithoutRef<\n typeof RadixDialogClose\n>;\n\n/** Closes the nearest dialog and supports custom controls through `asChild`. */\nexport const DialogClose = forwardRef<\n ComponentRef<typeof RadixDialogClose>,\n DialogCloseProps\n>((props, ref) => <RadixDialogClose ref={ref} {...props} />);\nDialogClose.displayName = 'DialogClose';\n\ntype TitleIconIntent = 'error' | 'warning' | 'info';\n\ninterface DialogContentProps {\n title?: ReactNode;\n description?: ReactNode;\n /** Icon component to display in the title area, inside a colored circular container */\n titleIcon?: IconComponent;\n /** Controls the background and color of the title icon container */\n titleIconIntent?: TitleIconIntent;\n showClose?: boolean;\n children: ReactNode;\n className?: string;\n childrenClassName?: string;\n onPointerDownOutside?: RadixDialogContentProps['onPointerDownOutside'];\n onInteractOutside?: RadixDialogContentProps['onInteractOutside'];\n onOpenAutoFocus?: RadixDialogContentProps['onOpenAutoFocus'];\n onCloseAutoFocus?: RadixDialogContentProps['onCloseAutoFocus'];\n onEscapeKeyDown?: RadixDialogContentProps['onEscapeKeyDown'];\n onKeyDown?: RadixDialogContentProps['onKeyDown'];\n}\n\nexport function Dialog({\n open,\n onOpenChange,\n children,\n className,\n onEscapeKeyDown,\n}: {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n children: ReactNode;\n className?: string;\n onEscapeKeyDown?: (e: ReactKeyboardEvent) => void;\n}) {\n const zIndex = useZIndex(zIndices.dialogOverlay);\n return (\n <RadixDialog modal={true} open={open} onOpenChange={onOpenChange}>\n <DialogPortal>\n <DialogOverlay\n className={cn(\n 'fixed inset-0 bg-overlay',\n 'data-[state=open]:animate-overlay-in data-[state=closed]:animate-overlay-out motion-reduce:animate-none',\n className\n )}\n style={{ zIndex }}\n onKeyDown={(e) => {\n if (e.key === 'Escape' && onEscapeKeyDown) {\n onEscapeKeyDown(e);\n }\n }}\n >\n {children}\n </DialogOverlay>\n </DialogPortal>\n </RadixDialog>\n );\n}\n\nexport const DialogContent = forwardRef<HTMLDivElement, DialogContentProps>(\n (\n {\n title,\n description,\n titleIcon: TitleIcon,\n titleIconIntent = 'info',\n showClose = true,\n children,\n className,\n childrenClassName,\n onPointerDownOutside,\n onInteractOutside,\n onOpenAutoFocus,\n onCloseAutoFocus,\n onEscapeKeyDown,\n onKeyDown,\n },\n ref\n ) => {\n const dialogZIndex = useZIndex(zIndices.dialogContent);\n const hasHeader = Boolean(title || description || showClose);\n // A modal Dialog sets `pointer-events: none` outside this node, so overlays\n // portaled to `document.body` (e.g. Typeahead's Popover) become mouse-inert.\n // Expose the content node so descendants can portal into it and stay live.\n const [contentNode, setContentNode] = useState<HTMLDivElement | null>(null);\n\n return (\n <RadixDialogContent\n ref={mergeRefs([ref, setContentNode])}\n className={cn(\n 'fixed left-[50%] top-[50%] flex max-h-[calc(100vh-2rem)] w-[37.5rem] translate-x-[-50%] translate-y-[-50%] flex-col rounded-lg bg-background',\n 'fade-in',\n 'data-[state=closed]:fade-out',\n className\n )}\n style={{ zIndex: dialogZIndex }}\n onPointerDownOutside={onPointerDownOutside}\n onInteractOutside={onInteractOutside}\n onOpenAutoFocus={onOpenAutoFocus}\n onCloseAutoFocus={onCloseAutoFocus}\n onEscapeKeyDown={onEscapeKeyDown}\n onKeyDown={onKeyDown}\n >\n <ZIndexProvider value={dialogZIndex}>\n <DialogContainerContext.Provider value={contentNode}>\n {hasHeader && (\n <div className=\"m-0 min-h-14 shrink-0 p-space-4\">\n <div className=\"flex items-center justify-between gap-space-4\">\n <div className=\"flex min-w-0 items-center gap-space-2\">\n {TitleIcon && (\n <Icon\n icon={TitleIcon}\n color={titleIconIntent}\n size=\"md\"\n />\n )}\n <div className=\"flex min-w-0 flex-col gap-space-1\">\n {title && (\n <DialogTitle asChild>\n <Text variant=\"h3\" weight=\"semibold\">\n {title}\n </Text>\n </DialogTitle>\n )}\n {description && (\n <DialogDescription asChild>\n <Text variant=\"sm\" className=\"text-quaternary\">\n {description}\n </Text>\n </DialogDescription>\n )}\n </div>\n </div>\n {showClose && (\n <DialogClose asChild>\n <IconButton\n icon={XIcon}\n label=\"Close\"\n color=\"secondary\"\n variant=\"plain\"\n className=\"shrink-0 self-start\"\n data-testid=\"dialog-close-button\"\n tooltipProps={{ disabled: true }}\n />\n </DialogClose>\n )}\n </div>\n </div>\n )}\n <div\n className={cn(\n 'flex min-h-0 flex-col gap-space-4 overflow-y-auto p-space-4',\n hasHeader && 'pt-0',\n childrenClassName\n )}\n >\n {children}\n </div>\n </DialogContainerContext.Provider>\n </ZIndexProvider>\n </RadixDialogContent>\n );\n }\n);\n\nDialogContent.displayName = 'DialogContent';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,yBAAyB,cAAkC,IAAI;AAG5E,SAAgB,qBAAyC;CACvD,OAAO,WAAW,sBAAsB;AAC1C;;AAOA,IAAa,cAAc,YAGxB,OAAO,QAAQ,oBAAC,eAAD;CAAuB;CAAK,GAAI;AAAQ,CAAA,CAAC;AAC3D,YAAY,cAAc;;AAO1B,IAAa,oBAAoB,YAG9B,OAAO,QAAQ,oBAAC,qBAAD;CAA6B;CAAK,GAAI;AAAQ,CAAA,CAAC;AACjE,kBAAkB,cAAc;;AAOhC,IAAa,cAAc,YAGxB,OAAO,QAAQ,oBAAC,eAAD;CAAuB;CAAK,GAAI;AAAQ,CAAA,CAAC;AAC3D,YAAY,cAAc;AAuB1B,SAAgB,OAAO,EACrB,MACA,cACA,UACA,WACA,mBAOC;CACD,MAAM,SAAS,UAAU,SAAS,aAAa;CAC/C,OACE,oBAAC,UAAD;EAAa,OAAO;EAAY;EAAoB;EAClD,UAAA,oBAAC,cAAD,EAAA,UACE,oBAAC,eAAD;GACE,WAAW,GACT,4BACA,2GACA,SACF;GACA,OAAO,EAAE,OAAO;GAChB,YAAY,MAAM;IAChB,IAAI,EAAE,QAAQ,YAAY,iBACxB,gBAAgB,CAAC;GAErB;GAEC;EACY,CAAA,EACH,CAAA;CACH,CAAA;AAEjB;AAEA,IAAa,gBAAgB,YAEzB,EACE,OACA,aACA,WAAW,WACX,kBAAkB,QACl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EC;IACE,CAAA,CAC0B;;EACnB,CAAA;CACE,CAAA;AAExB,CACF;AAEA,cAAc,cAAc"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Dialog/index.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type KeyboardEvent as ReactKeyboardEvent,\n type ReactNode,\n createContext,\n forwardRef,\n useContext,\n useState,\n} from 'react';\n\nimport {\n DialogClose as RadixDialogClose,\n DialogDescription as RadixDialogDescription,\n DialogOverlay,\n DialogPortal,\n DialogTitle as RadixDialogTitle,\n Dialog as RadixDialog,\n DialogContent as RadixDialogContent,\n type DialogContentProps as RadixDialogContentProps,\n} from '@radix-ui/react-dialog';\n\nimport { XIcon } from '../../icons/PaddedPhosphorIcons';\nimport { cn } from '../../utils/cn';\nimport {\n type DataAttributes,\n pickDataAttributes,\n} from '../../utils/dataAttributes';\nimport { mergeRefs } from '../../utils/merge-refs';\nimport {\n ModalLayerProvider,\n useCurrentModalLayer,\n useModalLayer,\n} from '../../utils/ModalLayerContext';\nexport { ModalProvider } from '../../utils/ModalLayerContext';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\nimport { Icon } from '../Icon';\nimport type { IconComponent } from '../Icon';\nimport { IconButton } from '../IconButton';\nimport { Text } from '../Text';\n\n/**\n * Exposes the modal DialogContent DOM node to descendants so portaled overlays\n * (e.g. Typeahead's Popover) can render inside the dialog. A modal Dialog sets\n * `pointer-events: none` outside DialogContent, so overlays portaled to\n * `document.body` become mouse-inert; portaling into this node keeps them\n * interactive. Null when not inside a Dialog.\n */\n// eslint-disable-next-line react-refresh/only-export-components\nexport const DialogContainerContext = createContext<HTMLElement | null>(null);\n\n// eslint-disable-next-line react-refresh/only-export-components\nexport function useDialogContainer(): HTMLElement | null {\n return useContext(DialogContainerContext);\n}\n\nexport type DialogTitleProps = ComponentPropsWithoutRef<\n typeof RadixDialogTitle\n>;\n\n/** Associates a custom-composed heading with the dialog content. */\nexport const DialogTitle = forwardRef<\n ComponentRef<typeof RadixDialogTitle>,\n DialogTitleProps\n>((props, ref) => <RadixDialogTitle ref={ref} {...props} />);\nDialogTitle.displayName = 'DialogTitle';\n\nexport type DialogDescriptionProps = ComponentPropsWithoutRef<\n typeof RadixDialogDescription\n>;\n\n/** Associates supporting copy with the dialog content. */\nexport const DialogDescription = forwardRef<\n ComponentRef<typeof RadixDialogDescription>,\n DialogDescriptionProps\n>((props, ref) => <RadixDialogDescription ref={ref} {...props} />);\nDialogDescription.displayName = 'DialogDescription';\n\nexport type DialogCloseProps = ComponentPropsWithoutRef<\n typeof RadixDialogClose\n>;\n\n/** Closes the nearest dialog and supports custom controls through `asChild`. */\nexport const DialogClose = forwardRef<\n ComponentRef<typeof RadixDialogClose>,\n DialogCloseProps\n>((props, ref) => <RadixDialogClose ref={ref} {...props} />);\nDialogClose.displayName = 'DialogClose';\n\nconst DialogEscapeContext = createContext<\n ((event: ReactKeyboardEvent) => void) | undefined\n>(undefined);\n\ntype TitleIconIntent = 'error' | 'warning' | 'info';\n\ninterface DialogContentProps extends DataAttributes {\n title?: ReactNode;\n description?: ReactNode;\n /** Icon component to display in the title area, inside a colored circular container */\n titleIcon?: IconComponent;\n /** Controls the background and color of the title icon container */\n titleIconIntent?: TitleIconIntent;\n showClose?: boolean;\n children: ReactNode;\n className?: string;\n childrenClassName?: string;\n onPointerDownOutside?: RadixDialogContentProps['onPointerDownOutside'];\n onInteractOutside?: RadixDialogContentProps['onInteractOutside'];\n onOpenAutoFocus?: RadixDialogContentProps['onOpenAutoFocus'];\n onCloseAutoFocus?: RadixDialogContentProps['onCloseAutoFocus'];\n onEscapeKeyDown?: RadixDialogContentProps['onEscapeKeyDown'];\n onKeyDown?: RadixDialogContentProps['onKeyDown'];\n}\n\nexport function Dialog({\n open,\n onOpenChange,\n children,\n className,\n onEscapeKeyDown,\n}: {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n children: ReactNode;\n className?: string;\n onEscapeKeyDown?: (e: ReactKeyboardEvent) => void;\n}) {\n const layer = useModalLayer(open);\n const zIndex = useZIndex(layer.zIndex ?? zIndices.dialogOverlay);\n return (\n <ModalLayerProvider layer={layer}>\n <DialogEscapeContext.Provider value={onEscapeKeyDown}>\n <ZIndexProvider value={zIndex}>\n <RadixDialog\n modal={true}\n open={open && !layer.suspended}\n onOpenChange={onOpenChange}\n >\n <DialogPortal forceMount={open || undefined}>\n <DialogOverlay\n forceMount={open || undefined}\n className={cn(\n 'fixed inset-0 bg-overlay',\n 'data-[state=open]:animate-overlay-in data-[state=closed]:animate-overlay-out motion-reduce:animate-none',\n className\n )}\n style={{\n zIndex,\n ...layer.backdropStyle,\n display: layer.suspended ? 'none' : undefined,\n }}\n />\n {children}\n </DialogPortal>\n </RadixDialog>\n </ZIndexProvider>\n </DialogEscapeContext.Provider>\n </ModalLayerProvider>\n );\n}\n\nexport const DialogContent = forwardRef<HTMLDivElement, DialogContentProps>(\n (\n {\n title,\n description,\n titleIcon: TitleIcon,\n titleIconIntent = 'info',\n showClose = true,\n children,\n className,\n childrenClassName,\n onPointerDownOutside,\n onInteractOutside,\n onOpenAutoFocus,\n onCloseAutoFocus,\n onEscapeKeyDown,\n onKeyDown,\n ...rest\n },\n ref\n ) => {\n const dialogZIndex = useZIndex(zIndices.dialogContent);\n const layer = useCurrentModalLayer();\n const onDialogEscape = useContext(DialogEscapeContext);\n const hasHeader = Boolean(title || description || showClose);\n // A modal Dialog sets `pointer-events: none` outside this node, so overlays\n // portaled to `document.body` (e.g. Typeahead's Popover) become mouse-inert.\n // Expose the content node so descendants can portal into it and stay live.\n const [contentNode, setContentNode] = useState<HTMLDivElement | null>(null);\n\n return (\n <RadixDialogContent\n forceMount={layer?.open || undefined}\n {...pickDataAttributes(rest)}\n ref={mergeRefs([ref, setContentNode])}\n className={cn(\n 'fixed left-[50%] top-[50%] flex max-h-[calc(100vh-2rem)] w-[37.5rem] translate-x-[-50%] translate-y-[-50%] flex-col rounded-lg bg-background',\n 'fade-in',\n 'data-[state=closed]:fade-out',\n className\n )}\n style={{\n zIndex: dialogZIndex,\n display: layer?.suspended ? 'none' : undefined,\n }}\n onPointerDownOutside={onPointerDownOutside}\n onInteractOutside={onInteractOutside}\n onOpenAutoFocus={onOpenAutoFocus}\n onCloseAutoFocus={onCloseAutoFocus}\n onEscapeKeyDown={onEscapeKeyDown}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.key === 'Escape') onDialogEscape?.(event);\n }}\n >\n <ZIndexProvider value={dialogZIndex}>\n <DialogContainerContext.Provider value={contentNode}>\n {hasHeader && (\n <div className=\"m-0 min-h-14 shrink-0 p-space-4\">\n <div className=\"flex items-center justify-between gap-space-4\">\n <div className=\"flex min-w-0 items-center gap-space-2\">\n {TitleIcon && (\n <Icon\n icon={TitleIcon}\n color={titleIconIntent}\n size=\"md\"\n />\n )}\n <div className=\"flex min-w-0 flex-col gap-space-1\">\n {title && (\n <DialogTitle asChild>\n <Text variant=\"h3\" weight=\"semibold\">\n {title}\n </Text>\n </DialogTitle>\n )}\n {description && (\n <DialogDescription asChild>\n <Text variant=\"sm\" className=\"text-quaternary\">\n {description}\n </Text>\n </DialogDescription>\n )}\n </div>\n </div>\n {showClose && (\n <DialogClose asChild>\n <IconButton\n icon={XIcon}\n label=\"Close\"\n color=\"secondary\"\n variant=\"plain\"\n className=\"shrink-0 self-start\"\n data-testid=\"dialog-close-button\"\n tooltipProps={{ disabled: true }}\n />\n </DialogClose>\n )}\n </div>\n </div>\n )}\n <div\n className={cn(\n 'flex min-h-0 flex-col gap-space-4 overflow-y-auto p-space-4',\n hasHeader && 'pt-0',\n childrenClassName\n )}\n >\n {children}\n </div>\n </DialogContainerContext.Provider>\n </ZIndexProvider>\n </RadixDialogContent>\n );\n }\n);\n\nDialogContent.displayName = 'DialogContent';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmDA,IAAa,yBAAyB,cAAkC,IAAI;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,cAAc,EAAE,UAAU,KAAK;OAChC,CAAA;MACU,CAAA,CAEZ;;IACF,CAAA,GAEP,oBAAC,OAAD;KACE,WAAW,GACT,+DACA,aAAa,QACb,iBACF;KAEC;IACE,CAAA,CAC0B;;EACnB,CAAA;CACE,CAAA;AAExB,CACF;AAEA,cAAc,cAAc"}
|
|
@@ -29,7 +29,7 @@ var AnimatedDonutArc = ({ arc, path, animationProgress, animationStartAngle, ani
|
|
|
29
29
|
return /* @__PURE__ */ jsx(animated.path, {
|
|
30
30
|
fill: arc.data.color,
|
|
31
31
|
opacity: isDimmed ? CHART_DIMMED_OPACITY : 1,
|
|
32
|
-
className: cn("transition-opacity duration-fast focus:outline-
|
|
32
|
+
className: cn("transition-opacity duration-fast focus:outline-hidden focus-visible:stroke-focus focus-visible:stroke-2 motion-reduce:transition-none", isInteractive && "cursor-pointer"),
|
|
33
33
|
d: animationProgress.to((progress) => {
|
|
34
34
|
const revealAngle = animationStartAngle + (animationEndAngle - animationStartAngle) * progress;
|
|
35
35
|
const endAngle = Math.min(arc.endAngle, Math.max(arc.startAngle, revealAngle));
|