lupine.components 1.1.13 → 1.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/package.json +42 -42
- package/src/components/action-sheet.tsx +419 -419
- package/src/components/button-push-animation.tsx +147 -138
- package/src/components/button.tsx +55 -55
- package/src/components/desktop-footer.tsx +17 -17
- package/src/components/desktop-header.tsx +52 -52
- package/src/components/drag-refresh.tsx +129 -129
- package/src/components/editable-label.tsx +83 -83
- package/src/components/float-window.tsx +233 -233
- package/src/components/grid.tsx +18 -18
- package/src/components/html-load.tsx +41 -41
- package/src/components/html-var.tsx +81 -81
- package/src/components/index.ts +43 -44
- package/src/components/input-with-title.tsx +24 -24
- package/src/components/link-item.tsx +13 -13
- package/src/components/link-list.tsx +62 -62
- package/src/components/menu-bar.tsx +219 -219
- package/src/components/menu-item-props.tsx +13 -13
- package/src/components/menu-sidebar.tsx +325 -318
- package/src/components/message-box.tsx +44 -44
- package/src/components/meta-data.tsx +36 -36
- package/src/components/meta-description.tsx +12 -12
- package/src/components/mobile-components/icon-menu-item-props.ts +6 -6
- package/src/components/mobile-components/index.ts +8 -9
- package/src/components/mobile-components/mobile-footer-menu.tsx +95 -95
- package/src/components/mobile-components/mobile-header-component.tsx +101 -101
- package/src/components/mobile-components/mobile-header-title-icon.tsx +109 -101
- package/src/components/mobile-components/mobile-header-with-back.tsx +127 -117
- package/src/components/mobile-components/mobile-side-menu.tsx +154 -154
- package/src/components/mobile-components/mobile-top-sys-icon.tsx +18 -18
- package/src/components/mobile-components/mobile-top-sys-menu.tsx +62 -62
- package/src/components/modal.tsx +33 -33
- package/src/components/notice-message.tsx +118 -118
- package/src/components/page-title.tsx +6 -6
- package/src/components/paging-link.tsx +175 -175
- package/src/components/panel.tsx +21 -21
- package/src/components/popup-menu.tsx +289 -289
- package/src/components/progress.tsx +91 -91
- package/src/components/radio-label-component.tsx +36 -36
- package/src/components/redirect.tsx +19 -19
- package/src/components/resizable-splitter.tsx +128 -128
- package/src/components/select-angle-component.tsx +127 -127
- package/src/components/select-with-title.tsx +37 -37
- package/src/components/slide-tab-component.tsx +144 -149
- package/src/components/spinner.tsx +106 -100
- package/src/components/stars-component.tsx +66 -66
- package/src/components/svg.tsx +24 -24
- package/src/components/tabs.tsx +279 -279
- package/src/components/text-glow.tsx +37 -37
- package/src/components/text-scale.tsx +42 -42
- package/src/components/text-wave.tsx +55 -55
- package/src/components/theme-selector.tsx +28 -28
- package/src/components/toggle-base.tsx +285 -269
- package/src/components/toggle-switch.tsx +160 -160
- package/src/frames/index.ts +3 -3
- package/src/frames/responsive-frame.tsx +83 -83
- package/src/frames/slider-frame.tsx +111 -111
- package/src/frames/top-frame.tsx +30 -30
- package/src/index.ts +5 -5
- package/src/lib/back-action-helper.ts +54 -54
- package/src/lib/base62.ts +23 -23
- package/src/lib/blob-utils.ts +23 -23
- package/src/lib/calculate-text-width.ts +13 -13
- package/src/lib/date-utils.ts +317 -317
- package/src/lib/deep-merge.ts +37 -37
- package/src/lib/document-ready.ts +34 -34
- package/src/lib/dom-utils.ts +32 -32
- package/src/lib/download-file.ts +118 -118
- package/src/lib/download-link.ts +12 -12
- package/src/lib/download-stream.ts +19 -19
- package/src/lib/drag-util.ts +118 -118
- package/src/lib/dynamical-load.ts +134 -134
- package/src/lib/encode-html.ts +27 -27
- package/src/lib/find-parent-tag.ts +8 -8
- package/src/lib/format-bytes.ts +11 -11
- package/src/lib/index.ts +24 -24
- package/src/lib/lite-dom.ts +225 -225
- package/src/lib/message-hub.ts +103 -104
- package/src/lib/observable.ts +188 -188
- package/src/lib/path-utils.ts +42 -42
- package/src/lib/promise-timeout.ts +1 -1
- package/src/lib/simple-storage.ts +40 -40
- package/src/lib/stop-propagation.ts +7 -7
- package/src/lib/upload-file.ts +101 -101
- package/src/styles/base-themes.ts +17 -17
- package/src/styles/dark-themes.ts +99 -99
- package/src/styles/index.ts +5 -5
- package/src/styles/light-themes.ts +106 -106
- package/src/styles/media-query.ts +93 -93
- package/src/styles/shared-themes.ts +57 -57
- package/tsconfig.json +113 -113
|
@@ -1,269 +1,285 @@
|
|
|
1
|
-
import { bindGlobalStyle, CssProps, RefProps, VNode } from 'lupine.web';
|
|
2
|
-
|
|
3
|
-
export const TogglePlayButtonSize = {
|
|
4
|
-
Small: { w: 50, h: 50 },
|
|
5
|
-
Medium: { w: 70, h: 70 },
|
|
6
|
-
Large: { w: 90, h: 90 },
|
|
7
|
-
};
|
|
8
|
-
export type TogglePlayButtonSizeProps = {
|
|
9
|
-
w: number;
|
|
10
|
-
h: number;
|
|
11
|
-
};
|
|
12
|
-
export type TogglePlayButtonProps = {
|
|
13
|
-
size: TogglePlayButtonSizeProps;
|
|
14
|
-
disabled?: boolean;
|
|
15
|
-
checked?: boolean;
|
|
16
|
-
onClick?: (checked: boolean) => void;
|
|
17
|
-
hook?: ToggleBaseHookProps;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
'
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
'.toggle-waves
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
},
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}
|
|
1
|
+
import { bindGlobalStyle, CssProps, RefProps, VNode } from 'lupine.web';
|
|
2
|
+
|
|
3
|
+
export const TogglePlayButtonSize = {
|
|
4
|
+
Small: { w: 50, h: 50 },
|
|
5
|
+
Medium: { w: 70, h: 70 },
|
|
6
|
+
Large: { w: 90, h: 90 },
|
|
7
|
+
};
|
|
8
|
+
export type TogglePlayButtonSizeProps = {
|
|
9
|
+
w: number;
|
|
10
|
+
h: number;
|
|
11
|
+
};
|
|
12
|
+
export type TogglePlayButtonProps = {
|
|
13
|
+
size: TogglePlayButtonSizeProps;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
checked?: boolean;
|
|
16
|
+
onClick?: (checked: boolean) => void;
|
|
17
|
+
hook?: ToggleBaseHookProps;
|
|
18
|
+
textColor?: string;
|
|
19
|
+
backgroundColor?: string;
|
|
20
|
+
noWave?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export const TogglePlayButton = (props: TogglePlayButtonProps) => {
|
|
23
|
+
const css: CssProps = {
|
|
24
|
+
width: `100%`,
|
|
25
|
+
height: `100%`,
|
|
26
|
+
borderRadius: '50%',
|
|
27
|
+
backgroundColor: '#3b29cc',
|
|
28
|
+
display: 'flex',
|
|
29
|
+
alignItems: 'center',
|
|
30
|
+
justifyContent: 'center',
|
|
31
|
+
transition: 'all 0.3s',
|
|
32
|
+
cursor: 'pointer',
|
|
33
|
+
'&:hover': {
|
|
34
|
+
opacity: 0.8,
|
|
35
|
+
},
|
|
36
|
+
'.play-icon': {
|
|
37
|
+
width: '50%',
|
|
38
|
+
height: '50%',
|
|
39
|
+
transition: 'all 0.2s ease-in-out',
|
|
40
|
+
backgroundColor: '#fff',
|
|
41
|
+
},
|
|
42
|
+
'&.toggle-off .play-icon': {
|
|
43
|
+
clipPath: 'polygon(20% 0, 20% 100%, 90% 50%, 90% 50%, 90% 50%, 90% 50%, 90% 50%, 90% 50%, 90% 50%)',
|
|
44
|
+
translate: '6% 0',
|
|
45
|
+
},
|
|
46
|
+
'&.toggle-on .play-icon': {
|
|
47
|
+
clipPath: 'polygon(0 0, 0 100%, 33.33% 100%, 33.33% 0, 66.66% 0, 100% 0, 100% 100%, 66.66% 100%, 66.66% 0)',
|
|
48
|
+
translate: '0 0',
|
|
49
|
+
},
|
|
50
|
+
'&.disabled': {
|
|
51
|
+
cursor: 'not-allowed',
|
|
52
|
+
backgroundColor: '#5d578b',
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
bindGlobalStyle('toggle-play-button-component', css);
|
|
56
|
+
|
|
57
|
+
const Btn = () => (
|
|
58
|
+
<div
|
|
59
|
+
class={`toggle-play-button-component toggle-placeholder ${props.checked ? 'toggle-on' : 'toggle-off'}${
|
|
60
|
+
props.disabled ? ' disabled' : ''
|
|
61
|
+
}`}
|
|
62
|
+
style={{ backgroundColor: props.backgroundColor }}
|
|
63
|
+
>
|
|
64
|
+
<div class='play-icon' style={{ backgroundColor: props.textColor }}></div>
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
return props.noWave ? (
|
|
68
|
+
<ToggleBase {...props}>
|
|
69
|
+
<Btn />
|
|
70
|
+
</ToggleBase>
|
|
71
|
+
) : (
|
|
72
|
+
<ToggleBase {...props}>
|
|
73
|
+
<ToggleWaveFrame>
|
|
74
|
+
<Btn />
|
|
75
|
+
</ToggleWaveFrame>
|
|
76
|
+
</ToggleBase>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export type ToggleButtonProps = {
|
|
81
|
+
// size: ToggleBaseSizeProps;
|
|
82
|
+
onText: string;
|
|
83
|
+
offText: string;
|
|
84
|
+
disabled?: boolean;
|
|
85
|
+
checked?: boolean;
|
|
86
|
+
onClick?: (checked: boolean) => void;
|
|
87
|
+
hook?: ToggleBaseHookProps;
|
|
88
|
+
};
|
|
89
|
+
export const ToggleButton = (props: ToggleButtonProps) => {
|
|
90
|
+
const css: CssProps = {
|
|
91
|
+
// width: `${props.size + 5}px`,
|
|
92
|
+
// height: `${props.size + 5}px`,
|
|
93
|
+
'&.disabled': {
|
|
94
|
+
cursor: 'not-allowed',
|
|
95
|
+
},
|
|
96
|
+
'&.toggle-on .on, &.toggle-off .off': {
|
|
97
|
+
display: 'block',
|
|
98
|
+
},
|
|
99
|
+
'&.toggle-on .off, &.toggle-off .on': {
|
|
100
|
+
display: 'none',
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
return (
|
|
104
|
+
<ToggleBase {...props} size={{ w: 'auto', h: 'auto' }}>
|
|
105
|
+
<div
|
|
106
|
+
css={css}
|
|
107
|
+
class={`toggle-button-component toggle-placeholder ${props.checked ? 'toggle-on' : 'toggle-off'}${
|
|
108
|
+
props.disabled ? ' disabled' : ''
|
|
109
|
+
}`}
|
|
110
|
+
>
|
|
111
|
+
<div class='on'>{props.onText}</div>
|
|
112
|
+
<div class='off'>{props.offText}</div>
|
|
113
|
+
</div>
|
|
114
|
+
</ToggleBase>
|
|
115
|
+
);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export type ToggleWaveFrameProps = {
|
|
119
|
+
children: VNode<any>;
|
|
120
|
+
};
|
|
121
|
+
export const ToggleWaveFrame = (props: ToggleWaveFrameProps) => {
|
|
122
|
+
const css: CssProps = {
|
|
123
|
+
width: `100%`,
|
|
124
|
+
height: `100%`,
|
|
125
|
+
'@keyframes pulse-border': {
|
|
126
|
+
'0%': {
|
|
127
|
+
transform: 'scale(0.6)',
|
|
128
|
+
opacity: 1,
|
|
129
|
+
},
|
|
130
|
+
'100%': {
|
|
131
|
+
transform: 'scale(1)',
|
|
132
|
+
opacity: 0,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
'.toggle-waves': {
|
|
136
|
+
position: 'absolute',
|
|
137
|
+
width: `100%`,
|
|
138
|
+
height: `100%`,
|
|
139
|
+
top: '0',
|
|
140
|
+
left: '0',
|
|
141
|
+
borderRadius: '50%',
|
|
142
|
+
backgroundColor: '#eb205580',
|
|
143
|
+
opacity: 0,
|
|
144
|
+
animation: 'pulse-border 3s ease-in-out infinite',
|
|
145
|
+
},
|
|
146
|
+
'.toggle-waves-1': {
|
|
147
|
+
'-webkit-animation-delay': '0s',
|
|
148
|
+
'animation-delay': '0s',
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
'.toggle-waves-2': {
|
|
152
|
+
'-webkit-animation-delay': '1s',
|
|
153
|
+
'animation-delay': '1s',
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
'.toggle-waves-3': {
|
|
157
|
+
'-webkit-animation-delay': '2s',
|
|
158
|
+
'animation-delay': '2s',
|
|
159
|
+
},
|
|
160
|
+
'.toggle-waves-box': {
|
|
161
|
+
position: 'absolute',
|
|
162
|
+
width: `100%`,
|
|
163
|
+
height: `100%`,
|
|
164
|
+
top: '0',
|
|
165
|
+
left: '0',
|
|
166
|
+
padding: `18%`,
|
|
167
|
+
},
|
|
168
|
+
'&.disabled .toggle-waves': {
|
|
169
|
+
backgroundColor: '#5d578b',
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
bindGlobalStyle('toggle-waves-box', css);
|
|
173
|
+
return (
|
|
174
|
+
<div class='toggle-waves-box toggle-placeholder'>
|
|
175
|
+
<div class='toggle-waves toggle-waves-1'></div>
|
|
176
|
+
<div class='toggle-waves toggle-waves-2'></div>
|
|
177
|
+
<div class='toggle-waves toggle-waves-3'></div>
|
|
178
|
+
<div class='toggle-waves-box'>{props.children}</div>
|
|
179
|
+
</div>
|
|
180
|
+
);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const ToggleBaseSize = {
|
|
184
|
+
Small: { w: 30, h: 30 },
|
|
185
|
+
Medium: { w: 50, h: 50 },
|
|
186
|
+
Large: { w: 70, h: 70 },
|
|
187
|
+
};
|
|
188
|
+
export type ToggleBaseSizeProps = {
|
|
189
|
+
w: number | string;
|
|
190
|
+
h: number | string;
|
|
191
|
+
};
|
|
192
|
+
export type ToggleBaseHookProps = {
|
|
193
|
+
setChecked?: (checked: boolean) => void;
|
|
194
|
+
getChecked?: () => boolean;
|
|
195
|
+
setEnabled?: (enabled: boolean) => void;
|
|
196
|
+
getEnabled?: () => boolean;
|
|
197
|
+
};
|
|
198
|
+
export type ToggleBaseProps = {
|
|
199
|
+
size: ToggleBaseSizeProps;
|
|
200
|
+
disabled?: boolean;
|
|
201
|
+
checked?: boolean;
|
|
202
|
+
onClick?: (checked: boolean) => void;
|
|
203
|
+
hook?: ToggleBaseHookProps;
|
|
204
|
+
children: VNode<any>;
|
|
205
|
+
};
|
|
206
|
+
export const ToggleBase = (props: ToggleBaseProps) => {
|
|
207
|
+
const applyToggle = (checked: boolean, disabled: boolean) => {
|
|
208
|
+
const childDom = ref.$all('.toggle-base-container .toggle-placeholder');
|
|
209
|
+
childDom.forEach((dom: HTMLElement) => {
|
|
210
|
+
dom.classList.toggle('toggle-on', checked);
|
|
211
|
+
dom.classList.toggle('toggle-off', !checked);
|
|
212
|
+
dom.classList.toggle('disabled', disabled);
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
let disabled = props.disabled || false;
|
|
216
|
+
const ref: RefProps = {
|
|
217
|
+
onLoad: async (el: Element) => {
|
|
218
|
+
applyToggle(props.checked || false, disabled);
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
const onClick = (e: MouseEvent) => {
|
|
222
|
+
if (disabled) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const checked = (e.target as HTMLInputElement).checked;
|
|
227
|
+
applyToggle(checked, disabled);
|
|
228
|
+
if (props.onClick) {
|
|
229
|
+
props.onClick(checked);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
if (props.hook) {
|
|
233
|
+
props.hook.setChecked = (checked: boolean) => {
|
|
234
|
+
(ref.$('input.toggle-base-checkbox') as HTMLInputElement).checked = checked;
|
|
235
|
+
applyToggle(checked, disabled);
|
|
236
|
+
};
|
|
237
|
+
props.hook.getChecked = () => {
|
|
238
|
+
return (ref.$('input.toggle-base-checkbox') as HTMLInputElement).checked;
|
|
239
|
+
};
|
|
240
|
+
props.hook.setEnabled = (enabled: boolean) => {
|
|
241
|
+
disabled = !enabled;
|
|
242
|
+
const dom = ref.$('input.toggle-base-checkbox') as HTMLInputElement;
|
|
243
|
+
dom.disabled = disabled;
|
|
244
|
+
applyToggle(dom.checked, disabled);
|
|
245
|
+
};
|
|
246
|
+
props.hook.getEnabled = () => {
|
|
247
|
+
return !disabled;
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const css: CssProps = {
|
|
252
|
+
'.toggle-base-box, .toggle-base-container': {
|
|
253
|
+
position: 'relative',
|
|
254
|
+
width: `100%`,
|
|
255
|
+
height: `100%`,
|
|
256
|
+
},
|
|
257
|
+
'.toggle-base-checkbox': {
|
|
258
|
+
opacity: 0,
|
|
259
|
+
position: 'absolute',
|
|
260
|
+
pointerEvents: 'none',
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
bindGlobalStyle('toggle-base-component', css);
|
|
264
|
+
return (
|
|
265
|
+
<div
|
|
266
|
+
ref={ref}
|
|
267
|
+
css={{
|
|
268
|
+
width: `${typeof props.size.w === 'number' ? props.size.w + 'px' : props.size.w}`,
|
|
269
|
+
height: `${typeof props.size.h === 'number' ? props.size.h + 'px' : props.size.h}`,
|
|
270
|
+
}}
|
|
271
|
+
class='toggle-base-component'
|
|
272
|
+
>
|
|
273
|
+
<label class='toggle-base-box'>
|
|
274
|
+
<div class='toggle-base-container'>{props.children}</div>
|
|
275
|
+
<input
|
|
276
|
+
type='checkbox'
|
|
277
|
+
class='toggle-base-checkbox'
|
|
278
|
+
checked={props.checked || false}
|
|
279
|
+
disabled={disabled}
|
|
280
|
+
onClick={onClick}
|
|
281
|
+
/>
|
|
282
|
+
</label>
|
|
283
|
+
</div>
|
|
284
|
+
);
|
|
285
|
+
};
|