dsh-plugin-core 0.2.14 → 0.3.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 +52 -83
- package/dist/design/tokens-css.d.ts +1 -1
- package/dist/design/tokens-css.d.ts.map +1 -1
- package/dist/design/tokens-css.generated.d.ts +2 -0
- package/dist/design/tokens-css.generated.d.ts.map +1 -0
- package/dist/design/tokens-css.generated.js +4 -0
- package/dist/design/tokens-css.generated.js.map +1 -0
- package/dist/design/tokens-css.js +1 -252
- package/dist/design/tokens-css.js.map +1 -1
- package/dist/explorer/FileBrowser.d.ts +41 -0
- package/dist/explorer/FileBrowser.d.ts.map +1 -0
- package/dist/explorer/FileBrowser.js +659 -0
- package/dist/explorer/FileBrowser.js.map +1 -0
- package/dist/explorer/explorer-css.d.ts +1 -1
- package/dist/explorer/explorer-css.d.ts.map +1 -1
- package/dist/explorer/explorer-css.generated.d.ts +2 -0
- package/dist/explorer/explorer-css.generated.d.ts.map +1 -0
- package/dist/explorer/explorer-css.generated.js +4 -0
- package/dist/explorer/explorer-css.generated.js.map +1 -0
- package/dist/explorer/explorer-css.js +1 -31
- package/dist/explorer/explorer-css.js.map +1 -1
- package/dist/explorer/index.d.ts +4 -2
- package/dist/explorer/index.d.ts.map +1 -1
- package/dist/explorer/index.js +4 -2
- package/dist/explorer/index.js.map +1 -1
- package/dist/explorer/open.d.ts +103 -0
- package/dist/explorer/open.d.ts.map +1 -0
- package/dist/explorer/open.js +282 -0
- package/dist/explorer/open.js.map +1 -0
- package/dist/explorer/preview/BytesPreview.d.ts +13 -0
- package/dist/explorer/preview/BytesPreview.d.ts.map +1 -0
- package/dist/explorer/preview/BytesPreview.js +56 -0
- package/dist/explorer/preview/BytesPreview.js.map +1 -0
- package/dist/explorer/preview/HtmlPreview.d.ts +18 -0
- package/dist/explorer/preview/HtmlPreview.d.ts.map +1 -0
- package/dist/explorer/preview/HtmlPreview.js +112 -0
- package/dist/explorer/preview/HtmlPreview.js.map +1 -0
- package/dist/explorer/preview/OfficePreview.d.ts +11 -0
- package/dist/explorer/preview/OfficePreview.d.ts.map +1 -0
- package/dist/explorer/preview/OfficePreview.js +53 -0
- package/dist/explorer/preview/OfficePreview.js.map +1 -0
- package/dist/explorer/preview/TextPreview.d.ts +17 -0
- package/dist/explorer/preview/TextPreview.d.ts.map +1 -0
- package/dist/explorer/preview/TextPreview.js +95 -0
- package/dist/explorer/preview/TextPreview.js.map +1 -0
- package/dist/explorer/preview/index.d.ts +10 -3
- package/dist/explorer/preview/index.d.ts.map +1 -1
- package/dist/explorer/preview/index.js +52 -55
- package/dist/explorer/preview/index.js.map +1 -1
- package/dist/explorer/preview/md-labels.d.ts +3 -0
- package/dist/explorer/preview/md-labels.d.ts.map +1 -0
- package/dist/explorer/preview/md-labels.js +12 -0
- package/dist/explorer/preview/md-labels.js.map +1 -0
- package/dist/explorer/types.d.ts +186 -4
- package/dist/explorer/types.d.ts.map +1 -1
- package/dist/explorer/types.js +401 -14
- package/dist/explorer/types.js.map +1 -1
- package/dist/host/index.d.ts +66 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +60 -0
- package/dist/host/index.js.map +1 -0
- package/dist/session/SessionViewModal.d.ts +42 -0
- package/dist/session/SessionViewModal.d.ts.map +1 -0
- package/dist/session/SessionViewModal.js +997 -0
- package/dist/session/SessionViewModal.js.map +1 -0
- package/dist/session/changes.d.ts +73 -0
- package/dist/session/changes.d.ts.map +1 -0
- package/dist/session/changes.js +134 -0
- package/dist/session/changes.js.map +1 -0
- package/dist/session/faces.d.ts +198 -0
- package/dist/session/faces.d.ts.map +1 -0
- package/dist/session/faces.js +17 -0
- package/dist/session/faces.js.map +1 -0
- package/dist/session/index.d.ts +5 -23
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +25 -70
- package/dist/session/index.js.map +1 -1
- package/dist/session/mirror/ChangedFileDiff.d.ts +22 -0
- package/dist/session/mirror/ChangedFileDiff.d.ts.map +1 -0
- package/dist/session/mirror/ChangedFileDiff.js +157 -0
- package/dist/session/mirror/ChangedFileDiff.js.map +1 -0
- package/dist/session/mirror/ChangedFilesCard.d.ts +18 -0
- package/dist/session/mirror/ChangedFilesCard.d.ts.map +1 -0
- package/dist/session/mirror/ChangedFilesCard.js +158 -0
- package/dist/session/mirror/ChangedFilesCard.js.map +1 -0
- package/dist/session/mirror/ChatGroupSeat.d.ts +24 -0
- package/dist/session/mirror/ChatGroupSeat.d.ts.map +1 -0
- package/dist/session/mirror/ChatGroupSeat.js +134 -0
- package/dist/session/mirror/ChatGroupSeat.js.map +1 -0
- package/dist/session/mirror/ChatNodeSeat.d.ts +43 -0
- package/dist/session/mirror/ChatNodeSeat.d.ts.map +1 -0
- package/dist/session/mirror/ChatNodeSeat.js +133 -0
- package/dist/session/mirror/ChatNodeSeat.js.map +1 -0
- package/dist/session/mirror/ChatView.d.ts +47 -0
- package/dist/session/mirror/ChatView.d.ts.map +1 -0
- package/dist/session/mirror/ChatView.js +127 -0
- package/dist/session/mirror/ChatView.js.map +1 -0
- package/dist/session/mirror/CommandCard.d.ts +20 -0
- package/dist/session/mirror/CommandCard.d.ts.map +1 -0
- package/dist/session/mirror/CommandCard.js +69 -0
- package/dist/session/mirror/CommandCard.js.map +1 -0
- package/dist/session/mirror/Deliverables.d.ts +24 -0
- package/dist/session/mirror/Deliverables.d.ts.map +1 -0
- package/dist/session/mirror/Deliverables.js +134 -0
- package/dist/session/mirror/Deliverables.js.map +1 -0
- package/dist/session/mirror/GenericCommandCard.d.ts +25 -0
- package/dist/session/mirror/GenericCommandCard.d.ts.map +1 -0
- package/dist/session/mirror/GenericCommandCard.js +567 -0
- package/dist/session/mirror/GenericCommandCard.js.map +1 -0
- package/dist/session/mirror/MessageIconActions.d.ts +16 -0
- package/dist/session/mirror/MessageIconActions.d.ts.map +1 -0
- package/dist/session/mirror/MessageIconActions.js +71 -0
- package/dist/session/mirror/MessageIconActions.js.map +1 -0
- package/dist/session/mirror/MessageItem.d.ts +66 -0
- package/dist/session/mirror/MessageItem.d.ts.map +1 -0
- package/dist/session/mirror/MessageItem.js +135 -0
- package/dist/session/mirror/MessageItem.js.map +1 -0
- package/dist/session/mirror/ReasoningRow.d.ts +11 -0
- package/dist/session/mirror/ReasoningRow.d.ts.map +1 -0
- package/dist/session/mirror/ReasoningRow.js +49 -0
- package/dist/session/mirror/ReasoningRow.js.map +1 -0
- package/dist/session/mirror/StatDialog.d.ts +20 -0
- package/dist/session/mirror/StatDialog.d.ts.map +1 -0
- package/dist/session/mirror/StatDialog.js +36 -0
- package/dist/session/mirror/StatDialog.js.map +1 -0
- package/dist/session/mirror/TurnProcessNodeView.d.ts +10 -0
- package/dist/session/mirror/TurnProcessNodeView.d.ts.map +1 -0
- package/dist/session/mirror/TurnProcessNodeView.js +68 -0
- package/dist/session/mirror/TurnProcessNodeView.js.map +1 -0
- package/dist/session/mirror/TurnTailNodeView.d.ts +32 -0
- package/dist/session/mirror/TurnTailNodeView.d.ts.map +1 -0
- package/dist/session/mirror/TurnTailNodeView.js +48 -0
- package/dist/session/mirror/TurnTailNodeView.js.map +1 -0
- package/dist/session/mirror/TurnTriggerNodeView.d.ts +14 -0
- package/dist/session/mirror/TurnTriggerNodeView.d.ts.map +1 -0
- package/dist/session/mirror/TurnTriggerNodeView.js +87 -0
- package/dist/session/mirror/TurnTriggerNodeView.js.map +1 -0
- package/dist/session/mirror/TurnUsagePanel.d.ts +21 -0
- package/dist/session/mirror/TurnUsagePanel.d.ts.map +1 -0
- package/dist/session/mirror/TurnUsagePanel.js +41 -0
- package/dist/session/mirror/TurnUsagePanel.js.map +1 -0
- package/dist/session/mirror/message-chrome.d.ts +33 -0
- package/dist/session/mirror/message-chrome.d.ts.map +1 -0
- package/dist/session/mirror/message-chrome.js +158 -0
- package/dist/session/mirror/message-chrome.js.map +1 -0
- package/dist/session/mirror/process-groups.d.ts +56 -0
- package/dist/session/mirror/process-groups.d.ts.map +1 -0
- package/dist/session/mirror/process-groups.js +202 -0
- package/dist/session/mirror/process-groups.js.map +1 -0
- package/dist/session/official-classes.d.ts +28 -0
- package/dist/session/official-classes.d.ts.map +1 -0
- package/dist/session/official-classes.js +146 -0
- package/dist/session/official-classes.js.map +1 -0
- package/dist/session/open-session-view.d.ts +17 -0
- package/dist/session/open-session-view.d.ts.map +1 -0
- package/dist/session/open-session-view.js +136 -0
- package/dist/session/open-session-view.js.map +1 -0
- package/dist/session/session-css.d.ts +1 -1
- package/dist/session/session-css.d.ts.map +1 -1
- package/dist/session/session-css.generated.d.ts +2 -0
- package/dist/session/session-css.generated.d.ts.map +1 -0
- package/dist/session/session-css.generated.js +4 -0
- package/dist/session/session-css.generated.js.map +1 -0
- package/dist/session/session-css.js +1 -17
- package/dist/session/session-css.js.map +1 -1
- package/dist/ui/AlertModal.d.ts +28 -0
- package/dist/ui/AlertModal.d.ts.map +1 -0
- package/dist/ui/AlertModal.js +29 -0
- package/dist/ui/AlertModal.js.map +1 -0
- package/dist/ui/Button.d.ts.map +1 -1
- package/dist/ui/Button.js +14 -1
- package/dist/ui/Button.js.map +1 -1
- package/dist/ui/Card.d.ts +4 -2
- package/dist/ui/Card.d.ts.map +1 -1
- package/dist/ui/Card.js +12 -6
- package/dist/ui/Card.js.map +1 -1
- package/dist/ui/Chip.d.ts +9 -1
- package/dist/ui/Chip.d.ts.map +1 -1
- package/dist/ui/Chip.js +8 -2
- package/dist/ui/Chip.js.map +1 -1
- package/dist/ui/CodeViewer.d.ts +36 -0
- package/dist/ui/CodeViewer.d.ts.map +1 -0
- package/dist/ui/CodeViewer.js +90 -0
- package/dist/ui/CodeViewer.js.map +1 -0
- package/dist/ui/ConfirmModal.d.ts +30 -0
- package/dist/ui/ConfirmModal.d.ts.map +1 -0
- package/dist/ui/ConfirmModal.js +23 -0
- package/dist/ui/ConfirmModal.js.map +1 -0
- package/dist/ui/DateTimePicker.d.ts +45 -0
- package/dist/ui/DateTimePicker.d.ts.map +1 -0
- package/dist/ui/DateTimePicker.js +447 -0
- package/dist/ui/DateTimePicker.js.map +1 -0
- package/dist/ui/Field.d.ts +11 -2
- package/dist/ui/Field.d.ts.map +1 -1
- package/dist/ui/Field.js +15 -5
- package/dist/ui/Field.js.map +1 -1
- package/dist/ui/MarqueeText.d.ts.map +1 -1
- package/dist/ui/MarqueeText.js +3 -1
- package/dist/ui/MarqueeText.js.map +1 -1
- package/dist/ui/Modal.d.ts +25 -3
- package/dist/ui/Modal.d.ts.map +1 -1
- package/dist/ui/Modal.js +41 -7
- package/dist/ui/Modal.js.map +1 -1
- package/dist/ui/ModelPicker.d.ts +25 -12
- package/dist/ui/ModelPicker.d.ts.map +1 -1
- package/dist/ui/ModelPicker.js +67 -19
- package/dist/ui/ModelPicker.js.map +1 -1
- package/dist/ui/PanelDock.d.ts +127 -0
- package/dist/ui/PanelDock.d.ts.map +1 -0
- package/dist/ui/PanelDock.js +297 -0
- package/dist/ui/PanelDock.js.map +1 -0
- package/dist/ui/Picker.d.ts +8 -2
- package/dist/ui/Picker.d.ts.map +1 -1
- package/dist/ui/Picker.js +86 -18
- package/dist/ui/Picker.js.map +1 -1
- package/dist/ui/SectionHead.d.ts +3 -3
- package/dist/ui/SectionHead.d.ts.map +1 -1
- package/dist/ui/SectionHead.js +4 -4
- package/dist/ui/SectionHead.js.map +1 -1
- package/dist/ui/Segmented.d.ts +2 -0
- package/dist/ui/Segmented.d.ts.map +1 -1
- package/dist/ui/Segmented.js +3 -1
- package/dist/ui/Segmented.js.map +1 -1
- package/dist/ui/Textarea.d.ts +2 -0
- package/dist/ui/Textarea.d.ts.map +1 -1
- package/dist/ui/Textarea.js +6 -1
- package/dist/ui/Textarea.js.map +1 -1
- package/dist/ui/Toast.d.ts +41 -8
- package/dist/ui/Toast.d.ts.map +1 -1
- package/dist/ui/Toast.js +216 -28
- package/dist/ui/Toast.js.map +1 -1
- package/dist/ui/WorkspacePicker.d.ts +15 -28
- package/dist/ui/WorkspacePicker.d.ts.map +1 -1
- package/dist/ui/WorkspacePicker.js +18 -27
- package/dist/ui/WorkspacePicker.js.map +1 -1
- package/dist/ui/card-css.d.ts +1 -1
- package/dist/ui/card-css.d.ts.map +1 -1
- package/dist/ui/card-css.generated.d.ts +2 -0
- package/dist/ui/card-css.generated.d.ts.map +1 -0
- package/dist/ui/card-css.generated.js +4 -0
- package/dist/ui/card-css.generated.js.map +1 -0
- package/dist/ui/card-css.js +1 -35
- package/dist/ui/card-css.js.map +1 -1
- package/dist/ui/chip-css.d.ts +1 -1
- package/dist/ui/chip-css.d.ts.map +1 -1
- package/dist/ui/chip-css.generated.d.ts +2 -0
- package/dist/ui/chip-css.generated.d.ts.map +1 -0
- package/dist/ui/chip-css.generated.js +4 -0
- package/dist/ui/chip-css.generated.js.map +1 -0
- package/dist/ui/chip-css.js +1 -17
- package/dist/ui/chip-css.js.map +1 -1
- package/dist/ui/code-viewer-css.d.ts +2 -0
- package/dist/ui/code-viewer-css.d.ts.map +1 -0
- package/dist/ui/code-viewer-css.generated.d.ts +2 -0
- package/dist/ui/code-viewer-css.generated.d.ts.map +1 -0
- package/dist/ui/code-viewer-css.generated.js +4 -0
- package/dist/ui/code-viewer-css.generated.js.map +1 -0
- package/dist/ui/code-viewer-css.js +3 -0
- package/dist/ui/code-viewer-css.js.map +1 -0
- package/dist/ui/code-viewer-lang.d.ts +15 -0
- package/dist/ui/code-viewer-lang.d.ts.map +1 -0
- package/dist/ui/code-viewer-lang.js +190 -0
- package/dist/ui/code-viewer-lang.js.map +1 -0
- package/dist/ui/code-viewer-theme.d.ts +5 -0
- package/dist/ui/code-viewer-theme.d.ts.map +1 -0
- package/dist/ui/code-viewer-theme.js +138 -0
- package/dist/ui/code-viewer-theme.js.map +1 -0
- package/dist/ui/controls/back-to-top-css.generated.d.ts +2 -0
- package/dist/ui/controls/back-to-top-css.generated.d.ts.map +1 -0
- package/dist/ui/controls/back-to-top-css.generated.js +4 -0
- package/dist/ui/controls/back-to-top-css.generated.js.map +1 -0
- package/dist/ui/controls/button-css.generated.d.ts +2 -0
- package/dist/ui/controls/button-css.generated.d.ts.map +1 -0
- package/dist/ui/controls/button-css.generated.js +4 -0
- package/dist/ui/controls/button-css.generated.js.map +1 -0
- package/dist/ui/controls/datetime-css.generated.d.ts +2 -0
- package/dist/ui/controls/datetime-css.generated.d.ts.map +1 -0
- package/dist/ui/controls/datetime-css.generated.js +4 -0
- package/dist/ui/controls/datetime-css.generated.js.map +1 -0
- package/dist/ui/controls/field-css.generated.d.ts +2 -0
- package/dist/ui/controls/field-css.generated.d.ts.map +1 -0
- package/dist/ui/controls/field-css.generated.js +4 -0
- package/dist/ui/controls/field-css.generated.js.map +1 -0
- package/dist/ui/controls/hint-css.generated.d.ts +2 -0
- package/dist/ui/controls/hint-css.generated.d.ts.map +1 -0
- package/dist/ui/controls/hint-css.generated.js +4 -0
- package/dist/ui/controls/hint-css.generated.js.map +1 -0
- package/dist/ui/controls/loading-css.generated.d.ts +2 -0
- package/dist/ui/controls/loading-css.generated.d.ts.map +1 -0
- package/dist/ui/controls/loading-css.generated.js +4 -0
- package/dist/ui/controls/loading-css.generated.js.map +1 -0
- package/dist/ui/controls/segmented-css.generated.d.ts +2 -0
- package/dist/ui/controls/segmented-css.generated.d.ts.map +1 -0
- package/dist/ui/controls/segmented-css.generated.js +4 -0
- package/dist/ui/controls/segmented-css.generated.js.map +1 -0
- package/dist/ui/controls-css.d.ts +7 -8
- package/dist/ui/controls-css.d.ts.map +1 -1
- package/dist/ui/controls-css.js +13 -11
- package/dist/ui/controls-css.js.map +1 -1
- package/dist/ui/css.d.ts +5 -0
- package/dist/ui/css.d.ts.map +1 -1
- package/dist/ui/css.js +13 -4
- package/dist/ui/css.js.map +1 -1
- package/dist/ui/datetime-logic.d.ts +100 -0
- package/dist/ui/datetime-logic.d.ts.map +1 -0
- package/dist/ui/datetime-logic.js +193 -0
- package/dist/ui/datetime-logic.js.map +1 -0
- package/dist/ui/feedback-css.d.ts +1 -1
- package/dist/ui/feedback-css.d.ts.map +1 -1
- package/dist/ui/feedback-css.generated.d.ts +2 -0
- package/dist/ui/feedback-css.generated.d.ts.map +1 -0
- package/dist/ui/feedback-css.generated.js +4 -0
- package/dist/ui/feedback-css.generated.js.map +1 -0
- package/dist/ui/feedback-css.js +1 -53
- package/dist/ui/feedback-css.js.map +1 -1
- package/dist/ui/host-data.d.ts +103 -0
- package/dist/ui/host-data.d.ts.map +1 -0
- package/dist/ui/host-data.js +106 -0
- package/dist/ui/host-data.js.map +1 -0
- package/dist/ui/host-toast.d.ts +23 -0
- package/dist/ui/host-toast.d.ts.map +1 -0
- package/dist/ui/host-toast.js +34 -0
- package/dist/ui/host-toast.js.map +1 -0
- package/dist/ui/index.d.ts +12 -6
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +10 -4
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/marquee-css.d.ts +2 -0
- package/dist/ui/marquee-css.d.ts.map +1 -0
- package/dist/ui/marquee-css.generated.d.ts +2 -0
- package/dist/ui/marquee-css.generated.d.ts.map +1 -0
- package/dist/ui/marquee-css.generated.js +4 -0
- package/dist/ui/marquee-css.generated.js.map +1 -0
- package/dist/ui/marquee-css.js +4 -0
- package/dist/ui/marquee-css.js.map +1 -0
- package/dist/ui/modal-host.d.ts +30 -0
- package/dist/ui/modal-host.d.ts.map +1 -0
- package/dist/ui/modal-host.js +101 -0
- package/dist/ui/modal-host.js.map +1 -0
- package/dist/ui/official.d.ts.map +1 -1
- package/dist/ui/official.js +45 -1
- package/dist/ui/official.js.map +1 -1
- package/dist/ui/panel-dock-css.d.ts +2 -0
- package/dist/ui/panel-dock-css.d.ts.map +1 -0
- package/dist/ui/panel-dock-css.generated.d.ts +2 -0
- package/dist/ui/panel-dock-css.generated.d.ts.map +1 -0
- package/dist/ui/panel-dock-css.generated.js +4 -0
- package/dist/ui/panel-dock-css.generated.js.map +1 -0
- package/dist/ui/panel-dock-css.js +4 -0
- package/dist/ui/panel-dock-css.js.map +1 -0
- package/dist/ui/panel-dock-logic.d.ts +50 -0
- package/dist/ui/panel-dock-logic.d.ts.map +1 -0
- package/dist/ui/panel-dock-logic.js +64 -0
- package/dist/ui/panel-dock-logic.js.map +1 -0
- package/dist/ui/picker-css.d.ts +1 -1
- package/dist/ui/picker-css.d.ts.map +1 -1
- package/dist/ui/picker-css.generated.d.ts +2 -0
- package/dist/ui/picker-css.generated.d.ts.map +1 -0
- package/dist/ui/picker-css.generated.js +4 -0
- package/dist/ui/picker-css.generated.js.map +1 -0
- package/dist/ui/picker-css.js +1 -48
- package/dist/ui/picker-css.js.map +1 -1
- package/dist/ui/picker-icons.d.ts +12 -0
- package/dist/ui/picker-icons.d.ts.map +1 -0
- package/dist/ui/picker-icons.js +29 -0
- package/dist/ui/picker-icons.js.map +1 -0
- package/dist/ui/picker-logic.d.ts +4 -1
- package/dist/ui/picker-logic.d.ts.map +1 -1
- package/dist/ui/picker-logic.js +1 -2
- package/dist/ui/picker-logic.js.map +1 -1
- package/dist/ui/resizer.d.ts +3 -1
- package/dist/ui/resizer.d.ts.map +1 -1
- package/dist/ui/resizer.js +1 -1
- package/dist/ui/resizer.js.map +1 -1
- package/dist/ui/toast-host.d.ts +24 -0
- package/dist/ui/toast-host.d.ts.map +1 -0
- package/dist/ui/toast-host.js +20 -0
- package/dist/ui/toast-host.js.map +1 -0
- package/dist/utils/date.d.ts +8 -0
- package/dist/utils/date.d.ts.map +1 -1
- package/dist/utils/date.js +16 -0
- package/dist/utils/date.js.map +1 -1
- package/dist/utils/i18n.d.ts +1 -1
- package/dist/utils/i18n.d.ts.map +1 -1
- package/dist/utils/i18n.js +437 -18
- package/dist/utils/i18n.js.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/path.d.ts.map +1 -1
- package/dist/utils/path.js +1 -0
- package/dist/utils/path.js.map +1 -1
- package/docs/README.md +12 -5
- package/docs/design/architecture.md +38 -8
- package/docs/design/copywriting.md +95 -0
- package/docs/design/doc-format.md +80 -0
- package/docs/design/doc-format.ts +39 -0
- package/docs/design/external/dsh-host.md +150 -1
- package/docs/design/features.md +4 -17
- package/docs/design/methods.md +13 -34
- package/docs/design/structure.md +25 -22
- package/docs/design/style.md +24 -50
- package/docs/help/design.doc.ts +112 -0
- package/docs/help/design.md +88 -0
- package/docs/help/explorer.doc.ts +136 -0
- package/docs/help/explorer.md +68 -0
- package/docs/help/index.doc.ts +79 -0
- package/docs/help/index.md +28 -0
- package/docs/help/integration.doc.ts +114 -0
- package/docs/help/integration.md +127 -0
- package/docs/help/methods.md +58 -0
- package/docs/help/session.doc.ts +154 -0
- package/docs/help/session.md +91 -0
- package/docs/help/style.md +80 -0
- package/docs/help/ui.doc.ts +404 -0
- package/docs/help/ui.md +342 -0
- package/docs/help/utils.doc.ts +133 -0
- package/docs/help/utils.md +96 -0
- package/docs/requirements.md +33 -12
- package/package.json +44 -3
- package/dist/ui/ErrorBoundary.d.ts +0 -22
- package/dist/ui/ErrorBoundary.d.ts.map +0 -1
- package/dist/ui/ErrorBoundary.js +0 -30
- package/dist/ui/ErrorBoundary.js.map +0 -1
- package/docs/design/features/design.md +0 -55
- package/docs/design/features/explorer.md +0 -73
- package/docs/design/features/session.md +0 -70
- package/docs/design/features/ui.md +0 -225
- package/docs/design/features/utils.md +0 -64
- package/docs/examples/integration.md +0 -103
package/docs/help/ui.md
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
<!-- 本文件由 scripts/gen-docs.mjs 自动生成,请勿手改;改对应的 .doc.ts 后重跑 node scripts/gen-docs.mjs -->
|
|
2
|
+
|
|
3
|
+
# ui —— 基础控件
|
|
4
|
+
|
|
5
|
+
> EN: ui — base controls
|
|
6
|
+
|
|
7
|
+
导出:Button、IconButton、Segmented、Input、PrefixedInput、NumberInput、Textarea、Checkbox、fieldMetricsOf、Picker、WorkspacePicker、ModelPicker、DateTimePicker、Card、StripCard、Chip、Modal、FieldHint、setTooltipRenderer、showToast、notify、showHostToast、Loading、RunningBlocks、SectionHead、MarqueeText、LiveText、BackToTop、startResizeLayoutWidth、PanelDock、createPanelDock、DockPanel、ensureControls、setStyleKit
|
|
8
|
+
|
|
9
|
+
## 概览
|
|
10
|
+
|
|
11
|
+
> EN: Overview
|
|
12
|
+
|
|
13
|
+
依赖 design。装的是「用 token 搭出来的零件」,直接用,不再自己写原生控件。纯零件不自己取数:选项、当前值都经 props 给(数据通道是插件私有的)。
|
|
14
|
+
|
|
15
|
+
> EN: Depends on design. "Parts built from tokens" — use them instead of writing native controls. No self-fetching: options and value come via props (the data channel is plugin-private).
|
|
16
|
+
|
|
17
|
+
入口零 `@deepseek-ai/*` 依赖(非宿主环境 import 不崩)。官方 primitives 走独立子路径 `dsh-plugin-core/ui/official`,封装一律从这条通路引。
|
|
18
|
+
|
|
19
|
+
> EN: The entry keeps zero `@deepseek-ai/*` deps (imports never crash outside the host). Official primitives come through the separate subpath `dsh-plugin-core/ui/official`; import them only from there.
|
|
20
|
+
|
|
21
|
+
定制边界:props 就是定制面,要改行为请组合 props,不要 fork 源码;追加 class/style 只允许补布局,皮肤走 token 覆盖;缺控件请先提需求。
|
|
22
|
+
|
|
23
|
+
> EN: Customization: props are the surface — compose them instead of forking source; appended class/style may only patch layout, skins go through token overrides; raise a request before writing a missing control yourself.
|
|
24
|
+
|
|
25
|
+
```ts id="ui-setup"
|
|
26
|
+
import { createStyleKit } from 'dsh-plugin-core/design'
|
|
27
|
+
import { ensureControls, setStyleKit } from 'dsh-plugin-core/ui'
|
|
28
|
+
|
|
29
|
+
setStyleKit(createStyleKit({ id: 'dsh-task-reminder-ui' }))
|
|
30
|
+
ensureControls()
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Button / IconButton / Segmented
|
|
34
|
+
|
|
35
|
+
> EN: Button / IconButton / Segmented
|
|
36
|
+
|
|
37
|
+
Button 10 档外观(实心 / 线框 / 无底)。hover / active 走 token 派生色(不用 opacity)。
|
|
38
|
+
|
|
39
|
+
> EN: Button offers 10 variant tiers (solid / outline / bare). hover/active use token-derived colors (no opacity).
|
|
40
|
+
|
|
41
|
+
IconButton:variant: plain|outline|danger(默认 plain)、size(默认 lg)、icon(必填)、label(必填,无障碍名兼 title)。
|
|
42
|
+
|
|
43
|
+
> EN: IconButton: variant plain|outline|danger (default plain), size (default lg), icon (required), label (required, doubles as a11y name and title).
|
|
44
|
+
|
|
45
|
+
Segmented:`items`(必填)支持单选 / 多选,另有 `size`(默认 lg)、`variant`(default / inset)。选中片 = 抬起底色 + 1px 描边 + 浮起阴影。
|
|
46
|
+
|
|
47
|
+
> EN: Segmented: `items` (required) supports single or multiple selection, plus `size` (default lg) and `variant` (default / inset). Selected = raised background + 1px border + lift shadow.
|
|
48
|
+
|
|
49
|
+
| 参数 | 类型 | 默认 | 说明(zh) | 说明(en) |
|
|
50
|
+
|---|---|---|---|---|
|
|
51
|
+
| `variant` | `上表 10 档(primary/secondary/danger/success/warning/info/outline/danger-outline/ghost/link)` | 'outline' | 外观档 | Appearance tier |
|
|
52
|
+
| `size` | `'sm' \| 'md' \| 'lg'` | 'lg' | 高度档(24 / 28 / 32,有边无边同高) | Height tier (24 / 28 / 32, same height with or without border) |
|
|
53
|
+
| `icon` | `ReactNode` | — | 前置图标(官方图标组件 / 字符串均可) | Leading icon (official icon component or string) |
|
|
54
|
+
| `iconRight` | `ReactNode` | — | 后置图标(展开箭头、外链) | Trailing icon (expand arrow, external link) |
|
|
55
|
+
| `color` | `string` | — | 自定义主色:实心档作底色,线框 / 无底档作主色 | Custom main color: background for solid tiers, main color for outline/bare |
|
|
56
|
+
| `loading` | `boolean` | 'false' | 文案前显示同色小圈,并自动 disabled | Shows a same-color spinner before the label and auto-disables |
|
|
57
|
+
| `block` | `boolean` | 'false' | 撑满父宽 | Fill parent width |
|
|
58
|
+
| `children` | `ReactNode` | — | 文案(由调用方按语言给:中文出中文、英文出英文,中英混排也支持) | Label (caller supplies per locale: zh shows zh, en shows en, mixed is supported) |
|
|
59
|
+
| `…rest` | `原生 button 属性` | — | type / disabled / title / aria-* / onClick 原样透传 | type / disabled / title / aria-* / onClick passed through |
|
|
60
|
+
|
|
61
|
+
## Input 家族(Field.ts)
|
|
62
|
+
|
|
63
|
+
> EN: Input family (Field.ts)
|
|
64
|
+
|
|
65
|
+
| 参数 | 类型 | 默认 | 说明(zh) | 说明(en) |
|
|
66
|
+
|---|---|---|---|---|
|
|
67
|
+
| `Input` | `value onChange(v) size(默认 sm) error disabled type placeholder inputRef onKeyDown onBlur aria-label title hint` | — | 基础输入框;error 描红;hint 给字符串即自动挂标准问号提示 | Basic input; error turns it red; passing hint as a string auto-attaches a standard question-mark hint |
|
|
68
|
+
| `PrefixedInput` | `同 Input + prefix: string` | — | 前置文案(https:// / C:\) | Leading text (https:// / C:\) |
|
|
69
|
+
| `NumberInput` | `value: number onChange(v) min max step(默认 1) inputWidth suffix label decreaseLabel increaseLabel hint` | — | 已 clamp;失焦回弹草稿 | Already clamped; reverts to draft on blur |
|
|
70
|
+
| `Textarea` | `value onChange(v) placeholder error disabled rows spellCheck(默认关) aria-label hint` | — | hint 的问号钉在右下角(单行控件则在行尾垂直居中) | hint’s question mark pins to the bottom-right (for single-line controls it centers at the row end) |
|
|
71
|
+
| `Checkbox` | `checked onChange(next) label accentColor disabled` | — | — | — |
|
|
72
|
+
| `fieldMetricsOf(size)` | `→ { height, font, line, icon, gap }` | — | 自己搭同款输入框时对齐尺寸 | Match dimensions when building your own same-style input |
|
|
73
|
+
|
|
74
|
+
## Picker / WorkspacePicker / ModelPicker
|
|
75
|
+
|
|
76
|
+
> EN: Picker / WorkspacePicker / ModelPicker
|
|
77
|
+
|
|
78
|
+
Picker:单 / 多选、上限、搜索、分组、空态,自绘。键盘:Esc 关、↑↓ 移游标、Enter 选。纯逻辑可单用:`toGroups` / `filterGroups` / `toggleValue`。
|
|
79
|
+
|
|
80
|
+
> EN: Picker: single/multiple selection, cap, search, grouping, empty state — self-drawn. Keyboard: Esc closes, ↑↓ move the cursor, Enter selects. Logic reusable standalone: `toGroups` / `filterGroups` / `toggleValue`.
|
|
81
|
+
|
|
82
|
+
WorkspacePicker:数据自带的领域选择器。在插件 apply 里调一次 `connectHost(ctx)`,组件即订阅官方 `workspaces` 快照。未接线 = 空态,不编造数据。
|
|
83
|
+
|
|
84
|
+
> EN: WorkspacePicker: a domain picker that brings its own data. Call `connectHost(ctx)` once in the plugin apply and it subscribes to the official `workspaces` snapshot. Unwired = empty state, never fabricated data.
|
|
85
|
+
|
|
86
|
+
ModelPicker:数据自带,`variant` 为 `grouped`(默认)/ `cascade`;`onChange` 一律发 `provider/id` 形式的模型 value。目录来自宿主 `serveModelCatalog`。
|
|
87
|
+
|
|
88
|
+
> EN: ModelPicker: brings its own data; `variant` is `grouped` (default) or `cascade`; `onChange` always emits the model value as `provider/id`. Catalog comes from the host `serveModelCatalog`.
|
|
89
|
+
|
|
90
|
+
| 参数 | 类型 | 默认 | 说明(zh) | 说明(en) |
|
|
91
|
+
|---|---|---|---|---|
|
|
92
|
+
| `groups / options` | `PickerGroup[] / PickerOption[]` | — | 二选一;options 会被当成一个无标题组 | One of the two; options is treated as a single untitled group |
|
|
93
|
+
| `value / defaultValue` | `string \| string[]` | — | 给了 value 即受控;否则内部管 | Passing value makes it controlled; otherwise it manages internally |
|
|
94
|
+
| `onChange` | `(v: string \| string[]) => void` | — | 单选回 string,多选回 string[] | Single returns string, multiple returns string[] |
|
|
95
|
+
| `mode` | `'single' \| 'multiple'` | 'single' | — | — |
|
|
96
|
+
| `max` | `number` | — | 多选上限;到上限其余项置灰 + 提示(不静默截断) | Multiple-select cap; at cap others grey out + a hint (no silent truncation) |
|
|
97
|
+
| `searchable` | `boolean` | 'false' | 显示搜索框;展开菜单时自动聚焦搜索框 | Shows a search box; auto-focuses it when the menu opens |
|
|
98
|
+
| `align` | `'left' \| 'center'` | 'left' | 触发器文字对齐 | Trigger text alignment |
|
|
99
|
+
| `clearable` | `boolean` | 'false' | 单选时列表顶部多一项「不选」 | In single mode, adds a "none" item at the top of the list |
|
|
100
|
+
| `placeholder` | `string` | 内置「请选择」 | — | — |
|
|
101
|
+
| `degraded` | `boolean` | 'false' | 候选可能不完整 ⇒ 顶部如实提示,不编造 | Candidates may be incomplete ⇒ honest top hint, no fabrication |
|
|
102
|
+
| `size` | `'sm' \| 'md' \| 'lg'` | 'md' | — | — |
|
|
103
|
+
| `placement` | `'down' \| 'up'` | 'down' | 触发器靠近视口底部时用 up | Use up when the trigger is near the viewport bottom |
|
|
104
|
+
| `closeOnSelect` | `boolean` | 多选 false / 单选恒关 | 选中后是否收起 | Whether to collapse after selection |
|
|
105
|
+
| `showLabels` | `boolean` | 'true' | 多选时触发器列出已选项,而非只显示「已选 N 项」 | In multiple mode the trigger lists selected items instead of just "N selected" |
|
|
106
|
+
| `icon` | `ReactNode` | — | 触发器文字前的图标 | Icon before the trigger text |
|
|
107
|
+
| `hint` | `string` | — | 问号提示文字:自动在触发器后挂标准 FieldHint | Hint text: auto-attaches a standard FieldHint after the trigger |
|
|
108
|
+
| `className` | `string` | — | 定制宽度 / 外边距 | Custom width / margin |
|
|
109
|
+
| `ariaLabel` | `string` | — | 无障碍名 | Accessible name |
|
|
110
|
+
| `translate` | `Translate` | 内置 | 覆盖文案 | Override copy |
|
|
111
|
+
|
|
112
|
+
| 参数 | 类型 | 默认 | 说明(zh) | 说明(en) |
|
|
113
|
+
|---|---|---|---|---|
|
|
114
|
+
| `value / defaultValue / onChange` | `选中值为 workspaceId(不是 title);'' = 「所有工作区」` | — | 不筛 | No filter |
|
|
115
|
+
| `allowDefault / defaultLabel` | `「所有工作区」默认项:默认提供、置顶、只在单选出现;选中发 '';false 关掉` | — | 文案可改 | Text is customizable |
|
|
116
|
+
| `mode / max` | `单选 / 多选 / 上限(到上限已选项仍可反选)` | — | — | — |
|
|
117
|
+
| `placeholder` | `string` | 默认「工作区」 | 想叫「选择工作区」就传它 | Pass it if you want "选择工作区" |
|
|
118
|
+
| `icon` | `ReactNode` | — | 触发器前置图标:不传 = 默认文件夹;null = 不显示;传元素 = 自定义 | Leading trigger icon: omitted = default folder; null = hidden; element = custom |
|
|
119
|
+
|
|
120
|
+
| 参数 | 类型 | 默认 | 说明(zh) | 说明(en) |
|
|
121
|
+
|---|---|---|---|---|
|
|
122
|
+
| `variant` | `'grouped' \| 'cascade'` | 'grouped' | grouped = 一个下拉完全独立;cascade = 两个下拉联动(先选供应商,模型列表跟着筛;换供应商清空已选) | grouped = one standalone dropdown; cascade = two linked dropdowns (pick provider first, model list filters; switching provider clears selection) |
|
|
123
|
+
| `allowDefault / defaultLabel` | `「默认模型」选项:默认提供;false 关闭;选中发 ''` | — | 文案可传 defaultLabel | Pass defaultLabel for the text |
|
|
124
|
+
| `placeholder` | `string` | 默认「模型」 | icon:不传 = 默认星形;null = 不显示;传元素 = 自定义 | icon: omitted = default star; null = hidden; element = custom |
|
|
125
|
+
| `透传 Picker` | `value / defaultValue / onChange / clearable / searchable / hint / size / placement / className / disabled / degraded / translate` | — | 同 Picker 同名参数 | Same-named params as Picker |
|
|
126
|
+
|
|
127
|
+
```tsx id="ui-workspacepicker-example"
|
|
128
|
+
import { WorkspacePicker, connectHost } from 'dsh-plugin-core/ui'
|
|
129
|
+
|
|
130
|
+
// apply(ctx) 里:connectHost(ctx)
|
|
131
|
+
h(WorkspacePicker, { value: cur, onChange: setCur, clearable: true })
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## DateTimePicker(日期时间选择)
|
|
135
|
+
|
|
136
|
+
> EN: DateTimePicker (date & time)
|
|
137
|
+
|
|
138
|
+
一个控件覆盖全部诉求:`mode` 选 `single`(一个时刻)/ `range`(时间段——触发器是**一个整条**:两个日期区 + 中间样式画的灰隔条,点整条展开;弹层里左右两块独立日历分别选);`precision` 选 `day` / `hour` / `minute` / `second`。值为本地 ISO(`YYYY-MM-DDTHH:mm:ss.SSS`),毫秒恒三位。
|
|
139
|
+
|
|
140
|
+
> EN: One control covers everything: `mode` picks `single` (one instant) or `range` (a span — the trigger is **one bar**: two date zones + a CSS-drawn grey separator, click anywhere to expand; two independent calendars side by side in the popup); `precision` picks `day` / `hour` / `minute` / `second`. Values are local ISO (`YYYY-MM-DDTHH:mm:ss.SSS`), milliseconds always three digits.
|
|
141
|
+
|
|
142
|
+
补全口径:起始端把未选单位归零(day ⇒ `00:00:00.000`),结束端拉满(day ⇒ `23:59:59.999`;hour ⇒ `H:59:59.999`;second 不动)。数据库只收到秒时 `23:59:59.999` 退化为「当天最后一秒」,语义不坏,无需特殊处理。
|
|
143
|
+
|
|
144
|
+
> EN: Fill rules: the start floors unselected units (day ⇒ `00:00:00.000`), the end ceils them (day ⇒ `23:59:59.999`; hour ⇒ `H:59:59.999`; second stays exact). If a DB stores seconds only, `23:59:59.999` degrades to "last second of the day" — semantics intact, nothing special to do.
|
|
145
|
+
|
|
146
|
+
显示口径:传出的数据恒是完整本地 ISO(到毫秒),但**显示只到 precision**——day 只出日期(不出现时分秒),hour / minute 到分,second 才出秒。调用方传的精度就是用户看到的精度。
|
|
147
|
+
|
|
148
|
+
> EN: Display rule: emitted data is always a complete local ISO (to milliseconds), but **display stops at the precision** — day shows the date only (no clock), hour/minute stop at minutes, second shows seconds. The precision you pass is exactly what the user sees.
|
|
149
|
+
|
|
150
|
+
弹层与 Picker 同机制(floating-ui 浮层、贴边翻转、点外关闭、无遮罩):两个端框 + 两块独立月历(左开始、右结束,各选各的,不标跨度)+ 每端自己的时/分/秒步进(▲▼、直接键入、↑↓ 键——不用逐格点 60 分钟;**时间不强制先选日期**,「确定」时没选日期就不传数据)。快捷键:day 精度叫「今天」(只置日期),带时分秒的叫「现在」(日期 + 时间一起置,之后可再改)。草稿态,「确定」才 onChange;Esc / 点外 = 丢弃。日历键盘:方向键移动、PageUp/Down 换月、Home/End 月内首尾、Enter 选中。结束早于开始时「确定」置灰并提示。
|
|
151
|
+
|
|
152
|
+
> EN: The popup shares Picker’s mechanics (floating-ui layer, edge flip, outside-click close, no mask): two end boxes + two independent calendars (left = start, right = end, each picks its own, no span marking) + per-end hour/minute/second steppers (▲▼, direct typing, ↑↓ keys — no clicking through 60 minutes; **time never requires picking a date first** — on confirm, no date means no data emitted). Quick button: "Today" at day precision (date only), "Now" when hours/minutes/seconds are on (sets date + time together, editable afterwards). Draft state; onChange only on confirm; Esc / outside = discard. Calendar keys: arrows move, PageUp/Down change month, Home/End jump to month bounds, Enter selects. When end precedes start, confirm greys out with a hint.
|
|
153
|
+
|
|
154
|
+
| 参数 | 类型 | 默认 | 说明(zh) | 说明(en) |
|
|
155
|
+
|---|---|---|---|---|
|
|
156
|
+
| `mode` | `'single' \| 'range'` | 'single' | single = 一个时刻;range = 一个整条触发器(两个日期区 + 灰隔条) | single = one instant; range = one-bar trigger (two date zones + grey separator) |
|
|
157
|
+
| `precision` | `'day' \| 'hour' \| 'minute' \| 'second'` | 'day' | 时间精度;day 不显示时分秒步进 | Time precision; day hides the steppers |
|
|
158
|
+
| `value / defaultValue` | `single: string \| null;range: [start, end] \| null` | — | 本地 ISO;给了 value 即受控 | Local ISO; passing value makes it controlled |
|
|
159
|
+
| `onChange` | `(v: string \| [string, string] \| null) => void` | — | 「确定」时提交;「清除」发 null | Emitted on confirm; clear emits null |
|
|
160
|
+
| `disabled / size / placeholder` | `boolean / 'sm' \| 'md' \| 'lg' / string` | false / 'md' / 内置「请选择日期时间」 | 与 Picker 同名参数对齐 | Aligned with Picker’s same-named params |
|
|
161
|
+
| `hint / className / ariaLabel / translate` | `string / string / string / Translate` | — | 同 Picker 同名参数 | Same-named params as Picker |
|
|
162
|
+
|
|
163
|
+
```tsx id="ui-datetimepicker-example"
|
|
164
|
+
import { DateTimePicker } from 'dsh-plugin-core/ui'
|
|
165
|
+
|
|
166
|
+
// 单个时刻,精确到分(起始端归零:14:30 ⇒ 14:30:00.000)
|
|
167
|
+
h(DateTimePicker, { precision: 'minute', value: startAt, onChange: setStartAt })
|
|
168
|
+
|
|
169
|
+
// 时间段:一个整条触发器(两个日期区 + 灰隔条 -),day 精度下结束端补到当天最后一刻
|
|
170
|
+
h(DateTimePicker, {
|
|
171
|
+
mode: 'range',
|
|
172
|
+
precision: 'day',
|
|
173
|
+
value: range,
|
|
174
|
+
onChange: setRange, // → ['2026-10-24T00:00:00.000', '2026-10-24T23:59:59.999']
|
|
175
|
+
})
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## FieldHint(问号提示)
|
|
179
|
+
|
|
180
|
+
> EN: FieldHint (hint)
|
|
181
|
+
|
|
182
|
+
独立组件,标题 / 输入框后随处可挂。气泡是官方 Tooltip 本体,启动时用 `setTooltipRenderer((p) => h(OfficialTooltip, p))` 注入,其余 props 透传。
|
|
183
|
+
|
|
184
|
+
> EN: Standalone — hang it after a title or input. The bubble is the official Tooltip, injected at startup via `setTooltipRenderer((p) => h(OfficialTooltip, p))`; other props pass through.
|
|
185
|
+
|
|
186
|
+
未注入 renderer 的环境只显示问号图标,不出气泡。
|
|
187
|
+
|
|
188
|
+
> EN: Without a renderer only the question-mark icon shows, no bubble.
|
|
189
|
+
|
|
190
|
+
## Card / StripCard
|
|
191
|
+
|
|
192
|
+
> EN: Card / StripCard
|
|
193
|
+
|
|
194
|
+
两种外观,两个组件:Card = surface 底 + 1px 边框 + 圆角(padding 14px,左 12 使竖条贴边);StripCard = 同色浅底 + 占位边框 + 方角。
|
|
195
|
+
|
|
196
|
+
> EN: Two appearances, two components: Card = surface background + 1px border + rounded corners (padding 14px, left 12 so the strip hugs the edge); StripCard = same-hue light background + placeholder border + square corners.
|
|
197
|
+
|
|
198
|
+
头部整体垂直居中,`action` 里裸放一个元素即居中。颜色全走 token,明暗跟随宿主。
|
|
199
|
+
|
|
200
|
+
> EN: The header centers vertically as a whole; drop a bare element into `action` and it centers. Colors come from tokens, so light/dark follows the host.
|
|
201
|
+
|
|
202
|
+
| 参数 | 类型 | 默认 | 说明(zh) | 说明(en) |
|
|
203
|
+
|---|---|---|---|---|
|
|
204
|
+
| `accent` | `5 档 or 任意 CSS 色值(business/success/warning/danger/neutral)` | 'business' | 档位映射到 design 的 token;也可传 '#f59e0b' 这类自定义值 | Tiers map to design tokens; also accepts custom values like '#f59e0b' |
|
|
205
|
+
| `expanded` | `boolean` | 'false' | 展开态(箭头朝向 + panel 显隐) | Expanded state (arrow direction + panel show/hide) |
|
|
206
|
+
| `onToggle` | `() => void` | — | 传了才显示右侧折叠箭头;展开状态由调用方管 | Only shows the right collapse arrow if provided; caller owns the expanded state |
|
|
207
|
+
| `action` | `ReactNode` | — | 右上角操作区 | Top-right action area |
|
|
208
|
+
| `children` | `ReactNode` | — | 主内容,排版随你 | Main content, layout is yours |
|
|
209
|
+
| `panel` | `ReactNode` | — | 展开后才显示的额外内容 | Extra content shown only when expanded |
|
|
210
|
+
| `className / style` | `—` | — | 追加类 / 样式 | Append class / style |
|
|
211
|
+
|
|
212
|
+
```tsx id="ui-card-example"
|
|
213
|
+
import { Card, Chip, StripCard } from 'dsh-plugin-core/ui'
|
|
214
|
+
|
|
215
|
+
h(Card, {
|
|
216
|
+
accent: 'warning',
|
|
217
|
+
action: h(Button, { size: 'sm', variant: 'ghost' }, '跳过'),
|
|
218
|
+
},
|
|
219
|
+
h('div', null, '标题'),
|
|
220
|
+
h(Chip, null, '#npm'),
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
h(StripCard, {
|
|
224
|
+
accent: 'success',
|
|
225
|
+
expanded: open, onToggle: () => setOpen(!open),
|
|
226
|
+
panel: h('div', null, '展开详情'),
|
|
227
|
+
}, h('div', null, '标题 + 元信息'))
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Chip
|
|
231
|
+
|
|
232
|
+
> EN: Chip
|
|
233
|
+
|
|
234
|
+
小标签。`tone`:neutral(默认)/ business / success / warning / danger;`size`:sm(默认)/ md(12px)。传 `onClick` 才可点。
|
|
235
|
+
|
|
236
|
+
> EN: A small tag. `tone`: neutral (default) / business / success / warning / danger; `size`: sm (default) / md (12px). Pass `onClick` to make it clickable.
|
|
237
|
+
|
|
238
|
+
边界:只做「胶囊标签」。纯图标的小按钮请用 IconButton,别拿 Chip 当图标底板。
|
|
239
|
+
|
|
240
|
+
> EN: Boundary: pill tags only. For an icon-only button use IconButton; never use Chip as an icon baseplate.
|
|
241
|
+
|
|
242
|
+
## 反馈件
|
|
243
|
+
|
|
244
|
+
> EN: Feedback
|
|
245
|
+
|
|
246
|
+
底层是 Sonner。toast 宿主是 globalThis 单例(`Symbol.for('dsh-plugin-core/toast-host')`):首个副本建容器,其余把 payload 交它渲染。
|
|
247
|
+
|
|
248
|
+
> EN: Backed by Sonner. The toast host is a singleton on globalThis (`Symbol.for('dsh-plugin-core/toast-host')`): the first copy mounts the container, the rest hand their payload to it.
|
|
249
|
+
|
|
250
|
+
三条取舍(照用别改):① 样式取首个副本;② position 全局共享;③ 不做卸载回收。无 document 的环境静默跳过。
|
|
251
|
+
|
|
252
|
+
> EN: Three trade-offs (accept them): ① styling comes from the first copy; ② position is shared per screen; ③ no unload reclamation. Environments without document skip silently.
|
|
253
|
+
|
|
254
|
+
Modal 是自绘 overlay,不走 react-dom portal。
|
|
255
|
+
|
|
256
|
+
> EN: Modal is a self-drawn overlay, not a react-dom portal.
|
|
257
|
+
|
|
258
|
+
遮罩右边界读 `--dshpc-page-inset-right`(多个 dock 求和),自动让开右侧分栏,弹窗在**剩余区域**居中。弹窗无需任何遮罩参数;也别自己量分栏宽度(挂载异步,恒为 0)。
|
|
259
|
+
|
|
260
|
+
> EN: The mask’s right edge reads `--dshpc-page-inset-right` (summed across docks) and yields to the right column, centering the dialog in the **remaining** area. The dialog needs no mask props; never measure the column yourself (mounting is async, it always reads 0).
|
|
261
|
+
|
|
262
|
+
| 参数 | 类型 | 默认 | 说明(zh) | 说明(en) |
|
|
263
|
+
|---|---|---|---|---|
|
|
264
|
+
| `showToast(message, opts?)` | `` | | 官方 Sonner 原生(对比 / demo 用)。opts: `{ variant?, durationMs?, color?, onDismiss?, position? }`,6 向定位,明暗跟随宿主 | Raw official Sonner (comparison / demo). opts `{ variant?, durationMs?, color?, onDismiss?, position? }`, 6-way placement, theme follows host |
|
|
265
|
+
| `notify(message, opts?)` | `` | | 默认用这个。opts: `{ variant?, description?, durationMs?, position?, actions? }`,actions 用自带 Button(1–2 个) | Use this by default. opts `{ variant?, description?, durationMs?, position?, actions? }`, actions use our own Button (1–2) |
|
|
266
|
+
| `showHostToast(message, opts?)` | `` | | 宿主原生 Toast,走 `dsh-plugin-core/ui/host` 子路径。opts: `{ tone?, holdMs?, actions?, onDismiss? }` | Host-native Toast from the `dsh-plugin-core/ui/host` subpath. opts `{ tone?, holdMs?, actions?, onDismiss? }` |
|
|
267
|
+
| `Loading({ anchorId? })` | `` | | 贴到主内容容器右下角的加载指示;anchorId 默认 dshpc-main | Loading indicator pinned to the main container’s bottom-right; anchorId defaults to dshpc-main |
|
|
268
|
+
| `RunningBlocks()` | `` | | 运行中的占位块 | Placeholder blocks while running |
|
|
269
|
+
| `SectionHead({ icon, title, right? })` | `` | | 分区标题 | Section heading |
|
|
270
|
+
| `MarqueeText({ text, style?, title?, className? })` | `` | | 超长省略、hover 滚动 | Ellipsis on overflow, scroll on hover |
|
|
271
|
+
| `LiveText({ render, style? })` | `` | | 定时重渲染(相对时间这类) | Periodic re-render (for relative time etc.) |
|
|
272
|
+
| `BackToTop({ anchorId? })` | `` | | 回到顶部,贴主容器右缘外侧 | Back-to-top, outside the main container’s right edge |
|
|
273
|
+
| `startResizeLayoutWidth(opts)` | `` | | 拖拽调整布局宽度(root 不传则回落 #dshpc-root) | Drag to resize layout width (falls back to #dshpc-root if root omitted) |
|
|
274
|
+
|
|
275
|
+
| 参数 | 类型 | 默认 | 说明(zh) | 说明(en) |
|
|
276
|
+
|---|---|---|---|---|
|
|
277
|
+
| `title` | `ReactNode` | — | 标题 | Title |
|
|
278
|
+
| `subtitle` | `ReactNode` | — | 标题**下方**的副标题行(等宽小字;会话 id 这类标识放这里,别塞正文) | Subtitle line **under** the title (monospace caption; put identifiers such as a session id here, not in the body) |
|
|
279
|
+
| `headerExtra` | `ReactNode` | — | 标题**同一行**右侧的小块(徽标 / 计数):紧跟标题,不跨标题与副标题两行居中 | Small block (badge / count) on the **same line** as the title: it sits right after the title, never centered across the title and subtitle lines |
|
|
280
|
+
| `headerActions` | `ReactNode` | — | 头部右侧动作区(关闭钮之外) | Header actions area (besides the close button) |
|
|
281
|
+
| `onClose` | `() => void` | — | 不传则不显示关闭钮 | No close button if omitted |
|
|
282
|
+
| `closeOnMask` | `boolean` | 'true' | 点遮罩关闭;误触代价大的场景设 false | Close on mask click; set false where mis-clicks are costly |
|
|
283
|
+
| `escClose` | `boolean` | 'true' | Esc 关闭 | Close on Esc |
|
|
284
|
+
| `maxWidth` | `string` | 按 size | 任意 CSS 值,覆盖 size 的宽度上限;不要用 vw(遮罩已按右侧分栏让位) | Any CSS value, overriding the size’s max width; avoid vw (the mask already yielded to the right column) |
|
|
285
|
+
| `hideHeader` | `boolean` | 'false' | 不渲染头部(沉浸式) | Skip header (immersive) |
|
|
286
|
+
| `footer` | `ReactNode` | — | 底栏(按钮区) | Footer (button area) |
|
|
287
|
+
| `children` | `ReactNode` | — | 主体 | Body |
|
|
288
|
+
|
|
289
|
+
## PanelDock(停靠分栏)
|
|
290
|
+
|
|
291
|
+
> EN: PanelDock (dock)
|
|
292
|
+
|
|
293
|
+
右侧分栏的通用壳,是**布局成员**而非浮层:占宽挤窄主区,要由调用方放进自己的 flex 根。分工:结构写在调用点(children),显隐归状态(`open` / `close` 只传 id)。
|
|
294
|
+
|
|
295
|
+
> EN: A generic shell for right-side columns — a **layout member**, not an overlay: it takes width and narrows the main area, so the caller puts it in their own flex root. Split of work: structure at the call site (children), visibility in state (`open`/`close` take only an id).
|
|
296
|
+
|
|
297
|
+
面板高度默认视口高;嵌在定高容器里时由调用方给 `--dshpc-dock-h`。不支持:同名多实例、tab 切换条、自动淘汰、浮层——标签切换请消费方在自己的面板内容里实现。
|
|
298
|
+
|
|
299
|
+
> EN: Panel height defaults to viewport height; in a fixed-height container the caller sets `--dshpc-dock-h`. Not supported: same-name duplicates, tab bars, auto-eviction, floating layers — tab switching belongs in the consumer’s own panel content.
|
|
300
|
+
|
|
301
|
+
占宽契约:已开栏宽之和实时写进根元素 `--dshpc-page-inset-right`(拖拽逐帧更新,全关即移除),全屏遮罩据此让位;同页多个 dock 求和。
|
|
302
|
+
|
|
303
|
+
> EN: Width contract: the sum of open widths goes to `--dshpc-page-inset-right` on the root element (every frame while dragging, removed when all close), and full-screen masks yield to it; multiple docks on one page are summed.
|
|
304
|
+
|
|
305
|
+
| 参数 | 类型 | 默认 | 说明(zh) | 说明(en) |
|
|
306
|
+
|---|---|---|---|---|
|
|
307
|
+
| `maxPanels` | `number` | 3 | 同时存在的栏数上限 | Max simultaneous panels |
|
|
308
|
+
| `defaultWidth / minWidth` | `number` | 460 / 320 | 兜底宽度与下限(面板自己给了就以面板为准) | Fallback width and floor (panel’s own value wins if given) |
|
|
309
|
+
| `storageKey` | `string` | 'dshpc-dock' | 宽度记忆前缀;传 false 关闭 | Width-memory prefix; false disables |
|
|
310
|
+
|
|
311
|
+
| 参数 | 类型 | 默认 | 说明(zh) | 说明(en) |
|
|
312
|
+
|---|---|---|---|---|
|
|
313
|
+
| `id` | `string` | — | 组名(寻址键),同名唯一 | Group name (address key), unique per name |
|
|
314
|
+
| `title / icon` | `ReactNode` | — | 内置头的标题与标题前图标 | Built-in header title and icon before it |
|
|
315
|
+
| `extra` | `ReactNode` | — | 标题右侧的任意内容(不只是按钮) | Any content to the right of the title (not just buttons) |
|
|
316
|
+
| `header` | `ReactNode \| null` | — | 整块替换头部:不传 = 内置头;null = 不要头部;其他 = 你的头 | Whole-header replacement: omitted = built-in; null = no header; else = your header |
|
|
317
|
+
| `closable / closeButton / closeIcon` | `—` | — | 关钮开关;位置 auto/header/floating/none | Close-button toggle; position auto/header/floating/none |
|
|
318
|
+
| `width / minWidth / maxWidth` | `number` | — | 宽度与可拖动区间 | Width and draggable range |
|
|
319
|
+
| `ariaLabel` | `string` | — | 无头部时的无障碍名 | A11y name when no header |
|
|
320
|
+
|
|
321
|
+
| 参数 | 类型 | 默认 | 说明(zh) | 说明(en) |
|
|
322
|
+
|---|---|---|---|---|
|
|
323
|
+
| `onOpen` | `({ id, created: true })` | — | 首次打开 | First open |
|
|
324
|
+
| `onBeforeClose` | `({ id, reason: 'button' \| 'api' }) => false?` | — | 关闭之前,返回 false 可取消 | Before close; returning false cancels |
|
|
325
|
+
| `onClose` | `({ id, reason })` | — | 已关闭 | Closed |
|
|
326
|
+
| `onResize` | `({ id, width })` | — | 拖宽松手 | Drag released |
|
|
327
|
+
| `onLimitReached` | `({ id })` | — | 到上限被拒 | Rejected at cap |
|
|
328
|
+
|
|
329
|
+
```ts id="ui-paneldock-example"
|
|
330
|
+
const dock = createPanelDock({ maxPanels: 3 }) // 一次,挂在插件级
|
|
331
|
+
|
|
332
|
+
// 页面里:结构就在这儿写,不塞进任何调用参数
|
|
333
|
+
h('div', { style: { display: 'flex' } },
|
|
334
|
+
h(Main, null), // flex:1 1 auto; min-width:0
|
|
335
|
+
h(PanelDock, { dock },
|
|
336
|
+
h(DockPanel, { id: 'files', title: '工作区' }, h(FilePanel)),
|
|
337
|
+
h(DockPanel, { id: 'preview', header: h(PreviewBar) }, h(PreviewBody)),
|
|
338
|
+
h(DockPanel, { id: 'raw', header: null, closeButton: 'floating' }, h(RawBody)),
|
|
339
|
+
),
|
|
340
|
+
)
|
|
341
|
+
// 之后任何地方:dock.open('files') / dock.close('files')
|
|
342
|
+
```
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// utils 子包的使用帮助 —— 真源(TS 数据模块)。内容全在此一处,demo 与 md 都从这份派生。
|
|
2
|
+
import type { DocTopic } from '../design/doc-format.js'
|
|
3
|
+
|
|
4
|
+
const doc: DocTopic = {
|
|
5
|
+
title: { zh: 'utils —— 通用方法', en: 'utils — common helpers' },
|
|
6
|
+
exports: [
|
|
7
|
+
'pad2', 'formatDateTime', 'formatYmd', 'formatClock', 'formatDurationHms',
|
|
8
|
+
'sameCalendarDay', 'relativePast', 'relativeFuture', 'formatRange', 'overlaps',
|
|
9
|
+
'baseNameOf', 'safeTrim', 'truncateBytes', 'formatBytes', 'formatCount',
|
|
10
|
+
'request', 'requestJson', 'HttpError', 'setLocale', 'getLocale', 't', 'type Translate',
|
|
11
|
+
],
|
|
12
|
+
sections: [
|
|
13
|
+
{
|
|
14
|
+
id: 'utils-overview',
|
|
15
|
+
heading: { zh: '概览', en: 'Overview' },
|
|
16
|
+
prose: [
|
|
17
|
+
{
|
|
18
|
+
zh: '零 React、零 DOM、零 design 依赖。装的是「和界面无关的纯方法」。',
|
|
19
|
+
en: 'Zero React, zero DOM, zero design dependency. Pure, UI-agnostic helpers.',
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: 'date',
|
|
25
|
+
heading: { zh: '日期', en: 'Date' },
|
|
26
|
+
prose: [
|
|
27
|
+
{
|
|
28
|
+
zh: '全部走本机时区;解析失败一律不抛错、按兜底返回,不编造时间。',
|
|
29
|
+
en: 'All use the local timezone; parse failures never throw — they fall back as specified, never inventing a time.',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
zh: 'relativePast 与 relativeFuture 是对偶的:调度表这类展示未来时间的场景必须用 relativeFuture——用 relativePast 会把「3 分钟后」显示成「刚刚」,直接丢语义。',
|
|
33
|
+
en: '`relativePast` and `relativeFuture` are duals: for future times (e.g. a schedule) you must use `relativeFuture`; using `relativePast` would render "in 3 minutes" as "just now", losing meaning.',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
api: [
|
|
37
|
+
{
|
|
38
|
+
id: 'utils-date',
|
|
39
|
+
rows: [
|
|
40
|
+
{ name: 'pad2', type: '(value: number | string) => string', def: '—', desc: { zh: '`9` ⇒ `\'09\'`', en: '`9` ⇒ `\'09\'`' } },
|
|
41
|
+
{ name: 'formatDateTime', type: '(iso, opts?: { seconds?, fallback? }) => string', def: '—', desc: { zh: '解析失败 ⇒ opts.fallback,缺省原串;seconds:true 补 :ss', en: 'On parse failure ⇒ opts.fallback (default: the original string); seconds:true appends :ss' } },
|
|
42
|
+
{ name: 'formatYmd', type: '(iso, opts?: { fallback? }) => string', def: '—', desc: { zh: '解析失败 ⇒ opts.fallback,缺省 —', en: 'On parse failure ⇒ opts.fallback (default —)' } },
|
|
43
|
+
{ name: 'formatClock', type: '(iso: string | null | undefined, opts?: { fallback? }) => string', def: '—', desc: { zh: '空值/解析失败 ⇒ opts.fallback,缺省 -', en: 'Null/parse failure ⇒ opts.fallback (default -)' } },
|
|
44
|
+
{ name: 'formatDurationHms', type: '(ms: number) => string', def: '—', desc: { zh: '有小时 ⇒ H:MM:SS,否则 MM:SS;负数/NaN ⇒ -', en: 'Has hours ⇒ H:MM:SS, else MM:SS; negative/NaN ⇒ -' } },
|
|
45
|
+
{ name: 'sameCalendarDay', type: '(a: Date, b: Date) => boolean', def: '—', desc: { zh: '本机时区比年月日', en: 'Compares year/month/day in local tz' } },
|
|
46
|
+
{ name: 'relativePast', type: '(iso, nowMs, translate?) => string', def: '—', desc: { zh: '过去时间 ⇒ 「3 分钟前」;未来/解析失败 ⇒ 「刚刚」', en: 'Past ⇒ "3 minutes ago"; future/parse failure ⇒ "just now"' } },
|
|
47
|
+
{ name: 'relativeFuture', type: '(iso, nowMs, translate?) => string', def: '—', desc: { zh: '未来时间 ⇒ 「3 分钟后」;解析失败回退 formatYmd', en: 'Future ⇒ "in 3 minutes"; parse failure falls back to formatYmd' } },
|
|
48
|
+
{ name: 'formatRange', type: '(fromIso, toIso, opts?: { seconds? }) => string', def: '—', desc: { zh: '同天 ⇒ 09:00 – 10:30;跨天两端带日期', en: 'Same day ⇒ 09:00 – 10:30; across days both ends show dates' } },
|
|
49
|
+
{ name: 'overlaps', type: '(aFrom, aTo, bFrom, bTo) => boolean', def: '—', desc: { zh: '半开区间 [from, to);NaN ⇒ 不重叠', en: 'Half-open [from, to); NaN ⇒ no overlap' } },
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'text',
|
|
56
|
+
heading: { zh: '字符串', en: 'String' },
|
|
57
|
+
api: [
|
|
58
|
+
{
|
|
59
|
+
id: 'utils-text',
|
|
60
|
+
rows: [
|
|
61
|
+
{ name: 'baseNameOf', type: '(path: string) => string', def: '—', desc: { zh: '取末段;目录尾斜杠不会取成空串', en: 'Last segment; a trailing slash never yields empty' } },
|
|
62
|
+
{ name: 'safeTrim', type: '(s: string) => string', def: '—', desc: { zh: '去首尾空白', en: 'Trim surrounding whitespace' } },
|
|
63
|
+
{ name: 'truncateBytes', type: '(s: string, maxBytes: number) => string', def: '—', desc: { zh: '按 UTF-8 字节截断,不切半个字', en: 'Truncate by UTF-8 bytes without splitting a char' } },
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: 'number',
|
|
70
|
+
heading: { zh: '数字', en: 'Number' },
|
|
71
|
+
api: [
|
|
72
|
+
{
|
|
73
|
+
id: 'utils-number',
|
|
74
|
+
rows: [
|
|
75
|
+
{ name: 'formatBytes', type: '(bytes: number) => string', def: '—', desc: { zh: '`12 KB` / `3.4 MB`;0 与负数 ⇒ —', en: '`12 KB` / `3.4 MB`; 0 and negatives ⇒ —' } },
|
|
76
|
+
{ name: 'formatCount', type: '(n: number) => string', def: '—', desc: { zh: '千分位', en: 'Thousands separator' } },
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
id: 'http',
|
|
83
|
+
heading: { zh: 'HTTP', en: 'HTTP' },
|
|
84
|
+
api: [
|
|
85
|
+
{
|
|
86
|
+
id: 'utils-http',
|
|
87
|
+
rows: [
|
|
88
|
+
{ name: 'request', type: '(url, opts?: RequestOptions) => Promise<Response>', def: '—', desc: { zh: '带超时(默认 10s)与 AbortSignal', en: 'With timeout (default 10s) and AbortSignal' } },
|
|
89
|
+
{ name: 'requestJson', type: '<T>(url, opts?) => Promise<T>', def: '—', desc: { zh: '自动解析 JSON', en: 'Parses JSON automatically' } },
|
|
90
|
+
{ name: 'HttpError', type: 'class extends Error', def: '—', desc: { zh: '带 status;超时抛 AbortError', en: 'Carries status; timeout throws AbortError' } },
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
prose: [
|
|
95
|
+
{
|
|
96
|
+
zh: 'RequestOptions:{ timeoutMs?, signal?, method?, body?, headers? }。',
|
|
97
|
+
en: '`RequestOptions`: { timeoutMs?, signal?, method?, body?, headers? }.',
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
id: 'i18n',
|
|
103
|
+
heading: { zh: '多语言', en: 'i18n' },
|
|
104
|
+
prose: [
|
|
105
|
+
{
|
|
106
|
+
zh: '核心提供的固定提示语(控件错误、加载中、空态…)由本包内置中英字典管。',
|
|
107
|
+
en: 'The fixed copy the core ships (control errors, loading, empty states…) is managed by this package’s built-in zh/en dictionary.',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
zh: '边界:插件自己界面的文案由插件自己管,本包不提供插件级 i18n 框架。想覆盖某条文案:给组件传 translate prop,或给自己的场景直接用 t + 自定义字典。',
|
|
111
|
+
en: 'Boundary: a plugin’s own UI copy is the plugin’s responsibility; this package offers no plugin-level i18n framework. To override a string: pass a `translate` prop, or use `t` with your own dictionary.',
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
zh: '可用 key 全集见 src/utils/i18n.ts 的 UtilMessageKey。',
|
|
115
|
+
en: 'Full key list: `UtilMessageKey` in `src/utils/i18n.ts`.',
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
api: [
|
|
119
|
+
{
|
|
120
|
+
id: 'utils-i18n',
|
|
121
|
+
rows: [
|
|
122
|
+
{ name: 'setLocale(locale)', type: "('zh' | 'en') => void", def: '—', desc: { zh: "'zh'(默认)/ 'en'", en: "'zh' (default) / 'en'" } },
|
|
123
|
+
{ name: 'getLocale()', type: '() => string', def: '—', desc: { zh: '当前语言', en: 'Current locale' } },
|
|
124
|
+
{ name: 't(key, vars?)', type: '(key, vars?) => string', def: '—', desc: { zh: '取文案;{n} 占位由 vars 填', en: 'Get copy; {n} placeholders filled by vars' } },
|
|
125
|
+
{ name: 'type Translate', type: '(key, vars?) => string', def: '—', desc: { zh: '组件都收这个参数供覆盖', en: 'Components accept this to override copy' } },
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export default doc
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<!-- 本文件由 scripts/gen-docs.mjs 自动生成,请勿手改;改对应的 .doc.ts 后重跑 node scripts/gen-docs.mjs -->
|
|
2
|
+
|
|
3
|
+
# utils —— 通用方法
|
|
4
|
+
|
|
5
|
+
> EN: utils — common helpers
|
|
6
|
+
|
|
7
|
+
导出:pad2、formatDateTime、formatYmd、formatClock、formatDurationHms、sameCalendarDay、relativePast、relativeFuture、formatRange、overlaps、baseNameOf、safeTrim、truncateBytes、formatBytes、formatCount、request、requestJson、HttpError、setLocale、getLocale、t、type Translate
|
|
8
|
+
|
|
9
|
+
## 概览
|
|
10
|
+
|
|
11
|
+
> EN: Overview
|
|
12
|
+
|
|
13
|
+
零 React、零 DOM、零 design 依赖。装的是「和界面无关的纯方法」。
|
|
14
|
+
|
|
15
|
+
> EN: Zero React, zero DOM, zero design dependency. Pure, UI-agnostic helpers.
|
|
16
|
+
|
|
17
|
+
## 日期
|
|
18
|
+
|
|
19
|
+
> EN: Date
|
|
20
|
+
|
|
21
|
+
全部走本机时区;解析失败一律不抛错、按兜底返回,不编造时间。
|
|
22
|
+
|
|
23
|
+
> EN: All use the local timezone; parse failures never throw — they fall back as specified, never inventing a time.
|
|
24
|
+
|
|
25
|
+
relativePast 与 relativeFuture 是对偶的:调度表这类展示未来时间的场景必须用 relativeFuture——用 relativePast 会把「3 分钟后」显示成「刚刚」,直接丢语义。
|
|
26
|
+
|
|
27
|
+
> EN: `relativePast` and `relativeFuture` are duals: for future times (e.g. a schedule) you must use `relativeFuture`; using `relativePast` would render "in 3 minutes" as "just now", losing meaning.
|
|
28
|
+
|
|
29
|
+
| 参数 | 类型 | 默认 | 说明(zh) | 说明(en) |
|
|
30
|
+
|---|---|---|---|---|
|
|
31
|
+
| `pad2` | `(value: number \| string) => string` | — | `9` ⇒ `'09'` | `9` ⇒ `'09'` |
|
|
32
|
+
| `formatDateTime` | `(iso, opts?: { seconds?, fallback? }) => string` | — | 解析失败 ⇒ opts.fallback,缺省原串;seconds:true 补 :ss | On parse failure ⇒ opts.fallback (default: the original string); seconds:true appends :ss |
|
|
33
|
+
| `formatYmd` | `(iso, opts?: { fallback? }) => string` | — | 解析失败 ⇒ opts.fallback,缺省 — | On parse failure ⇒ opts.fallback (default —) |
|
|
34
|
+
| `formatClock` | `(iso: string \| null \| undefined, opts?: { fallback? }) => string` | — | 空值/解析失败 ⇒ opts.fallback,缺省 - | Null/parse failure ⇒ opts.fallback (default -) |
|
|
35
|
+
| `formatDurationHms` | `(ms: number) => string` | — | 有小时 ⇒ H:MM:SS,否则 MM:SS;负数/NaN ⇒ - | Has hours ⇒ H:MM:SS, else MM:SS; negative/NaN ⇒ - |
|
|
36
|
+
| `sameCalendarDay` | `(a: Date, b: Date) => boolean` | — | 本机时区比年月日 | Compares year/month/day in local tz |
|
|
37
|
+
| `relativePast` | `(iso, nowMs, translate?) => string` | — | 过去时间 ⇒ 「3 分钟前」;未来/解析失败 ⇒ 「刚刚」 | Past ⇒ "3 minutes ago"; future/parse failure ⇒ "just now" |
|
|
38
|
+
| `relativeFuture` | `(iso, nowMs, translate?) => string` | — | 未来时间 ⇒ 「3 分钟后」;解析失败回退 formatYmd | Future ⇒ "in 3 minutes"; parse failure falls back to formatYmd |
|
|
39
|
+
| `formatRange` | `(fromIso, toIso, opts?: { seconds? }) => string` | — | 同天 ⇒ 09:00 – 10:30;跨天两端带日期 | Same day ⇒ 09:00 – 10:30; across days both ends show dates |
|
|
40
|
+
| `overlaps` | `(aFrom, aTo, bFrom, bTo) => boolean` | — | 半开区间 [from, to);NaN ⇒ 不重叠 | Half-open [from, to); NaN ⇒ no overlap |
|
|
41
|
+
|
|
42
|
+
## 字符串
|
|
43
|
+
|
|
44
|
+
> EN: String
|
|
45
|
+
|
|
46
|
+
| 参数 | 类型 | 默认 | 说明(zh) | 说明(en) |
|
|
47
|
+
|---|---|---|---|---|
|
|
48
|
+
| `baseNameOf` | `(path: string) => string` | — | 取末段;目录尾斜杠不会取成空串 | Last segment; a trailing slash never yields empty |
|
|
49
|
+
| `safeTrim` | `(s: string) => string` | — | 去首尾空白 | Trim surrounding whitespace |
|
|
50
|
+
| `truncateBytes` | `(s: string, maxBytes: number) => string` | — | 按 UTF-8 字节截断,不切半个字 | Truncate by UTF-8 bytes without splitting a char |
|
|
51
|
+
|
|
52
|
+
## 数字
|
|
53
|
+
|
|
54
|
+
> EN: Number
|
|
55
|
+
|
|
56
|
+
| 参数 | 类型 | 默认 | 说明(zh) | 说明(en) |
|
|
57
|
+
|---|---|---|---|---|
|
|
58
|
+
| `formatBytes` | `(bytes: number) => string` | — | `12 KB` / `3.4 MB`;0 与负数 ⇒ — | `12 KB` / `3.4 MB`; 0 and negatives ⇒ — |
|
|
59
|
+
| `formatCount` | `(n: number) => string` | — | 千分位 | Thousands separator |
|
|
60
|
+
|
|
61
|
+
## HTTP
|
|
62
|
+
|
|
63
|
+
> EN: HTTP
|
|
64
|
+
|
|
65
|
+
RequestOptions:{ timeoutMs?, signal?, method?, body?, headers? }。
|
|
66
|
+
|
|
67
|
+
> EN: `RequestOptions`: { timeoutMs?, signal?, method?, body?, headers? }.
|
|
68
|
+
|
|
69
|
+
| 参数 | 类型 | 默认 | 说明(zh) | 说明(en) |
|
|
70
|
+
|---|---|---|---|---|
|
|
71
|
+
| `request` | `(url, opts?: RequestOptions) => Promise<Response>` | — | 带超时(默认 10s)与 AbortSignal | With timeout (default 10s) and AbortSignal |
|
|
72
|
+
| `requestJson` | `<T>(url, opts?) => Promise<T>` | — | 自动解析 JSON | Parses JSON automatically |
|
|
73
|
+
| `HttpError` | `class extends Error` | — | 带 status;超时抛 AbortError | Carries status; timeout throws AbortError |
|
|
74
|
+
|
|
75
|
+
## 多语言
|
|
76
|
+
|
|
77
|
+
> EN: i18n
|
|
78
|
+
|
|
79
|
+
核心提供的固定提示语(控件错误、加载中、空态…)由本包内置中英字典管。
|
|
80
|
+
|
|
81
|
+
> EN: The fixed copy the core ships (control errors, loading, empty states…) is managed by this package’s built-in zh/en dictionary.
|
|
82
|
+
|
|
83
|
+
边界:插件自己界面的文案由插件自己管,本包不提供插件级 i18n 框架。想覆盖某条文案:给组件传 translate prop,或给自己的场景直接用 t + 自定义字典。
|
|
84
|
+
|
|
85
|
+
> EN: Boundary: a plugin’s own UI copy is the plugin’s responsibility; this package offers no plugin-level i18n framework. To override a string: pass a `translate` prop, or use `t` with your own dictionary.
|
|
86
|
+
|
|
87
|
+
可用 key 全集见 src/utils/i18n.ts 的 UtilMessageKey。
|
|
88
|
+
|
|
89
|
+
> EN: Full key list: `UtilMessageKey` in `src/utils/i18n.ts`.
|
|
90
|
+
|
|
91
|
+
| 参数 | 类型 | 默认 | 说明(zh) | 说明(en) |
|
|
92
|
+
|---|---|---|---|---|
|
|
93
|
+
| `setLocale(locale)` | `('zh' \| 'en') => void` | — | 'zh'(默认)/ 'en' | 'zh' (default) / 'en' |
|
|
94
|
+
| `getLocale()` | `() => string` | — | 当前语言 | Current locale |
|
|
95
|
+
| `t(key, vars?)` | `(key, vars?) => string` | — | 取文案;{n} 占位由 vars 填 | Get copy; {n} placeholders filled by vars |
|
|
96
|
+
| `type Translate` | `(key, vars?) => string` | — | 组件都收这个参数供覆盖 | Components accept this to override copy |
|