@health-samurai/react-components 0.0.0-alpha.4 → 0.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.css +1375 -484
- package/dist/src/components/code-editor/http/grammar/http.d.ts +3 -0
- package/dist/src/components/code-editor/http/grammar/http.d.ts.map +1 -0
- package/dist/src/components/code-editor/http/grammar/http.grammar +74 -0
- package/dist/src/components/code-editor/http/grammar/http.js +38 -0
- package/dist/src/components/code-editor/http/grammar/http.js.map +1 -0
- package/dist/src/components/code-editor/http/grammar/http.terms.d.ts +2 -0
- package/dist/src/components/code-editor/http/grammar/http.terms.d.ts.map +1 -0
- package/dist/src/components/code-editor/http/grammar/http.terms.js +4 -0
- package/dist/src/components/code-editor/http/grammar/http.terms.js.map +1 -0
- package/dist/src/components/code-editor/http/grammar/http.test.d.ts +2 -0
- package/dist/src/components/code-editor/http/grammar/http.test.d.ts.map +1 -0
- package/dist/src/components/code-editor/http/grammar/http.test.js +80 -0
- package/dist/src/components/code-editor/http/grammar/http.test.js.map +1 -0
- package/dist/src/components/code-editor/http/index.d.ts +4 -0
- package/dist/src/components/code-editor/http/index.d.ts.map +1 -0
- package/dist/src/components/code-editor/http/index.js +66 -0
- package/dist/src/components/code-editor/http/index.js.map +1 -0
- package/dist/src/components/code-editor/index.d.ts +14 -2
- package/dist/src/components/code-editor/index.d.ts.map +1 -1
- package/dist/src/components/code-editor/index.js +309 -20
- package/dist/src/components/code-editor/index.js.map +1 -1
- package/dist/src/components/code-editor.stories.d.ts +1 -0
- package/dist/src/components/code-editor.stories.d.ts.map +1 -1
- package/dist/src/components/code-editor.stories.js +255 -2
- package/dist/src/components/code-editor.stories.js.map +1 -1
- package/dist/src/components/copy-icon.d.ts +5 -1
- package/dist/src/components/copy-icon.d.ts.map +1 -1
- package/dist/src/components/copy-icon.js +41 -3
- package/dist/src/components/copy-icon.js.map +1 -1
- package/dist/src/components/data-table.d.ts +8 -0
- package/dist/src/components/data-table.d.ts.map +1 -0
- package/dist/src/components/data-table.js +65 -0
- package/dist/src/components/data-table.js.map +1 -0
- package/dist/src/components/data-table.stories.d.ts +7 -0
- package/dist/src/components/data-table.stories.d.ts.map +1 -0
- package/dist/src/components/data-table.stories.js +44 -0
- package/dist/src/components/data-table.stories.js.map +1 -0
- package/dist/src/components/fhir-structure-view.d.ts +34 -0
- package/dist/src/components/fhir-structure-view.d.ts.map +1 -0
- package/dist/src/components/fhir-structure-view.js +229 -0
- package/dist/src/components/fhir-structure-view.js.map +1 -0
- package/dist/src/components/fhir-structure-view.stories.d.ts +7 -0
- package/dist/src/components/fhir-structure-view.stories.d.ts.map +1 -0
- package/dist/src/components/fhir-structure-view.stories.js +447 -0
- package/dist/src/components/fhir-structure-view.stories.js.map +1 -0
- package/dist/src/components/patient-table.d.ts +73 -0
- package/dist/src/components/patient-table.d.ts.map +1 -0
- package/dist/src/components/patient-table.js +921 -0
- package/dist/src/components/patient-table.js.map +1 -0
- package/dist/src/components/patient-table.stories.d.ts +111 -0
- package/dist/src/components/patient-table.stories.d.ts.map +1 -0
- package/dist/src/components/patient-table.stories.js +172 -0
- package/dist/src/components/patient-table.stories.js.map +1 -0
- package/dist/src/components/request-line-editor.d.ts +13 -35
- package/dist/src/components/request-line-editor.d.ts.map +1 -1
- package/dist/src/components/request-line-editor.js +72 -49
- package/dist/src/components/request-line-editor.js.map +1 -1
- package/dist/src/components/request-line-editor.stories.d.ts.map +1 -1
- package/dist/src/components/request-line-editor.stories.js +17 -53
- package/dist/src/components/request-line-editor.stories.js.map +1 -1
- package/dist/src/components/segment-control.d.ts +16 -0
- package/dist/src/components/segment-control.d.ts.map +1 -0
- package/dist/src/components/segment-control.js +48 -0
- package/dist/src/components/segment-control.js.map +1 -0
- package/dist/src/components/segment-control.stories.d.ts +15 -0
- package/dist/src/components/segment-control.stories.d.ts.map +1 -0
- package/dist/src/components/segment-control.stories.js +33 -0
- package/dist/src/components/segment-control.stories.js.map +1 -0
- package/dist/src/components/split-button.d.ts +5 -0
- package/dist/src/components/split-button.d.ts.map +1 -0
- package/dist/src/components/split-button.js +12 -0
- package/dist/src/components/split-button.js.map +1 -0
- package/dist/src/components/split-button.stories.d.ts +7 -0
- package/dist/src/components/split-button.stories.d.ts.map +1 -0
- package/dist/src/components/split-button.stories.js +57 -0
- package/dist/src/components/split-button.stories.js.map +1 -0
- package/dist/src/components/tree-view.d.ts +22 -0
- package/dist/src/components/tree-view.d.ts.map +1 -0
- package/dist/src/components/tree-view.js +101 -0
- package/dist/src/components/tree-view.js.map +1 -0
- package/dist/src/components/tree-view.stories.d.ts +13 -0
- package/dist/src/components/tree-view.stories.d.ts.map +1 -0
- package/dist/src/components/tree-view.stories.js +274 -0
- package/dist/src/components/tree-view.stories.js.map +1 -0
- package/dist/src/icons.d.ts +9 -0
- package/dist/src/icons.d.ts.map +1 -0
- package/dist/src/icons.js +279 -0
- package/dist/src/icons.js.map +1 -0
- package/dist/src/index.css +42 -3
- package/dist/src/index.d.ts +9 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +9 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/shadcn/components/ui/accordion.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/accordion.js +23 -5
- package/dist/src/shadcn/components/ui/accordion.js.map +1 -1
- package/dist/src/shadcn/components/ui/alert-dialog.d.ts +3 -1
- package/dist/src/shadcn/components/ui/alert-dialog.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/alert-dialog.js +5 -2
- package/dist/src/shadcn/components/ui/alert-dialog.js.map +1 -1
- package/dist/src/shadcn/components/ui/alert.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/alert.js +12 -5
- package/dist/src/shadcn/components/ui/alert.js.map +1 -1
- package/dist/src/shadcn/components/ui/avatar.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/avatar.js +4 -3
- package/dist/src/shadcn/components/ui/avatar.js.map +1 -1
- package/dist/src/shadcn/components/ui/badge.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/badge.js +16 -5
- package/dist/src/shadcn/components/ui/badge.js.map +1 -1
- package/dist/src/shadcn/components/ui/breadcrumb.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/breadcrumb.js +6 -6
- package/dist/src/shadcn/components/ui/breadcrumb.js.map +1 -1
- package/dist/src/shadcn/components/ui/button.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/button.js +19 -11
- package/dist/src/shadcn/components/ui/button.js.map +1 -1
- package/dist/src/shadcn/components/ui/card.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/card.js +14 -6
- package/dist/src/shadcn/components/ui/card.js.map +1 -1
- package/dist/src/shadcn/components/ui/checkbox.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/checkbox.js +20 -5
- package/dist/src/shadcn/components/ui/checkbox.js.map +1 -1
- package/dist/src/shadcn/components/ui/checkbox.stories.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/checkbox.stories.js +44 -35
- package/dist/src/shadcn/components/ui/checkbox.stories.js.map +1 -1
- package/dist/src/shadcn/components/ui/combobox.d.ts +18 -0
- package/dist/src/shadcn/components/ui/combobox.d.ts.map +1 -0
- package/dist/src/shadcn/components/ui/combobox.js +121 -0
- package/dist/src/shadcn/components/ui/combobox.js.map +1 -0
- package/dist/src/shadcn/components/ui/combobox.stories.d.ts +11 -0
- package/dist/src/shadcn/components/ui/combobox.stories.d.ts.map +1 -0
- package/dist/src/shadcn/components/ui/combobox.stories.js +16 -0
- package/dist/src/shadcn/components/ui/combobox.stories.js.map +1 -0
- package/dist/src/shadcn/components/ui/command.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/command.js +73 -12
- package/dist/src/shadcn/components/ui/command.js.map +1 -1
- package/dist/src/shadcn/components/ui/command.stories.js +0 -1
- package/dist/src/shadcn/components/ui/command.stories.js.map +1 -1
- package/dist/src/shadcn/components/ui/dialog.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/dialog.js +35 -7
- package/dist/src/shadcn/components/ui/dialog.js.map +1 -1
- package/dist/src/shadcn/components/ui/drawer.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/drawer.js +26 -5
- package/dist/src/shadcn/components/ui/drawer.js.map +1 -1
- package/dist/src/shadcn/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/dropdown-menu.js +12 -1
- package/dist/src/shadcn/components/ui/dropdown-menu.js.map +1 -1
- package/dist/src/shadcn/components/ui/form.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/form.js +12 -4
- package/dist/src/shadcn/components/ui/form.js.map +1 -1
- package/dist/src/shadcn/components/ui/input.d.ts +3 -1
- package/dist/src/shadcn/components/ui/input.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/input.js +126 -17
- package/dist/src/shadcn/components/ui/input.js.map +1 -1
- package/dist/src/shadcn/components/ui/label.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/label.js +8 -1
- package/dist/src/shadcn/components/ui/label.js.map +1 -1
- package/dist/src/shadcn/components/ui/menubar.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/menubar.js +35 -13
- package/dist/src/shadcn/components/ui/menubar.js.map +1 -1
- package/dist/src/shadcn/components/ui/pagination.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/pagination.js +6 -6
- package/dist/src/shadcn/components/ui/pagination.js.map +1 -1
- package/dist/src/shadcn/components/ui/popover.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/popover.js +12 -1
- package/dist/src/shadcn/components/ui/popover.js.map +1 -1
- package/dist/src/shadcn/components/ui/progress.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/progress.js +6 -2
- package/dist/src/shadcn/components/ui/progress.js.map +1 -1
- package/dist/src/shadcn/components/ui/radio-group.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/radio-group.js +11 -6
- package/dist/src/shadcn/components/ui/radio-group.js.map +1 -1
- package/dist/src/shadcn/components/ui/radio-group.stories.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/radio-group.stories.js +57 -34
- package/dist/src/shadcn/components/ui/radio-group.stories.js.map +1 -1
- package/dist/src/shadcn/components/ui/scroll-area.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/scroll-area.js +9 -3
- package/dist/src/shadcn/components/ui/scroll-area.js.map +1 -1
- package/dist/src/shadcn/components/ui/select.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/select.js +49 -14
- package/dist/src/shadcn/components/ui/select.js.map +1 -1
- package/dist/src/shadcn/components/ui/select.stories.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/select.stories.js +1 -4
- package/dist/src/shadcn/components/ui/select.stories.js.map +1 -1
- package/dist/src/shadcn/components/ui/separator.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/separator.js +7 -1
- package/dist/src/shadcn/components/ui/separator.js.map +1 -1
- package/dist/src/shadcn/components/ui/sidebar.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/sidebar.js +20 -6
- package/dist/src/shadcn/components/ui/sidebar.js.map +1 -1
- package/dist/src/shadcn/components/ui/skeleton.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/skeleton.js +3 -1
- package/dist/src/shadcn/components/ui/skeleton.js.map +1 -1
- package/dist/src/shadcn/components/ui/slider.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/slider.js +34 -4
- package/dist/src/shadcn/components/ui/slider.js.map +1 -1
- package/dist/src/shadcn/components/ui/sonner.d.ts +16 -1
- package/dist/src/shadcn/components/ui/sonner.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/sonner.js +23 -3
- package/dist/src/shadcn/components/ui/sonner.js.map +1 -1
- package/dist/src/shadcn/components/ui/sonner.stories.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/sonner.stories.js +19 -11
- package/dist/src/shadcn/components/ui/sonner.stories.js.map +1 -1
- package/dist/src/shadcn/components/ui/switch.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/switch.js +18 -2
- package/dist/src/shadcn/components/ui/switch.js.map +1 -1
- package/dist/src/shadcn/components/ui/table.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/table.js +12 -8
- package/dist/src/shadcn/components/ui/table.js.map +1 -1
- package/dist/src/shadcn/components/ui/tabs.d.ts +21 -3
- package/dist/src/shadcn/components/ui/tabs.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/tabs.js +315 -9
- package/dist/src/shadcn/components/ui/tabs.js.map +1 -1
- package/dist/src/shadcn/components/ui/tabs.stories.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/tabs.stories.js +50 -1
- package/dist/src/shadcn/components/ui/tabs.stories.js.map +1 -1
- package/dist/src/shadcn/components/ui/textarea.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/textarea.js +15 -1
- package/dist/src/shadcn/components/ui/textarea.js.map +1 -1
- package/dist/src/shadcn/components/ui/toggle-group.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/toggle-group.js +6 -2
- package/dist/src/shadcn/components/ui/toggle-group.js.map +1 -1
- package/dist/src/shadcn/components/ui/toggle.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/toggle.js +18 -6
- package/dist/src/shadcn/components/ui/toggle.js.map +1 -1
- package/dist/src/shadcn/components/ui/tooltip.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/tooltip.js +11 -1
- package/dist/src/shadcn/components/ui/tooltip.js.map +1 -1
- package/dist/src/shadcn/components/ui/tree.d.ts +28 -0
- package/dist/src/shadcn/components/ui/tree.d.ts.map +1 -0
- package/dist/src/shadcn/components/ui/tree.js +122 -0
- package/dist/src/shadcn/components/ui/tree.js.map +1 -0
- package/dist/src/typography.css +12 -0
- package/package.json +13 -2
- package/src/components/code-editor/http/grammar/http.grammar +74 -0
- package/src/components/code-editor/http/grammar/http.terms.ts +9 -0
- package/src/components/code-editor/http/grammar/http.test.ts +110 -0
- package/src/components/code-editor/http/grammar/http.ts +21 -0
- package/src/components/code-editor/http/index.ts +87 -0
- package/src/components/code-editor/index.tsx +307 -21
- package/src/components/code-editor.stories.tsx +295 -1
- package/src/components/copy-icon.tsx +57 -3
- package/src/components/data-table.stories.tsx +38 -0
- package/src/components/data-table.tsx +117 -0
- package/src/components/fhir-structure-view.stories.tsx +439 -0
- package/src/components/fhir-structure-view.tsx +231 -0
- package/src/components/patient-table.stories.tsx +111 -0
- package/src/components/patient-table.tsx +1301 -0
- package/src/components/request-line-editor.stories.tsx +17 -27
- package/src/components/request-line-editor.tsx +98 -61
- package/src/components/segment-control.stories.tsx +29 -0
- package/src/components/segment-control.tsx +80 -0
- package/src/components/split-button.stories.tsx +49 -0
- package/src/components/split-button.tsx +17 -0
- package/src/components/tree-view.stories.tsx +259 -0
- package/src/components/tree-view.tsx +172 -0
- package/src/icons.tsx +287 -0
- package/src/index.css +42 -3
- package/src/index.tsx +9 -2
- package/src/shadcn/components/ui/accordion.tsx +66 -8
- package/src/shadcn/components/ui/alert-dialog.tsx +6 -2
- package/src/shadcn/components/ui/alert.tsx +53 -15
- package/src/shadcn/components/ui/avatar.tsx +17 -6
- package/src/shadcn/components/ui/badge.tsx +67 -18
- package/src/shadcn/components/ui/breadcrumb.tsx +35 -7
- package/src/shadcn/components/ui/button.tsx +118 -57
- package/src/shadcn/components/ui/card.tsx +44 -13
- package/src/shadcn/components/ui/checkbox.stories.tsx +20 -24
- package/src/shadcn/components/ui/checkbox.tsx +45 -4
- package/src/shadcn/components/ui/combobox.stories.tsx +19 -0
- package/src/shadcn/components/ui/combobox.tsx +142 -0
- package/src/shadcn/components/ui/command.stories.tsx +1 -1
- package/src/shadcn/components/ui/command.tsx +192 -36
- package/src/shadcn/components/ui/dialog.tsx +101 -13
- package/src/shadcn/components/ui/drawer.tsx +93 -18
- package/src/shadcn/components/ui/dropdown-menu.tsx +37 -9
- package/src/shadcn/components/ui/form.tsx +16 -4
- package/src/shadcn/components/ui/input.tsx +400 -29
- package/src/shadcn/components/ui/label.tsx +21 -4
- package/src/shadcn/components/ui/menubar.tsx +188 -43
- package/src/shadcn/components/ui/pagination.tsx +12 -6
- package/src/shadcn/components/ui/popover.tsx +35 -4
- package/src/shadcn/components/ui/progress.tsx +21 -5
- package/src/shadcn/components/ui/radio-group.stories.tsx +22 -14
- package/src/shadcn/components/ui/radio-group.tsx +42 -5
- package/src/shadcn/components/ui/scroll-area.tsx +33 -5
- package/src/shadcn/components/ui/select.stories.tsx +0 -2
- package/src/shadcn/components/ui/select.tsx +184 -33
- package/src/shadcn/components/ui/separator.tsx +15 -5
- package/src/shadcn/components/ui/sidebar.tsx +68 -26
- package/src/shadcn/components/ui/skeleton.tsx +4 -1
- package/src/shadcn/components/ui/slider.tsx +82 -11
- package/src/shadcn/components/ui/sonner.stories.tsx +19 -15
- package/src/shadcn/components/ui/sonner.tsx +53 -3
- package/src/shadcn/components/ui/switch.tsx +53 -7
- package/src/shadcn/components/ui/table.tsx +38 -11
- package/src/shadcn/components/ui/tabs.stories.tsx +32 -0
- package/src/shadcn/components/ui/tabs.tsx +456 -17
- package/src/shadcn/components/ui/textarea.tsx +42 -4
- package/src/shadcn/components/ui/toggle-group.tsx +27 -5
- package/src/shadcn/components/ui/toggle.tsx +59 -18
- package/src/shadcn/components/ui/tooltip.tsx +33 -8
- package/src/shadcn/components/ui/tree.tsx +233 -0
- package/src/typography.css +12 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/shadcn/components/ui/tree.tsx"],"sourcesContent":["import type { ItemInstance } from \"@headless-tree/core\";\nimport { ChevronDownIcon } from \"lucide-react\";\nimport { Slot } from \"radix-ui\";\nimport * as React from \"react\";\n\nimport { cn } from \"#shadcn/lib/utils\";\n\ntype WithMeta = {\n\tmeta?: {\n\t\tlastNode?: boolean;\n\t};\n};\n\n// biome-ignore lint/suspicious/noExplicitAny: FIXME Origin UI as-is\ninterface TreeContextValue<T = any> {\n\tindent: number;\n\tcurrentItem?: ItemInstance<T>;\n\t// biome-ignore lint/suspicious/noExplicitAny: FIXME Origin UI as-is\n\ttree?: any;\n}\n\nconst TreeContext = React.createContext<TreeContextValue>({\n\tindent: 20,\n});\n\n// biome-ignore lint/suspicious/noExplicitAny: FIXME Origin UI as-is\nfunction useTreeContext<T = any>() {\n\treturn React.useContext(TreeContext) as TreeContextValue<T>;\n}\n\ninterface TreeProps extends React.HTMLAttributes<HTMLDivElement> {\n\tindent?: number;\n\t// biome-ignore lint/suspicious/noExplicitAny: FIXME Origin UI as-is\n\ttree?: any;\n}\n\nfunction Tree({ indent = 20, tree, className, ...props }: TreeProps) {\n\tconst containerProps =\n\t\ttree && typeof tree.getContainerProps === \"function\"\n\t\t\t? tree.getContainerProps()\n\t\t\t: {};\n\tconst mergedProps = { ...props, ...containerProps };\n\n\t// Extract style from mergedProps to merge with our custom styles\n\tconst { style: propStyle, ...otherProps } = mergedProps;\n\n\t// Merge styles\n\tconst mergedStyle = {\n\t\t...propStyle,\n\t\t\"--tree-indent\": `${indent}px`,\n\t\t\"--border\": `var(--color-fg-disabled)`,\n\t} as React.CSSProperties;\n\n\treturn (\n\t\t<TreeContext.Provider value={{ indent, tree }}>\n\t\t\t<div\n\t\t\t\tdata-slot=\"tree\"\n\t\t\t\tstyle={mergedStyle}\n\t\t\t\tclassName={cn(\"flex flex-col\", className)}\n\t\t\t\t{...otherProps}\n\t\t\t/>\n\t\t</TreeContext.Provider>\n\t);\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: FIXME Origin UI as-is\ninterface TreeItemProps<T = any>\n\textends React.HTMLAttributes<HTMLButtonElement> {\n\titem: ItemInstance<T>;\n\tindent?: number;\n\tasChild?: boolean;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: FIXME Origin UI as-is\nfunction TreeItem<T = any>({\n\titem,\n\tclassName,\n\tasChild,\n\tchildren,\n\t...props\n}: Omit<TreeItemProps<T>, \"indent\">) {\n\tconst { indent } = useTreeContext<T>();\n\n\tconst itemProps = typeof item.getProps === \"function\" ? item.getProps() : {};\n\tconst mergedProps = { ...props, ...itemProps };\n\n\t// Extract style from mergedProps to merge with our custom styles\n\tconst { style: propStyle, ...otherProps } = mergedProps;\n\n\t// Merge styles\n\tconst mergedStyle = {\n\t\t...propStyle,\n\t\t\"--tree-padding\": `${item.getItemMeta().level * indent}px`,\n\t} as React.CSSProperties;\n\n\tconst Comp = asChild ? Slot.Root : \"button\";\n\n\treturn (\n\t\t<TreeContext.Provider value={{ indent, currentItem: item }}>\n\t\t\t<Comp\n\t\t\t\tdata-slot=\"tree-item\"\n\t\t\t\tstyle={mergedStyle}\n\t\t\t\tclassName={cn(\n\t\t\t\t\t\"z-10 ps-(--tree-padding) outline-hidden select-none focus:z-20 data-[disabled]:pointer-events-none data-[disabled]:opacity-50\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tdata-focus={\n\t\t\t\t\ttypeof item.isFocused === \"function\"\n\t\t\t\t\t\t? item.isFocused() || false\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\tdata-folder={\n\t\t\t\t\ttypeof item.isFolder === \"function\"\n\t\t\t\t\t\t? item.isFolder() || false\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\tdata-selected={\n\t\t\t\t\ttypeof item.isSelected === \"function\"\n\t\t\t\t\t\t? item.isSelected() || false\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\tdata-drag-target={\n\t\t\t\t\ttypeof item.isDragTarget === \"function\"\n\t\t\t\t\t\t? item.isDragTarget() || false\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\tdata-search-match={\n\t\t\t\t\ttypeof item.isMatchingSearch === \"function\"\n\t\t\t\t\t\t? item.isMatchingSearch() || false\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\taria-expanded={item.isExpanded()}\n\t\t\t\t{...otherProps}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</Comp>\n\t\t</TreeContext.Provider>\n\t);\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: FIXME Origin UI as-is\ninterface TreeItemLabelProps<T = any>\n\textends React.HTMLAttributes<HTMLSpanElement> {\n\thideChevron?: boolean;\n\tdisableHover?: boolean;\n\titem?: ItemInstance<T>;\n\thorizontalLines?: boolean;\n}\n\nfunction TreeItemLabel<T>({\n\titem: propItem,\n\tchildren,\n\tclassName,\n\tdisableHover,\n\thorizontalLines,\n\thideChevron,\n\t...props\n}: TreeItemLabelProps<T & WithMeta>) {\n\tconst { currentItem } = useTreeContext<T & WithMeta>();\n\tconst item = propItem || currentItem;\n\n\tif (!item) {\n\t\tconsole.warn(\"TreeItemLabel: No item provided via props or context\");\n\t\treturn null;\n\t}\n\n\tconst data = item.getItemData?.();\n\tconst isLastNode = data?.meta?.lastNode;\n\tconst itemMeta = item.getItemMeta();\n\n\treturn (\n\t\t<span\n\t\t\tdata-slot=\"tree-item-label\"\n\t\t\tclassName={cn(\n\t\t\t\t\"group/tree-item-label relative select-text cursor-pointer border-l-2 border-l-transparent in-focus-visible:ring-ring/50 bg-background text-text-secondary in-data-[drag-target=true]:bg-accent flex items-center gap-2 pr-2 pl-2.5 py-1.5 text-sm transition-colors not-in-data-[folder=true]:ps-2.5 in-focus-visible:ring-[3px] in-data-[search-match=true]:bg-blue-400/20! [&_svg]:pointer-events-none [&_svg]:shrink-0\",\n\t\t\t\t!disableHover &&\n\t\t\t\t\t\"in-data-[selected=true]:bg-bg-secondary hover:bg-bg-secondary hover:text-text-primary in-data-[selected=true]:text-text-primary\",\n\t\t\t\tdisableHover && \"text-text-primary\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t>\n\t\t\t{item.isFolder() && (\n\t\t\t\t<ChevronDownIcon className=\"text-muted-foreground size-4 in-aria-[expanded=false]:-rotate-90 self-start mt-0.5\" />\n\t\t\t)}\n\t\t\t{!item.isFolder() && horizontalLines && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={`w-5 min-w-5 h-px border-t mt-2.25 -ml-1 self-start`}\n\t\t\t\t></div>\n\t\t\t)}\n\t\t\t{item.isFolder() && item.isExpanded() && horizontalLines && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={`absolute left-4.25 top-4 w-px min-h-full h-full border-l mt-2.25 self-start `}\n\t\t\t\t></div>\n\t\t\t)}\n\t\t\t{horizontalLines && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={`absolute left-0 top-5.5 -m-1.75 border-t w-4 ${isLastNode ? \"h-full bg-inherit \" : \"\"} ${itemMeta.level === 0 ? \"hidden\" : \"\"}`}\n\t\t\t\t></div>\n\t\t\t)}\n\t\t\t{children ||\n\t\t\t\t(typeof item.getItemName === \"function\" ? item.getItemName() : null)}\n\t\t</span>\n\t);\n}\n\nfunction TreeDragLine({\n\tclassName,\n\t...props\n}: React.HTMLAttributes<HTMLDivElement>) {\n\tconst { tree } = useTreeContext();\n\n\tif (!tree || typeof tree.getDragLineStyle !== \"function\") {\n\t\tconsole.warn(\n\t\t\t\"TreeDragLine: No tree provided via context or tree does not have getDragLineStyle method\",\n\t\t);\n\t\treturn null;\n\t}\n\n\tconst dragLine = tree.getDragLineStyle();\n\treturn (\n\t\t<div\n\t\t\tstyle={dragLine}\n\t\t\tclassName={cn(\n\t\t\t\t\"bg-primary before:bg-background before:border-primary absolute z-30 -mt-px h-0.5 w-[unset] before:absolute before:-top-[3px] before:left-0 before:size-2 before:rounded-full before:border-2\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nexport { Tree, TreeItem, TreeItemLabel, TreeDragLine, type ItemInstance };\n"],"names":["ChevronDownIcon","Slot","React","cn","TreeContext","createContext","indent","useTreeContext","useContext","Tree","tree","className","props","containerProps","getContainerProps","mergedProps","style","propStyle","otherProps","mergedStyle","Provider","value","div","data-slot","TreeItem","item","asChild","children","itemProps","getProps","getItemMeta","level","Comp","Root","currentItem","data-focus","isFocused","undefined","data-folder","isFolder","data-selected","isSelected","data-drag-target","isDragTarget","data-search-match","isMatchingSearch","aria-expanded","isExpanded","TreeItemLabel","propItem","disableHover","horizontalLines","hideChevron","console","warn","data","getItemData","isLastNode","meta","lastNode","itemMeta","span","getItemName","TreeDragLine","getDragLineStyle","dragLine"],"mappings":"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"}
|
package/dist/src/typography.css
CHANGED
|
@@ -42,6 +42,18 @@ body {
|
|
|
42
42
|
font-weight: var(--font-weight-normal);
|
|
43
43
|
line-height: var(--font-leading-4);
|
|
44
44
|
}
|
|
45
|
+
.typo-body-xs {
|
|
46
|
+
font-size: var(--font-size-xs);
|
|
47
|
+
font-family: var(--font-family-sans);
|
|
48
|
+
font-weight: var(--font-weight-normal);
|
|
49
|
+
line-height: var(--font-leading-3);
|
|
50
|
+
}
|
|
51
|
+
.typo-label-xs {
|
|
52
|
+
font-size: var(--font-size-xs);
|
|
53
|
+
font-family: var(--font-family-sans);
|
|
54
|
+
font-weight: var(--font-weight-medium);
|
|
55
|
+
line-height: var(--font-leading-3);
|
|
56
|
+
}
|
|
45
57
|
|
|
46
58
|
.h1 {
|
|
47
59
|
font-size: var(--font-size-4xl);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@health-samurai/react-components",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -20,13 +20,19 @@
|
|
|
20
20
|
"@codemirror/autocomplete": "^6.18.6",
|
|
21
21
|
"@codemirror/commands": "^6.8.1",
|
|
22
22
|
"@codemirror/lang-json": "^6.0.2",
|
|
23
|
+
"@codemirror/lang-yaml": "^6.1.2",
|
|
24
|
+
"@codemirror/lang-sql": "^6.10.0",
|
|
23
25
|
"@codemirror/language": "^6.11.3",
|
|
24
26
|
"@codemirror/lint": "^6.8.5",
|
|
25
27
|
"@codemirror/search": "^6.5.11",
|
|
26
28
|
"@codemirror/state": "^6.5.2",
|
|
27
29
|
"@codemirror/view": "^6.38.1",
|
|
30
|
+
"@headless-tree/core": "^1.4.0",
|
|
31
|
+
"@headless-tree/react": "^1.4.0",
|
|
28
32
|
"@hookform/resolvers": "^5.2.1",
|
|
33
|
+
"@lezer/common": "^1.2.3",
|
|
29
34
|
"@lezer/highlight": "^1.2.1",
|
|
35
|
+
"@lezer/lr": "^1.4.2",
|
|
30
36
|
"@radix-ui/react-accordion": "^1.2.11",
|
|
31
37
|
"@radix-ui/react-alert-dialog": "^1.1.14",
|
|
32
38
|
"@radix-ui/react-aspect-ratio": "^1.1.7",
|
|
@@ -53,6 +59,7 @@
|
|
|
53
59
|
"@radix-ui/react-toggle": "^1.1.9",
|
|
54
60
|
"@radix-ui/react-toggle-group": "^1.1.10",
|
|
55
61
|
"@radix-ui/react-tooltip": "^1.2.7",
|
|
62
|
+
"@tanstack/react-table": "^8.21.3",
|
|
56
63
|
"class-variance-authority": "^0.7.1",
|
|
57
64
|
"clsx": "^2.1.1",
|
|
58
65
|
"cmdk": "^1.1.1",
|
|
@@ -61,6 +68,7 @@
|
|
|
61
68
|
"input-otp": "^1.4.2",
|
|
62
69
|
"lucide-react": "^0.539.0",
|
|
63
70
|
"next-themes": "^0.4.6",
|
|
71
|
+
"radix-ui": "^1.4.3",
|
|
64
72
|
"react": "^19.1.0",
|
|
65
73
|
"react-day-picker": "^9.8.1",
|
|
66
74
|
"react-dom": "^19.1.0",
|
|
@@ -73,6 +81,7 @@
|
|
|
73
81
|
"zod": "^4.0.17"
|
|
74
82
|
},
|
|
75
83
|
"devDependencies": {
|
|
84
|
+
"@lezer/generator": "^1.8.0",
|
|
76
85
|
"@storybook/addon-docs": "^9.1.1",
|
|
77
86
|
"@storybook/react-vite": "^9.1.1",
|
|
78
87
|
"@swc/cli": "^0.7.8",
|
|
@@ -83,12 +92,14 @@
|
|
|
83
92
|
"@types/react": "^19.1.8",
|
|
84
93
|
"@types/react-dom": "^19.1.6",
|
|
85
94
|
"@vitejs/plugin-react-swc": "^3.10.2",
|
|
95
|
+
"chokidar": "^4.0.3",
|
|
86
96
|
"storybook": "^9.1.1",
|
|
87
97
|
"tailwindcss": "^4.1.11",
|
|
88
98
|
"tsx": "^4.20.4",
|
|
89
99
|
"tw-animate-css": "^1.3.6",
|
|
90
100
|
"typescript": "~5.8.3",
|
|
91
|
-
"vite": "^7.0.4"
|
|
101
|
+
"vite": "^7.0.4",
|
|
102
|
+
"vitest": "^3.2.4"
|
|
92
103
|
},
|
|
93
104
|
"publishConfig": {
|
|
94
105
|
"access": "public"
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
@top Http {
|
|
2
|
+
httpRequest
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
@tokens {
|
|
6
|
+
eof { @eof }
|
|
7
|
+
|
|
8
|
+
lf { $[\n] }
|
|
9
|
+
notLf { ![\n] }
|
|
10
|
+
|
|
11
|
+
cr { $[\r] }
|
|
12
|
+
notCr { ![\r] }
|
|
13
|
+
|
|
14
|
+
colon { $[:] }
|
|
15
|
+
notColon { ![:] }
|
|
16
|
+
|
|
17
|
+
space { $[ \t] }
|
|
18
|
+
notSpace { ![ \t] }
|
|
19
|
+
|
|
20
|
+
headerNameChar { ![\n\r \t:] }
|
|
21
|
+
headerNameText { headerNameChar+ }
|
|
22
|
+
|
|
23
|
+
headerValueFirstChar { ![\n\r \t] }
|
|
24
|
+
headerValueChar { ![\n\r] }
|
|
25
|
+
headerValueLastChar { headerValueFirstChar }
|
|
26
|
+
headerValueText { headerValueFirstChar headerValueChar* headerValueLastChar | headerValueFirstChar }
|
|
27
|
+
|
|
28
|
+
methodChar { ![\n\r \t] }
|
|
29
|
+
methodText { methodChar+ }
|
|
30
|
+
|
|
31
|
+
pathChar { ![\n\r] }
|
|
32
|
+
firstPathChar { ![\n\r \t] }
|
|
33
|
+
pathText { firstPathChar pathChar* }
|
|
34
|
+
|
|
35
|
+
crlf { (cr lf) | cr | lf }
|
|
36
|
+
|
|
37
|
+
bodyChar { _ }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
HttpRequestMethod[group="Method"] {
|
|
41
|
+
methodText
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
HttpRequestPath {
|
|
45
|
+
pathText
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
httpRequestLine {
|
|
49
|
+
space* HttpRequestMethod space+ HttpRequestPath crlf
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
HttpHeaderName {
|
|
53
|
+
headerNameText
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
HttpHeaderValue {
|
|
57
|
+
headerValueText
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
HttpHeader {
|
|
61
|
+
space* HttpHeaderName space* colon space* HttpHeaderValue space* crlf
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
HttpHeaders {
|
|
65
|
+
HttpHeader+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
HttpBody {
|
|
69
|
+
bodyChar*
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
httpRequest {
|
|
73
|
+
httpRequestLine HttpHeaders? crlf HttpBody
|
|
74
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Tests for lezer Http grammar
|
|
2
|
+
|
|
3
|
+
import { testTree } from "@lezer/generator/test";
|
|
4
|
+
import { parser } from "./http";
|
|
5
|
+
|
|
6
|
+
type StackEntry = {
|
|
7
|
+
name: string;
|
|
8
|
+
from: number;
|
|
9
|
+
to: number;
|
|
10
|
+
value: string;
|
|
11
|
+
children: StackEntry[];
|
|
12
|
+
textNode?: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
function parseHttp(input: string): StackEntry {
|
|
16
|
+
const stack: StackEntry[] = [];
|
|
17
|
+
parser.parse(input).iterate({
|
|
18
|
+
enter: (node) => {
|
|
19
|
+
const nodeName = node.type.name;
|
|
20
|
+
const nodeFrom = node.from;
|
|
21
|
+
const nodeTo = node.to;
|
|
22
|
+
const value = input.slice(nodeFrom, nodeTo);
|
|
23
|
+
|
|
24
|
+
stack.push({
|
|
25
|
+
name: nodeName,
|
|
26
|
+
from: nodeFrom,
|
|
27
|
+
to: nodeTo,
|
|
28
|
+
value: value,
|
|
29
|
+
children: [],
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
leave: () => {
|
|
34
|
+
const current = stack.pop();
|
|
35
|
+
if (current === undefined) {
|
|
36
|
+
throw "Stack underflow";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (stack.length === 0) {
|
|
40
|
+
// Re-push root
|
|
41
|
+
stack.push(current);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const parent = stack[stack.length - 1];
|
|
46
|
+
if (parent === undefined) {
|
|
47
|
+
throw "Impossible";
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
parent.children.push(current);
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const res = stack.pop();
|
|
55
|
+
if (res === undefined) {
|
|
56
|
+
throw "Stack underflow";
|
|
57
|
+
}
|
|
58
|
+
return res;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
type Tree = TreeNode | string;
|
|
62
|
+
type TreeNode = {
|
|
63
|
+
name: string;
|
|
64
|
+
children: Tree[];
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
function transform(root: StackEntry): Tree {
|
|
68
|
+
const tree: Tree = {
|
|
69
|
+
name: root.name,
|
|
70
|
+
children: [],
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
let pos = root.from;
|
|
74
|
+
for (const child of root.children) {
|
|
75
|
+
if (pos < child.from) {
|
|
76
|
+
const prefix = root.value.slice(pos - root.from, child.from - root.from);
|
|
77
|
+
tree.children.push(prefix);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
tree.children.push(transform(child));
|
|
81
|
+
pos = child.to;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (pos < root.to) {
|
|
85
|
+
tree.children.push(root.value.slice(pos - root.from));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return tree;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const tree = parser.parse("GET /\nAccept: text/yaml\n\nhello: world");
|
|
92
|
+
console.dir(parseHttp("GET /\nAccept: text/yaml\n\nhello: world\n\nagain"), {
|
|
93
|
+
depth: null,
|
|
94
|
+
});
|
|
95
|
+
console.dir(
|
|
96
|
+
transform(parseHttp("GET /\nAccept: text/yaml\n\nhello: world\n\nagain")),
|
|
97
|
+
{
|
|
98
|
+
depth: null,
|
|
99
|
+
},
|
|
100
|
+
);
|
|
101
|
+
console.log(tree);
|
|
102
|
+
tree.iterate({
|
|
103
|
+
enter: (node) => {
|
|
104
|
+
console.log(`ENTER ${node.type.name}[${node.from}:${node.to}]`);
|
|
105
|
+
},
|
|
106
|
+
leave: (node) => {
|
|
107
|
+
console.log(`LEAVE ${node.type.name}[${node.from}:${node.to}]`);
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
testTree(tree, `Http`);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
|
2
|
+
import { LRParser } from "@lezer/lr";
|
|
3
|
+
export const parser = LRParser.deserialize({
|
|
4
|
+
version: 14,
|
|
5
|
+
states:
|
|
6
|
+
"'zOQOPOOOOOO'#Ce'#CeOQOPO'#CjOOOO'#C^'#C^OYOPO'#CjO_OQO'#CiQOOOOOOOOO-E6c-E6cOYOPO,59UOjOSO,59UOrOQO'#CaOOOO'#Cb'#CbOzOQO'#CaOOOO'#Cf'#CfO!SOQO'#C`O!_OWO,59TO!gOPO,59TOjOSO1G.pOOOO'#C_'#C_O!lOPO1G.pO!qOQO,58{O!qOQO,58{O!yO`O,58{OOOO-E6d-E6dOOOO'#Cg'#CgO#ROWO'#CdOOOO1G.o1G.oO!_OWO1G.oO#ZOPO7+$[OOOO7+$[7+$[O#`OQO1G.gO!yO`O1G.gO!yO`O1G.gOOOO'#Cc'#CcO#hOPO1G.gOOOO-E6e-E6eOOOO7+$Z7+$ZOOOO<<Gv<<GvO!yO`O7+$RO!yO`O7+$RO#pOPO7+$RO#pOPO7+$ROOOO7+$R7+$RO!yO`O<<GmO#xOPO<<GmO#xOPO<<GmOOOO<<Gm<<GmO$QOPOAN=XO$QOPOAN=XOOOOAN=XAN=XO$YOPOG22sOOOOG22sG22sOOOOLD(_LD(_",
|
|
7
|
+
stateData:
|
|
8
|
+
"$b~O_PO`RO~O_PO~O_POb_OcZO~O_POabO~O_POcZO~O_POdfO~O_POcZObSX~OfhO[WP~ObkO~ObmO~O_POdoO~O_POeqO~OfhO[WX~ObuO~O_POdvO~O_PObzO~O_POb!OO~O_POb!RO~O_POb!TO~O_POb!UO~O",
|
|
9
|
+
goto: "#|_PP`flosz!Y!`#i#oP#v#yQSORWQQcXRlaR`TT]T^S[T^RdYQrfSxopS|vwR!P{Qj_RtkQQOjVQXYaenpwy{}!Q!SQXSSYT^QaWQe[QndQpfQwoQyrQ{vQ}xQ!Q|R!S!PQ^TRg^Si_kRsiRUORTO",
|
|
10
|
+
nodeNames:
|
|
11
|
+
"⚠ Http HttpRequestMethod HttpRequestPath HttpHeaders HttpHeader HttpHeaderName HttpHeaderValue HttpBody",
|
|
12
|
+
maxTerm: 22,
|
|
13
|
+
nodeProps: [["group", 2, "Method"]],
|
|
14
|
+
skippedNodes: [0],
|
|
15
|
+
repeatNodeCount: 3,
|
|
16
|
+
tokenData:
|
|
17
|
+
"'xoR]OXzXY&VYZ&^Z]z]^&e^pzpq&Vq![z![!]&t!];'Sz;'S;=`'k;=`<%l's<%lOzo!XYfWcQe``PaSOX!wXY#rZ]!w^p!wpq#rq![!w![!]%W!];'S!w;'S;=`&P<%lO!wg#SYcQe``PaSOX!wXY#rZ]!w^p!wpq#rq![!w![!]%W!];'S!w;'S;=`&P<%lO!wd#wWaSOX$aXY#rZ]$a^p$apq#rq;'S$a;'S;=`%Q<%lO$ad$hWe`aSOX$aXY#rZ]$a^p$apq#rq;'S$a;'S;=`%Q<%lO$ad%TP;=`<%l$ae%aWe``PaSOX%WXY#rZ]%W^p%Wpq#rq;'S%W;'S;=`%y<%lO%We%|P;=`<%l%Wg&SP;=`<%l!wo&^OfW_gZ&eOfWbRZ&lPfWbRYZ&oR&tObRo'RWfWdQe``PaSOX%WXY#rZ]%W^p%Wpq#rq;'S%W;'S;=`%y<%lO%Wo'pPfW;=`<%lzW'xOfW",
|
|
18
|
+
tokenizers: [0, 1, 2, 3, 4],
|
|
19
|
+
topRules: { Http: [0, 1] },
|
|
20
|
+
tokenPrec: 0,
|
|
21
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import {
|
|
2
|
+
foldInside,
|
|
3
|
+
foldNodeProp,
|
|
4
|
+
type Language,
|
|
5
|
+
LanguageSupport,
|
|
6
|
+
LRLanguage,
|
|
7
|
+
} from "@codemirror/language";
|
|
8
|
+
import { parseMixed } from "@lezer/common";
|
|
9
|
+
import { styleTags, tags } from "@lezer/highlight";
|
|
10
|
+
import type { LRParser } from "@lezer/lr";
|
|
11
|
+
import { parser } from "./grammar/http";
|
|
12
|
+
|
|
13
|
+
function makeParser(
|
|
14
|
+
bodyLanguages: (contentType: string) => Language | null,
|
|
15
|
+
): LRParser {
|
|
16
|
+
return parser.configure({
|
|
17
|
+
props: [
|
|
18
|
+
styleTags({
|
|
19
|
+
HttpHeaderName: tags.variableName,
|
|
20
|
+
HttpHeaderValue: tags.attributeValue,
|
|
21
|
+
}),
|
|
22
|
+
|
|
23
|
+
foldNodeProp.add({
|
|
24
|
+
HttpHeaders: foldInside,
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
27
|
+
wrap: parseMixed((node, input) => {
|
|
28
|
+
if (node.name !== "HttpBody") {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const headers = node.node.prevSibling;
|
|
33
|
+
if (headers?.name !== "HttpHeaders") {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let contentType: string | null = null;
|
|
38
|
+
|
|
39
|
+
for (
|
|
40
|
+
let child = headers.firstChild;
|
|
41
|
+
child !== null;
|
|
42
|
+
child = child.nextSibling
|
|
43
|
+
) {
|
|
44
|
+
const headerNameNode = child.getChild("HttpHeaderName");
|
|
45
|
+
if (headerNameNode === null) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const headerName = input.read(headerNameNode.from, headerNameNode.to);
|
|
50
|
+
if (headerName.toLowerCase() !== "content-type") {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (contentType !== null) {
|
|
55
|
+
// Disallow multiple content types
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const headerValueNode = child.getChild("HttpHeaderValue");
|
|
60
|
+
if (headerValueNode === null) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
contentType = input.read(headerValueNode.from, headerValueNode.to);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (contentType === null) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const language = bodyLanguages(contentType);
|
|
72
|
+
if (language === null) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return { parser: language.parser };
|
|
77
|
+
}),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function http(bodyLanguages: (contentType: string) => Language | null) {
|
|
82
|
+
const parser = makeParser(bodyLanguages);
|
|
83
|
+
const language = LRLanguage.define({ parser: parser });
|
|
84
|
+
return new LanguageSupport(language, []);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { http };
|