antd-solid 0.0.3 → 0.0.5

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.
Files changed (125) hide show
  1. package/dist/index.css +69 -0
  2. package/dist/index.esm.js +2369 -0
  3. package/dist/index.umd.js +1 -0
  4. package/package.json +5 -3
  5. package/.eslintignore +0 -2
  6. package/.eslintrc.cjs +0 -36
  7. package/.husky/pre-commit +0 -4
  8. package/.prettierrc +0 -11
  9. package/.vscode/settings.json +0 -13
  10. package/docs/.vitepress/components/Code.vue +0 -175
  11. package/docs/.vitepress/config.ts +0 -87
  12. package/docs/.vitepress/theme/index.css +0 -19
  13. package/docs/.vitepress/theme/index.ts +0 -12
  14. package/docs/components/button/Base.tsx +0 -21
  15. package/docs/components/button/Danger.tsx +0 -21
  16. package/docs/components/button.md +0 -35
  17. package/docs/components/collapse/Base.tsx +0 -25
  18. package/docs/components/collapse.md +0 -26
  19. package/docs/components/color-picker/Base.tsx +0 -14
  20. package/docs/components/color-picker.md +0 -26
  21. package/docs/components/compact/Base.tsx +0 -27
  22. package/docs/components/compact.md +0 -26
  23. package/docs/components/date-picker/Base.tsx +0 -15
  24. package/docs/components/date-picker.md +0 -26
  25. package/docs/components/empty/Base.tsx +0 -8
  26. package/docs/components/empty/PRESENTED_IMAGE_SIMPLE.tsx +0 -8
  27. package/docs/components/empty.md +0 -32
  28. package/docs/components/form/Base.tsx +0 -63
  29. package/docs/components/form.md +0 -27
  30. package/docs/components/image/Base.tsx +0 -13
  31. package/docs/components/image.md +0 -26
  32. package/docs/components/input/AddonBeforeAndAfter.tsx +0 -14
  33. package/docs/components/input/Base.tsx +0 -15
  34. package/docs/components/input/Disabled.tsx +0 -19
  35. package/docs/components/input/PrefixAndSuffix.tsx +0 -14
  36. package/docs/components/input/Status.tsx +0 -25
  37. package/docs/components/input/TextArea.tsx +0 -14
  38. package/docs/components/input-number/Base.tsx +0 -15
  39. package/docs/components/input-number/MinMax.tsx +0 -17
  40. package/docs/components/input-number.md +0 -34
  41. package/docs/components/input.md +0 -57
  42. package/docs/components/modal/Base.tsx +0 -35
  43. package/docs/components/modal.md +0 -26
  44. package/docs/components/popconfirm/Base.tsx +0 -25
  45. package/docs/components/popconfirm.md +0 -26
  46. package/docs/components/popover/Base.tsx +0 -19
  47. package/docs/components/popover.md +0 -26
  48. package/docs/components/progress/Base.tsx +0 -16
  49. package/docs/components/progress.md +0 -26
  50. package/docs/components/radio/Base.tsx +0 -10
  51. package/docs/components/radio.md +0 -26
  52. package/docs/components/segmented/Base.tsx +0 -10
  53. package/docs/components/segmented/Block.tsx +0 -10
  54. package/docs/components/segmented/Disabled.tsx +0 -28
  55. package/docs/components/segmented.md +0 -38
  56. package/docs/components/select/AllowClear.tsx +0 -18
  57. package/docs/components/select/Base.tsx +0 -17
  58. package/docs/components/select.md +0 -35
  59. package/docs/components/switch/Base.tsx +0 -14
  60. package/docs/components/switch.md +0 -26
  61. package/docs/components/table/Base.tsx +0 -34
  62. package/docs/components/table.md +0 -29
  63. package/docs/components/tabs/Base.tsx +0 -25
  64. package/docs/components/tabs/Segment.tsx +0 -25
  65. package/docs/components/tabs.md +0 -33
  66. package/docs/components/tooltip/Base.tsx +0 -12
  67. package/docs/components/tooltip/Placement.tsx +0 -90
  68. package/docs/components/tooltip.md +0 -32
  69. package/docs/components/tree/Base.tsx +0 -45
  70. package/docs/components/tree.md +0 -26
  71. package/docs/index.md +0 -28
  72. package/global.d.ts +0 -9
  73. package/patches/vitepress@1.0.0-rc.4.patch +0 -60
  74. package/rollup.config.js +0 -65
  75. package/scripts/annotationNonProductionCode.js +0 -30
  76. package/scripts/cancelAnnotationNonProductionCode.js +0 -30
  77. package/src/Button.tsx +0 -125
  78. package/src/Collapse/index.tsx +0 -86
  79. package/src/ColorPicker.tsx +0 -11
  80. package/src/Compact.tsx +0 -15
  81. package/src/DatePicker.tsx +0 -12
  82. package/src/Empty/PRESENTED_IMAGE_SIMPLE.tsx +0 -15
  83. package/src/Empty/assets/EmptySvg.tsx +0 -43
  84. package/src/Empty/assets/SimpleEmptySvg.tsx +0 -16
  85. package/src/Empty/index.tsx +0 -20
  86. package/src/Image.tsx +0 -29
  87. package/src/Input.tsx +0 -202
  88. package/src/InputNumber.test.tsx +0 -46
  89. package/src/InputNumber.tsx +0 -125
  90. package/src/Modal.tsx +0 -196
  91. package/src/Popconfirm.tsx +0 -75
  92. package/src/Popover.tsx +0 -30
  93. package/src/Progress.tsx +0 -4
  94. package/src/Radio.tsx +0 -132
  95. package/src/Result.tsx +0 -38
  96. package/src/Segmented/index.tsx +0 -95
  97. package/src/Select.tsx +0 -128
  98. package/src/Skeleton.tsx +0 -14
  99. package/src/Spin.tsx +0 -23
  100. package/src/Switch.tsx +0 -34
  101. package/src/Table.tsx +0 -53
  102. package/src/Tabs.tsx +0 -131
  103. package/src/Timeline.tsx +0 -33
  104. package/src/Tooltip.tsx +0 -355
  105. package/src/Tree.tsx +0 -246
  106. package/src/Upload.tsx +0 -10
  107. package/src/form/Form.tsx +0 -94
  108. package/src/form/FormItem.tsx +0 -139
  109. package/src/form/context.ts +0 -16
  110. package/src/form/index.ts +0 -13
  111. package/src/hooks/createControllableValue.ts +0 -68
  112. package/src/hooks/createUpdateEffect.ts +0 -16
  113. package/src/hooks/index.ts +0 -2
  114. package/src/hooks/useClickAway.ts +0 -18
  115. package/src/hooks/useSize.ts +0 -26
  116. package/src/types/index.ts +0 -5
  117. package/src/utils/EventEmitter.ts +0 -15
  118. package/src/utils/ReactToSolid.tsx +0 -38
  119. package/src/utils/SolidToReact.tsx +0 -27
  120. package/src/utils/array.ts +0 -21
  121. package/src/utils/component.tsx +0 -85
  122. package/src/utils/solid.ts +0 -53
  123. package/src/utils/zh_CN.ts +0 -236
  124. package/tsconfig.json +0 -25
  125. package/unocss.config.ts +0 -176
package/src/Progress.tsx DELETED
@@ -1,4 +0,0 @@
1
- import { Progress as ProgressAntd } from 'antd'
2
- import { reactToSolidComponent, replaceChildren, replaceClassName } from './utils/component'
3
-
4
- export default replaceChildren(replaceClassName(reactToSolidComponent(ProgressAntd)))
package/src/Radio.tsx DELETED
@@ -1,132 +0,0 @@
1
- import {
2
- type Component,
3
- type JSXElement,
4
- type ParentProps,
5
- type JSX,
6
- untrack,
7
- For,
8
- createSelector,
9
- mergeProps,
10
- } from 'solid-js'
11
- import { Dynamic } from 'solid-js/web'
12
- import cs from 'classnames'
13
- import createControllableValue from './hooks/createControllableValue'
14
-
15
- export interface RadioProps extends ParentProps {
16
- defaultChecked?: boolean
17
- checked?: boolean
18
- /**
19
- * input 的 value
20
- */
21
- value?: string
22
- onChange?: JSX.ChangeEventHandler<HTMLInputElement, Event>
23
- }
24
-
25
- export interface RadioGroupProps {
26
- defaultValue?: string
27
- value?: string
28
- onChange?: JSX.ChangeEventHandler<HTMLInputElement, Event>
29
- optionType?: 'default' | 'button'
30
- options: Array<{ label: JSXElement; value: string; disabled?: boolean }>
31
- block?: boolean
32
- }
33
-
34
- const Radio: Component<RadioProps> & {
35
- Group: Component<RadioGroupProps>
36
- Button: Component<RadioProps>
37
- } = props => {
38
- const [checked, setChecked] = createControllableValue(props, {
39
- defaultValue: false,
40
- defaultValuePropName: 'defaultChecked',
41
- valuePropName: 'checked',
42
- trigger: undefined,
43
- })
44
-
45
- return (
46
- <label class="ant-inline-flex ant-gap-4px">
47
- <input
48
- checked={checked()}
49
- value={props.value ?? ''}
50
- type="radio"
51
- onInput={e => {
52
- setChecked(e.target.checked)
53
- untrack(() => props.onChange?.(e))
54
- }}
55
- />
56
- {props.children}
57
- </label>
58
- )
59
- }
60
-
61
- Radio.Button = props => {
62
- const [checked, setChecked] = createControllableValue(props, {
63
- defaultValue: false,
64
- defaultValuePropName: 'defaultChecked',
65
- valuePropName: 'checked',
66
- trigger: undefined,
67
- })
68
-
69
- return (
70
- <label
71
- class={cs(
72
- 'ant-px-15px ant-[border:1px_solid_rgb(217,217,217)] first:ant-rounded-l-6px last:ant-rounded-r-6px ant-h-32px ant-inline-flex ant-items-center hover:ant-text-[var(--primary-color)] not[:last-child]:ant-border-r-transparent ant-cursor-pointer ant-flex-grow ant-justify-center',
73
- checked() &&
74
- 'ant-text-[var(--primary-color)] ant-[border:1px_solid_var(--primary-color)] !ant-border-r-[var(--primary-color)]',
75
- )}
76
- >
77
- <input
78
- class="ant-w-0 ant-h-0"
79
- checked={checked()}
80
- value={props.value ?? ''}
81
- type="radio"
82
- onInput={e => {
83
- setChecked(e.target.checked)
84
- untrack(() => props.onChange?.(e))
85
- }}
86
- />
87
- {props.children}
88
- </label>
89
- )
90
- }
91
-
92
- Radio.Group = _props => {
93
- const props = mergeProps(
94
- {
95
- optionType: 'default',
96
- } as RadioGroupProps,
97
- _props,
98
- )
99
- const [value, setValue] = createControllableValue<string>(props, {
100
- trigger: undefined,
101
- })
102
- const isChecked = createSelector(value)
103
-
104
- return (
105
- <div
106
- class={cs(
107
- props.block ? 'ant-flex' : 'ant-inline-flex',
108
- props.optionType === 'default' ? 'ant-gap-8px' : '',
109
- )}
110
- >
111
- <For each={props.options}>
112
- {option => (
113
- <Dynamic
114
- component={props.optionType === 'default' ? Radio : Radio.Button}
115
- checked={isChecked(option.value)}
116
- value={option.value}
117
- onChange={
118
- (e => {
119
- setValue(option.value)
120
- untrack(() => props.onChange?.(e))
121
- }) as JSX.ChangeEventHandler<HTMLInputElement, Event>
122
- }
123
- >
124
- {option.label}
125
- </Dynamic>
126
- )}
127
- </For>
128
- </div>
129
- )
130
- }
131
-
132
- export default Radio
package/src/Result.tsx DELETED
@@ -1,38 +0,0 @@
1
- import { type JSXElement, type Component, type ParentProps } from 'solid-js'
2
- import cs from 'classnames'
3
-
4
- type ResultStatusType = 'success' | 'error' | 'info' | 'warning'
5
-
6
- export interface ResultProps extends ParentProps {
7
- status?: ResultStatusType
8
- title?: JSXElement
9
- subTitle?: JSXElement
10
- extra?: JSXElement
11
- }
12
-
13
- const statusIconMap = {
14
- success: 'ant-text-#52c41a i-ant-design:check-circle-filled',
15
- info: 'ant-text-[var(--primary-color)] i-ant-design:exclamation-circle-filled',
16
- warning: 'ant-text-#faad14 i-ant-design:warning-filled',
17
- error: 'ant-text-#ff4d4f i-ant-design:close-circle-filled',
18
- }
19
-
20
- const Result: Component<ResultProps> = props => {
21
- return (
22
- <div class="ant-text-center ant-px-32px ant-py-48px">
23
- <div class="ant-mb-24px">
24
- <span class={cs(statusIconMap[props.status!], 'ant-text-72px')} />
25
- </div>
26
-
27
- <div class="ant-my-8px ant-text-[rgba(0,0,0,.88)] ant-text-24px">{props.title}</div>
28
-
29
- <div class="ant-text-[rgba(0,0,0,.45)] ant-text-14px">{props.subTitle}</div>
30
-
31
- <div class="ant-mt-24px">{props.extra}</div>
32
-
33
- <div class="ant-mt-24px">{props.children}</div>
34
- </div>
35
- )
36
- }
37
-
38
- export default Result
@@ -1,95 +0,0 @@
1
- import { type Component, For, createSelector, type JSX, Show } from 'solid-js'
2
- import cs from 'classnames'
3
- import { type StringOrJSXElement, type Key } from '../types'
4
- import createControllableValue from '../hooks/createControllableValue'
5
- import { unwrapStringOrJSXElement } from '../utils/solid'
6
-
7
- export interface SegmentedProps {
8
- block?: boolean
9
- disabled?: boolean
10
- options: Array<
11
- | string
12
- | number
13
- | {
14
- label: StringOrJSXElement
15
- value: string
16
- disabled?: boolean
17
- onClick?: (
18
- e: MouseEvent & {
19
- currentTarget: HTMLDivElement
20
- target: Element
21
- },
22
- ) => void
23
- }
24
- >
25
- value?: Key
26
- onChange?: (value: Key) => void
27
- class?: string
28
- style?: JSX.CSSProperties
29
- }
30
-
31
- const unWarpValue = (value: SegmentedProps['options'][0]) =>
32
- typeof value === 'object' ? value.value : value
33
-
34
- const Segmented: Component<SegmentedProps> = props => {
35
- const [value, setValue] = createControllableValue<Key>(props, {
36
- defaultValue: unWarpValue(props.options[0]),
37
- })
38
- const isSelected = createSelector(value)
39
-
40
- const isDisabledValue = (v: SegmentedProps['options'][0]) => {
41
- if (props.disabled) return true
42
- return typeof v === 'object' ? v.disabled : false
43
- }
44
-
45
- return (
46
- <div
47
- class={cs(
48
- 'ant-bg-[var(--ant-color-bg-layout)] ant-rounded-[var(--ant-border-radius)] ant-p-2px',
49
- props.block ? 'ant-flex' : 'ant-inline-flex',
50
- props.class,
51
- )}
52
- style={{
53
- '--ant-segmented-item-color': 'rgba(0, 0, 0, 0.65)',
54
- '--ant-segmented-item-hover-bg': 'rgba(0, 0, 0, 0.06)',
55
- '--ant-segmented-item-active-bg': 'rgba(0, 0, 0, 0.15)',
56
- ...props.style,
57
- }}
58
- >
59
- <For each={props.options}>
60
- {item => (
61
- <div
62
- class={cs(
63
- props.block && 'ant-basis-0 ant-grow-1',
64
- isDisabledValue(item) && 'ant-cursor-not-allowed',
65
- )}
66
- >
67
- <div
68
- class={cs(
69
- 'ant-rounded-[var(--ant-border-radius-sm)] ant-px-[var(--ant-padding-sm)] where:ant-cursor-pointer ant-leading-28px where:hover:ant-bg-[var(--ant-segmented-item-hover-bg)] where:active:ant-bg-[var(--ant-segmented-item-active-bg)]',
70
- isSelected(unWarpValue(item)) &&
71
- 'ant-bg-white ant-shadow-[var(--ant-box-shadow-tertiary)]',
72
- props.block && 'ant-flex ant-justify-center',
73
- isDisabledValue(item) &&
74
- 'ant-[pointer-events:none] ant-text-[var(--ant-color-text-disabled)]',
75
- )}
76
- onClick={e => {
77
- setValue(unWarpValue(item))
78
- typeof item === 'object' && item.onClick?.(e)
79
- }}
80
- >
81
- <Show
82
- when={typeof item !== 'object'}
83
- fallback={typeof item === 'object' && unwrapStringOrJSXElement(item.label)}
84
- >
85
- {item as string | number}
86
- </Show>
87
- </div>
88
- </div>
89
- )}
90
- </For>
91
- </div>
92
- )
93
- }
94
-
95
- export default Segmented
package/src/Select.tsx DELETED
@@ -1,128 +0,0 @@
1
- import {
2
- type JSXElement,
3
- type Component,
4
- For,
5
- createSelector,
6
- createSignal,
7
- Show,
8
- createMemo,
9
- } from 'solid-js'
10
- import Tooltip from './Tooltip'
11
- import { type Key } from './types'
12
- import createControllableValue from './hooks/createControllableValue'
13
- import cs from 'classnames'
14
- import { useClickAway } from './hooks'
15
- import { isNil } from 'lodash-es'
16
-
17
- interface SelectOption {
18
- label: JSXElement
19
- value: Key
20
- }
21
-
22
- interface SelectProps {
23
- value?: Key
24
- onChange?: (value: Key) => void
25
- options: SelectOption[]
26
- placeholder?: string
27
- allowClear?: boolean
28
- class?: string
29
- }
30
-
31
- const Select: Component<SelectProps> = props => {
32
- let select: HTMLDivElement
33
-
34
- const [value, setValue] = createControllableValue<Key | undefined>(props)
35
- const selectedValue = createSelector(value)
36
- const selectedOption = createMemo(() => !isNil(value()) ? props.options.find(option => option.value === value()) : undefined)
37
-
38
- const [open, setOpen] = createSignal(false)
39
- useClickAway(
40
- () => setOpen(false),
41
- () => select!,
42
- )
43
-
44
- const [width, setWidth] = createSignal(0)
45
- const [hover, setHover] = createSignal(false)
46
- const showClearBtn = createMemo(() => props.allowClear && hover() && !isNil(value()))
47
-
48
- return (
49
- <Tooltip
50
- mode="light"
51
- open={open()}
52
- onOpenChange={setOpen}
53
- trigger={[]}
54
- placement="bottomLeft"
55
- arrow={false}
56
- contentStyle={{
57
- padding: 0,
58
- }}
59
- content={close => (
60
- <div class="ant-bg-white ant-w-200px" style={{ width: `${width()}px` }}>
61
- <For each={props.options}>
62
- {item => (
63
- <div
64
- class={cs(
65
- 'ant-box-content ant-px-12px ant-py-5px ant-h-22px ant-leading-22px hover:ant-bg-[var(--hover-bg-color)]',
66
- selectedValue(item.value) ? '!ant-bg-[var(--active-bg-color)]' : '',
67
- )}
68
- onClick={() => {
69
- setValue(item.value)
70
- close()
71
- }}
72
- >
73
- {item.label}
74
- </div>
75
- )}
76
- </For>
77
- </div>
78
- )}
79
- >
80
- <div
81
- ref={select!}
82
- class={cs('ant-h-32px ant-leading-32px ant-rounded-6px ant-[border:1px_solid_var(--ant-color-border)] ant-px-11px focus:ant-[border-color:var(--primary-color)]', props.class)}
83
- tabIndex="0"
84
- onClick={e => {
85
- setOpen(true)
86
- setWidth(e.currentTarget.offsetWidth)
87
- e.currentTarget.focus()
88
- }}
89
- onMouseEnter={() => setHover(true)}
90
- onMouseLeave={() => setHover(false)}
91
- style={{
92
- '--ant-arrow-color': 'rgba(146, 146, 146, 1)',
93
- '--ant-clear-color': 'rgba(146, 146, 146, 1)',
94
- '--ant-clear-color-hover': 'rgba(194, 194, 194, 1)',
95
- }}
96
- >
97
- <div class="ant-relative ant-h-full">
98
- <Show
99
- when={!isNil(value())}
100
- fallback={
101
- <input
102
- class="ant-h-full ant-w-full ant-float-left ant-[outline:none]"
103
- readOnly
104
- placeholder={props.placeholder}
105
- />
106
- }
107
- >
108
- <div>{selectedOption()!.label ?? value()}</div>
109
- </Show>
110
-
111
- <div class="ant-absolute ant-top-0 ant-bottom-0 ant-right-0">
112
- <Show when={showClearBtn()} fallback={<span class="i-ant-design:down-outlined ant-text-[var(--ant-allow-color)]" />}>
113
- <span
114
- class="i-ant-design:close-circle-filled ant-cursor-pointer ant-text-[var(--ant-clear-color)] hover:ant-text-[var(--ant-clear-color-hover)]"
115
- onClick={e => {
116
- e.stopPropagation()
117
- setValue(undefined)
118
- }}
119
- />
120
- </Show>
121
- </div>
122
- </div>
123
- </div>
124
- </Tooltip>
125
- )
126
- }
127
-
128
- export default Select
package/src/Skeleton.tsx DELETED
@@ -1,14 +0,0 @@
1
- import { Skeleton as SkeletonAntd } from 'antd'
2
- import { reactToSolidComponent, replaceClassName } from './utils/component'
3
-
4
- const _Skeleton = replaceClassName(reactToSolidComponent(SkeletonAntd))
5
-
6
- const Image = replaceClassName(reactToSolidComponent(SkeletonAntd.Image))
7
-
8
- const Skeleton = _Skeleton as typeof _Skeleton & {
9
- Image: typeof Image
10
- }
11
-
12
- Skeleton.Image = Image
13
-
14
- export default Skeleton
package/src/Spin.tsx DELETED
@@ -1,23 +0,0 @@
1
- import { Show, type Component, type ParentProps } from 'solid-js'
2
-
3
- interface SpinProps extends ParentProps {
4
- /**
5
- * 是否为加载中状态
6
- */
7
- spinning?: boolean
8
- }
9
-
10
- const Spin: Component<SpinProps> = props => {
11
- return (
12
- <div class="ant-relative ant-min-h-32px">
13
- {props.children}
14
- <Show when={props.spinning}>
15
- <div class="ant-absolute ant-inset-0 ant-flex ant-items-center ant-justify-center ant-bg-[rgba(255,255,255,.5)]">
16
- <span class="i-ant-design:loading keyframes-spin ant-[animation:spin_1s_linear_infinite] ant-text-32px ant-text-[var(--primary-color)]" />
17
- </div>
18
- </Show>
19
- </div>
20
- )
21
- }
22
-
23
- export default Spin
package/src/Switch.tsx DELETED
@@ -1,34 +0,0 @@
1
- import { type Component } from 'solid-js'
2
- import createControllableValue from './hooks/createControllableValue'
3
- import cs from 'classnames'
4
-
5
- export interface SwitchProps {
6
- defaultChecked?: boolean
7
- checked?: boolean
8
- onChange?: (checked: boolean) => void
9
- }
10
-
11
- const Switch: Component<SwitchProps> = props => {
12
- const [checked, setChecked] = createControllableValue<boolean>(props, {
13
- defaultValuePropName: 'defaultChecked',
14
- valuePropName: 'checked',
15
- })
16
- return (
17
- <button
18
- class={cs(
19
- 'ant-w-44px ant-h-22px ant-rounded-100px ant-relative',
20
- checked() ? 'ant-bg-[var(--primary-color)]' : 'ant-bg-[rgba(0,0,0,0.45)]',
21
- )}
22
- onClick={() => setChecked(c => !c)}
23
- >
24
- <div
25
- class={cs(
26
- 'ant-w-18px ant-h-18px ant-rounded-50% ant-bg-white ant-absolute ant-top-1/2 -ant-translate-y-1/2 ant-transition-left',
27
- checked() ? 'ant-left-[calc(100%-20px)]' : 'ant-left-2px',
28
- )}
29
- />
30
- </button>
31
- )
32
- }
33
-
34
- export default Switch
package/src/Table.tsx DELETED
@@ -1,53 +0,0 @@
1
- import Empty from './Empty'
2
- import { type JSXElement, For, Show } from 'solid-js'
3
-
4
- export interface TableColumn<R extends {}> {
5
- title: JSXElement
6
- render: (row: R) => JSXElement
7
- }
8
-
9
- export interface TableProps<R extends {}> {
10
- columns: Array<TableColumn<R>>
11
- dataSource: R[]
12
- }
13
-
14
- const Table = <R extends {}>(props: TableProps<R>) => {
15
- return (
16
- <div>
17
- <table class="ant-w-full">
18
- <thead>
19
- <tr>
20
- <For each={props.columns}>
21
- {item => (
22
- <th class="ant-p-16px ant-bg-[var(--light-bg-color)] ant-font-bold ant-[border-bottom:1px_solid_var(--secondary-border-color)] ant-text-left">
23
- {item.title}
24
- </th>
25
- )}
26
- </For>
27
- </tr>
28
- </thead>
29
- <tbody>
30
- <For each={props.dataSource}>
31
- {row => (
32
- <tr class="hover:ant-bg-[var(--light-bg-color)]">
33
- <For each={props.columns}>
34
- {item => (
35
- <td class="ant-p-16px ant-[border-bottom:1px_solid_var(--secondary-border-color)]">
36
- {item.render(row)}
37
- </td>
38
- )}
39
- </For>
40
- </tr>
41
- )}
42
- </For>
43
- </tbody>
44
- </table>
45
-
46
- <Show when={!props.dataSource.length}>
47
- <Empty.PRESENTED_IMAGE_SIMPLE />
48
- </Show>
49
- </div>
50
- )
51
- }
52
-
53
- export default Table
package/src/Tabs.tsx DELETED
@@ -1,131 +0,0 @@
1
- import {
2
- type Component,
3
- For,
4
- createSelector,
5
- createSignal,
6
- onMount,
7
- untrack,
8
- type JSX,
9
- onCleanup,
10
- mergeProps,
11
- Switch,
12
- Match,
13
- } from 'solid-js'
14
- import cs from 'classnames'
15
- import Segmented from './Segmented'
16
- import { type StringOrJSXElement } from './types'
17
- import { unwrapStringOrJSXElement } from './utils/solid'
18
-
19
- export interface Tab {
20
- key: string
21
- label: StringOrJSXElement
22
- children?: StringOrJSXElement
23
- }
24
-
25
- export interface TabsProps {
26
- type?: 'line' | 'segment'
27
- class?: string
28
- navClass?: string
29
- navItemClass?: string
30
- contentClass?: string
31
- items: Tab[]
32
- }
33
-
34
- const Tabs: Component<TabsProps> = _props => {
35
- const props = mergeProps(
36
- {
37
- type: 'line',
38
- } as TabsProps,
39
- _props,
40
- )
41
-
42
- const [selectedItem, setSelectedItem] = createSignal<Tab | undefined>(
43
- untrack(() => props.items[0]),
44
- )
45
- const isSelectedItem = createSelector(() => selectedItem()?.key)
46
- const [selectedBarStyle, setSelectedBarStyle] = createSignal<JSX.CSSProperties>({
47
- left: '0px',
48
- width: '0px',
49
- })
50
-
51
- let nav: HTMLDivElement | undefined
52
- const updateSelectedBarStyle = () => {
53
- if (!nav) return
54
-
55
- const el = nav.querySelector<HTMLElement>(':scope > .selected')
56
- if (!el) return
57
-
58
- setSelectedBarStyle({
59
- left: `${el.offsetLeft}px`,
60
- width: `${el.clientWidth}px`,
61
- })
62
- }
63
- onMount(() => {
64
- if (!nav) return
65
-
66
- updateSelectedBarStyle()
67
-
68
- const resizeObserver = new ResizeObserver(() => {
69
- updateSelectedBarStyle()
70
- })
71
-
72
- resizeObserver.observe(nav)
73
- onCleanup(() => {
74
- resizeObserver.disconnect()
75
- })
76
- })
77
-
78
- return (
79
- <div class={props.class}>
80
- <Switch>
81
- <Match when={props.type === 'line'}>
82
- <div
83
- ref={nav!}
84
- class={cs(
85
- 'ant-mb-16px ant-flex ant-gap-32px ant-[border-bottom:solid_1px_rgba(5,5,5,0.1)] ant-relative',
86
- props.navClass,
87
- )}
88
- >
89
- <For each={props.items}>
90
- {item => (
91
- <div
92
- class={cs(
93
- 'ant-py-12px ant-cursor-pointer',
94
- props.navItemClass,
95
- isSelectedItem(item.key) && 'ant-text-[var(--primary-color)] selected',
96
- )}
97
- onClick={() => {
98
- setSelectedItem(item)
99
- updateSelectedBarStyle()
100
- }}
101
- >
102
- {unwrapStringOrJSXElement(item.label)}
103
- </div>
104
- )}
105
- </For>
106
-
107
- <div
108
- role={'selected-bar' as any}
109
- class="ant-absolute ant-bottom-0 ant-bg-[var(--primary-color)] ant-h-2px ant-transition-left"
110
- style={selectedBarStyle()}
111
- />
112
- </div>
113
- </Match>
114
- <Match when={props.type === 'segment'}>
115
- <Segmented
116
- block
117
- options={props.items.map(item => ({
118
- label: item.label,
119
- value: item.key,
120
- onClick: () => setSelectedItem(item),
121
- }))}
122
- />
123
- </Match>
124
- </Switch>
125
-
126
- <div class={props.contentClass}>{unwrapStringOrJSXElement(selectedItem()?.children)}</div>
127
- </div>
128
- )
129
- }
130
-
131
- export default Tabs
package/src/Timeline.tsx DELETED
@@ -1,33 +0,0 @@
1
- import { type Accessor, type Component, For, type JSXElement } from 'solid-js'
2
- import { type TimelineItemProps as TimelineItemAntdProps } from 'antd'
3
-
4
- interface TimelineItemProps extends Omit<TimelineItemAntdProps, 'children' | 'dot' | 'label'> {
5
- dot?: JSXElement
6
- label?: JSXElement
7
- children?: Accessor<JSXElement>
8
- }
9
-
10
- interface TimelineProps {
11
- class?: string
12
- items: TimelineItemProps[]
13
- }
14
-
15
- const Timeline: Component<TimelineProps> = props => {
16
- return (
17
- <div class="ant-flex ant-flex-col ant-gap-[16px]">
18
- <For each={props.items}>
19
- {(item, i) => (
20
- <div class="ant-flex ant-relative">
21
- {i() !== props.items.length - 1 && (
22
- <div class="ant-absolute ant-top-[8px] ant-bottom-[-24px] ant-left-[4px] ant-w-[2px] ant-bg-[rgba(5,5,5,.06)]" />
23
- )}
24
- <div class="ant-w-[10px] ant-h-[10px] ant-border-solid ant-border-width-[3px] ant-border-[var(--primary-color)] ant-bg-white ant-rounded-[50%] ant-mt-[8px]" />
25
- <div class="ant-ml-[8px]">{item.children?.()}</div>
26
- </div>
27
- )}
28
- </For>
29
- </div>
30
- )
31
- }
32
-
33
- export default Timeline