antd-solid 0.0.11 → 0.0.13
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/css/index.css +10 -73
- package/dist/index.esm.js +7802 -2378
- package/dist/index.umd.js +1 -1
- package/es/Alert/index.d.ts +10 -0
- package/es/Alert/index.js +26 -0
- package/es/Button/index.d.ts +32 -0
- package/es/Button/index.js +123 -0
- package/es/Button/index.scss.js +6 -0
- package/es/Checkbox/Group.d.ts +19 -0
- package/es/Checkbox/Group.js +49 -0
- package/es/Checkbox/index.d.ts +15 -0
- package/es/Checkbox/index.js +60 -0
- package/es/CodeInput/index.d.ts +18 -0
- package/es/CodeInput/index.js +72 -0
- package/es/Collapse/Item.d.ts +46 -0
- package/es/Collapse/Item.js +130 -0
- package/es/Collapse/context.d.ts +5 -0
- package/es/Collapse/context.js +8 -0
- package/es/Collapse/index.d.ts +25 -10
- package/es/Collapse/index.js +95 -74
- package/es/Collapse/utils.d.ts +8 -0
- package/es/Collapse/utils.js +35 -0
- package/es/ColorPicker/ColorPickerInput.d.ts +3 -0
- package/es/ColorPicker/ColorPickerInput.js +250 -0
- package/es/ColorPicker/ColorPickerSelect.d.ts +3 -0
- package/es/ColorPicker/ColorPickerSelect.js +71 -0
- package/es/ColorPicker/ColorPickerSlider.d.ts +3 -0
- package/es/ColorPicker/ColorPickerSlider.js +115 -0
- package/es/ColorPicker/color.d.ts +24 -0
- package/es/ColorPicker/color.js +63 -0
- package/es/ColorPicker/context.d.ts +9 -0
- package/es/ColorPicker/context.js +5 -0
- package/es/ColorPicker/index.d.ts +31 -0
- package/es/ColorPicker/index.js +139 -0
- package/es/Command/context.d.ts +9 -0
- package/es/Command/context.js +11 -0
- package/es/Command/createCommand.d.ts +17 -0
- package/es/Command/createCommand.js +112 -0
- package/es/Command/index.d.ts +7 -0
- package/es/Command/index.js +9 -0
- package/es/Command/useCommandProps.d.ts +13 -0
- package/es/Command/useCommandProps.js +28 -0
- package/es/Compact/CompactContextIsolator.d.ts +3 -0
- package/es/Compact/CompactContextIsolator.js +15 -0
- package/es/Compact/context.d.ts +4 -0
- package/es/Compact/context.js +7 -0
- package/es/Compact/index.d.ts +14 -0
- package/es/Compact/index.js +32 -0
- package/es/Compact/index.scss.js +6 -0
- package/es/ConfigProvider/context.d.ts +11 -0
- package/es/ConfigProvider/context.js +15 -0
- package/es/ConfigProvider/dark/colorAlgorithm.d.ts +2 -0
- package/es/ConfigProvider/dark/colorAlgorithm.js +9 -0
- package/es/ConfigProvider/dark/colors.d.ts +3 -0
- package/es/ConfigProvider/dark/colors.js +47 -0
- package/es/ConfigProvider/dark/index.d.ts +2 -0
- package/es/ConfigProvider/dark/index.js +11 -0
- package/es/ConfigProvider/index.d.ts +32 -0
- package/es/ConfigProvider/index.js +44 -0
- package/es/ConfigProvider/light/colorAlgorithm.d.ts +2 -0
- package/es/ConfigProvider/light/colorAlgorithm.js +9 -0
- package/es/ConfigProvider/light/colors.d.ts +3 -0
- package/es/ConfigProvider/light/colors.js +45 -0
- package/es/ConfigProvider/light/index.d.ts +2 -0
- package/es/ConfigProvider/light/index.js +11 -0
- package/es/ConfigProvider/seed.d.ts +3 -0
- package/es/ConfigProvider/seed.js +22 -0
- package/es/ConfigProvider/types/index.d.ts +594 -0
- package/es/ConfigProvider/types/index.js +1 -0
- package/es/ConfigProvider/utils/genColorMapToken.d.ts +7 -0
- package/es/ConfigProvider/utils/genColorMapToken.js +85 -0
- package/es/ConfigProvider/utils/getAlphaColor.d.ts +2 -0
- package/es/ConfigProvider/utils/getAlphaColor.js +44 -0
- package/es/ConfigProvider/utils/index.d.ts +3 -0
- package/es/ConfigProvider/utils/index.js +181 -0
- package/es/ContextMenu/index.d.ts +8 -0
- package/es/ContextMenu/index.js +99 -0
- package/es/Cursor/index.d.ts +6 -0
- package/es/Cursor/index.js +71 -0
- package/es/DelayShow/index.d.ts +16 -0
- package/es/DelayShow/index.js +27 -0
- package/es/Divider/index.d.ts +17 -0
- package/es/Divider/index.js +71 -0
- package/es/Drawer/index.d.ts +20 -16
- package/es/Drawer/index.js +162 -112
- package/es/Drawer/index.scss.js +1 -1
- package/es/Dropdown/index.d.ts +16 -0
- package/es/Dropdown/index.js +47 -0
- package/es/Element/index.d.ts +10 -0
- package/es/Element/index.js +42 -0
- package/es/Empty/PRESENTED_IMAGE_SIMPLE.d.ts +2 -1
- package/es/Empty/PRESENTED_IMAGE_SIMPLE.js +25 -9
- package/es/Empty/assets/EmptySvg.js +1 -1
- package/es/Empty/assets/SimpleEmptySvg.js +1 -1
- package/es/Empty/index.d.ts +9 -3
- package/es/Empty/index.js +24 -9
- package/es/Form/Form.d.ts +8 -5
- package/es/Form/Form.js +50 -34
- package/es/Form/FormItem.d.ts +10 -5
- package/es/Form/FormItem.js +121 -104
- package/es/Form/context.d.ts +9 -9
- package/es/Form/context.js +4 -2
- package/es/Fragment/index.d.ts +4 -0
- package/es/Fragment/index.js +7 -0
- package/es/Image/index.d.ts +10 -0
- package/es/Image/index.js +37 -0
- package/es/Input/TextArea.d.ts +23 -0
- package/es/Input/TextArea.js +84 -0
- package/es/Input/index.d.ts +44 -0
- package/es/Input/index.js +213 -0
- package/es/Input/index.scss.js +6 -0
- package/es/InputNumber/index.d.ts +30 -0
- package/es/InputNumber/index.js +122 -0
- package/es/{InputNumber.test.js → InputNumber/index.test.js} +2 -1
- package/es/Menu/InternalMenu.d.ts +22 -0
- package/es/Menu/InternalMenu.js +196 -0
- package/es/Menu/index.d.ts +75 -0
- package/es/Menu/index.js +64 -0
- package/es/Message/Message.d.ts +9 -0
- package/es/Message/Message.js +34 -0
- package/es/Message/index.d.ts +12 -0
- package/es/Message/index.js +80 -0
- package/es/Message/index.scss.js +6 -0
- package/es/Message/useMessage.d.ts +6 -0
- package/es/Message/useMessage.js +54 -0
- package/es/Modal/index.d.ts +73 -0
- package/es/Modal/index.js +237 -0
- package/es/Modal/index.scss.js +6 -0
- package/es/Modal/useModal.d.ts +5 -0
- package/es/Modal/useModal.js +51 -0
- package/es/Modal/warning.d.ts +5 -0
- package/es/Modal/warning.js +43 -0
- package/es/{Popconfirm.d.ts → Popconfirm/index.d.ts} +2 -2
- package/es/Popconfirm/index.js +62 -0
- package/es/{Popover.d.ts → Popover/index.d.ts} +2 -2
- package/es/{Popover.js → Popover/index.js} +7 -12
- package/es/Progress/Circle.d.ts +16 -0
- package/es/Progress/Circle.js +122 -0
- package/es/Progress/index.d.ts +6 -4
- package/es/Progress/index.js +75 -60
- package/es/Radio/Button.d.ts +7 -0
- package/es/Radio/Button.js +72 -0
- package/es/Radio/Group.d.ts +18 -0
- package/es/Radio/Group.js +57 -0
- package/es/Radio/index.d.ts +14 -0
- package/es/Radio/index.js +68 -0
- package/es/RangeInput/index.d.ts +23 -0
- package/es/RangeInput/index.js +208 -0
- package/es/Result/index.js +49 -0
- package/es/Segmented/index.d.ts +10 -7
- package/es/Segmented/index.js +54 -53
- package/es/Select/index.d.ts +17 -0
- package/es/Select/index.js +75 -0
- package/es/SelectInput/index.d.ts +39 -0
- package/es/SelectInput/index.js +245 -0
- package/es/Slider/index.d.ts +47 -0
- package/es/Slider/index.js +177 -0
- package/es/Space/index.d.ts +13 -0
- package/es/Space/index.js +16 -0
- package/es/Spin/index.d.ts +19 -0
- package/es/Spin/index.js +82 -0
- package/es/{Switch.d.ts → Switch/index.d.ts} +9 -0
- package/es/Switch/index.js +41 -0
- package/es/{Table.d.ts → Table/index.d.ts} +6 -2
- package/es/Table/index.js +71 -0
- package/es/Tabs/index.d.ts +49 -0
- package/es/Tabs/index.js +256 -0
- package/es/Timeline/index.js +31 -0
- package/es/Tooltip/context.d.ts +5 -0
- package/es/Tooltip/context.js +5 -0
- package/es/Tooltip/index.d.ts +64 -0
- package/es/Tooltip/index.js +499 -0
- package/es/Transformer/index.d.ts +88 -0
- package/es/Transformer/index.js +882 -0
- package/es/Tree/SingleLevelTree.d.ts +28 -0
- package/es/Tree/SingleLevelTree.js +299 -0
- package/es/Tree/index.d.ts +83 -0
- package/es/Tree/index.js +197 -0
- package/es/TreeFor/index.d.ts +31 -0
- package/es/TreeFor/index.js +80 -0
- package/es/TreeSelect/index.d.ts +26 -0
- package/es/TreeSelect/index.js +98 -0
- package/es/Upload/index.d.ts +64 -0
- package/es/Upload/index.js +112 -0
- package/es/assets/svg/ColorPickUp.d.ts +4 -0
- package/es/assets/svg/ColorPickUp.js +25 -0
- package/es/assets/svg/Crosshair.d.ts +7 -0
- package/es/assets/svg/Crosshair.js +51 -0
- package/es/assets/svg/Resize.d.ts +4 -0
- package/es/assets/svg/Resize.js +25 -0
- package/es/assets/svg/Rotate.d.ts +4 -0
- package/es/assets/svg/Rotate.js +20 -0
- package/es/assets/svg/RotateArrow.d.ts +4 -0
- package/es/assets/svg/RotateArrow.js +21 -0
- package/es/assets/svg/common.d.ts +2 -0
- package/es/assets/svg/common.js +9 -0
- package/es/hooks/createControllableValue.d.ts +1 -1
- package/es/hooks/createControllableValue.js +16 -17
- package/es/hooks/createTransition.d.ts +6 -2
- package/es/hooks/createTransition.js +12 -8
- package/es/hooks/useClickAway.d.ts +1 -1
- package/es/hooks/useClickAway.js +4 -3
- package/es/hooks/useComponentSize.d.ts +3 -0
- package/es/hooks/useComponentSize.js +12 -0
- package/es/hooks/useCounter.d.ts +12 -0
- package/es/hooks/useCounter.js +30 -0
- package/es/hooks/useFocus.d.ts +2 -0
- package/es/hooks/useFocus.js +24 -0
- package/es/hooks/useHover.d.ts +2 -0
- package/es/hooks/useHover.js +33 -0
- package/es/hooks/useLocale.d.ts +1 -0
- package/es/hooks/useLocale.js +11 -0
- package/es/hooks/useMouse.d.ts +1 -0
- package/es/hooks/useMouse.js +18 -0
- package/es/hooks/useScroll.d.ts +2 -0
- package/es/hooks/useScroll.js +29 -0
- package/es/hooks/useSize.d.ts +8 -2
- package/es/hooks/useSize.js +25 -13
- package/es/hooks/useVirtualList.d.ts +14 -0
- package/es/hooks/useVirtualList.js +45 -0
- package/es/index.d.ts +59 -8
- package/es/index.js +53 -23
- package/es/locale/en_US.d.ts +3 -0
- package/es/locale/en_US.js +9 -0
- package/es/locale/index.d.ts +5 -0
- package/es/locale/index.js +1 -0
- package/es/locale/zh_CN.d.ts +3 -0
- package/es/locale/zh_CN.js +9 -0
- package/es/types/index.d.ts +11 -2
- package/es/utils/animation.d.ts +6 -0
- package/es/utils/animation.js +20 -0
- package/es/utils/array.d.ts +2 -1
- package/es/utils/array.js +5 -1
- package/es/utils/domPoint.d.ts +7 -0
- package/es/utils/domPoint.js +11 -0
- package/es/utils/math.d.ts +17 -0
- package/es/utils/math.js +25 -0
- package/es/utils/number.d.ts +1 -0
- package/es/utils/number.js +14 -0
- package/es/utils/setupGlobalDrag.d.ts +10 -0
- package/es/utils/setupGlobalDrag.js +38 -0
- package/es/utils/solid.d.ts +2 -2
- package/es/utils/solid.js +7 -8
- package/package.json +10 -11
- package/es/Button.d.ts +0 -19
- package/es/Button.js +0 -73
- package/es/ColorPicker.d.ts +0 -8
- package/es/ColorPicker.js +0 -6
- package/es/Compact.d.ts +0 -12
- package/es/Compact.js +0 -17
- package/es/DatePicker.d.ts +0 -19
- package/es/DatePicker.js +0 -9
- package/es/Image.d.ts +0 -9
- package/es/Image.js +0 -22
- package/es/Input.d.ts +0 -29
- package/es/Input.js +0 -144
- package/es/InputNumber.d.ts +0 -11
- package/es/InputNumber.js +0 -92
- package/es/Modal.d.ts +0 -48
- package/es/Modal.js +0 -209
- package/es/Popconfirm.js +0 -64
- package/es/Radio.d.ts +0 -27
- package/es/Radio.js +0 -93
- package/es/Result.js +0 -29
- package/es/Select.d.ts +0 -16
- package/es/Select.js +0 -113
- package/es/Skeleton.d.ts +0 -9
- package/es/Skeleton.js +0 -9
- package/es/Spin.d.ts +0 -9
- package/es/Spin.js +0 -22
- package/es/Switch.js +0 -30
- package/es/Table.js +0 -57
- package/es/Tabs.d.ts +0 -17
- package/es/Tabs.js +0 -117
- package/es/Timeline.js +0 -30
- package/es/Tooltip.d.ts +0 -34
- package/es/Tooltip.js +0 -302
- package/es/Tree.d.ts +0 -28
- package/es/Tree.js +0 -198
- package/es/Upload.d.ts +0 -11
- package/es/Upload.js +0 -6
- package/es/hooks/createUpdateEffect.d.ts +0 -5
- package/es/hooks/createUpdateEffect.js +0 -12
- package/es/utils/EventEmitter.d.ts +0 -7
- package/es/utils/EventEmitter.js +0 -13
- package/es/utils/ReactToSolid.d.ts +0 -8
- package/es/utils/ReactToSolid.js +0 -30
- package/es/utils/SolidToReact.d.ts +0 -8
- package/es/utils/SolidToReact.js +0 -23
- package/es/utils/component.d.ts +0 -31
- package/es/utils/component.js +0 -68
- package/es/utils/zh_CN.d.ts +0 -2
- package/es/utils/zh_CN.js +0 -236
- package/src/Button.tsx +0 -128
- package/src/Collapse/index.tsx +0 -86
- package/src/ColorPicker.tsx +0 -11
- package/src/Compact.tsx +0 -15
- package/src/DatePicker.tsx +0 -30
- package/src/Drawer/index.scss +0 -53
- package/src/Drawer/index.tsx +0 -212
- package/src/Empty/PRESENTED_IMAGE_SIMPLE.tsx +0 -15
- package/src/Empty/assets/EmptySvg.tsx +0 -43
- package/src/Empty/assets/SimpleEmptySvg.tsx +0 -16
- package/src/Empty/index.tsx +0 -20
- package/src/Form/Form.tsx +0 -94
- package/src/Form/FormItem.tsx +0 -141
- package/src/Form/context.ts +0 -16
- package/src/Form/index.ts +0 -13
- package/src/Image.tsx +0 -29
- package/src/Input.tsx +0 -202
- package/src/InputNumber.test.tsx +0 -46
- package/src/InputNumber.tsx +0 -125
- package/src/Modal.tsx +0 -220
- package/src/Popconfirm.tsx +0 -75
- package/src/Popover.tsx +0 -30
- package/src/Progress/index.tsx +0 -73
- package/src/Radio.tsx +0 -142
- package/src/Result.tsx +0 -38
- package/src/Segmented/index.tsx +0 -95
- package/src/Select.tsx +0 -128
- package/src/Skeleton.tsx +0 -14
- package/src/Spin.tsx +0 -23
- package/src/Switch.tsx +0 -34
- package/src/Table.tsx +0 -53
- package/src/Tabs.tsx +0 -131
- package/src/Timeline.tsx +0 -33
- package/src/Tooltip.tsx +0 -340
- package/src/Tree.tsx +0 -246
- package/src/Upload.tsx +0 -10
- package/src/hooks/createControllableValue.ts +0 -68
- package/src/hooks/createTransition.ts +0 -52
- package/src/hooks/createUpdateEffect.ts +0 -16
- package/src/hooks/index.ts +0 -2
- package/src/hooks/useClickAway.ts +0 -18
- package/src/hooks/useSize.ts +0 -26
- package/src/index.ts +0 -47
- package/src/types/index.ts +0 -5
- package/src/utils/EventEmitter.ts +0 -15
- package/src/utils/ReactToSolid.tsx +0 -38
- package/src/utils/SolidToReact.tsx +0 -27
- package/src/utils/array.ts +0 -21
- package/src/utils/component.tsx +0 -85
- package/src/utils/solid.ts +0 -61
- package/src/utils/zh_CN.ts +0 -236
- /package/es/{InputNumber.test.d.ts → InputNumber/index.test.d.ts} +0 -0
- /package/es/{Result.d.ts → Result/index.d.ts} +0 -0
- /package/es/{Timeline.d.ts → Timeline/index.d.ts} +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ParentProps, type Component } from 'solid-js';
|
|
2
|
+
export interface AlertProps extends ParentProps {
|
|
3
|
+
/**
|
|
4
|
+
* 指定警告提示的样式,有四种选择 success、info、warning、error
|
|
5
|
+
* 默认 'info'
|
|
6
|
+
*/
|
|
7
|
+
type?: 'success' | 'info' | 'warning' | 'error';
|
|
8
|
+
}
|
|
9
|
+
declare const Alert: Component<AlertProps>;
|
|
10
|
+
export default Alert;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createComponent } from 'solid-js/web';
|
|
2
|
+
import { mergeProps } from 'solid-js';
|
|
3
|
+
import cs from 'classnames';
|
|
4
|
+
import Element from '../Element/index.js';
|
|
5
|
+
|
|
6
|
+
const TypeClassDict = {
|
|
7
|
+
success: 'bg-[var(--ant-color-success-bg)] [border:var(--ant-line-width)_var(--ant-line-type)_var(--ant-color-success-border)]',
|
|
8
|
+
info: 'bg-[var(--ant-color-info-bg)] [border:var(--ant-line-width)_var(--ant-line-type)_var(--ant-color-info-border)]',
|
|
9
|
+
warning: 'bg-[var(--ant-color-warning-bg)] [border:var(--ant-line-width)_var(--ant-line-type)_var(--ant-color-warning-border)]',
|
|
10
|
+
error: 'bg-[var(--ant-color-error-bg)] [border:var(--ant-line-width)_var(--ant-line-type)_var(--ant-color-error-border)]'
|
|
11
|
+
};
|
|
12
|
+
const Alert = _props => {
|
|
13
|
+
const props = mergeProps({
|
|
14
|
+
type: 'info'
|
|
15
|
+
}, _props);
|
|
16
|
+
return createComponent(Element, {
|
|
17
|
+
get ["class"]() {
|
|
18
|
+
return cs('p-[var(--ant-alert-default-padding)] rounded-[var(--ant-border-radius-lg)] [font-size:var(--ant-font-size)] text-[var(--ant-color-text)] leading-[var(--ant-line-height)]', TypeClassDict[props.type]);
|
|
19
|
+
},
|
|
20
|
+
get children() {
|
|
21
|
+
return props.children;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { Alert as default };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Component, type ParentProps, type JSX } from 'solid-js';
|
|
2
|
+
import './index.scss';
|
|
3
|
+
import { type StringOrJSXElement } from '../types';
|
|
4
|
+
export interface ButtonProps extends ParentProps, JSX.CustomAttributes<HTMLButtonElement>, JSX.HTMLAttributes<HTMLButtonElement> {
|
|
5
|
+
type?: 'default' | 'primary' | 'dashed' | 'text' | 'link';
|
|
6
|
+
onClick?: ((e: MouseEvent) => void) | ((e: MouseEvent) => Promise<unknown>);
|
|
7
|
+
/**
|
|
8
|
+
* 默认: middle
|
|
9
|
+
*/
|
|
10
|
+
size?: 'small' | 'middle' | 'large';
|
|
11
|
+
class?: string;
|
|
12
|
+
style?: JSX.CSSProperties;
|
|
13
|
+
/**
|
|
14
|
+
* 按钮加载中状态
|
|
15
|
+
* 'auto' 代表开启自动 loading,当按钮 click 事件返回 promise 对象时,会自动开启 loading 状态
|
|
16
|
+
*/
|
|
17
|
+
loading?: boolean | 'auto';
|
|
18
|
+
/**
|
|
19
|
+
* 设置危险按钮
|
|
20
|
+
*/
|
|
21
|
+
danger?: boolean;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* 将按钮宽度调整为其父宽度的选项
|
|
25
|
+
*/
|
|
26
|
+
block?: boolean;
|
|
27
|
+
contentClass?: string;
|
|
28
|
+
contentStyle?: JSX.CSSProperties;
|
|
29
|
+
icon?: StringOrJSXElement;
|
|
30
|
+
}
|
|
31
|
+
declare const Button: Component<ButtonProps>;
|
|
32
|
+
export default Button;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { createComponent, mergeProps as mergeProps$1, insert, effect, className, style, template } from 'solid-js/web';
|
|
2
|
+
import { onMount, mergeProps, splitProps, createSignal, createMemo, children, Show } from 'solid-js';
|
|
3
|
+
import cs from 'classnames';
|
|
4
|
+
import './index.scss.js';
|
|
5
|
+
import { wave } from '../utils/animation.js';
|
|
6
|
+
import Element from '../Element/index.js';
|
|
7
|
+
import useComponentSize from '../hooks/useComponentSize.js';
|
|
8
|
+
import { unwrapStringOrJSXElement } from '../utils/solid.js';
|
|
9
|
+
|
|
10
|
+
var _tmpl$ = /*#__PURE__*/template(`<span class="i-ant-design:loading [vertical-align:-0.125em] keyframes-spin [animation:spin_1s_linear_infinite]">`),
|
|
11
|
+
_tmpl$2 = /*#__PURE__*/template(`<span>`),
|
|
12
|
+
_tmpl$3 = /*#__PURE__*/template(`<span class="inline-block leading-inherit">`);
|
|
13
|
+
const sizeClassMap = {
|
|
14
|
+
large: 'px-15px py-7px h-40px leading-24px',
|
|
15
|
+
middle: 'px-15px py-4px h-32px leading-22px',
|
|
16
|
+
small: 'px-7px h-24px leading-22px'
|
|
17
|
+
};
|
|
18
|
+
// 有边框按钮的 disabled 样式
|
|
19
|
+
const disabledWithBorderClass = '[border:1px_solid_var(--ant-button-border-color-disabled)] bg-[var(--ant-color-bg-container-disabled)] text-[var(--ant-color-text-disabled)]';
|
|
20
|
+
// 无边框按钮的 disabled 样式
|
|
21
|
+
const disabledWithNoBorderClass = 'text-[var(--ant-color-text-disabled)]';
|
|
22
|
+
const typeClassMap = {
|
|
23
|
+
default: (danger, disabled) => disabled ? disabledWithBorderClass : cs('bg-[var(--ant-button-default-bg)]', danger ? '[border:1px_solid_var(--ant-color-error)] text-[var(--ant-color-error)] hover:[border-color:var(--ant-color-error-border-hover)] hover:text-[var(--ant-color-error-border-hover)] active:[border-color:var(--ant-color-error-active)] active:text-[var(--ant-color-error-active)]' : '[border:1px_solid_var(--ant-color-border)] text-[var(--ant-button-default-color)] hover:[border-color:var(--ant-color-primary-hover)] hover:text-[var(--ant-color-primary-hover)] active:[border-color:var(--ant-color-primary-active)] active:text-[var(--ant-color-primary-active)]'),
|
|
24
|
+
primary: (danger, disabled) => disabled ? disabledWithBorderClass : cs('text-white', danger ? '[border:1px_solid_var(--ant-color-error)] bg-[var(--ant-color-error)] hover:[border-color:var(--ant-color-error-border-hover)] hover:bg-[var(--ant-color-error-border-hover)] active:[border-color:var(--ant-color-error-active)] active:bg-[var(--ant-color-error-active)]' : '[border:1px_solid_var(--ant-color-primary)] bg-[var(--ant-color-primary)] hover:[border-color:var(--ant-color-primary-hover)] hover:bg-[var(--ant-color-primary-hover)] active:[border-color:var(--ant-color-primary-active)] active:bg-[var(--ant-color-primary-active)]'),
|
|
25
|
+
dashed: (danger, disabled) => disabled ? disabledWithBorderClass : cs(' bg-[var(--ant-button-default-bg)]', danger ? '[border:1px_dashed_var(--ant-color-error)] text-[var(--ant-color-error)] hover:[border-color:var(--ant-color-error-border-hover)] hover:text-[var(--ant-color-error-border-hover)] active:[border-color:var(--ant-color-error-active)] active:text-[var(--ant-color-error-active)]' : '[border:1px_dashed_var(--ant-color-border)] text-[var(--ant-button-default-color)] hover:[border-color:var(--ant-color-primary-hover)] hover:text-[var(--ant-color-primary-hover)] active:[border-color:var(--ant-color-primary-active)] active:text-[var(--ant-color-primary-active)]'),
|
|
26
|
+
text: (danger, disabled) => disabled ? disabledWithNoBorderClass : cs('border-none bg-transparent', danger ? 'text-[var(--ant-color-error)] hover:bg-[var(--ant-color-error-bg)] active:bg-[var(--ant-color-error-bg)]' : 'text-[var(--ant-color-text)] hover:bg-[var(--ant-color-bg-text-hover)] active:bg-[var(--ant-color-bg-text-active)]'),
|
|
27
|
+
link: (danger, disabled) => disabled ? disabledWithNoBorderClass : cs('border-none bg-transparent', danger ? 'text-[var(--ant-color-error)] hover:text-[var(--ant-color-error-border-hover)] active:text-[var(--ant-color-error-active)]' : 'text-[var(--ant-color-primary)] hover:text-[var(--ant-color-primary-hover)] active:text-[var(--ant-color-primary-active)]')
|
|
28
|
+
};
|
|
29
|
+
const Button = _props => {
|
|
30
|
+
console.log('onMount button before');
|
|
31
|
+
onMount(() => {
|
|
32
|
+
console.log('onMount button');
|
|
33
|
+
});
|
|
34
|
+
console.log('onMount button after');
|
|
35
|
+
const props = mergeProps({
|
|
36
|
+
type: 'default',
|
|
37
|
+
danger: false,
|
|
38
|
+
disabled: false
|
|
39
|
+
}, _props);
|
|
40
|
+
const size = useComponentSize(() => props.size);
|
|
41
|
+
const [, buttonElementProps] = splitProps(props, ['type', 'size', 'loading', 'danger']);
|
|
42
|
+
const [innerLoading, setLoading] = createSignal(false);
|
|
43
|
+
const loading = createMemo(() => typeof props.loading === 'boolean' ? props.loading : innerLoading());
|
|
44
|
+
const resolvedChildren = children(() => props.children);
|
|
45
|
+
const resolvedIcon = children(() => unwrapStringOrJSXElement(props.icon));
|
|
46
|
+
return createComponent(Element, mergeProps$1({
|
|
47
|
+
tag: "button"
|
|
48
|
+
}, buttonElementProps, {
|
|
49
|
+
ref(r$) {
|
|
50
|
+
var _ref$ = props.ref;
|
|
51
|
+
typeof _ref$ === "function" ? _ref$(r$) : props.ref = r$;
|
|
52
|
+
},
|
|
53
|
+
get ["class"]() {
|
|
54
|
+
return cs(`ant-btn ant-btn-${props.type}`, 'inline-flex justify-center items-center gap-8px', 'relative cursor-pointer [font-size:var(--ant-font-size)] rounded-[--ant-button-border-radius]', 'focus-visible:[outline:4px_solid_var(--ant-color-primary-border)] focus-visible:[outline-offset:1px]', props.block && 'block w-full', props.class, sizeClassMap[size()], props.disabled && 'cursor-not-allowed', typeClassMap[props.type](props.danger, props.disabled), loading() && 'opacity-65');
|
|
55
|
+
},
|
|
56
|
+
get style() {
|
|
57
|
+
return {
|
|
58
|
+
'--ant-button-border-radius': {
|
|
59
|
+
small: 'var(--ant-border-radius-sm)',
|
|
60
|
+
middle: 'var(--ant-border-radius)',
|
|
61
|
+
large: 'var(--ant-border-radius-lg)'
|
|
62
|
+
}[size()],
|
|
63
|
+
...props.style
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
get disabled() {
|
|
67
|
+
return props.disabled;
|
|
68
|
+
},
|
|
69
|
+
onClick: e => {
|
|
70
|
+
const res = props.onClick?.(e);
|
|
71
|
+
if (props.loading === 'auto' && res instanceof Promise) {
|
|
72
|
+
setLoading(true);
|
|
73
|
+
res.finally(() => setLoading(false));
|
|
74
|
+
}
|
|
75
|
+
if (props.type === 'default' || props.type === 'primary' || props.type === 'dashed') {
|
|
76
|
+
wave(e.currentTarget, props.danger ? 'var(--ant-color-error-border-hover)' : 'var(--ant-color-primary-hover)');
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
get children() {
|
|
80
|
+
return [createComponent(Show, {
|
|
81
|
+
get when() {
|
|
82
|
+
return loading();
|
|
83
|
+
},
|
|
84
|
+
get fallback() {
|
|
85
|
+
return createComponent(Show, {
|
|
86
|
+
get when() {
|
|
87
|
+
return resolvedIcon();
|
|
88
|
+
},
|
|
89
|
+
get children() {
|
|
90
|
+
var _el$3 = _tmpl$3();
|
|
91
|
+
insert(_el$3, resolvedIcon);
|
|
92
|
+
return _el$3;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
get children() {
|
|
97
|
+
return _tmpl$();
|
|
98
|
+
}
|
|
99
|
+
}), createComponent(Show, {
|
|
100
|
+
get when() {
|
|
101
|
+
return resolvedChildren();
|
|
102
|
+
},
|
|
103
|
+
get children() {
|
|
104
|
+
var _el$2 = _tmpl$2();
|
|
105
|
+
insert(_el$2, resolvedChildren);
|
|
106
|
+
effect(_p$ => {
|
|
107
|
+
var _v$ = cs('inline-block leading-inherit', props.contentClass),
|
|
108
|
+
_v$2 = props.contentStyle;
|
|
109
|
+
_v$ !== _p$.e && className(_el$2, _p$.e = _v$);
|
|
110
|
+
_p$.t = style(_el$2, _v$2, _p$.t);
|
|
111
|
+
return _p$;
|
|
112
|
+
}, {
|
|
113
|
+
e: undefined,
|
|
114
|
+
t: undefined
|
|
115
|
+
});
|
|
116
|
+
return _el$2;
|
|
117
|
+
}
|
|
118
|
+
})];
|
|
119
|
+
}
|
|
120
|
+
}));
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export { Button as default };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import styleInject from '../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js';
|
|
2
|
+
|
|
3
|
+
var css_248z = ".ant-compact-horizontal .ant-btn {\n border-radius: 0;\n}\n.ant-compact-horizontal > :first-child.ant-btn, .ant-compact-horizontal > :first-child .ant-btn {\n border-top-left-radius: var(--ant-button-border-radius);\n border-bottom-left-radius: var(--ant-button-border-radius);\n}\n.ant-compact-horizontal > :last-child.ant-btn, .ant-compact-horizontal > :last-child .ant-btn {\n border-top-right-radius: var(--ant-button-border-radius);\n border-bottom-right-radius: var(--ant-button-border-radius);\n}\n.ant-compact-horizontal > :not(:first-child).ant-btn-primary, .ant-compact-horizontal > :not(:first-child) .ant-btn-primary {\n border-left: 1px solid white;\n}\n.ant-compact-horizontal > :not(:last-child).ant-btn-primary, .ant-compact-horizontal > :not(:last-child) .ant-btn-primary {\n border-right: 1px solid white;\n}\n\n.ant-compact-vertical .ant-btn {\n border-radius: 0;\n}\n.ant-compact-vertical > :first-child.ant-btn, .ant-compact-vertical > :first-child .ant-btn {\n border-top-left-radius: var(--ant-button-border-radius);\n border-top-right-radius: var(--ant-button-border-radius);\n}\n.ant-compact-vertical > :last-child.ant-btn, .ant-compact-vertical > :last-child .ant-btn {\n border-bottom-left-radius: var(--ant-button-border-radius);\n border-bottom-right-radius: var(--ant-button-border-radius);\n}\n.ant-compact-vertical > :not(:first-child).ant-btn-primary, .ant-compact-vertical > :not(:first-child) .ant-btn-primary {\n border-top: 1px solid white;\n}\n.ant-compact-vertical > :not(:last-child).ant-btn-primary, .ant-compact-vertical > :not(:last-child) .ant-btn-primary {\n border-bottom: 1px solid white;\n}";
|
|
4
|
+
styleInject(css_248z);
|
|
5
|
+
|
|
6
|
+
export { css_248z as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Component, JSX } from 'solid-js';
|
|
2
|
+
import { type StringOrJSXElement, type Key } from '../types';
|
|
3
|
+
interface CheckboxOption {
|
|
4
|
+
label: StringOrJSXElement;
|
|
5
|
+
value: Key;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface CheckboxGroupProps {
|
|
9
|
+
defaultValue?: Key[];
|
|
10
|
+
value?: Key[];
|
|
11
|
+
onChange?: (values: Key[]) => void;
|
|
12
|
+
options: string[] | number[] | CheckboxOption[];
|
|
13
|
+
block?: boolean;
|
|
14
|
+
class?: string;
|
|
15
|
+
style?: JSX.CSSProperties;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
}
|
|
18
|
+
declare const Group: Component<CheckboxGroupProps>;
|
|
19
|
+
export default Group;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { createComponent, memo } from 'solid-js/web';
|
|
2
|
+
import { For } from 'solid-js';
|
|
3
|
+
import cs from 'classnames';
|
|
4
|
+
import createControllableValue from '../hooks/createControllableValue.js';
|
|
5
|
+
import Checkbox from './index.js';
|
|
6
|
+
import { unwrapStringOrJSXElement } from '../utils/solid.js';
|
|
7
|
+
import Element from '../Element/index.js';
|
|
8
|
+
|
|
9
|
+
const getOptionValue = option => typeof option === 'object' ? option.value : option;
|
|
10
|
+
const Group = props => {
|
|
11
|
+
const [value, setValue] = createControllableValue(props, {
|
|
12
|
+
defaultValue: []
|
|
13
|
+
});
|
|
14
|
+
return createComponent(Element, {
|
|
15
|
+
get ["class"]() {
|
|
16
|
+
return cs(props.block ? 'flex' : 'inline-flex', props.class);
|
|
17
|
+
},
|
|
18
|
+
get style() {
|
|
19
|
+
return props.style;
|
|
20
|
+
},
|
|
21
|
+
get children() {
|
|
22
|
+
return createComponent(For, {
|
|
23
|
+
get each() {
|
|
24
|
+
return props.options;
|
|
25
|
+
},
|
|
26
|
+
children: option => createComponent(Checkbox, {
|
|
27
|
+
get checked() {
|
|
28
|
+
return value().includes(getOptionValue(option));
|
|
29
|
+
},
|
|
30
|
+
onChange: e => {
|
|
31
|
+
if (e.target.checked) {
|
|
32
|
+
setValue(l => [...l, getOptionValue(option)]);
|
|
33
|
+
} else {
|
|
34
|
+
setValue(l => l.filter(v => getOptionValue(v) !== getOptionValue(option)));
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
get disabled() {
|
|
38
|
+
return props.disabled;
|
|
39
|
+
},
|
|
40
|
+
get children() {
|
|
41
|
+
return [memo(() => typeof option === 'object' ? unwrapStringOrJSXElement(option.label) : option), ' '];
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export { Group as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ParentProps, type Component, type JSX } from 'solid-js';
|
|
2
|
+
import Group from './Group';
|
|
3
|
+
export interface CheckboxProps extends ParentProps {
|
|
4
|
+
defaultChecked?: boolean;
|
|
5
|
+
indeterminate?: boolean;
|
|
6
|
+
checked?: boolean;
|
|
7
|
+
onChange?: JSX.ChangeEventHandler<HTMLInputElement, Event>;
|
|
8
|
+
class?: string;
|
|
9
|
+
style?: JSX.CSSProperties;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const Checkbox: Component<CheckboxProps> & {
|
|
13
|
+
Group: typeof Group;
|
|
14
|
+
};
|
|
15
|
+
export default Checkbox;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createComponent, effect, className, insert, template } from 'solid-js/web';
|
|
2
|
+
import { Show } from 'solid-js';
|
|
3
|
+
import cs from 'classnames';
|
|
4
|
+
import createControllableValue from '../hooks/createControllableValue.js';
|
|
5
|
+
import Group from './Group.js';
|
|
6
|
+
import Element from '../Element/index.js';
|
|
7
|
+
|
|
8
|
+
var _tmpl$ = /*#__PURE__*/template(`<span><input class="m-0 hidden"type=checkbox>`),
|
|
9
|
+
_tmpl$2 = /*#__PURE__*/template(`<span>`);
|
|
10
|
+
const Checkbox = props => {
|
|
11
|
+
const [checked, setChecked] = createControllableValue(props, {
|
|
12
|
+
defaultValue: false,
|
|
13
|
+
defaultValuePropName: 'defaultChecked',
|
|
14
|
+
valuePropName: 'checked',
|
|
15
|
+
trigger: false
|
|
16
|
+
});
|
|
17
|
+
return createComponent(Element, {
|
|
18
|
+
tag: "label",
|
|
19
|
+
get ["class"]() {
|
|
20
|
+
return cs('inline-flex cursor-pointer inline-flex items-center [font-size:var(--ant-font-size)] text-[var(--ant-color-text)] leading-[var(--ant-line-height)]', props.class, props.disabled && 'cursor-not-allowed');
|
|
21
|
+
},
|
|
22
|
+
get style() {
|
|
23
|
+
return props.style;
|
|
24
|
+
},
|
|
25
|
+
get children() {
|
|
26
|
+
return [(() => {
|
|
27
|
+
var _el$ = _tmpl$(),
|
|
28
|
+
_el$2 = _el$.firstChild;
|
|
29
|
+
_el$2.addEventListener("change", e => {
|
|
30
|
+
if (props.disabled) return;
|
|
31
|
+
e.target.checked = setChecked(v => !v);
|
|
32
|
+
props.onChange?.(e);
|
|
33
|
+
});
|
|
34
|
+
effect(() => className(_el$, cs('w-16px h-16px rounded-[var(--ant-border-radius-sm)] relative', (() => {
|
|
35
|
+
if (checked()) {
|
|
36
|
+
return ['after:content-empty after:block after:absolute after:top-[calc(50%-1px)] after:left-1/2 after:-translate-1/2 after:-rotate-45 after:w-10px after:h-6px', 'after:border-solid after:border-2px after:border-t-0px after:border-r-0px', props.disabled ? 'bg-[var(--ant-color-bg-container-disabled)] [border:1px_solid_var(--ant-color-border)] after:border-[var(--ant-color-text-disabled)]' : 'bg-[var(--ant-color-primary)] after:border-white'];
|
|
37
|
+
}
|
|
38
|
+
if (props.indeterminate) {
|
|
39
|
+
return ['[border:1px_solid_var(--ant-color-border)]', 'after:content-empty after:block after:absolute after:top-1/2 after:left-1/2 after:-translate-1/2 after:w-8px after:h-8px', props.disabled ? 'after:bg-[var(--ant-color-text-disabled)]' : 'after:bg-[var(--ant-color-primary)]'];
|
|
40
|
+
}
|
|
41
|
+
return ['[border:1px_solid_var(--ant-color-border)]', props.disabled ? 'bg-[var(--ant-color-bg-container-disabled)]' : 'bg-[--ant-color-bg-container]'];
|
|
42
|
+
})())));
|
|
43
|
+
return _el$;
|
|
44
|
+
})(), createComponent(Show, {
|
|
45
|
+
get when() {
|
|
46
|
+
return props.children;
|
|
47
|
+
},
|
|
48
|
+
get children() {
|
|
49
|
+
var _el$3 = _tmpl$2();
|
|
50
|
+
insert(_el$3, () => props.children);
|
|
51
|
+
effect(() => className(_el$3, cs('px-8px', props.disabled && 'text-[var(--ant-color-text-disabled)]')));
|
|
52
|
+
return _el$3;
|
|
53
|
+
}
|
|
54
|
+
})];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
Checkbox.Group = Group;
|
|
59
|
+
|
|
60
|
+
export { Checkbox as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Component } from 'solid-js';
|
|
2
|
+
import { type StyleProps } from '../types';
|
|
3
|
+
export interface CodeInputProps extends StyleProps {
|
|
4
|
+
defaultValue?: string;
|
|
5
|
+
value?: string;
|
|
6
|
+
onChange?: (value: string) => void;
|
|
7
|
+
/**
|
|
8
|
+
* 验证码输入完全触发
|
|
9
|
+
*/
|
|
10
|
+
onComplete?: (value: string) => void;
|
|
11
|
+
/**
|
|
12
|
+
* 验证码长度
|
|
13
|
+
* 默认:6
|
|
14
|
+
*/
|
|
15
|
+
length?: number;
|
|
16
|
+
}
|
|
17
|
+
declare const CodeInput: Component<CodeInputProps>;
|
|
18
|
+
export default CodeInput;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { createComponent } from 'solid-js/web';
|
|
2
|
+
import { mergeProps, createMemo, createEffect, on, For, onCleanup } from 'solid-js';
|
|
3
|
+
import { unset } from 'lodash-es';
|
|
4
|
+
import cs from 'classnames';
|
|
5
|
+
import Element from '../Element/index.js';
|
|
6
|
+
import Input from '../Input/index.js';
|
|
7
|
+
import createControllableValue from '../hooks/createControllableValue.js';
|
|
8
|
+
|
|
9
|
+
const CodeInput = _props => {
|
|
10
|
+
const props = mergeProps({
|
|
11
|
+
length: 6
|
|
12
|
+
}, _props);
|
|
13
|
+
const [_value, setValue] = createControllableValue(props);
|
|
14
|
+
const value = createMemo(() => _value() ?? '');
|
|
15
|
+
createEffect(on(value, () => {
|
|
16
|
+
onFocus();
|
|
17
|
+
}, {
|
|
18
|
+
defer: true
|
|
19
|
+
}));
|
|
20
|
+
const inputRefDict = {};
|
|
21
|
+
const onFocus = () => {
|
|
22
|
+
const index = Math.min(value().length, props.length - 1);
|
|
23
|
+
inputRefDict[index].focus();
|
|
24
|
+
};
|
|
25
|
+
return createComponent(Element, {
|
|
26
|
+
get ["class"]() {
|
|
27
|
+
return cs(props.class, 'flex gap-[--ant-margin-sm] cursor-text');
|
|
28
|
+
},
|
|
29
|
+
get style() {
|
|
30
|
+
return props.style;
|
|
31
|
+
},
|
|
32
|
+
tabIndex: 0,
|
|
33
|
+
onFocus: onFocus,
|
|
34
|
+
onKeyDown: e => {
|
|
35
|
+
if (e.code !== 'Backspace') return;
|
|
36
|
+
setValue(e.metaKey ? '' : value().slice(0, -1));
|
|
37
|
+
},
|
|
38
|
+
get children() {
|
|
39
|
+
return createComponent(For, {
|
|
40
|
+
get each() {
|
|
41
|
+
return Array(props.length).fill(0).map((_, i) => i);
|
|
42
|
+
},
|
|
43
|
+
children: item => {
|
|
44
|
+
onCleanup(() => {
|
|
45
|
+
unset(inputRefDict, item);
|
|
46
|
+
});
|
|
47
|
+
return createComponent(Input, {
|
|
48
|
+
ref: el => {
|
|
49
|
+
inputRefDict[item] = el;
|
|
50
|
+
},
|
|
51
|
+
"class": "!w-32px !text-center",
|
|
52
|
+
get value() {
|
|
53
|
+
return value()[item];
|
|
54
|
+
},
|
|
55
|
+
onChange: e => {
|
|
56
|
+
const v = e.target.value;
|
|
57
|
+
if (!v || value().length >= props.length) return;
|
|
58
|
+
const newValue = `${value()}${v}`.replace(/\D/g, '');
|
|
59
|
+
if (newValue.length === props.length) {
|
|
60
|
+
props.onComplete?.(newValue);
|
|
61
|
+
}
|
|
62
|
+
setValue(newValue.slice(0, props.length));
|
|
63
|
+
},
|
|
64
|
+
onFocus: onFocus
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export { CodeInput as default };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type Accessor, type Component, type JSX, type ParentProps } from 'solid-js';
|
|
2
|
+
import { type StyleProps, type StringOrJSXElement } from '../types';
|
|
3
|
+
export interface CollapseItemProps extends ParentProps, StyleProps {
|
|
4
|
+
defaultOpen?: boolean;
|
|
5
|
+
open?: boolean;
|
|
6
|
+
onOpenChange?: (open: boolean) => void;
|
|
7
|
+
label: StringOrJSXElement;
|
|
8
|
+
/**
|
|
9
|
+
* 类型
|
|
10
|
+
* 默认 'line'
|
|
11
|
+
*/
|
|
12
|
+
type?: 'line' | 'card';
|
|
13
|
+
bordered?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* 设置折叠面板大小
|
|
16
|
+
* 默认 'middle'
|
|
17
|
+
*/
|
|
18
|
+
size?: 'small' | 'middle' | 'large';
|
|
19
|
+
/**
|
|
20
|
+
* 自定义渲染每个面板右上角的内容
|
|
21
|
+
*/
|
|
22
|
+
extra?: StringOrJSXElement;
|
|
23
|
+
/**
|
|
24
|
+
* 是否禁用 children
|
|
25
|
+
*/
|
|
26
|
+
disabledChildren?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 自定义切换图标
|
|
29
|
+
* 为 false 代表不显示图标
|
|
30
|
+
*/
|
|
31
|
+
expandIcon?: boolean | ((options: {
|
|
32
|
+
isActive: Accessor<boolean>;
|
|
33
|
+
}) => JSX.Element);
|
|
34
|
+
/**
|
|
35
|
+
* 设置图标位置
|
|
36
|
+
* 默认 'left'
|
|
37
|
+
*/
|
|
38
|
+
expandIconPosition?: 'left' | 'right' | 'end';
|
|
39
|
+
/**
|
|
40
|
+
* collapse header style
|
|
41
|
+
*/
|
|
42
|
+
headerStyle?: JSX.CSSProperties;
|
|
43
|
+
bodyStyle?: JSX.CSSProperties;
|
|
44
|
+
}
|
|
45
|
+
declare const CollapseItem: Component<CollapseItemProps>;
|
|
46
|
+
export default CollapseItem;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { delegateEvents, createComponent, Dynamic, insert, effect, className, style, template, memo } from 'solid-js/web';
|
|
2
|
+
import { mergeProps, useContext, Show } from 'solid-js';
|
|
3
|
+
import cs from 'classnames';
|
|
4
|
+
import { Transition } from 'solid-transition-group';
|
|
5
|
+
import { unwrapStringOrJSXElement } from '../utils/solid.js';
|
|
6
|
+
import createControllableValue from '../hooks/createControllableValue.js';
|
|
7
|
+
import Element from '../Element/index.js';
|
|
8
|
+
import CollapseContext from './context.js';
|
|
9
|
+
import useComponentSize from '../hooks/useComponentSize.js';
|
|
10
|
+
import { getElementClass, getElementCssVariables } from './utils.js';
|
|
11
|
+
|
|
12
|
+
var _tmpl$ = /*#__PURE__*/template(`<span>`),
|
|
13
|
+
_tmpl$2 = /*#__PURE__*/template(`<div><span class="inline-flex items-center gap-[--ant-margin-sm]"></span><span class="inline-flex items-center gap-[--ant-margin-sm]">`),
|
|
14
|
+
_tmpl$3 = /*#__PURE__*/template(`<div class=overflow-hidden><div>`);
|
|
15
|
+
const CollapseItem = _props => {
|
|
16
|
+
const props = mergeProps({
|
|
17
|
+
type: 'line',
|
|
18
|
+
bordered: true,
|
|
19
|
+
expandIconPosition: 'left'
|
|
20
|
+
}, _props);
|
|
21
|
+
const {
|
|
22
|
+
list
|
|
23
|
+
} = useContext(CollapseContext);
|
|
24
|
+
const size = useComponentSize(() => props.size);
|
|
25
|
+
const [open, setOpen] = createControllableValue(props, {
|
|
26
|
+
defaultValuePropName: 'defaultOpen',
|
|
27
|
+
valuePropName: 'open',
|
|
28
|
+
trigger: 'onOpenChange'
|
|
29
|
+
});
|
|
30
|
+
const getExpandIcon = position => {
|
|
31
|
+
return createComponent(Show, {
|
|
32
|
+
get when() {
|
|
33
|
+
return !props.disabledChildren && props.expandIcon !== false && props.expandIconPosition === position;
|
|
34
|
+
},
|
|
35
|
+
get children() {
|
|
36
|
+
return memo(() => typeof props.expandIcon === 'function')() ? props.expandIcon({
|
|
37
|
+
isActive: () => !!open()
|
|
38
|
+
}) : (() => {
|
|
39
|
+
var _el$ = _tmpl$();
|
|
40
|
+
effect(() => className(_el$, cs('i-ant-design:right-outlined', 'duration-.3s', open() && 'rotate-[90deg]')));
|
|
41
|
+
return _el$;
|
|
42
|
+
})();
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
return createComponent(Dynamic, {
|
|
47
|
+
component: list ? 'div' : Element,
|
|
48
|
+
get ["class"]() {
|
|
49
|
+
return list ? props.class : cs(getElementClass(props.type), props.class);
|
|
50
|
+
},
|
|
51
|
+
get style() {
|
|
52
|
+
return {
|
|
53
|
+
...(list ? {} : getElementCssVariables(props.type, size())),
|
|
54
|
+
...props.style
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
get children() {
|
|
58
|
+
return [(() => {
|
|
59
|
+
var _el$2 = _tmpl$2(),
|
|
60
|
+
_el$3 = _el$2.firstChild,
|
|
61
|
+
_el$4 = _el$3.nextSibling;
|
|
62
|
+
_el$2.$$click = () => {
|
|
63
|
+
if (props.disabledChildren) return;
|
|
64
|
+
setOpen(!open());
|
|
65
|
+
};
|
|
66
|
+
insert(_el$3, () => getExpandIcon('left'), null);
|
|
67
|
+
insert(_el$3, () => unwrapStringOrJSXElement(props.label), null);
|
|
68
|
+
insert(_el$3, () => getExpandIcon('right'), null);
|
|
69
|
+
insert(_el$4, () => unwrapStringOrJSXElement(props.extra), null);
|
|
70
|
+
insert(_el$4, () => getExpandIcon('end'), null);
|
|
71
|
+
effect(_p$ => {
|
|
72
|
+
var _v$ = cs('text-[--ant-color-text-heading] flex justify-between items-center cursor-pointer', props.type === 'card' && 'bg-[var(--ant-collapse-header-bg)] p-[--ant-collapse-header-padding]'),
|
|
73
|
+
_v$2 = props.headerStyle;
|
|
74
|
+
_v$ !== _p$.e && className(_el$2, _p$.e = _v$);
|
|
75
|
+
_p$.t = style(_el$2, _v$2, _p$.t);
|
|
76
|
+
return _p$;
|
|
77
|
+
}, {
|
|
78
|
+
e: undefined,
|
|
79
|
+
t: undefined
|
|
80
|
+
});
|
|
81
|
+
return _el$2;
|
|
82
|
+
})(), createComponent(Transition, {
|
|
83
|
+
onEnter: (el, done) => {
|
|
84
|
+
el.animate([{
|
|
85
|
+
height: '0px'
|
|
86
|
+
}, {
|
|
87
|
+
height: `${el.scrollHeight}px`
|
|
88
|
+
}], {
|
|
89
|
+
duration: 300
|
|
90
|
+
}).finished.finally(done);
|
|
91
|
+
},
|
|
92
|
+
onExit: (el, done) => {
|
|
93
|
+
el.animate([{
|
|
94
|
+
height: `${el.scrollHeight}px`
|
|
95
|
+
}, {
|
|
96
|
+
height: '0px'
|
|
97
|
+
}], {
|
|
98
|
+
duration: 300
|
|
99
|
+
}).finished.finally(done);
|
|
100
|
+
},
|
|
101
|
+
get children() {
|
|
102
|
+
return createComponent(Show, {
|
|
103
|
+
get when() {
|
|
104
|
+
return open();
|
|
105
|
+
},
|
|
106
|
+
get children() {
|
|
107
|
+
var _el$5 = _tmpl$3(),
|
|
108
|
+
_el$6 = _el$5.firstChild;
|
|
109
|
+
insert(_el$6, () => props.children);
|
|
110
|
+
effect(_p$ => {
|
|
111
|
+
var _v$3 = cs('p-[--ant-collapse-content-padding]', props.type === 'card' && '[border-top:1px_solid_var(--ant-color-border)]'),
|
|
112
|
+
_v$4 = props.bodyStyle;
|
|
113
|
+
_v$3 !== _p$.e && className(_el$6, _p$.e = _v$3);
|
|
114
|
+
_p$.t = style(_el$6, _v$4, _p$.t);
|
|
115
|
+
return _p$;
|
|
116
|
+
}, {
|
|
117
|
+
e: undefined,
|
|
118
|
+
t: undefined
|
|
119
|
+
});
|
|
120
|
+
return _el$5;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
})];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
delegateEvents(["click"]);
|
|
129
|
+
|
|
130
|
+
export { CollapseItem as default };
|