@superad/ui 0.1.1
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/LICENSE +21 -0
- package/README.md +42 -0
- package/es/Button/Button.d.mts +7 -0
- package/es/Button/Button.mjs +29 -0
- package/es/Button/Button.mjs.map +1 -0
- package/es/Button/index.d.mts +3 -0
- package/es/Button/index.d.ts +1 -0
- package/es/Button/index.js +1 -0
- package/es/Button/index.mjs +2 -0
- package/es/Button/style.mjs +33 -0
- package/es/Button/style.mjs.map +1 -0
- package/es/Button/type.d.mts +21 -0
- package/es/ConfigProvider/index.d.mts +9 -0
- package/es/ConfigProvider/index.d.ts +1 -0
- package/es/ConfigProvider/index.js +1 -0
- package/es/ConfigProvider/index.mjs +82 -0
- package/es/ConfigProvider/index.mjs.map +1 -0
- package/es/ConfigProvider/type.d.mts +24 -0
- package/es/DraggablePanel/DraggablePanel.d.mts +6 -0
- package/es/DraggablePanel/DraggablePanel.mjs +104 -0
- package/es/DraggablePanel/DraggablePanel.mjs.map +1 -0
- package/es/DraggablePanel/index.d.mts +3 -0
- package/es/DraggablePanel/index.d.ts +1 -0
- package/es/DraggablePanel/index.js +1 -0
- package/es/DraggablePanel/index.mjs +3 -0
- package/es/DraggablePanel/style.mjs +86 -0
- package/es/DraggablePanel/style.mjs.map +1 -0
- package/es/DraggablePanel/type.d.mts +27 -0
- package/es/Flex/Center.d.mts +7 -0
- package/es/Flex/Center.mjs +14 -0
- package/es/Flex/Center.mjs.map +1 -0
- package/es/Flex/FlexBasic.d.mts +6 -0
- package/es/Flex/FlexBasic.mjs +46 -0
- package/es/Flex/FlexBasic.mjs.map +1 -0
- package/es/Flex/Flexbox.d.mts +2 -0
- package/es/Flex/index.d.mts +5 -0
- package/es/Flex/index.d.ts +1 -0
- package/es/Flex/index.js +1 -0
- package/es/Flex/index.mjs +3 -0
- package/es/Flex/type.d.mts +35 -0
- package/es/Flex/utils.mjs +24 -0
- package/es/Flex/utils.mjs.map +1 -0
- package/es/FontLoader/index.d.mts +9 -0
- package/es/FontLoader/index.d.ts +1 -0
- package/es/FontLoader/index.js +1 -0
- package/es/FontLoader/index.mjs +23 -0
- package/es/FontLoader/index.mjs.map +1 -0
- package/es/GlobalFocusRing/index.d.mts +6 -0
- package/es/GlobalFocusRing/index.d.ts +1 -0
- package/es/GlobalFocusRing/index.js +1 -0
- package/es/GlobalFocusRing/index.mjs +204 -0
- package/es/GlobalFocusRing/index.mjs.map +1 -0
- package/es/GlobalFocusRing/style.mjs +35 -0
- package/es/GlobalFocusRing/style.mjs.map +1 -0
- package/es/Provider.d.mts +5 -0
- package/es/Table/canvas/canvasPalette.mjs +11 -0
- package/es/Table/canvas/canvasPalette.mjs.map +1 -0
- package/es/Table/canvas/chipPainters.mjs +408 -0
- package/es/Table/canvas/chipPainters.mjs.map +1 -0
- package/es/Table/canvas/controlPainters.mjs +193 -0
- package/es/Table/canvas/controlPainters.mjs.map +1 -0
- package/es/Table/canvas/groupTitle.mjs +181 -0
- package/es/Table/canvas/groupTitle.mjs.map +1 -0
- package/es/Table/canvas/paintUtils.mjs +70 -0
- package/es/Table/canvas/paintUtils.mjs.map +1 -0
- package/es/Table/canvas/rowSeries.mjs +130 -0
- package/es/Table/canvas/rowSeries.mjs.map +1 -0
- package/es/Table/canvas/textPainters.mjs +97 -0
- package/es/Table/canvas/textPainters.mjs.map +1 -0
- package/es/Table/canvas/theme.d.mts +14 -0
- package/es/Table/canvas/theme.mjs +276 -0
- package/es/Table/canvas/theme.mjs.map +1 -0
- package/es/Table/core/cellValue.d.mts +1 -0
- package/es/Table/core/cellValue.mjs +240 -0
- package/es/Table/core/cellValue.mjs.map +1 -0
- package/es/Table/core/rowSelection.mjs +138 -0
- package/es/Table/core/rowSelection.mjs.map +1 -0
- package/es/Table/core/size.mjs +60 -0
- package/es/Table/core/size.mjs.map +1 -0
- package/es/Table/core/tableI18n.d.mts +11 -0
- package/es/Table/core/tableI18n.mjs +123 -0
- package/es/Table/core/tableI18n.mjs.map +1 -0
- package/es/Table/core/tagTone.mjs +245 -0
- package/es/Table/core/tagTone.mjs.map +1 -0
- package/es/Table/core/zIndex.mjs +7 -0
- package/es/Table/core/zIndex.mjs.map +1 -0
- package/es/Table/index.d.mts +6 -0
- package/es/Table/index.d.ts +1 -0
- package/es/Table/index.js +1 -0
- package/es/Table/index.mjs +6 -0
- package/es/Table/react/Table.d.mts +9 -0
- package/es/Table/react/Table.mjs +407 -0
- package/es/Table/react/Table.mjs.map +1 -0
- package/es/Table/react/TableColumnSettings.mjs +65 -0
- package/es/Table/react/TableColumnSettings.mjs.map +1 -0
- package/es/Table/react/a11y.mjs +72 -0
- package/es/Table/react/a11y.mjs.map +1 -0
- package/es/Table/react/editors/base.mjs +427 -0
- package/es/Table/react/editors/base.mjs.map +1 -0
- package/es/Table/react/editors/inline.mjs +225 -0
- package/es/Table/react/editors/inline.mjs.map +1 -0
- package/es/Table/react/editors/picker.mjs +368 -0
- package/es/Table/react/editors/picker.mjs.map +1 -0
- package/es/Table/react/overlayChips.mjs +50 -0
- package/es/Table/react/overlayChips.mjs.map +1 -0
- package/es/Table/react/sameRenderInputs.mjs +50 -0
- package/es/Table/react/sameRenderInputs.mjs.map +1 -0
- package/es/Table/react/style.mjs +650 -0
- package/es/Table/react/style.mjs.map +1 -0
- package/es/Table/react/useTableCellEvents.mjs +32 -0
- package/es/Table/react/useTableCellEvents.mjs.map +1 -0
- package/es/Table/react/useTableColumnSettings.mjs +107 -0
- package/es/Table/react/useTableColumnSettings.mjs.map +1 -0
- package/es/Table/react/useTableEditorSync.mjs +41 -0
- package/es/Table/react/useTableEditorSync.mjs.map +1 -0
- package/es/Table/react/useTableHoverHint.mjs +62 -0
- package/es/Table/react/useTableHoverHint.mjs.map +1 -0
- package/es/Table/react/useTableKeyboard.mjs +41 -0
- package/es/Table/react/useTableKeyboard.mjs.map +1 -0
- package/es/Table/react/useTableRenderState.mjs +194 -0
- package/es/Table/react/useTableRenderState.mjs.map +1 -0
- package/es/Table/react/useTableScroll.mjs +33 -0
- package/es/Table/react/useTableScroll.mjs.map +1 -0
- package/es/Table/react/useTableSelectionInfo.mjs +48 -0
- package/es/Table/react/useTableSelectionInfo.mjs.map +1 -0
- package/es/Table/react/useTableVTableEvents.mjs +132 -0
- package/es/Table/react/useTableVTableEvents.mjs.map +1 -0
- package/es/Table/type.d.mts +279 -0
- package/es/Table/type.mjs +34 -0
- package/es/Table/type.mjs.map +1 -0
- package/es/Table/vtable/columns.d.mts +17 -0
- package/es/Table/vtable/columns.mjs +381 -0
- package/es/Table/vtable/columns.mjs.map +1 -0
- package/es/Table/vtable/frozenShadow.mjs +27 -0
- package/es/Table/vtable/frozenShadow.mjs.map +1 -0
- package/es/Table/vtable/interaction.mjs +175 -0
- package/es/Table/vtable/interaction.mjs.map +1 -0
- package/es/Table/vtable/option.d.mts +39 -0
- package/es/Table/vtable/option.mjs +232 -0
- package/es/Table/vtable/option.mjs.map +1 -0
- package/es/Table/vtable/seriesSelection.mjs +374 -0
- package/es/Table/vtable/seriesSelection.mjs.map +1 -0
- package/es/Table/vtable/vtableAdapter.mjs +96 -0
- package/es/Table/vtable/vtableAdapter.mjs.map +1 -0
- package/es/ThemeProvider/AppElementContext.d.mts +5 -0
- package/es/ThemeProvider/AppElementContext.mjs +10 -0
- package/es/ThemeProvider/AppElementContext.mjs.map +1 -0
- package/es/ThemeProvider/ConfigProvider.mjs +29 -0
- package/es/ThemeProvider/ConfigProvider.mjs.map +1 -0
- package/es/ThemeProvider/GlobalStyle/antdOverride.mjs +73 -0
- package/es/ThemeProvider/GlobalStyle/antdOverride.mjs.map +1 -0
- package/es/ThemeProvider/GlobalStyle/essential.mjs +50 -0
- package/es/ThemeProvider/GlobalStyle/essential.mjs.map +1 -0
- package/es/ThemeProvider/GlobalStyle/global.mjs +90 -0
- package/es/ThemeProvider/GlobalStyle/global.mjs.map +1 -0
- package/es/ThemeProvider/GlobalStyle/index.mjs +14 -0
- package/es/ThemeProvider/GlobalStyle/index.mjs.map +1 -0
- package/es/ThemeProvider/Meta.d.mts +7 -0
- package/es/ThemeProvider/Meta.mjs +48 -0
- package/es/ThemeProvider/Meta.mjs.map +1 -0
- package/es/ThemeProvider/ThemeProvider.d.mts +6 -0
- package/es/ThemeProvider/ThemeProvider.mjs +89 -0
- package/es/ThemeProvider/ThemeProvider.mjs.map +1 -0
- package/es/ThemeProvider/constants.d.mts +5 -0
- package/es/ThemeProvider/constants.mjs +6 -0
- package/es/ThemeProvider/constants.mjs.map +1 -0
- package/es/ThemeProvider/index.d.mts +6 -0
- package/es/ThemeProvider/index.d.ts +1 -0
- package/es/ThemeProvider/index.js +1 -0
- package/es/ThemeProvider/index.mjs +5 -0
- package/es/ThemeProvider/type.d.mts +48 -0
- package/es/_virtual/_rolldown/runtime.mjs +13 -0
- package/es/color/colors/blue.d.mts +6 -0
- package/es/color/colors/blue.mjs +67 -0
- package/es/color/colors/blue.mjs.map +1 -0
- package/es/color/colors/cyan.d.mts +6 -0
- package/es/color/colors/cyan.mjs +67 -0
- package/es/color/colors/cyan.mjs.map +1 -0
- package/es/color/colors/geekblue.d.mts +6 -0
- package/es/color/colors/geekblue.mjs +67 -0
- package/es/color/colors/geekblue.mjs.map +1 -0
- package/es/color/colors/gold.d.mts +6 -0
- package/es/color/colors/gold.mjs +67 -0
- package/es/color/colors/gold.mjs.map +1 -0
- package/es/color/colors/gray.d.mts +6 -0
- package/es/color/colors/gray.mjs +67 -0
- package/es/color/colors/gray.mjs.map +1 -0
- package/es/color/colors/green.d.mts +6 -0
- package/es/color/colors/green.mjs +67 -0
- package/es/color/colors/green.mjs.map +1 -0
- package/es/color/colors/index.d.mts +22 -0
- package/es/color/colors/index.mjs +35 -0
- package/es/color/colors/index.mjs.map +1 -0
- package/es/color/colors/lime.d.mts +6 -0
- package/es/color/colors/lime.mjs +67 -0
- package/es/color/colors/lime.mjs.map +1 -0
- package/es/color/colors/magenta.d.mts +6 -0
- package/es/color/colors/magenta.mjs +67 -0
- package/es/color/colors/magenta.mjs.map +1 -0
- package/es/color/colors/orange.d.mts +6 -0
- package/es/color/colors/orange.mjs +67 -0
- package/es/color/colors/orange.mjs.map +1 -0
- package/es/color/colors/primary.d.mts +6 -0
- package/es/color/colors/primary.mjs +67 -0
- package/es/color/colors/primary.mjs.map +1 -0
- package/es/color/colors/purple.d.mts +6 -0
- package/es/color/colors/purple.mjs +67 -0
- package/es/color/colors/purple.mjs.map +1 -0
- package/es/color/colors/red.d.mts +6 -0
- package/es/color/colors/red.mjs +67 -0
- package/es/color/colors/red.mjs.map +1 -0
- package/es/color/colors/volcano.d.mts +6 -0
- package/es/color/colors/volcano.mjs +67 -0
- package/es/color/colors/volcano.mjs.map +1 -0
- package/es/color/colors/yellow.d.mts +6 -0
- package/es/color/colors/yellow.mjs +67 -0
- package/es/color/colors/yellow.mjs.map +1 -0
- package/es/color/index.d.mts +23 -0
- package/es/color/index.d.ts +1 -0
- package/es/color/index.js +1 -0
- package/es/color/index.mjs +22 -0
- package/es/color/neutrals/index.d.mts +13 -0
- package/es/color/neutrals/index.mjs +17 -0
- package/es/color/neutrals/index.mjs.map +1 -0
- package/es/color/neutrals/mauve.d.mts +6 -0
- package/es/color/neutrals/mauve.mjs +67 -0
- package/es/color/neutrals/mauve.mjs.map +1 -0
- package/es/color/neutrals/olive.d.mts +6 -0
- package/es/color/neutrals/olive.mjs +67 -0
- package/es/color/neutrals/olive.mjs.map +1 -0
- package/es/color/neutrals/sage.d.mts +6 -0
- package/es/color/neutrals/sage.mjs +67 -0
- package/es/color/neutrals/sage.mjs.map +1 -0
- package/es/color/neutrals/sand.d.mts +6 -0
- package/es/color/neutrals/sand.mjs +67 -0
- package/es/color/neutrals/sand.mjs.map +1 -0
- package/es/color/neutrals/slate.d.mts +6 -0
- package/es/color/neutrals/slate.mjs +67 -0
- package/es/color/neutrals/slate.mjs.map +1 -0
- package/es/color/types.d.mts +16 -0
- package/es/eslint/index.d.mts +26 -0
- package/es/eslint/index.d.ts +1 -0
- package/es/eslint/index.js +1 -0
- package/es/eslint/index.mjs +11 -0
- package/es/eslint/index.mjs.map +1 -0
- package/es/hooks/useIsClient.d.mts +8 -0
- package/es/hooks/useIsClient.mjs +13 -0
- package/es/hooks/useIsClient.mjs.map +1 -0
- package/es/i18n/context.d.mts +7 -0
- package/es/i18n/context.mjs +16 -0
- package/es/i18n/context.mjs.map +1 -0
- package/es/i18n/index.d.mts +6 -0
- package/es/i18n/index.d.ts +1 -0
- package/es/i18n/index.js +1 -0
- package/es/i18n/index.mjs +5 -0
- package/es/i18n/resources/en/common.d.mts +35 -0
- package/es/i18n/resources/en/common.mjs +36 -0
- package/es/i18n/resources/en/common.mjs.map +1 -0
- package/es/i18n/resources/en/index.d.mts +7 -0
- package/es/i18n/resources/en/index.mjs +8 -0
- package/es/i18n/resources/en/index.mjs.map +1 -0
- package/es/i18n/resources/zhCn/common.d.mts +35 -0
- package/es/i18n/resources/zhCn/common.mjs +36 -0
- package/es/i18n/resources/zhCn/common.mjs.map +1 -0
- package/es/i18n/resources/zhCn/index.d.mts +7 -0
- package/es/i18n/resources/zhCn/index.mjs +8 -0
- package/es/i18n/resources/zhCn/index.mjs.map +1 -0
- package/es/i18n/types.d.mts +22 -0
- package/es/i18n/useTranslation.d.mts +12 -0
- package/es/i18n/useTranslation.mjs +22 -0
- package/es/i18n/useTranslation.mjs.map +1 -0
- package/es/index.d.mts +43 -0
- package/es/index.mjs +26 -0
- package/es/storybook/StoryBook/StoryBook.d.mts +7 -0
- package/es/storybook/StoryBook/StoryBook.mjs +52 -0
- package/es/storybook/StoryBook/StoryBook.mjs.map +1 -0
- package/es/storybook/StoryBook/index.d.mts +3 -0
- package/es/storybook/StoryBook/style.mjs +97 -0
- package/es/storybook/StoryBook/style.mjs.map +1 -0
- package/es/storybook/StoryBook/type.d.mts +13 -0
- package/es/storybook/index.d.mts +4 -0
- package/es/storybook/index.d.ts +1 -0
- package/es/storybook/index.js +1 -0
- package/es/storybook/index.mjs +2 -0
- package/es/styles/classNames.d.mts +11 -0
- package/es/styles/classNames.mjs +12 -0
- package/es/styles/classNames.mjs.map +1 -0
- package/es/styles/customTheme.d.mts +36 -0
- package/es/styles/customTheme.mjs +71 -0
- package/es/styles/customTheme.mjs.map +1 -0
- package/es/styles/index.d.mts +6 -0
- package/es/styles/index.d.ts +1 -0
- package/es/styles/index.js +1 -0
- package/es/styles/index.mjs +6 -0
- package/es/styles/theme/algorithms/darkAlgorithm.mjs +18 -0
- package/es/styles/theme/algorithms/darkAlgorithm.mjs.map +1 -0
- package/es/styles/theme/algorithms/lightAlgorithm.mjs +18 -0
- package/es/styles/theme/algorithms/lightAlgorithm.mjs.map +1 -0
- package/es/styles/theme/algorithms/resolveScales.mjs +25 -0
- package/es/styles/theme/algorithms/resolveScales.mjs.map +1 -0
- package/es/styles/theme/antdTheme.mjs +31 -0
- package/es/styles/theme/antdTheme.mjs.map +1 -0
- package/es/styles/theme/customStylish.d.mts +7 -0
- package/es/styles/theme/customStylish.mjs +158 -0
- package/es/styles/theme/customStylish.mjs.map +1 -0
- package/es/styles/theme/customStylishStatic.d.mts +6 -0
- package/es/styles/theme/customStylishStatic.mjs +156 -0
- package/es/styles/theme/customStylishStatic.mjs.map +1 -0
- package/es/styles/theme/customToken.d.mts +7 -0
- package/es/styles/theme/customToken.mjs +127 -0
- package/es/styles/theme/customToken.mjs.map +1 -0
- package/es/styles/theme/generateColorPalette.d.mts +16 -0
- package/es/styles/theme/generateColorPalette.mjs +170 -0
- package/es/styles/theme/generateColorPalette.mjs.map +1 -0
- package/es/styles/theme/token/base.mjs +64 -0
- package/es/styles/theme/token/base.mjs.map +1 -0
- package/es/styles/theme/token/dark.mjs +37 -0
- package/es/styles/theme/token/dark.mjs.map +1 -0
- package/es/styles/theme/token/light.mjs +37 -0
- package/es/styles/theme/token/light.mjs.map +1 -0
- package/es/types/customStylish.d.mts +28 -0
- package/es/types/customToken.d.mts +34 -0
- package/es/types/customToken.mjs +32 -0
- package/es/types/customToken.mjs.map +1 -0
- package/es/types/index.d.mts +15 -0
- package/es/types/index.d.ts +1 -0
- package/es/types/index.js +1 -0
- package/es/types/index.mjs +2 -0
- package/es/utils/composeEventHandlers.d.mts +5 -0
- package/es/utils/composeEventHandlers.mjs +10 -0
- package/es/utils/composeEventHandlers.mjs.map +1 -0
- package/es/utils/copyToClipboard.d.mts +5 -0
- package/es/utils/copyToClipboard.mjs +28 -0
- package/es/utils/copyToClipboard.mjs.map +1 -0
- package/es/utils/dom.d.mts +15 -0
- package/es/utils/dom.mjs +16 -0
- package/es/utils/dom.mjs.map +1 -0
- package/es/utils/genCdnUrl.d.mts +12 -0
- package/es/utils/genCdnUrl.mjs +17 -0
- package/es/utils/genCdnUrl.mjs.map +1 -0
- package/es/utils/safeReadableColor.mjs +6 -0
- package/es/utils/safeReadableColor.mjs.map +1 -0
- package/package.json +96 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SuperAd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# SuperAd UI
|
|
2
|
+
|
|
3
|
+
可扩展的 React 组件库。技术栈为 **React 19 + Ant Design 6 + antd-style**,文档站由 `docs.config.ts` + `src/*/index.mdx` + `demos/` 驱动。
|
|
4
|
+
|
|
5
|
+
## 快速开始
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm install
|
|
9
|
+
pnpm dev # 文档站
|
|
10
|
+
pnpm test:run
|
|
11
|
+
pnpm type-check
|
|
12
|
+
pnpm build
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
业务项目中:
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { Button, Flexbox, ThemeProvider } from '@superad/ui';
|
|
19
|
+
|
|
20
|
+
export default function App() {
|
|
21
|
+
return (
|
|
22
|
+
<ThemeProvider>
|
|
23
|
+
<Flexbox gap={12} horizontal>
|
|
24
|
+
<Button type="primary">确认</Button>
|
|
25
|
+
<Button>取消</Button>
|
|
26
|
+
</Flexbox>
|
|
27
|
+
</ThemeProvider>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 文档站
|
|
33
|
+
|
|
34
|
+
`pnpm dev` 会启动组件文档站:
|
|
35
|
+
|
|
36
|
+
- `docs.config.ts` 声明 `atomDirs: [{ dir: 'src' }]`
|
|
37
|
+
- 每个组件的 `index.mdx` 自动变成 `/components/<kebab-name>`
|
|
38
|
+
- 侧栏按 frontmatter 的 `category` 分组
|
|
39
|
+
- MDX 里用 `<Demo of={...} />`、`<Api name="Button" />`
|
|
40
|
+
- 可交互 demo 用 `@superad/ui/storybook` 的 `StoryBook` + `useControls`(Leva)
|
|
41
|
+
|
|
42
|
+
新增组件:复制 `templates/Component`,写好 `index.mdx` 后刷新文档站即可看到。详见 [docs/add-component.mdx](./docs/add-component.mdx)。
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { variants } from "./style.mjs";
|
|
3
|
+
import { Button } from "antd";
|
|
4
|
+
import { cx, useThemeMode } from "antd-style";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/Button/Button.tsx
|
|
7
|
+
const Button$1 = ({ icon, variant, glass, shadow, className, type, color, children, ref, ...rest }) => {
|
|
8
|
+
const { isDarkMode } = useThemeMode();
|
|
9
|
+
const resolvedVariant = type ? void 0 : variant || (isDarkMode ? "filled" : "outlined");
|
|
10
|
+
const resolvedColor = color || (resolvedVariant === "filled" ? "default" : void 0);
|
|
11
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
12
|
+
...rest,
|
|
13
|
+
className: cx(variants({
|
|
14
|
+
glass,
|
|
15
|
+
shadow
|
|
16
|
+
}), className),
|
|
17
|
+
color: resolvedColor,
|
|
18
|
+
icon,
|
|
19
|
+
ref,
|
|
20
|
+
type,
|
|
21
|
+
variant: resolvedVariant,
|
|
22
|
+
children
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
Button$1.displayName = "SuperadButton";
|
|
26
|
+
//#endregion
|
|
27
|
+
export { Button$1 as default };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=Button.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.mjs","names":["Button","AntdButton"],"sources":["../../src/Button/Button.tsx"],"sourcesContent":["'use client';\n\nimport { Button as AntdButton } from 'antd';\nimport { cx, useThemeMode } from 'antd-style';\nimport { type FC } from 'react';\n\nimport { variants } from './style';\nimport type { ButtonProps } from './type';\n\nconst Button: FC<ButtonProps> = ({\n icon,\n variant,\n glass,\n shadow,\n className,\n type,\n color,\n children,\n ref,\n ...rest\n}) => {\n const { isDarkMode } = useThemeMode();\n // 未显式给 type 时按外观派生默认变体:暗色 filled、亮色 outlined\n const resolvedVariant = type ? undefined : variant || (isDarkMode ? 'filled' : 'outlined');\n const resolvedColor = color || (resolvedVariant === 'filled' ? 'default' : undefined);\n\n return (\n <AntdButton\n {...rest}\n className={cx(variants({ glass, shadow }), className)}\n color={resolvedColor}\n icon={icon}\n ref={ref}\n type={type}\n variant={resolvedVariant}\n >\n {children}\n </AntdButton>\n );\n};\n\nButton.displayName = 'SuperadButton';\n\nexport default Button;\n"],"mappings":";;;;;;AASA,MAAMA,YAA2B,EAC/B,MACA,SACA,OACA,QACA,WACA,MACA,OACA,UACA,KACA,GAAG,WACC;CACJ,MAAM,EAAE,eAAe,aAAa;CAEpC,MAAM,kBAAkB,OAAO,KAAA,IAAY,YAAY,aAAa,WAAW;CAC/E,MAAM,gBAAgB,UAAU,oBAAoB,WAAW,YAAY,KAAA;CAE3E,OACE,oBAACC,QAAD;EACE,GAAI;EACJ,WAAW,GAAG,SAAS;GAAE;GAAO;EAAO,CAAC,GAAG,SAAS;EACpD,OAAO;EACD;EACD;EACC;EACN,SAAS;EAER;CACS,CAAA;AAEhB;AAEA,SAAO,cAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.d.mts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.mjs';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { staticStylish } from "../styles/theme/customStylishStatic.mjs";
|
|
2
|
+
import { createStaticStyles } from "antd-style";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
//#region src/Button/style.ts
|
|
5
|
+
const styles = createStaticStyles(({ css, cssVar }) => ({
|
|
6
|
+
glass: staticStylish.blur,
|
|
7
|
+
root: css`
|
|
8
|
+
&[class*='ant-btn'] > [class*='ant-btn-icon'] {
|
|
9
|
+
display: flex;
|
|
10
|
+
}
|
|
11
|
+
`,
|
|
12
|
+
shadow: css`
|
|
13
|
+
box-shadow: ${cssVar.boxShadowTertiary} !important;
|
|
14
|
+
`
|
|
15
|
+
}));
|
|
16
|
+
const flag = (active) => ({
|
|
17
|
+
false: null,
|
|
18
|
+
true: active
|
|
19
|
+
});
|
|
20
|
+
const variants = cva(styles.root, {
|
|
21
|
+
defaultVariants: {
|
|
22
|
+
glass: false,
|
|
23
|
+
shadow: false
|
|
24
|
+
},
|
|
25
|
+
variants: {
|
|
26
|
+
glass: flag(styles.glass),
|
|
27
|
+
shadow: flag(styles.shadow)
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
//#endregion
|
|
31
|
+
export { styles, variants };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=style.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.mjs","names":["superadStaticStylish"],"sources":["../../src/Button/style.ts"],"sourcesContent":["import { createStaticStyles } from 'antd-style';\nimport { cva } from 'class-variance-authority';\n\nimport { superadStaticStylish } from '@/styles';\n\nexport const styles = createStaticStyles(({ css, cssVar }) => ({\n // 毛玻璃直接复用全局 stylish\n glass: superadStaticStylish.blur,\n // antd 按钮的图标容器默认不是 flex,图标会偏;这里修齐\n root: css`\n &[class*='ant-btn'] > [class*='ant-btn-icon'] {\n display: flex;\n }\n `,\n shadow: css`\n box-shadow: ${cssVar.boxShadowTertiary} !important;\n `,\n}));\n\nconst flag = (active: string) => ({ false: null, true: active });\n\nexport const variants = cva(styles.root, {\n defaultVariants: { glass: false, shadow: false },\n variants: {\n glass: flag(styles.glass),\n shadow: flag(styles.shadow),\n },\n});\n"],"mappings":";;;;AAKA,MAAa,SAAS,oBAAoB,EAAE,KAAK,cAAc;CAE7D,OAAOA,cAAqB;CAE5B,MAAM,GAAG;;;;;CAKT,QAAQ,GAAG;kBACK,OAAO,kBAAkB;;AAE3C,EAAE;AAEF,MAAM,QAAQ,YAAoB;CAAE,OAAO;CAAM,MAAM;AAAO;AAE9D,MAAa,WAAW,IAAI,OAAO,MAAM;CACvC,iBAAiB;EAAE,OAAO;EAAO,QAAQ;CAAM;CAC/C,UAAU;EACR,OAAO,KAAK,OAAO,KAAK;EACxB,QAAQ,KAAK,OAAO,MAAM;CAC5B;AACF,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ButtonProps } from "antd";
|
|
2
|
+
import { ReactNode, Ref } from "react";
|
|
3
|
+
//#region src/Button/type.d.ts
|
|
4
|
+
/** SuperAd button, extending Ant Design Button. */
|
|
5
|
+
interface ButtonProps$1 extends ButtonProps {
|
|
6
|
+
/**
|
|
7
|
+
* Frosted glass surface.
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
glass?: boolean;
|
|
11
|
+
icon?: ReactNode;
|
|
12
|
+
ref?: Ref<HTMLButtonElement | HTMLAnchorElement>;
|
|
13
|
+
/**
|
|
14
|
+
* Elevated shadow.
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
shadow?: boolean;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { ButtonProps$1 as ButtonProps };
|
|
21
|
+
//# sourceMappingURL=type.d.mts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { I18nContextValue } from "../i18n/types.mjs";
|
|
2
|
+
import { CdnFn, Config, ConfigProviderProps } from "./type.mjs";
|
|
3
|
+
//#region src/ConfigProvider/index.d.ts
|
|
4
|
+
declare const ConfigProvider: import("react").NamedExoticComponent<ConfigProviderProps>;
|
|
5
|
+
declare const useCdnFn: () => CdnFn;
|
|
6
|
+
declare const useI18n: () => I18nContextValue;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { type Config, ConfigProvider as default, useCdnFn, useI18n };
|
|
9
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.d.mts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.mjs';
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { installGlobalFocusRing } from "../GlobalFocusRing/index.mjs";
|
|
3
|
+
import common_default from "../i18n/resources/en/common.mjs";
|
|
4
|
+
import { genCdnUrl } from "../utils/genCdnUrl.mjs";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { createContext, memo, use, useEffect, useMemo, useRef, useState } from "react";
|
|
7
|
+
//#region src/ConfigProvider/index.tsx
|
|
8
|
+
const ConfigContext = createContext(null);
|
|
9
|
+
const I18nContext = createContext({
|
|
10
|
+
locale: "en",
|
|
11
|
+
t: (key) => key
|
|
12
|
+
});
|
|
13
|
+
const isThenable = (value) => typeof value?.then === "function";
|
|
14
|
+
const defaultResources = [common_default];
|
|
15
|
+
const ConfigProvider = memo(({ children, config, locale, resources }) => {
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (config?.globalFocusRing === false) return;
|
|
18
|
+
return installGlobalFocusRing();
|
|
19
|
+
}, [config?.globalFocusRing]);
|
|
20
|
+
const fallbackLocale = locale ?? "en";
|
|
21
|
+
const inputResources = resources ?? defaultResources;
|
|
22
|
+
const [resolvedResources, setResolvedResources] = useState(() => inputResources && !isThenable(inputResources) ? inputResources : void 0);
|
|
23
|
+
const [resolvedLocale, setResolvedLocale] = useState(fallbackLocale);
|
|
24
|
+
const latestRequestIdRef = useRef(0);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const requestId = ++latestRequestIdRef.current;
|
|
27
|
+
if (isThenable(inputResources)) {
|
|
28
|
+
const targetLocale = fallbackLocale;
|
|
29
|
+
inputResources.then((nextResources) => {
|
|
30
|
+
if (latestRequestIdRef.current !== requestId) return;
|
|
31
|
+
setResolvedResources(nextResources);
|
|
32
|
+
setResolvedLocale(targetLocale);
|
|
33
|
+
}).catch(() => {
|
|
34
|
+
if (latestRequestIdRef.current !== requestId) return;
|
|
35
|
+
});
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
setResolvedResources(inputResources);
|
|
39
|
+
setResolvedLocale(fallbackLocale);
|
|
40
|
+
}, [fallbackLocale, inputResources]);
|
|
41
|
+
const currentResources = isThenable(inputResources) ? resolvedResources : inputResources;
|
|
42
|
+
const currentLocale = isThenable(inputResources) ? resolvedLocale : fallbackLocale;
|
|
43
|
+
const i18nValue = useMemo(() => {
|
|
44
|
+
const resourceList = Array.isArray(currentResources) ? currentResources : currentResources ? Object.values(currentResources) : [];
|
|
45
|
+
const mergedResources = Object.assign({}, ...resourceList);
|
|
46
|
+
const t = (key) => mergedResources[key] || key;
|
|
47
|
+
return {
|
|
48
|
+
locale: currentLocale,
|
|
49
|
+
t
|
|
50
|
+
};
|
|
51
|
+
}, [currentLocale, currentResources]);
|
|
52
|
+
return /* @__PURE__ */ jsx(I18nContext, {
|
|
53
|
+
value: i18nValue,
|
|
54
|
+
children: /* @__PURE__ */ jsx(ConfigContext, {
|
|
55
|
+
value: config ?? null,
|
|
56
|
+
children
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
ConfigProvider.displayName = "SuperadConfigProvider";
|
|
61
|
+
const cdnFallback = ({ pkg, version, path }) => genCdnUrl({
|
|
62
|
+
path,
|
|
63
|
+
pkg,
|
|
64
|
+
proxy: "aliyun",
|
|
65
|
+
version
|
|
66
|
+
});
|
|
67
|
+
const useCdnFn = () => {
|
|
68
|
+
const config = use(ConfigContext);
|
|
69
|
+
if (!config) return cdnFallback;
|
|
70
|
+
if (config.proxy !== "custom") return ({ pkg, version, path }) => genCdnUrl({
|
|
71
|
+
path,
|
|
72
|
+
pkg,
|
|
73
|
+
proxy: config.proxy,
|
|
74
|
+
version
|
|
75
|
+
});
|
|
76
|
+
return config.customCdnFn || cdnFallback;
|
|
77
|
+
};
|
|
78
|
+
const useI18n = () => use(I18nContext);
|
|
79
|
+
//#endregion
|
|
80
|
+
export { ConfigContext, I18nContext, ConfigProvider as default, useCdnFn, useI18n };
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["en.common"],"sources":["../../src/ConfigProvider/index.tsx"],"sourcesContent":["'use client';\n\nimport { createContext, memo, use, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { installGlobalFocusRing } from '@/GlobalFocusRing';\nimport { en } from '@/i18n/resources';\nimport {\n type I18nContextValue,\n type TranslationKey,\n type TranslationResourcesMap,\n} from '@/i18n/types';\nimport { type CDN, genCdnUrl } from '@/utils/genCdnUrl';\n\nimport type { CdnFn, Config, ConfigProviderProps } from './type';\n\nexport type { CdnFn, Config, ConfigProviderProps } from './type';\n\nexport const ConfigContext = createContext<Config | null>(null);\n\nconst I18nContext = createContext<I18nContextValue>({\n locale: 'en',\n t: (key: TranslationKey) => key,\n});\n\nconst isThenable = (value: unknown): value is Promise<TranslationResourcesMap> =>\n typeof (value as { then?: unknown })?.then === 'function';\n\nconst defaultResources: TranslationResourcesMap = [en.common];\n\nconst ConfigProvider = memo<ConfigProviderProps>(({ children, config, locale, resources }) => {\n useEffect(() => {\n if (config?.globalFocusRing === false) return;\n return installGlobalFocusRing();\n }, [config?.globalFocusRing]);\n\n const fallbackLocale = locale ?? 'en';\n const inputResources = resources ?? defaultResources;\n const [resolvedResources, setResolvedResources] = useState<TranslationResourcesMap | undefined>(\n () => (inputResources && !isThenable(inputResources) ? inputResources : undefined),\n );\n const [resolvedLocale, setResolvedLocale] = useState(fallbackLocale);\n const latestRequestIdRef = useRef(0);\n\n useEffect(() => {\n const requestId = ++latestRequestIdRef.current;\n\n if (isThenable(inputResources)) {\n const targetLocale = fallbackLocale;\n inputResources\n .then((nextResources) => {\n if (latestRequestIdRef.current !== requestId) return;\n setResolvedResources(nextResources);\n setResolvedLocale(targetLocale);\n })\n .catch(() => {\n if (latestRequestIdRef.current !== requestId) return;\n });\n return;\n }\n\n // 非 thenable 时这两个写入对本次渲染不可见(currentResources / currentLocale 会直接\n // 由 props 推导),但保留它们能让随后到达的 thenable 先显示上一份资源而不是空白。\n /* eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect */\n setResolvedResources(inputResources);\n /* eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect */\n setResolvedLocale(fallbackLocale);\n }, [fallbackLocale, inputResources]);\n\n const currentResources = isThenable(inputResources) ? resolvedResources : inputResources;\n const currentLocale = isThenable(inputResources) ? resolvedLocale : fallbackLocale;\n\n const i18nValue = useMemo((): I18nContextValue => {\n const resourceList = Array.isArray(currentResources)\n ? currentResources\n : currentResources\n ? Object.values(currentResources)\n : [];\n const mergedResources = Object.assign({}, ...resourceList);\n const t = (key: TranslationKey): string => mergedResources[key] || key;\n return { locale: currentLocale, t };\n }, [currentLocale, currentResources]);\n\n return (\n <I18nContext value={i18nValue}>\n <ConfigContext value={config ?? null}>{children}</ConfigContext>\n </I18nContext>\n );\n});\n\nConfigProvider.displayName = 'SuperadConfigProvider';\n\nconst cdnFallback: CdnFn = ({ pkg, version, path }) =>\n genCdnUrl({ path, pkg, proxy: 'aliyun', version });\n\nexport const useCdnFn = (): CdnFn => {\n const config = use(ConfigContext);\n if (!config) return cdnFallback;\n if (config.proxy !== 'custom') {\n return ({ pkg, version, path }) =>\n genCdnUrl({ path, pkg, proxy: config.proxy as CDN, version });\n }\n return config.customCdnFn || cdnFallback;\n};\n\nexport const useI18n = () => use(I18nContext);\n\nexport { I18nContext };\n\nexport default ConfigProvider;\n"],"mappings":";;;;;;;AAiBA,MAAa,gBAAgB,cAA6B,IAAI;AAE9D,MAAM,cAAc,cAAgC;CAClD,QAAQ;CACR,IAAI,QAAwB;AAC9B,CAAC;AAED,MAAM,cAAc,UAClB,OAAQ,OAA8B,SAAS;AAEjD,MAAM,mBAA4C,CAACA,cAAS;AAE5D,MAAM,iBAAiB,MAA2B,EAAE,UAAU,QAAQ,QAAQ,gBAAgB;CAC5F,gBAAgB;EACd,IAAI,QAAQ,oBAAoB,OAAO;EACvC,OAAO,uBAAuB;CAChC,GAAG,CAAC,QAAQ,eAAe,CAAC;CAE5B,MAAM,iBAAiB,UAAU;CACjC,MAAM,iBAAiB,aAAa;CACpC,MAAM,CAAC,mBAAmB,wBAAwB,eACzC,kBAAkB,CAAC,WAAW,cAAc,IAAI,iBAAiB,KAAA,CAC1E;CACA,MAAM,CAAC,gBAAgB,qBAAqB,SAAS,cAAc;CACnE,MAAM,qBAAqB,OAAO,CAAC;CAEnC,gBAAgB;EACd,MAAM,YAAY,EAAE,mBAAmB;EAEvC,IAAI,WAAW,cAAc,GAAG;GAC9B,MAAM,eAAe;GACrB,eACG,MAAM,kBAAkB;IACvB,IAAI,mBAAmB,YAAY,WAAW;IAC9C,qBAAqB,aAAa;IAClC,kBAAkB,YAAY;GAChC,CAAC,CAAC,CACD,YAAY;IACX,IAAI,mBAAmB,YAAY,WAAW;GAChD,CAAC;GACH;EACF;EAKA,qBAAqB,cAAc;EAEnC,kBAAkB,cAAc;CAClC,GAAG,CAAC,gBAAgB,cAAc,CAAC;CAEnC,MAAM,mBAAmB,WAAW,cAAc,IAAI,oBAAoB;CAC1E,MAAM,gBAAgB,WAAW,cAAc,IAAI,iBAAiB;CAEpE,MAAM,YAAY,cAAgC;EAChD,MAAM,eAAe,MAAM,QAAQ,gBAAgB,IAC/C,mBACA,mBACE,OAAO,OAAO,gBAAgB,IAC9B,CAAC;EACP,MAAM,kBAAkB,OAAO,OAAO,CAAC,GAAG,GAAG,YAAY;EACzD,MAAM,KAAK,QAAgC,gBAAgB,QAAQ;EACnE,OAAO;GAAE,QAAQ;GAAe;EAAE;CACpC,GAAG,CAAC,eAAe,gBAAgB,CAAC;CAEpC,OACE,oBAAC,aAAD;EAAa,OAAO;EAClB,UAAA,oBAAC,eAAD;GAAe,OAAO,UAAU;GAAO;EAAwB,CAAA;CACpD,CAAA;AAEjB,CAAC;AAED,eAAe,cAAc;AAE7B,MAAM,eAAsB,EAAE,KAAK,SAAS,WAC1C,UAAU;CAAE;CAAM;CAAK,OAAO;CAAU;AAAQ,CAAC;AAEnD,MAAa,iBAAwB;CACnC,MAAM,SAAS,IAAI,aAAa;CAChC,IAAI,CAAC,QAAQ,OAAO;CACpB,IAAI,OAAO,UAAU,UACnB,QAAQ,EAAE,KAAK,SAAS,WACtB,UAAU;EAAE;EAAM;EAAK,OAAO,OAAO;EAAc;CAAQ,CAAC;CAEhE,OAAO,OAAO,eAAe;AAC/B;AAEA,MAAa,gBAAgB,IAAI,WAAW"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TranslationResourcesInput } from "../i18n/types.mjs";
|
|
2
|
+
import { CDN, CdnApi } from "../utils/genCdnUrl.mjs";
|
|
3
|
+
import { ElementType, ReactNode } from "react";
|
|
4
|
+
//#region src/ConfigProvider/type.d.ts
|
|
5
|
+
type CdnFn = ({ pkg, version, path }: CdnApi) => string;
|
|
6
|
+
interface Config {
|
|
7
|
+
aAs?: ElementType;
|
|
8
|
+
customCdnFn?: CdnFn;
|
|
9
|
+
/** @default true */
|
|
10
|
+
globalFocusRing?: boolean;
|
|
11
|
+
imgAs?: ElementType;
|
|
12
|
+
imgUnoptimized?: boolean;
|
|
13
|
+
proxy?: CDN | 'custom';
|
|
14
|
+
}
|
|
15
|
+
interface ConfigProviderProps {
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
config?: Config;
|
|
18
|
+
/** @default en */
|
|
19
|
+
locale?: string;
|
|
20
|
+
resources?: TranslationResourcesInput;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { CdnFn, Config, ConfigProviderProps };
|
|
24
|
+
//# sourceMappingURL=type.d.mts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DraggablePanelProps } from "./type.mjs";
|
|
2
|
+
//#region src/DraggablePanel/DraggablePanel.d.ts
|
|
3
|
+
declare const DraggablePanel: import("react").NamedExoticComponent<DraggablePanelProps>;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { DraggablePanel as default };
|
|
6
|
+
//# sourceMappingURL=DraggablePanel.d.mts.map
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { styles } from "./style.mjs";
|
|
3
|
+
import { cx } from "antd-style";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { memo, useCallback, useState } from "react";
|
|
6
|
+
import { Resizable } from "re-resizable";
|
|
7
|
+
//#region src/DraggablePanel/DraggablePanel.tsx
|
|
8
|
+
const chevronRotate = {
|
|
9
|
+
bottom: {
|
|
10
|
+
collapsed: 90,
|
|
11
|
+
expanded: -90
|
|
12
|
+
},
|
|
13
|
+
left: {
|
|
14
|
+
collapsed: 0,
|
|
15
|
+
expanded: 180
|
|
16
|
+
},
|
|
17
|
+
right: {
|
|
18
|
+
collapsed: 180,
|
|
19
|
+
expanded: 0
|
|
20
|
+
},
|
|
21
|
+
top: {
|
|
22
|
+
collapsed: -90,
|
|
23
|
+
expanded: 90
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const Chevron = ({ rotate }) => /* @__PURE__ */ jsx("svg", {
|
|
27
|
+
"aria-hidden": true,
|
|
28
|
+
fill: "none",
|
|
29
|
+
height: "14",
|
|
30
|
+
stroke: "currentColor",
|
|
31
|
+
strokeLinecap: "round",
|
|
32
|
+
strokeLinejoin: "round",
|
|
33
|
+
strokeWidth: "2",
|
|
34
|
+
style: { transform: `rotate(${rotate}deg)` },
|
|
35
|
+
viewBox: "0 0 24 24",
|
|
36
|
+
width: "14",
|
|
37
|
+
children: /* @__PURE__ */ jsx("path", { d: "m15 18-6-6 6-6" })
|
|
38
|
+
});
|
|
39
|
+
const DraggablePanel = memo(({ children, className, defaultExpand = true, defaultSize, expandable = true, maxWidth = 480, minHeight = 180, minWidth = 280, onExpandChange, onSizeChange, placement = "right", style }) => {
|
|
40
|
+
const isVertical = placement === "top" || placement === "bottom";
|
|
41
|
+
const [expand, setExpand] = useState(defaultExpand);
|
|
42
|
+
const [size, setSize] = useState({
|
|
43
|
+
height: defaultSize?.height ?? minHeight,
|
|
44
|
+
width: defaultSize?.width ?? minWidth
|
|
45
|
+
});
|
|
46
|
+
const toggle = useCallback(() => {
|
|
47
|
+
setExpand((current) => {
|
|
48
|
+
const next = !current;
|
|
49
|
+
onExpandChange?.(next);
|
|
50
|
+
return next;
|
|
51
|
+
});
|
|
52
|
+
}, [onExpandChange]);
|
|
53
|
+
const handleClass = placement === "bottom" ? styles.handleBottom : placement === "top" ? styles.handleTop : placement === "left" ? styles.handleLeft : styles.handleRight;
|
|
54
|
+
const panelSize = {
|
|
55
|
+
height: isVertical ? expand ? size.height : 0 : "100%",
|
|
56
|
+
width: isVertical ? "100%" : expand ? size.width : 0
|
|
57
|
+
};
|
|
58
|
+
return /* @__PURE__ */ jsxs("aside", {
|
|
59
|
+
className: cx(styles.root, isVertical && styles.rootBottom, className),
|
|
60
|
+
"data-expand": expand,
|
|
61
|
+
"data-placement": placement,
|
|
62
|
+
children: [expandable ? /* @__PURE__ */ jsx("button", {
|
|
63
|
+
"aria-expanded": expand,
|
|
64
|
+
"aria-label": expand ? "Collapse panel" : "Expand panel",
|
|
65
|
+
className: cx(styles.handle, handleClass),
|
|
66
|
+
type: "button",
|
|
67
|
+
onClick: toggle,
|
|
68
|
+
children: /* @__PURE__ */ jsx(Chevron, { rotate: expand ? chevronRotate[placement].expanded : chevronRotate[placement].collapsed })
|
|
69
|
+
}) : null, /* @__PURE__ */ jsx(Resizable, {
|
|
70
|
+
className: styles.panel,
|
|
71
|
+
maxWidth: isVertical ? "100%" : maxWidth,
|
|
72
|
+
minHeight: isVertical ? expand ? minHeight : 0 : void 0,
|
|
73
|
+
minWidth: isVertical ? void 0 : expand ? minWidth : 0,
|
|
74
|
+
size: panelSize,
|
|
75
|
+
style,
|
|
76
|
+
enable: {
|
|
77
|
+
bottom: placement === "top" && expand,
|
|
78
|
+
bottomLeft: false,
|
|
79
|
+
bottomRight: false,
|
|
80
|
+
left: placement === "right" && expand,
|
|
81
|
+
right: placement === "left" && expand,
|
|
82
|
+
top: placement === "bottom" && expand,
|
|
83
|
+
topLeft: false,
|
|
84
|
+
topRight: false
|
|
85
|
+
},
|
|
86
|
+
onResizeStop: (_event, _direction, element, delta) => {
|
|
87
|
+
setSize({
|
|
88
|
+
height: element.offsetHeight,
|
|
89
|
+
width: element.offsetWidth
|
|
90
|
+
});
|
|
91
|
+
onSizeChange?.(delta, {
|
|
92
|
+
height: element.style.height,
|
|
93
|
+
width: element.style.width
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
children: expand ? children : null
|
|
97
|
+
})]
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
DraggablePanel.displayName = "DraggablePanel";
|
|
101
|
+
//#endregion
|
|
102
|
+
export { DraggablePanel as default };
|
|
103
|
+
|
|
104
|
+
//# sourceMappingURL=DraggablePanel.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DraggablePanel.mjs","names":[],"sources":["../../src/DraggablePanel/DraggablePanel.tsx"],"sourcesContent":["'use client';\n\nimport { cx } from 'antd-style';\nimport { Resizable } from 're-resizable';\nimport { type CSSProperties, memo, useCallback, useState } from 'react';\n\nimport { styles } from './style';\nimport type { DraggablePanelPlacement, DraggablePanelProps } from './type';\n\nconst chevronRotate: Record<DraggablePanelPlacement, { collapsed: number; expanded: number }> = {\n bottom: { collapsed: 90, expanded: -90 },\n left: { collapsed: 0, expanded: 180 },\n right: { collapsed: 180, expanded: 0 },\n top: { collapsed: -90, expanded: 90 },\n};\n\nconst Chevron = ({ rotate }: { rotate: number }) => (\n <svg\n aria-hidden\n fill=\"none\"\n height=\"14\"\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"2\"\n style={{ transform: `rotate(${rotate}deg)` }}\n viewBox=\"0 0 24 24\"\n width=\"14\"\n >\n <path d=\"m15 18-6-6 6-6\" />\n </svg>\n);\n\nconst DraggablePanel = memo<DraggablePanelProps>(\n ({\n children,\n className,\n defaultExpand = true,\n defaultSize,\n expandable = true,\n maxWidth = 480,\n minHeight = 180,\n minWidth = 280,\n onExpandChange,\n onSizeChange,\n placement = 'right',\n style,\n }) => {\n const isVertical = placement === 'top' || placement === 'bottom';\n const [expand, setExpand] = useState(defaultExpand);\n const [size, setSize] = useState({\n height: defaultSize?.height ?? minHeight,\n width: defaultSize?.width ?? minWidth,\n });\n\n const toggle = useCallback(() => {\n setExpand((current) => {\n const next = !current;\n onExpandChange?.(next);\n return next;\n });\n }, [onExpandChange]);\n\n const handleClass =\n placement === 'bottom'\n ? styles.handleBottom\n : placement === 'top'\n ? styles.handleTop\n : placement === 'left'\n ? styles.handleLeft\n : styles.handleRight;\n\n const panelSize = {\n height: isVertical ? (expand ? size.height : 0) : '100%',\n width: isVertical ? '100%' : expand ? size.width : 0,\n } as CSSProperties;\n\n return (\n <aside\n className={cx(styles.root, isVertical && styles.rootBottom, className)}\n data-expand={expand}\n data-placement={placement}\n >\n {expandable ? (\n <button\n aria-expanded={expand}\n aria-label={expand ? 'Collapse panel' : 'Expand panel'}\n className={cx(styles.handle, handleClass)}\n type=\"button\"\n onClick={toggle}\n >\n <Chevron\n rotate={\n expand ? chevronRotate[placement].expanded : chevronRotate[placement].collapsed\n }\n />\n </button>\n ) : null}\n <Resizable\n className={styles.panel}\n maxWidth={isVertical ? '100%' : maxWidth}\n minHeight={isVertical ? (expand ? minHeight : 0) : undefined}\n minWidth={isVertical ? undefined : expand ? minWidth : 0}\n size={panelSize}\n style={style}\n enable={{\n bottom: placement === 'top' && expand,\n bottomLeft: false,\n bottomRight: false,\n left: placement === 'right' && expand,\n right: placement === 'left' && expand,\n top: placement === 'bottom' && expand,\n topLeft: false,\n topRight: false,\n }}\n onResizeStop={(_event, _direction, element, delta) => {\n setSize({\n height: element.offsetHeight,\n width: element.offsetWidth,\n });\n onSizeChange?.(delta, {\n height: element.style.height,\n width: element.style.width,\n });\n }}\n >\n {expand ? children : null}\n </Resizable>\n </aside>\n );\n },\n);\n\nDraggablePanel.displayName = 'DraggablePanel';\n\nexport default DraggablePanel;\n"],"mappings":";;;;;;;AASA,MAAM,gBAA0F;CAC9F,QAAQ;EAAE,WAAW;EAAI,UAAU;CAAI;CACvC,MAAM;EAAE,WAAW;EAAG,UAAU;CAAI;CACpC,OAAO;EAAE,WAAW;EAAK,UAAU;CAAE;CACrC,KAAK;EAAE,WAAW;EAAK,UAAU;CAAG;AACtC;AAEA,MAAM,WAAW,EAAE,aACjB,oBAAC,OAAD;CACE,eAAA;CACA,MAAK;CACL,QAAO;CACP,QAAO;CACP,eAAc;CACd,gBAAe;CACf,aAAY;CACZ,OAAO,EAAE,WAAW,UAAU,OAAO,MAAM;CAC3C,SAAQ;CACR,OAAM;CAEN,UAAA,oBAAC,QAAD,EAAM,GAAE,iBAAkB,CAAA;AACvB,CAAA;AAGP,MAAM,iBAAiB,MACpB,EACC,UACA,WACA,gBAAgB,MAChB,aACA,aAAa,MACb,WAAW,KACX,YAAY,KACZ,WAAW,KACX,gBACA,cACA,YAAY,SACZ,YACI;CACJ,MAAM,aAAa,cAAc,SAAS,cAAc;CACxD,MAAM,CAAC,QAAQ,aAAa,SAAS,aAAa;CAClD,MAAM,CAAC,MAAM,WAAW,SAAS;EAC/B,QAAQ,aAAa,UAAU;EAC/B,OAAO,aAAa,SAAS;CAC/B,CAAC;CAED,MAAM,SAAS,kBAAkB;EAC/B,WAAW,YAAY;GACrB,MAAM,OAAO,CAAC;GACd,iBAAiB,IAAI;GACrB,OAAO;EACT,CAAC;CACH,GAAG,CAAC,cAAc,CAAC;CAEnB,MAAM,cACJ,cAAc,WACV,OAAO,eACP,cAAc,QACZ,OAAO,YACP,cAAc,SACZ,OAAO,aACP,OAAO;CAEjB,MAAM,YAAY;EAChB,QAAQ,aAAc,SAAS,KAAK,SAAS,IAAK;EAClD,OAAO,aAAa,SAAS,SAAS,KAAK,QAAQ;CACrD;CAEA,OACE,qBAAC,SAAD;EACE,WAAW,GAAG,OAAO,MAAM,cAAc,OAAO,YAAY,SAAS;EACrE,eAAa;EACb,kBAAgB;EAHlB,UAAA,CAKG,aACC,oBAAC,UAAD;GACE,iBAAe;GACf,cAAY,SAAS,mBAAmB;GACxC,WAAW,GAAG,OAAO,QAAQ,WAAW;GACxC,MAAK;GACL,SAAS;GAET,UAAA,oBAAC,SAAD,EACE,QACE,SAAS,cAAc,UAAU,CAAC,WAAW,cAAc,UAAU,CAAC,UAEzE,CAAA;EACK,CAAA,IACN,MACJ,oBAAC,WAAD;GACE,WAAW,OAAO;GAClB,UAAU,aAAa,SAAS;GAChC,WAAW,aAAc,SAAS,YAAY,IAAK,KAAA;GACnD,UAAU,aAAa,KAAA,IAAY,SAAS,WAAW;GACvD,MAAM;GACC;GACP,QAAQ;IACN,QAAQ,cAAc,SAAS;IAC/B,YAAY;IACZ,aAAa;IACb,MAAM,cAAc,WAAW;IAC/B,OAAO,cAAc,UAAU;IAC/B,KAAK,cAAc,YAAY;IAC/B,SAAS;IACT,UAAU;GACZ;GACA,eAAe,QAAQ,YAAY,SAAS,UAAU;IACpD,QAAQ;KACN,QAAQ,QAAQ;KAChB,OAAO,QAAQ;IACjB,CAAC;IACD,eAAe,OAAO;KACpB,QAAQ,QAAQ,MAAM;KACtB,OAAO,QAAQ,MAAM;IACvB,CAAC;GACH;GAEC,UAAA,SAAS,WAAW;EACZ,CAAA,CACN;;AAEX,CACF;AAEA,eAAe,cAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.d.mts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.mjs';
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { createStaticStyles } from "antd-style";
|
|
2
|
+
//#region src/DraggablePanel/style.ts
|
|
3
|
+
const styles = createStaticStyles(({ css, cssVar }) => ({
|
|
4
|
+
handle: css`
|
|
5
|
+
cursor: pointer;
|
|
6
|
+
|
|
7
|
+
position: absolute;
|
|
8
|
+
z-index: 10;
|
|
9
|
+
|
|
10
|
+
display: grid;
|
|
11
|
+
place-items: center;
|
|
12
|
+
|
|
13
|
+
width: 1rem;
|
|
14
|
+
height: 3.375rem;
|
|
15
|
+
padding: 0;
|
|
16
|
+
border: 0;
|
|
17
|
+
border-radius: 0.5rem;
|
|
18
|
+
|
|
19
|
+
color: ${cssVar.colorTextSecondary};
|
|
20
|
+
|
|
21
|
+
background: ${cssVar.colorBgElevated};
|
|
22
|
+
box-shadow: ${cssVar.boxShadowTertiary};
|
|
23
|
+
|
|
24
|
+
&:hover {
|
|
25
|
+
color: ${cssVar.colorText};
|
|
26
|
+
}
|
|
27
|
+
`,
|
|
28
|
+
handleBottom: css`
|
|
29
|
+
inset-block-start: -0.5rem;
|
|
30
|
+
inset-inline-start: 50%;
|
|
31
|
+
transform: translateX(-50%);
|
|
32
|
+
|
|
33
|
+
width: 3.375rem;
|
|
34
|
+
height: 1rem;
|
|
35
|
+
`,
|
|
36
|
+
handleLeft: css`
|
|
37
|
+
inset-block-start: 0.75rem;
|
|
38
|
+
inset-inline-end: 0.25rem;
|
|
39
|
+
height: 2rem;
|
|
40
|
+
`,
|
|
41
|
+
handleRight: css`
|
|
42
|
+
inset-block-start: 0.75rem;
|
|
43
|
+
inset-inline-start: 0.25rem;
|
|
44
|
+
height: 2rem;
|
|
45
|
+
`,
|
|
46
|
+
handleTop: css`
|
|
47
|
+
inset-block-end: -0.5rem;
|
|
48
|
+
inset-inline-start: 50%;
|
|
49
|
+
transform: translateX(-50%);
|
|
50
|
+
|
|
51
|
+
width: 3.375rem;
|
|
52
|
+
height: 1rem;
|
|
53
|
+
`,
|
|
54
|
+
panel: css`
|
|
55
|
+
position: relative;
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
height: 100%;
|
|
58
|
+
background: ${cssVar.colorBgLayout};
|
|
59
|
+
`,
|
|
60
|
+
root: css`
|
|
61
|
+
position: relative;
|
|
62
|
+
|
|
63
|
+
display: flex;
|
|
64
|
+
flex: none;
|
|
65
|
+
|
|
66
|
+
min-width: 0;
|
|
67
|
+
height: 100%;
|
|
68
|
+
|
|
69
|
+
&[data-expand='false'][data-placement='right'] button {
|
|
70
|
+
inset-inline-start: -0.5rem;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&[data-expand='false'][data-placement='left'] button {
|
|
74
|
+
inset-inline-end: -0.5rem;
|
|
75
|
+
}
|
|
76
|
+
`,
|
|
77
|
+
rootBottom: css`
|
|
78
|
+
width: 100%;
|
|
79
|
+
height: auto;
|
|
80
|
+
min-height: 0;
|
|
81
|
+
`
|
|
82
|
+
}));
|
|
83
|
+
//#endregion
|
|
84
|
+
export { styles };
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=style.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.mjs","names":[],"sources":["../../src/DraggablePanel/style.ts"],"sourcesContent":["import { createStaticStyles } from 'antd-style';\n\nexport const styles = createStaticStyles(({ css, cssVar }) => ({\n handle: css`\n cursor: pointer;\n\n position: absolute;\n z-index: 10;\n\n display: grid;\n place-items: center;\n\n width: 1rem;\n height: 3.375rem;\n padding: 0;\n border: 0;\n border-radius: 0.5rem;\n\n color: ${cssVar.colorTextSecondary};\n\n background: ${cssVar.colorBgElevated};\n box-shadow: ${cssVar.boxShadowTertiary};\n\n &:hover {\n color: ${cssVar.colorText};\n }\n `,\n handleBottom: css`\n inset-block-start: -0.5rem;\n inset-inline-start: 50%;\n transform: translateX(-50%);\n\n width: 3.375rem;\n height: 1rem;\n `,\n handleLeft: css`\n inset-block-start: 0.75rem;\n inset-inline-end: 0.25rem;\n height: 2rem;\n `,\n handleRight: css`\n inset-block-start: 0.75rem;\n inset-inline-start: 0.25rem;\n height: 2rem;\n `,\n handleTop: css`\n inset-block-end: -0.5rem;\n inset-inline-start: 50%;\n transform: translateX(-50%);\n\n width: 3.375rem;\n height: 1rem;\n `,\n panel: css`\n position: relative;\n overflow: hidden;\n height: 100%;\n background: ${cssVar.colorBgLayout};\n `,\n root: css`\n position: relative;\n\n display: flex;\n flex: none;\n\n min-width: 0;\n height: 100%;\n\n &[data-expand='false'][data-placement='right'] button {\n inset-inline-start: -0.5rem;\n }\n\n &[data-expand='false'][data-placement='left'] button {\n inset-inline-end: -0.5rem;\n }\n `,\n rootBottom: css`\n width: 100%;\n height: auto;\n min-height: 0;\n `,\n}));\n"],"mappings":";;AAEA,MAAa,SAAS,oBAAoB,EAAE,KAAK,cAAc;CAC7D,QAAQ,GAAG;;;;;;;;;;;;;;;aAeA,OAAO,mBAAmB;;kBAErB,OAAO,gBAAgB;kBACvB,OAAO,kBAAkB;;;eAG5B,OAAO,UAAU;;;CAG9B,cAAc,GAAG;;;;;;;;CAQjB,YAAY,GAAG;;;;;CAKf,aAAa,GAAG;;;;;CAKhB,WAAW,GAAG;;;;;;;;CAQd,OAAO,GAAG;;;;kBAIM,OAAO,cAAc;;CAErC,MAAM,GAAG;;;;;;;;;;;;;;;;;CAiBT,YAAY,GAAG;;;;;AAKjB,EAAE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from "react";
|
|
2
|
+
import { NumberSize, Size } from "re-resizable";
|
|
3
|
+
//#region src/DraggablePanel/type.d.ts
|
|
4
|
+
type DraggablePanelPlacement = 'right' | 'left' | 'top' | 'bottom';
|
|
5
|
+
/** Resizable side panel used by StoryBook and layout chrome. */
|
|
6
|
+
interface DraggablePanelProps {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
/** @default true */
|
|
10
|
+
defaultExpand?: boolean;
|
|
11
|
+
defaultSize?: Partial<Size>;
|
|
12
|
+
/** @default true */
|
|
13
|
+
expandable?: boolean;
|
|
14
|
+
maxWidth?: number | string;
|
|
15
|
+
/** @default 180 */
|
|
16
|
+
minHeight?: number;
|
|
17
|
+
/** @default 280 */
|
|
18
|
+
minWidth?: number;
|
|
19
|
+
onExpandChange?: (expand: boolean) => void;
|
|
20
|
+
onSizeChange?: (delta: NumberSize, size?: Size) => void;
|
|
21
|
+
/** @default right */
|
|
22
|
+
placement?: DraggablePanelPlacement;
|
|
23
|
+
style?: CSSProperties;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { DraggablePanelPlacement, DraggablePanelProps };
|
|
27
|
+
//# sourceMappingURL=type.d.mts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import FlexBasic_default from "./FlexBasic.mjs";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/Flex/Center.tsx
|
|
4
|
+
const Center = ({ children, ref, ...props }) => /* @__PURE__ */ jsx(FlexBasic_default, {
|
|
5
|
+
...props,
|
|
6
|
+
align: "center",
|
|
7
|
+
justify: "center",
|
|
8
|
+
ref,
|
|
9
|
+
children
|
|
10
|
+
});
|
|
11
|
+
//#endregion
|
|
12
|
+
export { Center as default };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=Center.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Center.mjs","names":["FlexBasic"],"sources":["../../src/Flex/Center.tsx"],"sourcesContent":["import { type FC } from 'react';\n\nimport FlexBasic from './FlexBasic';\nimport type { CenterProps } from './type';\n\nconst Center: FC<CenterProps> = ({ children, ref, ...props }) => (\n <FlexBasic {...props} align=\"center\" justify=\"center\" ref={ref}>\n {children}\n </FlexBasic>\n);\n\nexport default Center;\n"],"mappings":";;;AAKA,MAAM,UAA2B,EAAE,UAAU,KAAK,GAAG,YACnD,oBAACA,mBAAD;CAAW,GAAI;CAAO,OAAM;CAAS,SAAQ;CAAc;CACxD;AACQ,CAAA"}
|