antd-solid 0.0.6 → 0.0.8

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 (147) hide show
  1. package/dist/index.esm.js +2356 -0
  2. package/dist/index.umd.js +1 -0
  3. package/es/Button.d.ts +19 -0
  4. package/es/Button.js +73 -0
  5. package/es/Collapse/index.d.ts +16 -0
  6. package/es/Collapse/index.js +87 -0
  7. package/es/ColorPicker.d.ts +8 -0
  8. package/es/ColorPicker.js +6 -0
  9. package/es/Compact.d.ts +12 -0
  10. package/es/Compact.js +17 -0
  11. package/es/DatePicker.d.ts +19 -0
  12. package/es/DatePicker.js +9 -0
  13. package/es/Empty/PRESENTED_IMAGE_SIMPLE.d.ts +3 -0
  14. package/es/Empty/PRESENTED_IMAGE_SIMPLE.js +14 -0
  15. package/es/Empty/assets/EmptySvg.d.ts +2 -0
  16. package/es/Empty/assets/EmptySvg.js +6 -0
  17. package/es/Empty/assets/SimpleEmptySvg.d.ts +2 -0
  18. package/es/Empty/assets/SimpleEmptySvg.js +6 -0
  19. package/es/Empty/index.d.ts +5 -0
  20. package/es/Empty/index.js +16 -0
  21. package/es/Image.d.ts +9 -0
  22. package/es/Image.js +22 -0
  23. package/es/Input.d.ts +29 -0
  24. package/es/Input.js +144 -0
  25. package/es/InputNumber.d.ts +11 -0
  26. package/es/InputNumber.js +92 -0
  27. package/es/InputNumber.test.d.ts +1 -0
  28. package/es/InputNumber.test.js +42 -0
  29. package/es/Modal.d.ts +47 -0
  30. package/es/Modal.js +195 -0
  31. package/es/Popconfirm.d.ts +21 -0
  32. package/es/Popconfirm.js +64 -0
  33. package/es/Popover.d.ts +7 -0
  34. package/es/Popover.js +36 -0
  35. package/es/Progress.d.ts +7 -0
  36. package/es/Progress.js +6 -0
  37. package/es/Radio.d.ts +27 -0
  38. package/es/Radio.js +89 -0
  39. package/es/Result.d.ts +10 -0
  40. package/es/Result.js +29 -0
  41. package/es/Segmented/index.d.ts +21 -0
  42. package/es/Segmented/index.js +72 -0
  43. package/es/Select.d.ts +16 -0
  44. package/es/Select.js +113 -0
  45. package/es/Skeleton.d.ts +9 -0
  46. package/es/Skeleton.js +9 -0
  47. package/es/Spin.d.ts +9 -0
  48. package/es/Spin.js +22 -0
  49. package/es/Switch.d.ts +8 -0
  50. package/es/Switch.js +30 -0
  51. package/es/Table.d.ts +11 -0
  52. package/es/Table.js +57 -0
  53. package/es/Tabs.d.ts +17 -0
  54. package/es/Tabs.js +117 -0
  55. package/es/Timeline.d.ts +13 -0
  56. package/es/Timeline.js +30 -0
  57. package/es/Tooltip.d.ts +34 -0
  58. package/es/Tooltip.js +302 -0
  59. package/es/Tree.d.ts +28 -0
  60. package/es/Tree.js +198 -0
  61. package/es/Upload.d.ts +11 -0
  62. package/es/Upload.js +6 -0
  63. package/es/form/Form.d.ts +18 -0
  64. package/es/form/Form.js +70 -0
  65. package/es/form/FormItem.d.ts +19 -0
  66. package/es/form/FormItem.js +141 -0
  67. package/es/form/context.d.ts +12 -0
  68. package/es/form/context.js +5 -0
  69. package/es/form/index.d.ts +8 -0
  70. package/es/form/index.js +7 -0
  71. package/es/hooks/createControllableValue.d.ts +16 -0
  72. package/es/hooks/createControllableValue.js +41 -0
  73. package/es/hooks/createUpdateEffect.d.ts +5 -0
  74. package/es/hooks/createUpdateEffect.js +12 -0
  75. package/es/hooks/index.d.ts +2 -0
  76. package/es/hooks/index.js +2 -0
  77. package/es/hooks/useClickAway.d.ts +2 -0
  78. package/es/hooks/useClickAway.js +17 -0
  79. package/es/hooks/useSize.d.ts +5 -0
  80. package/es/hooks/useSize.js +22 -0
  81. package/es/index.d.ts +42 -0
  82. package/es/index.js +29 -0
  83. package/es/types/index.d.ts +3 -0
  84. package/es/types/index.js +1 -0
  85. package/es/utils/EventEmitter.d.ts +7 -0
  86. package/es/utils/EventEmitter.js +13 -0
  87. package/es/utils/ReactToSolid.d.ts +8 -0
  88. package/es/utils/ReactToSolid.js +30 -0
  89. package/es/utils/SolidToReact.d.ts +8 -0
  90. package/es/utils/SolidToReact.js +23 -0
  91. package/es/utils/array.d.ts +15 -0
  92. package/es/utils/array.js +19 -0
  93. package/es/utils/component.d.ts +31 -0
  94. package/es/utils/component.js +68 -0
  95. package/es/utils/solid.d.ts +15 -0
  96. package/es/utils/solid.js +32 -0
  97. package/es/utils/zh_CN.d.ts +2 -0
  98. package/{src/utils/zh_CN.ts → es/utils/zh_CN.js} +34 -34
  99. package/package.json +7 -6
  100. package/src/Button.tsx +0 -125
  101. package/src/Collapse/index.tsx +0 -86
  102. package/src/ColorPicker.tsx +0 -11
  103. package/src/Compact.tsx +0 -15
  104. package/src/DatePicker.tsx +0 -22
  105. package/src/Empty/PRESENTED_IMAGE_SIMPLE.tsx +0 -15
  106. package/src/Empty/assets/EmptySvg.tsx +0 -43
  107. package/src/Empty/assets/SimpleEmptySvg.tsx +0 -16
  108. package/src/Empty/index.tsx +0 -20
  109. package/src/Image.tsx +0 -29
  110. package/src/Input.tsx +0 -202
  111. package/src/InputNumber.test.tsx +0 -46
  112. package/src/InputNumber.tsx +0 -125
  113. package/src/Modal.tsx +0 -196
  114. package/src/Popconfirm.tsx +0 -75
  115. package/src/Popover.tsx +0 -30
  116. package/src/Progress.tsx +0 -4
  117. package/src/Radio.tsx +0 -132
  118. package/src/Result.tsx +0 -38
  119. package/src/Segmented/index.tsx +0 -95
  120. package/src/Select.tsx +0 -128
  121. package/src/Skeleton.tsx +0 -14
  122. package/src/Spin.tsx +0 -23
  123. package/src/Switch.tsx +0 -34
  124. package/src/Table.tsx +0 -53
  125. package/src/Tabs.tsx +0 -131
  126. package/src/Timeline.tsx +0 -33
  127. package/src/Tooltip.tsx +0 -355
  128. package/src/Tree.tsx +0 -246
  129. package/src/Upload.tsx +0 -10
  130. package/src/form/Form.tsx +0 -94
  131. package/src/form/FormItem.tsx +0 -139
  132. package/src/form/context.ts +0 -16
  133. package/src/form/index.ts +0 -13
  134. package/src/hooks/createControllableValue.ts +0 -68
  135. package/src/hooks/createUpdateEffect.ts +0 -16
  136. package/src/hooks/index.ts +0 -2
  137. package/src/hooks/useClickAway.ts +0 -18
  138. package/src/hooks/useSize.ts +0 -26
  139. package/src/index.ts +0 -44
  140. package/src/types/index.ts +0 -5
  141. package/src/utils/EventEmitter.ts +0 -15
  142. package/src/utils/ReactToSolid.tsx +0 -38
  143. package/src/utils/SolidToReact.tsx +0 -27
  144. package/src/utils/array.ts +0 -21
  145. package/src/utils/component.tsx +0 -85
  146. package/src/utils/solid.ts +0 -53
  147. /package/{dist → css}/index.css +0 -0
@@ -1,125 +0,0 @@
1
- import { type Component, createEffect, on, splitProps, untrack, createSignal, mergeProps } from 'solid-js'
2
- import { CommonInput, type InputProps } from './Input'
3
- import { clamp, isNil } from 'lodash-es'
4
- import { dispatchEventHandlerUnion } from './utils/solid'
5
-
6
- export interface InputNumberProps
7
- extends Omit<
8
- InputProps,
9
- 'defaultValue' | 'value' | 'onChange' | 'inputAfter' | 'onKeyDown' | 'min' | 'max' | 'suffix'
10
- > {
11
- defaultValue?: number | null | undefined
12
- value?: number | null | undefined
13
- onChange?: (value: number | null) => void
14
- min?: number
15
- max?: number
16
- }
17
-
18
- const isEmptyValue = (value: number | string | null | undefined) => isNil(value) || value === ''
19
-
20
- const actionBtnClass =
21
- 'ant-text-12px ant-flex ant-justify-center ant-items-center ant-h-1/2 ant-cursor-pointer ant-opacity-70 hover:ant-h-100% hover:ant-text-[var(--primary-color)] ant-transition-color ant-transition-height ant-transition-duration-500'
22
-
23
- const InputNumber: Component<InputNumberProps> = _props => {
24
- const props = mergeProps({
25
- min: -Infinity,
26
- max: Infinity,
27
- }, _props)
28
- const [_, inputProps] = splitProps(props, [
29
- 'defaultValue',
30
- 'value',
31
- 'onChange',
32
- 'onBlur',
33
- ])
34
-
35
- const clampValue = (v: number) => untrack(() => clamp(v, props.min, props.max))
36
-
37
- let prev: number | null = null
38
- const updatePrev = (v: number | null) => {
39
- if (prev === v) return
40
-
41
- prev = v
42
- props.onChange?.(prev)
43
- }
44
-
45
- const [value, setValue] = createSignal<number | string | null | undefined>(untrack(() => props.value ?? props.defaultValue))
46
- createEffect(on(() => props.value, () => {
47
- setValue(props.value)
48
- }, {
49
- defer: true
50
- }))
51
-
52
- const add = (addon: number) => {
53
- let newValue: number | null
54
- if (isEmptyValue(value())) {
55
- newValue = clampValue(addon)
56
- } else {
57
- const num = Number(value())
58
- newValue = Number.isNaN(num) ? null : clampValue(num + addon)
59
- }
60
-
61
- if (!Object.keys(props).includes('value')) {
62
- setValue(newValue)
63
- }
64
- updatePrev(newValue)
65
- }
66
- const up = () => {
67
- add(1)
68
- }
69
- const down = () => {
70
- add(-1)
71
- }
72
-
73
- return (
74
- <CommonInput
75
- {...inputProps}
76
- actions={
77
- <div class="ant-flex ant-flex-col ant-h-full ant-w-24px ant-[border-left:1px_solid_var(--ant-color-border)]">
78
- <div class={actionBtnClass} onClick={up}>
79
- <div class="i-ant-design:up-outlined" />
80
- </div>
81
- <div
82
- class={`ant-[border-top:1px_solid_var(--ant-color-border)] ${actionBtnClass}`}
83
- onClick={down}
84
- >
85
- <div class="i-ant-design:down-outlined" />
86
- </div>
87
- </div>
88
- }
89
- value={`${value() ?? ''}`}
90
- onKeyDown={e => {
91
- switch (e.key) {
92
- case 'ArrowUp':
93
- up()
94
- e.preventDefault()
95
- return
96
- case 'ArrowDown':
97
- down()
98
- e.preventDefault()
99
- }
100
- }}
101
- onChange={e => {
102
- const newValue = e.target.value
103
- setValue(newValue)
104
-
105
- let newValueNum: number | null = Number(newValue)
106
- if (Number.isNaN(newValueNum)) return
107
-
108
- if (isEmptyValue(newValue)) {
109
- newValueNum = null
110
- } else {
111
- newValueNum = clampValue(newValueNum)
112
- }
113
-
114
- updatePrev(newValueNum)
115
- }}
116
- onBlur={e => {
117
- setValue(props.value ?? prev)
118
-
119
- dispatchEventHandlerUnion(props.onBlur, e)
120
- }}
121
- />
122
- )
123
- }
124
-
125
- export default InputNumber
package/src/Modal.tsx DELETED
@@ -1,196 +0,0 @@
1
- import { type JSXElement, Show, createSignal, untrack, type Ref, mergeProps } from 'solid-js'
2
- import { Portal, render } from 'solid-js/web'
3
- import Button from './Button'
4
- import cs from 'classnames'
5
-
6
- export interface ModalInstance {
7
- open: () => void
8
- close: () => void
9
- }
10
-
11
- export interface ModalProps {
12
- ref?: Ref<ModalInstance>
13
- title?: JSXElement
14
- defaultOpen?: boolean
15
- width?: string
16
- height?: string
17
- children?: JSXElement
18
- /**
19
- * 垂直居中展示 Modal
20
- */
21
- centered?: boolean
22
- /**
23
- * 点击蒙层是否允许关闭
24
- * 默认 true
25
- */
26
- maskClosable?: boolean
27
- /**
28
- * 设置为 false 时隐藏关闭按钮
29
- */
30
- closeIcon?: boolean
31
- footer?: boolean | ((modal: ModalInstance) => JSXElement)
32
- /**
33
- * 关闭时销毁 Modal 里的子元素
34
- */
35
- destroyOnClose?: boolean
36
- /**
37
- * 返回 true,会自动关闭 modal
38
- */
39
- onOk?: () => boolean | Promise<boolean>
40
- afterClose?: () => void
41
- /**
42
- * 自定义渲染对话框
43
- */
44
- modalRender?: () => JSXElement
45
- }
46
-
47
- export interface MethodProps
48
- extends Pick<ModalProps, 'title' | 'children' | 'onOk' | 'afterClose'> {}
49
-
50
- function Modal(_props: ModalProps) {
51
- const props = mergeProps({ footer: true }, _props)
52
- const [open, setOpen] = createSignal(props.defaultOpen ?? false)
53
- const [hide, setHide] = createSignal(false)
54
-
55
- const instance: ModalInstance = {
56
- open() {
57
- setOpen(true)
58
- setHide(false)
59
- },
60
- close() {
61
- untrack(() => {
62
- if (props.destroyOnClose) {
63
- setOpen(false)
64
- } else {
65
- setHide(true)
66
- }
67
- })
68
- },
69
- }
70
- untrack(() => {
71
- if (typeof props.ref === 'function') {
72
- props.ref?.(instance)
73
- }
74
- })
75
-
76
- const close = () => {
77
- instance.close()
78
- props.afterClose?.()
79
- }
80
-
81
- const [confirmLoading, setConfirmLoading] = createSignal(false)
82
-
83
- return (
84
- <Show when={open()}>
85
- <Portal>
86
- <div
87
- class={cs(
88
- 'ant-fixed ant-justify-center ant-inset-0 ant-bg-[rgba(0,0,0,.45)] ant-flex ant-z-1000',
89
- props.centered && 'ant-items-center',
90
- )}
91
- onClick={() => {
92
- if (props.maskClosable ?? true) {
93
- close()
94
- }
95
- }}
96
- style={{ display: hide() ? 'none' : undefined }}
97
- >
98
- <Show when={typeof props.modalRender !== 'function'} fallback={props.modalRender!()}>
99
- <div
100
- class={cs(
101
- 'ant-absolute ant-px-24px ant-py-20px ant-rounded-8px ant-overflow-hidden ant-bg-white ant-flex ant-flex-col',
102
- // '!ant-[animation-duration:.5s]',
103
- !props.centered && 'ant-top-100px',
104
- )}
105
- onClick={e => {
106
- e.stopPropagation()
107
- }}
108
- style={{
109
- width: props.width ?? '520px',
110
- height: props.height,
111
- }}
112
- >
113
- {/* 关闭按钮 */}
114
- <Show when={props.closeIcon !== false}>
115
- <Button
116
- type="text"
117
- class={cs(
118
- 'ant-rm-size-btn !ant-w-22px !ant-h-22px !ant-flex !ant-justify-center !ant-items-center ant-text-center ant-text-18px !ant-absolute !ant-top-16px !ant-right-16px ant-z-1000 ant-text-[rgba(0,0,0,.45)] hover:!ant-text-[rgba(0,0,0,.88)]',
119
- )}
120
- onClick={close}
121
- >
122
- <span class="i-ant-design:close-outlined" />
123
- </Button>
124
- </Show>
125
-
126
- <div class="ant-text-[rgba(0,0,0,.88)] ant-text-16px ant-font-600 ant-mb-8px">
127
- {props.title}
128
- </div>
129
- <div class="ant-grow">{props.children}</div>
130
-
131
- <Show when={props.footer !== false}>
132
- <div class="ant-mt-12px">
133
- <Show when={typeof props.footer !== 'function'} fallback={typeof props.footer === 'function' && props.footer(instance)}>
134
- <div class='ant-flex ant-gap-8px ant-justify-end'>
135
- <Button onClick={close}>取消</Button>
136
- <Button
137
- type="primary"
138
- loading={confirmLoading()}
139
- // eslint-disable-next-line solid/reactivity, @typescript-eslint/no-misused-promises
140
- onClick={async () => {
141
- if (!props.onOk) return
142
-
143
- let res = props.onOk?.()
144
- if (res instanceof Promise) {
145
- setConfirmLoading(true)
146
- res = await res.finally(() => setConfirmLoading(false))
147
- }
148
- if (res) {
149
- instance.close()
150
- }
151
- }}
152
- >
153
- 确定
154
- </Button>
155
- </div>
156
- </Show>
157
- </div>
158
- </Show>
159
- </div>
160
- </Show>
161
- </div>
162
- </Portal>
163
- </Show>
164
- )
165
- }
166
-
167
- Modal.warning = (props: MethodProps) => {
168
- const div = document.createElement('div')
169
- document.body.appendChild(div)
170
- const dispose = render(
171
- () => (
172
- <Modal
173
- width="416px"
174
- maskClosable={false}
175
- closeIcon={false}
176
- {...props}
177
- title={
178
- <>
179
- <span class="i-ant-design:exclamation-circle ant-text-22px ant-mr-12px ant-text-[var(--warning-color)]" />
180
- {props.title}
181
- </>
182
- }
183
- children={<div class="ant-ml-34px">{props.children}</div>}
184
- defaultOpen
185
- afterClose={() => {
186
- document.body.removeChild(div)
187
- dispose()
188
- props.afterClose?.()
189
- }}
190
- />
191
- ),
192
- div,
193
- )
194
- }
195
-
196
- export default Modal
@@ -1,75 +0,0 @@
1
- import { type Component, type JSXElement, createSignal, mergeProps, untrack, splitProps } from 'solid-js'
2
- import Button from './Button'
3
- import Tooltip, { type TooltipProps } from './Tooltip'
4
-
5
- interface PopconfirmProps extends Pick<TooltipProps, 'placement' | 'arrow'> {
6
- title?: JSXElement
7
- content?: JSXElement
8
- children: JSXElement
9
- onCancel?: () => void
10
- onConfirm?: () => void
11
- /**
12
- * 确认按钮文字
13
- * 默认:确定
14
- */
15
- okText?: string
16
- /**
17
- * 取消按钮文字
18
- * 默认:取消
19
- */
20
- cancelText?: string
21
- }
22
-
23
- const Popconfirm: Component<PopconfirmProps> = props => {
24
- const mergedProps = mergeProps({ okText: '确定', cancelText: '取消' }, props)
25
- const [tooltipProps] = splitProps(props, ['placement', 'arrow'])
26
- const [open, setOpen] = createSignal(false)
27
-
28
- return (
29
- <Tooltip
30
- mode="light"
31
- trigger="click"
32
- open={open()}
33
- onOpenChange={setOpen}
34
- content={
35
- <div>
36
- <div class="ant-mb-8px ant-flex ant-items-center">
37
- <span class="i-ant-design:exclamation-circle-fill ant-text-#faad14" />
38
- <span class="ant-ml-8px ant-text-[rgba(0,0,0,0.88)] ant-font-600">{mergedProps.title}</span>
39
- </div>
40
-
41
- <div class="ant-ml-22px ant-mb-8px ant-text-[rgba(0,0,0,0.88)]">{mergedProps.content}</div>
42
-
43
- <div class="ant-text-right">
44
- <Button
45
- class="ant-ml-8px"
46
- size="small"
47
- onClick={() => {
48
- setOpen(false)
49
- untrack(() => mergedProps.onCancel?.())
50
- }}
51
- >
52
- {mergedProps.cancelText}
53
- </Button>
54
- <Button
55
- class="ant-ml-8px"
56
- type="primary"
57
- size="small"
58
- onClick={() => {
59
- setOpen(false)
60
- untrack(() => mergedProps.onConfirm?.())
61
- }}
62
- >
63
- {mergedProps.okText}
64
- </Button>
65
- </div>
66
- </div>
67
- }
68
- {...tooltipProps}
69
- >
70
- {mergedProps.children}
71
- </Tooltip>
72
- )
73
- }
74
-
75
- export default Popconfirm
package/src/Popover.tsx DELETED
@@ -1,30 +0,0 @@
1
- import { type Component, type JSXElement, Show } from 'solid-js'
2
- import Tooltip, { Content, type TooltipProps } from './Tooltip'
3
-
4
- interface PopoverProps extends TooltipProps {
5
- title?: JSXElement
6
- }
7
-
8
- const Popover: Component<PopoverProps> = props => {
9
- return (
10
- <Tooltip
11
- mode="light"
12
- {...props}
13
- content={close =>
14
- <div>
15
- <Show when={props.title}>
16
- <div class="ant-mb-8px ant-flex ant-items-center">
17
- <span class="ant-text-[rgba(0,0,0,0.88)] ant-font-600">{props.title}</span>
18
- </div>
19
- </Show>
20
-
21
- <div class="ant-text-[rgba(0,0,0,0.88)]">
22
- <Content content={props.content} close={close} />
23
- </div>
24
- </div>
25
- }
26
- />
27
- )
28
- }
29
-
30
- export default Popover
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