@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,259 @@
|
|
|
1
|
+
import type { ItemInstance } from "@headless-tree/core";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
3
|
+
import { Ellipsis, Pin, Plus } from "lucide-react";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { action } from "storybook/actions";
|
|
6
|
+
import { Button } from "#shadcn/components/ui/button.js";
|
|
7
|
+
import { PinIcon } from "../icons";
|
|
8
|
+
import type { TreeViewItem } from "./tree-view";
|
|
9
|
+
import { TreeView } from "./tree-view";
|
|
10
|
+
|
|
11
|
+
const meta: Meta<typeof TreeView> = {
|
|
12
|
+
title: "Component/Tree view",
|
|
13
|
+
component: TreeView,
|
|
14
|
+
parameters: {
|
|
15
|
+
layout: "fullscreen",
|
|
16
|
+
},
|
|
17
|
+
tags: ["autodocs"],
|
|
18
|
+
};
|
|
19
|
+
type ItemMeta = {
|
|
20
|
+
pinned?: boolean;
|
|
21
|
+
method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
22
|
+
path?: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default meta;
|
|
26
|
+
type Story = StoryObj<typeof TreeView<ItemMeta>>;
|
|
27
|
+
|
|
28
|
+
const items: Record<string, TreeViewItem<ItemMeta>> = {
|
|
29
|
+
root: {
|
|
30
|
+
name: "Root",
|
|
31
|
+
children: ["collection1", "collection2", "collection3"],
|
|
32
|
+
},
|
|
33
|
+
collection1: {
|
|
34
|
+
name: "Collection 1",
|
|
35
|
+
children: ["request1", "request2", "request3"],
|
|
36
|
+
meta: {
|
|
37
|
+
pinned: true,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
collection2: {
|
|
41
|
+
name: "Collection 2",
|
|
42
|
+
children: ["request4", "request5", "request6"],
|
|
43
|
+
},
|
|
44
|
+
collection3: {
|
|
45
|
+
name: "New Collection",
|
|
46
|
+
children: [
|
|
47
|
+
"request7",
|
|
48
|
+
"request8",
|
|
49
|
+
"request9",
|
|
50
|
+
"request10",
|
|
51
|
+
"request11",
|
|
52
|
+
"collection4",
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
collection4: {
|
|
56
|
+
name: "New Collection",
|
|
57
|
+
children: ["request12", "request13", "request14"],
|
|
58
|
+
},
|
|
59
|
+
request1: {
|
|
60
|
+
meta: {
|
|
61
|
+
method: "GET",
|
|
62
|
+
path: "/request1",
|
|
63
|
+
},
|
|
64
|
+
name: "Request 1",
|
|
65
|
+
},
|
|
66
|
+
request2: {
|
|
67
|
+
meta: {
|
|
68
|
+
method: "POST",
|
|
69
|
+
path: "/request2",
|
|
70
|
+
},
|
|
71
|
+
name: "Request 2",
|
|
72
|
+
},
|
|
73
|
+
request3: {
|
|
74
|
+
meta: {
|
|
75
|
+
method: "PUT",
|
|
76
|
+
path: "/request3",
|
|
77
|
+
},
|
|
78
|
+
name: "Request 3",
|
|
79
|
+
},
|
|
80
|
+
request4: {
|
|
81
|
+
meta: {
|
|
82
|
+
method: "DELETE",
|
|
83
|
+
path: "/request4",
|
|
84
|
+
},
|
|
85
|
+
name: "Request 4",
|
|
86
|
+
},
|
|
87
|
+
request5: {
|
|
88
|
+
meta: {
|
|
89
|
+
method: "PATCH",
|
|
90
|
+
path: "/request5",
|
|
91
|
+
},
|
|
92
|
+
name: "Request 5",
|
|
93
|
+
},
|
|
94
|
+
request6: {
|
|
95
|
+
meta: {
|
|
96
|
+
method: "GET",
|
|
97
|
+
path: "/request6",
|
|
98
|
+
},
|
|
99
|
+
name: "Request 6",
|
|
100
|
+
},
|
|
101
|
+
request7: {
|
|
102
|
+
meta: {
|
|
103
|
+
method: "PATCH",
|
|
104
|
+
path: "/fhir/Patient/123",
|
|
105
|
+
},
|
|
106
|
+
name: "Request 7",
|
|
107
|
+
},
|
|
108
|
+
request8: {
|
|
109
|
+
meta: {
|
|
110
|
+
method: "DELETE",
|
|
111
|
+
path: "/fhir/Patient/123",
|
|
112
|
+
},
|
|
113
|
+
name: "Request 8",
|
|
114
|
+
},
|
|
115
|
+
request9: {
|
|
116
|
+
meta: {
|
|
117
|
+
method: "PUT",
|
|
118
|
+
path: "/fhir/Patient/123",
|
|
119
|
+
},
|
|
120
|
+
name: "Request 9",
|
|
121
|
+
},
|
|
122
|
+
request10: {
|
|
123
|
+
meta: {
|
|
124
|
+
method: "POST",
|
|
125
|
+
path: "/fhir/Patient/123",
|
|
126
|
+
},
|
|
127
|
+
name: "Request 10",
|
|
128
|
+
},
|
|
129
|
+
request11: {
|
|
130
|
+
meta: {
|
|
131
|
+
method: "GET",
|
|
132
|
+
path: "/fhir/Patient/123",
|
|
133
|
+
},
|
|
134
|
+
name: "Request 11",
|
|
135
|
+
},
|
|
136
|
+
request12: {
|
|
137
|
+
meta: {
|
|
138
|
+
method: "PUT",
|
|
139
|
+
path: "/fhir/Patient/123",
|
|
140
|
+
},
|
|
141
|
+
name: "Request 12",
|
|
142
|
+
},
|
|
143
|
+
request13: {
|
|
144
|
+
meta: {
|
|
145
|
+
method: "PUT",
|
|
146
|
+
path: "/fhir/Patient/123",
|
|
147
|
+
},
|
|
148
|
+
name: "Request 13",
|
|
149
|
+
},
|
|
150
|
+
request14: {
|
|
151
|
+
meta: {
|
|
152
|
+
method: "PUT",
|
|
153
|
+
path: "/fhir/Patient/123",
|
|
154
|
+
},
|
|
155
|
+
name: "Request 14",
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export const Default: Story = {
|
|
160
|
+
args: {
|
|
161
|
+
items: items,
|
|
162
|
+
rootItemId: "root",
|
|
163
|
+
selectedItemId: "request9",
|
|
164
|
+
expandedItemIds: ["collection3"],
|
|
165
|
+
onSelectItem: (a) => action("onSelectItem")(a),
|
|
166
|
+
},
|
|
167
|
+
render: (args) => <TreeView {...args} />,
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const customItemView = (item: ItemInstance<TreeViewItem<ItemMeta>>) => {
|
|
171
|
+
const isRootLevel = item.getItemMeta().level === 0;
|
|
172
|
+
const hasChildren = item.getItemData()?.children !== undefined;
|
|
173
|
+
const requestMethhod = item.getItemData()?.meta?.method;
|
|
174
|
+
const requestPath = item.getItemData()?.meta?.path;
|
|
175
|
+
const itemName = item.getItemData()?.name;
|
|
176
|
+
|
|
177
|
+
const requestMethodView = () => {
|
|
178
|
+
switch (requestMethhod) {
|
|
179
|
+
case "GET":
|
|
180
|
+
return (
|
|
181
|
+
<div className="opacity-50 group-hover/tree-item-label:opacity-100 in-data-[selected=true]:opacity-100 font-medium min-w-13 w-13 text-utility-green text-left">
|
|
182
|
+
GET
|
|
183
|
+
</div>
|
|
184
|
+
);
|
|
185
|
+
case "POST":
|
|
186
|
+
return (
|
|
187
|
+
<div className="opacity-50 group-hover/tree-item-label:opacity-100 in-data-[selected=true]:opacity-100 font-medium min-w-13 w-13 text-utility-yellow text-left">
|
|
188
|
+
POST
|
|
189
|
+
</div>
|
|
190
|
+
);
|
|
191
|
+
case "PUT":
|
|
192
|
+
return (
|
|
193
|
+
<div className="opacity-50 group-hover/tree-item-label:opacity-100 in-data-[selected=true]:opacity-100 font-medium min-w-13 w-13 text-utility-blue text-left">
|
|
194
|
+
PUT
|
|
195
|
+
</div>
|
|
196
|
+
);
|
|
197
|
+
case "PATCH":
|
|
198
|
+
return (
|
|
199
|
+
<div className="opacity-50 group-hover/tree-item-label:opacity-100 in-data-[selected=true]:opacity-100 font-medium min-w-13 w-13 text-utility-violet text-left">
|
|
200
|
+
PATCH
|
|
201
|
+
</div>
|
|
202
|
+
);
|
|
203
|
+
case "DELETE":
|
|
204
|
+
return (
|
|
205
|
+
<div className="opacity-50 group-hover/tree-item-label:opacity-100 in-data-[selected=true]:opacity-100 font-medium min-w-13 w-13 text-utility-red text-left">
|
|
206
|
+
DELETE
|
|
207
|
+
</div>
|
|
208
|
+
);
|
|
209
|
+
default:
|
|
210
|
+
return (
|
|
211
|
+
<div className="opacity-50 group-hover/tree-item-label:opacity-100 in-data-[selected=true]:opacity-100 font-medium min-w-13 w-13 text-utility-gray text-left">
|
|
212
|
+
Unknown
|
|
213
|
+
</div>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
return (
|
|
219
|
+
<div className="w-full flex justify-between gap-2">
|
|
220
|
+
<div className="flex items-center gap-2 truncate">
|
|
221
|
+
{hasChildren ? (
|
|
222
|
+
itemName
|
|
223
|
+
) : (
|
|
224
|
+
<React.Fragment>
|
|
225
|
+
{requestMethodView()}
|
|
226
|
+
{requestPath}
|
|
227
|
+
</React.Fragment>
|
|
228
|
+
)}
|
|
229
|
+
</div>
|
|
230
|
+
<div className="gap-2 hidden group-hover/tree-item-label:flex items-center">
|
|
231
|
+
{isRootLevel && (
|
|
232
|
+
<Button variant="link" size="small" className="p-0 h-4">
|
|
233
|
+
{item.getItemData()?.meta?.pinned ? <PinIcon /> : <Pin />}
|
|
234
|
+
</Button>
|
|
235
|
+
)}
|
|
236
|
+
{hasChildren && (
|
|
237
|
+
<Button variant="link" size="small" className="p-0 h-4">
|
|
238
|
+
<Plus />
|
|
239
|
+
</Button>
|
|
240
|
+
)}
|
|
241
|
+
<Button variant="link" size="small" className="p-0 h-4">
|
|
242
|
+
<Ellipsis />
|
|
243
|
+
</Button>
|
|
244
|
+
</div>
|
|
245
|
+
</div>
|
|
246
|
+
);
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
export const CustomItemView: Story = {
|
|
250
|
+
args: {
|
|
251
|
+
items: items,
|
|
252
|
+
rootItemId: "root",
|
|
253
|
+
selectedItemId: "request11",
|
|
254
|
+
expandedItemIds: ["collection3", "collection4"],
|
|
255
|
+
onSelectItem: (a) => action("onSelectItem")(a.getItemData()?.name),
|
|
256
|
+
customItemView: customItemView,
|
|
257
|
+
},
|
|
258
|
+
render: (args) => <TreeView {...args} />,
|
|
259
|
+
};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FeatureImplementation,
|
|
3
|
+
ItemInstance,
|
|
4
|
+
TreeConfig,
|
|
5
|
+
TreeInstance,
|
|
6
|
+
TreeState,
|
|
7
|
+
} from "@headless-tree/core";
|
|
8
|
+
import {
|
|
9
|
+
hotkeysCoreFeature,
|
|
10
|
+
renamingFeature,
|
|
11
|
+
selectionFeature,
|
|
12
|
+
syncDataLoaderFeature,
|
|
13
|
+
} from "@headless-tree/core";
|
|
14
|
+
import { useTree } from "@headless-tree/react";
|
|
15
|
+
import React, { useEffect } from "react";
|
|
16
|
+
import { Tree, TreeItem, TreeItemLabel } from "#shadcn/components/ui/tree";
|
|
17
|
+
import { cn } from "#shadcn/lib/utils.js";
|
|
18
|
+
|
|
19
|
+
// Styles
|
|
20
|
+
const treeItemStyle = cn(
|
|
21
|
+
"relative",
|
|
22
|
+
"before:absolute",
|
|
23
|
+
"before:inset-0",
|
|
24
|
+
"before:-ms-1",
|
|
25
|
+
"before:bg-[repeating-linear-gradient(to_right,transparent_0,transparent_calc(var(--tree-indent)-1px),var(--border)_calc(var(--tree-indent)-1px),var(--border)_calc(var(--tree-indent)))]",
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const treeItemLabelStyle = cn(
|
|
29
|
+
"before:bg-background",
|
|
30
|
+
"relative",
|
|
31
|
+
"before:absolute",
|
|
32
|
+
"before:inset-x-0",
|
|
33
|
+
"before:-inset-y-0",
|
|
34
|
+
"before:-z-10",
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
interface TreeViewItem<T> {
|
|
38
|
+
name: string;
|
|
39
|
+
children?: string[];
|
|
40
|
+
meta?: T;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const customClickBehavior: FeatureImplementation = {
|
|
44
|
+
itemInstance: {
|
|
45
|
+
getProps: ({ tree, item, prev }) => ({
|
|
46
|
+
...prev?.(),
|
|
47
|
+
onClick: () => {
|
|
48
|
+
item.primaryAction();
|
|
49
|
+
if (item.isExpanded()) {
|
|
50
|
+
item.collapse();
|
|
51
|
+
} else {
|
|
52
|
+
item.expand();
|
|
53
|
+
}
|
|
54
|
+
if (!item.isFolder()) {
|
|
55
|
+
tree.setSelectedItems([item.getItemMeta().itemId]);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
}),
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const indent = 24;
|
|
63
|
+
|
|
64
|
+
function TreeView<T>({
|
|
65
|
+
rootItemId,
|
|
66
|
+
items,
|
|
67
|
+
selectedItemId,
|
|
68
|
+
expandedItemIds,
|
|
69
|
+
onSelectItem,
|
|
70
|
+
customItemView,
|
|
71
|
+
onRename,
|
|
72
|
+
disableHover,
|
|
73
|
+
zebra,
|
|
74
|
+
horizontalLines,
|
|
75
|
+
hideChevron,
|
|
76
|
+
}: {
|
|
77
|
+
rootItemId: string;
|
|
78
|
+
selectedItemId?: string;
|
|
79
|
+
expandedItemIds?: string[];
|
|
80
|
+
onSelectItem?: (item: ItemInstance<TreeViewItem<T>>) => void;
|
|
81
|
+
items: Record<string, TreeViewItem<T>>;
|
|
82
|
+
customItemView?: (
|
|
83
|
+
item: ItemInstance<TreeViewItem<T>>,
|
|
84
|
+
tree: TreeInstance<TreeViewItem<T>>,
|
|
85
|
+
) => React.ReactNode;
|
|
86
|
+
onRename?:
|
|
87
|
+
| ((item: ItemInstance<TreeViewItem<T>>, value: string) => void)
|
|
88
|
+
| undefined;
|
|
89
|
+
disableHover?: boolean;
|
|
90
|
+
zebra?: boolean;
|
|
91
|
+
horizontalLines?: boolean;
|
|
92
|
+
hideChevron?: boolean;
|
|
93
|
+
}) {
|
|
94
|
+
const [state, setState] = React.useState<Partial<TreeState<TreeViewItem<T>>>>(
|
|
95
|
+
{},
|
|
96
|
+
);
|
|
97
|
+
const treeConfig: TreeConfig<TreeViewItem<T>> = {
|
|
98
|
+
initialState: {
|
|
99
|
+
selectedItems: selectedItemId ? [selectedItemId] : [],
|
|
100
|
+
expandedItems: expandedItemIds ?? [],
|
|
101
|
+
},
|
|
102
|
+
state,
|
|
103
|
+
setState,
|
|
104
|
+
indent,
|
|
105
|
+
rootItemId: rootItemId,
|
|
106
|
+
isItemFolder: (item: ItemInstance<TreeViewItem<T>>) =>
|
|
107
|
+
item.getItemData()?.children !== undefined,
|
|
108
|
+
getItemName: (item: ItemInstance<TreeViewItem<T>>) =>
|
|
109
|
+
item.getItemData()?.name,
|
|
110
|
+
dataLoader: {
|
|
111
|
+
getItem: (itemId) => (items[itemId] as TreeViewItem<T>) ?? {},
|
|
112
|
+
getChildren: (itemId) => items[itemId]?.children ?? [],
|
|
113
|
+
},
|
|
114
|
+
...(onRename ? { onRename: onRename } : {}),
|
|
115
|
+
features: [
|
|
116
|
+
syncDataLoaderFeature,
|
|
117
|
+
hotkeysCoreFeature,
|
|
118
|
+
selectionFeature,
|
|
119
|
+
customClickBehavior,
|
|
120
|
+
renamingFeature,
|
|
121
|
+
],
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const tree = useTree<TreeViewItem<T>>(treeConfig);
|
|
125
|
+
|
|
126
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: We must have explicit sync here
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
tree.rebuildTree();
|
|
129
|
+
}, [items]);
|
|
130
|
+
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
setState((currentState) => {
|
|
133
|
+
return {
|
|
134
|
+
...currentState,
|
|
135
|
+
selectedItems: selectedItemId ? [selectedItemId] : [],
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
}, [selectedItemId]);
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<Tree tree={tree} indent={indent}>
|
|
142
|
+
{tree.getItems().map((item) => {
|
|
143
|
+
return (
|
|
144
|
+
<TreeItem
|
|
145
|
+
key={item.getId()}
|
|
146
|
+
item={item}
|
|
147
|
+
className={cn(
|
|
148
|
+
treeItemStyle,
|
|
149
|
+
zebra
|
|
150
|
+
? "even:bg-bg-secondary even:[&_[data-slot=tree-item-label]]:bg-bg-secondary"
|
|
151
|
+
: "",
|
|
152
|
+
)}
|
|
153
|
+
>
|
|
154
|
+
<TreeItemLabel
|
|
155
|
+
hideChevron={hideChevron ?? false}
|
|
156
|
+
disableHover={disableHover ?? false}
|
|
157
|
+
className={treeItemLabelStyle}
|
|
158
|
+
onClick={() => onSelectItem?.(item)}
|
|
159
|
+
horizontalLines={horizontalLines ?? false}
|
|
160
|
+
>
|
|
161
|
+
{customItemView
|
|
162
|
+
? customItemView(item, tree)
|
|
163
|
+
: item.getItemData()?.name}
|
|
164
|
+
</TreeItemLabel>
|
|
165
|
+
</TreeItem>
|
|
166
|
+
);
|
|
167
|
+
})}
|
|
168
|
+
</Tree>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export { TreeView, type TreeViewItem, type TreeInstance };
|