lupine.web 1.0.15 → 1.0.17
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 +1 -1
- package/package.json +1 -5
- package/src/core/bind-lang.ts +6 -5
- package/src/core/bind-links.ts +2 -2
- package/src/core/bind-meta.tsx +52 -0
- package/src/core/bind-theme.ts +11 -9
- package/src/core/export-lupine.ts +64 -0
- package/src/core/index.ts +3 -1
- package/src/core/{core.ts → initialize.ts} +12 -79
- package/src/core/page-router.ts +3 -2
- package/src/core/server-cookie.ts +5 -3
- package/src/index.ts +2 -3
- package/src/lib/index.ts +2 -13
- package/src/lib/is-frontend.ts +3 -0
- package/src/models/index.ts +2 -0
- package/src/models/json-props.ts +8 -0
- package/src/models/theme-props.ts +7 -0
- package/src/{types → styles}/index.ts +0 -2
- package/src/assets/themes/base-themes.ts +0 -16
- package/src/assets/themes/dark-themes.ts +0 -85
- package/src/assets/themes/index.ts +0 -4
- package/src/assets/themes/light-themes.ts +0 -92
- package/src/assets/themes/shared-themes.ts +0 -50
- package/src/components/button-push-animation.tsx +0 -138
- package/src/components/button.tsx +0 -55
- package/src/components/drag-refresh.tsx +0 -110
- package/src/components/editable-label.tsx +0 -83
- package/src/components/float-window.tsx +0 -226
- package/src/components/grid.tsx +0 -18
- package/src/components/html-var.tsx +0 -41
- package/src/components/index.ts +0 -36
- package/src/components/input-with-title.tsx +0 -24
- package/src/components/link-item.tsx +0 -13
- package/src/components/link-list.tsx +0 -62
- package/src/components/menu-bar.tsx +0 -220
- package/src/components/menu-item-props.tsx +0 -10
- package/src/components/menu-sidebar.tsx +0 -289
- package/src/components/message-box.tsx +0 -44
- package/src/components/meta-data.tsx +0 -54
- package/src/components/meta-description.tsx +0 -19
- package/src/components/meta-title.tsx +0 -19
- package/src/components/modal.tsx +0 -29
- package/src/components/notice-message.tsx +0 -119
- package/src/components/paging-link.tsx +0 -100
- package/src/components/panel.tsx +0 -24
- package/src/components/popup-menu.tsx +0 -218
- package/src/components/progress.tsx +0 -91
- package/src/components/redirect.tsx +0 -19
- package/src/components/resizable-splitter.tsx +0 -129
- package/src/components/select-with-title.tsx +0 -37
- package/src/components/spinner.tsx +0 -100
- package/src/components/svg.tsx +0 -24
- package/src/components/tabs.tsx +0 -252
- package/src/components/text-glow.tsx +0 -36
- package/src/components/text-wave.tsx +0 -54
- package/src/components/theme-selector.tsx +0 -35
- package/src/components/toggle-base.tsx +0 -260
- package/src/components/toggle-switch.tsx +0 -156
- package/src/lib/date-utils.ts +0 -317
- package/src/lib/deep-merge.ts +0 -37
- package/src/lib/document-ready.ts +0 -36
- package/src/lib/dom/calculate-text-width.ts +0 -13
- package/src/lib/dom/download-stream.ts +0 -17
- package/src/lib/dom/download.ts +0 -12
- package/src/lib/dom/index.ts +0 -71
- package/src/lib/dynamical-load.ts +0 -138
- package/src/lib/format-bytes.ts +0 -11
- package/src/lib/lite-dom.ts +0 -227
- package/src/lib/message-hub.ts +0 -105
- package/src/lib/observable.ts +0 -188
- package/src/lib/promise-timeout.ts +0 -1
- package/src/lib/simple-storage.ts +0 -40
- package/src/lib/stop-propagation.ts +0 -7
- package/src/lib/upload-file.ts +0 -68
- package/src/types/css-types.ts +0 -17
- package/src/types/media-query.ts +0 -93
- /package/src/lib/{dom/cookie.ts → cookie.ts} +0 -0
- /package/src/{types → styles}/css-styles.ts +0 -0
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { sharedThemes } from './shared-themes';
|
|
2
|
-
|
|
3
|
-
export const lightThemes: { [key: string]: string } = {
|
|
4
|
-
...sharedThemes,
|
|
5
|
-
'--theme-name': 'light',
|
|
6
|
-
|
|
7
|
-
// scroll bar
|
|
8
|
-
'--scrollbar-bg': '#d5d5d5',
|
|
9
|
-
'--scrollbar-thumb-bg': '#979797',
|
|
10
|
-
'--scrollbar-active-thumb-bg': '#737373',
|
|
11
|
-
|
|
12
|
-
'--primary-color': '#303030',
|
|
13
|
-
'--primary-color-disabled': '#a0a0a0',
|
|
14
|
-
'--primary-bg-color': '#ffffff',
|
|
15
|
-
'--primary-border-color': '#858585',
|
|
16
|
-
'--primary-border': '1px solid var(--primary-border-color)',
|
|
17
|
-
// '--secondary-color': '#505050',
|
|
18
|
-
// '--secondary-bg-color': '#ffffff',
|
|
19
|
-
// '--secondary-border': '1px solid #858585',
|
|
20
|
-
'--primary-opacity': 'unset', // used for dark theme
|
|
21
|
-
'--primary-disabled-opacity': '0.5', // used for dark theme
|
|
22
|
-
'--primary-accent-color': '#0a74c9', // used for radio and checkbox's background color
|
|
23
|
-
|
|
24
|
-
// including menus, tabs, sidebars
|
|
25
|
-
'--activatable-color-normal': 'var(--primary-color)',
|
|
26
|
-
'--activatable-bg-color-normal': 'var(--primary-bg-color)',
|
|
27
|
-
'--activatable-color-hover': '#1d1d1d',
|
|
28
|
-
'--activatable-bg-color-hover': '#bcbcbc',
|
|
29
|
-
'--activatable-color-selected': '#2d2d2d',
|
|
30
|
-
'--activatable-bg-color-selected': '#dcdcdc',
|
|
31
|
-
// '--menu-color-hover': '#303030',
|
|
32
|
-
// '--menu-bg-color': '#ffffff',
|
|
33
|
-
// '--menu-bg-color-hover': '#a0a0a0',
|
|
34
|
-
'--menu-font-size': '1rem',
|
|
35
|
-
'--menubar-color': '#eeeeee',
|
|
36
|
-
'--menubar-bg-color': '#000000',
|
|
37
|
-
'--menubar-sub-bg-color': '#f9f9f9',
|
|
38
|
-
'--sidebar-color': 'var(--primary-color)',
|
|
39
|
-
'--sidebar-bg-color': '#f4f3f4',
|
|
40
|
-
// '--sidebar-sub-color': 'var(--sidebar-color)',
|
|
41
|
-
// '--sidebar-sub-bg-color': '#eaeaea',
|
|
42
|
-
'--sidebar-border': '1px solid #858585',
|
|
43
|
-
// '--sidebar-hover-color': 'var(--sidebar-color)',
|
|
44
|
-
// '--sidebar-hover-bg-color': '#e0e0e0',
|
|
45
|
-
|
|
46
|
-
'--row-bg-color1': '#ffffff',
|
|
47
|
-
'--row-bg-color2': '#ffffff',
|
|
48
|
-
|
|
49
|
-
'--success-color': '#04AA6D',
|
|
50
|
-
'--info-color': '#2196F3',
|
|
51
|
-
'--warning-color': '#ff9800',
|
|
52
|
-
'--error-color': '#f44336',
|
|
53
|
-
'--success-bg-color': '#04AA6D',
|
|
54
|
-
'--info-bg-color': '#2196F3',
|
|
55
|
-
'--warning-bg-color': '#ff9800',
|
|
56
|
-
'--error-bg-color': '#f44336',
|
|
57
|
-
'--notice-color-with-bg': '#ffffff',
|
|
58
|
-
|
|
59
|
-
'--cover-mask-bg-color': '#00000060',
|
|
60
|
-
'--cover-bg-color': '#f5f5f5',
|
|
61
|
-
'--cover-box-shadow': '3px 3px 8px #767676',
|
|
62
|
-
|
|
63
|
-
// for input, checkbox, radio box, select
|
|
64
|
-
'--input-color': '#4e4e4e',
|
|
65
|
-
'--input-bg-color': '#ffffff',
|
|
66
|
-
'--input-box-shadow': '0px 0px 0px #000000, 1px 1px 0px 0px #50505045',
|
|
67
|
-
'--input-border-focus': '1px solid #0074d9',
|
|
68
|
-
|
|
69
|
-
// for button, div
|
|
70
|
-
'--button-color': '#4e4e4e',
|
|
71
|
-
'--button-bg': '-webkit-linear-gradient(top, #ffffff 0%, #f6f6f6 74%, #ededed 100%)',
|
|
72
|
-
'--button-bg-hover': '-webkit-linear-gradient(top, #ffffff 0%, #e6e6e6 74%, #dddddd 100%)',
|
|
73
|
-
'--button-border': '1px solid #f6f6f6',
|
|
74
|
-
'--button-box-shadow': '1px 1px 1px #00000085, 0px 1px 0px 2px #0705053b',
|
|
75
|
-
|
|
76
|
-
'--header-color': '#000080',
|
|
77
|
-
'--header-bg-color': '#ffffff',
|
|
78
|
-
|
|
79
|
-
// '--po-background': '#e5e5e5', // Background for surfaces on top of primary background
|
|
80
|
-
// // backgroundSecondary: '#f5f5f5', // Secondary background
|
|
81
|
-
// // backgroundOnSecondary: '#e5e5e5', // Background for surfaces on top of secondary background
|
|
82
|
-
// '--background-modifier-hover': '', // Hovered elements
|
|
83
|
-
// '--background-modifier-active-hover': '', // Active hovered elements
|
|
84
|
-
// '--background-modifier-border': '', // Border color
|
|
85
|
-
// '--background-modifier-border-hover': '', // Border color (hover)
|
|
86
|
-
// '--background-modifier-border-focus': '', // Border color (focus)
|
|
87
|
-
// '--background-modifier-error': '', // Error background
|
|
88
|
-
// '--background-modifier-error-hover': '', // Error background (hover)
|
|
89
|
-
// '--background-modifier-success': '', // Success background
|
|
90
|
-
// '--background-modifier-message': '', // Messages background
|
|
91
|
-
// '--background-modifier-form-field': '', // Form field background
|
|
92
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export const sharedThemes: { [key: string]: string } = {
|
|
2
|
-
// z-index
|
|
3
|
-
'--layer-cover': '10',
|
|
4
|
-
'--layer-sidebar': '100',
|
|
5
|
-
'--layer-sidebar-sub': '110',
|
|
6
|
-
'--layer-float-window': '200',
|
|
7
|
-
'--layer-modal': '300',
|
|
8
|
-
'--layer-modal-over': '310',
|
|
9
|
-
'--layer-menu': '400', // popup menu
|
|
10
|
-
'--layer-menu-sub': '410',
|
|
11
|
-
'--layer-notice': '500',
|
|
12
|
-
'--layer-tooltip': '510',
|
|
13
|
-
'--layer-dragged-item': '600',
|
|
14
|
-
|
|
15
|
-
'--font-size-base': '16px',
|
|
16
|
-
'--font-weight-base': '', //'400',
|
|
17
|
-
'--font-family-base': 'SimSun, "Microsoft YaHei", Helvetica, Arial, sans-serif',
|
|
18
|
-
'--line-height-base': '1.1',
|
|
19
|
-
|
|
20
|
-
'--font-size-h1-l': '2.5rem', //40px
|
|
21
|
-
'--font-size-h1': '2rem', //32px
|
|
22
|
-
'--font-size-h2': '1.5rem', //24px
|
|
23
|
-
'--font-size-h3': '1.17rem', //18.72px
|
|
24
|
-
'--font-size-h3-5': '1.08rem', //17.28px
|
|
25
|
-
'--font-size-h4': '1rem', //16px
|
|
26
|
-
'--font-size-h4-5': '.91rem', //14.56px
|
|
27
|
-
'--font-size-h5': '.83rem', //13.28px
|
|
28
|
-
'--font-size-h6': '.67rem', //10.72px
|
|
29
|
-
'--font-size-h6-s': '.55rem', //9.28px
|
|
30
|
-
'--font-size-title': 'var(--font-size-h2)',
|
|
31
|
-
'--font-size-subtitle': 'var(--font-size-h3-5)',
|
|
32
|
-
'--font-size-paragraph': 'var(--font-size-h4)',
|
|
33
|
-
'--font-size-paragraph-s': 'var(--font-size-h5)',
|
|
34
|
-
|
|
35
|
-
'--input-height': '2.2rem',
|
|
36
|
-
'--input-padding': '.3rem .6rem',
|
|
37
|
-
'--button-height': '2.1rem',
|
|
38
|
-
'--button-padding': '.3rem .9rem',
|
|
39
|
-
|
|
40
|
-
// space for margin, padding
|
|
41
|
-
'--space-ss': '.15rem',
|
|
42
|
-
'--space-s': '.25rem',
|
|
43
|
-
'--space-m': '.5rem',
|
|
44
|
-
'--space-l': '1rem',
|
|
45
|
-
'--space-ll': '2rem',
|
|
46
|
-
|
|
47
|
-
'--border-radius-s': '2px',
|
|
48
|
-
'--border-radius-m': '4px',
|
|
49
|
-
'--border-radius-l': '8px',
|
|
50
|
-
};
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { CssProps, RefProps } from 'lupine.web';
|
|
2
|
-
|
|
3
|
-
export enum ButtonPushAnimationSize {
|
|
4
|
-
SmallSmall = 'button-ss',
|
|
5
|
-
Small = 'button-s',
|
|
6
|
-
Medium = 'button-m',
|
|
7
|
-
Large = 'button-l',
|
|
8
|
-
LargeLarge = 'button-ll',
|
|
9
|
-
}
|
|
10
|
-
export type ButtonPushAnimationHookProps = {
|
|
11
|
-
setEnabled?: (enabled: boolean) => void;
|
|
12
|
-
getEnabled?: () => boolean;
|
|
13
|
-
};
|
|
14
|
-
export type ButtonPushAnimationProps = {
|
|
15
|
-
text: string;
|
|
16
|
-
size: ButtonPushAnimationSize;
|
|
17
|
-
disabled?: boolean;
|
|
18
|
-
onClick?: () => void;
|
|
19
|
-
hook?: ButtonPushAnimationHookProps;
|
|
20
|
-
class?: string;
|
|
21
|
-
css?: CssProps;
|
|
22
|
-
};
|
|
23
|
-
export const ButtonPushAnimation = (props: ButtonPushAnimationProps) => {
|
|
24
|
-
let disabled = props.disabled || false;
|
|
25
|
-
const onClick = () => {
|
|
26
|
-
if (disabled) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (props.onClick) {
|
|
30
|
-
props.onClick();
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
if (props.hook) {
|
|
34
|
-
props.hook.setEnabled = (enabled: boolean) => {
|
|
35
|
-
disabled = !enabled;
|
|
36
|
-
ref.current.disabled = disabled;
|
|
37
|
-
};
|
|
38
|
-
props.hook.getEnabled = () => {
|
|
39
|
-
return !disabled;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const ref: RefProps = {};
|
|
44
|
-
const css: CssProps = {
|
|
45
|
-
all: 'unset',
|
|
46
|
-
cursor: 'pointer',
|
|
47
|
-
'-webkit-tap-highlight-color': 'rgba(0, 0, 0, 0)',
|
|
48
|
-
position: 'relative',
|
|
49
|
-
borderRadius: 'var(--border-radius-m)',
|
|
50
|
-
backgroundColor: 'rgba(0, 0, 0, 0.75)',
|
|
51
|
-
boxShadow: '-0.15em -0.15em 0.15em -0.075em rgba(5, 5, 5, 0.25), 0.0375em 0.0375em 0.0675em 0 rgba(5, 5, 5, 0.1)',
|
|
52
|
-
'.button-outer': {
|
|
53
|
-
position: 'relative',
|
|
54
|
-
zIndex: 1,
|
|
55
|
-
borderRadius: 'inherit',
|
|
56
|
-
transition: 'box-shadow 300ms ease',
|
|
57
|
-
willChange: 'box-shadow',
|
|
58
|
-
boxShadow: '0 0.05em 0.05em -0.01em rgba(5, 5, 5, 1), 0 0.01em 0.01em -0.01em rgba(5, 5, 5, 0.5), 0.15em 0.3em 0.1em -0.01em rgba(5, 5, 5, 0.25)',
|
|
59
|
-
},
|
|
60
|
-
'.button-inner': {
|
|
61
|
-
position: 'relative',
|
|
62
|
-
zIndex: 2,
|
|
63
|
-
borderRadius: 'inherit',
|
|
64
|
-
padding: 'var(--button-padding)',
|
|
65
|
-
background: 'linear-gradient(135deg, #ffffff, #eeeeee)',
|
|
66
|
-
transition: 'box-shadow 300ms ease, background-image 250ms ease, transform 250ms ease;',
|
|
67
|
-
willChange: 'box-shadow, background-image, transform',
|
|
68
|
-
overflow: 'clip',
|
|
69
|
-
// clipPath: 'inset(0 0 0 0 round 999vw)',
|
|
70
|
-
boxShadow: '0 0 0 0 inset rgba(5, 5, 5, 0.1), -0.05em -0.05em 0.05em 0 inset rgba(5, 5, 5, 0.25), 0 0 0 0 inset rgba(5, 5, 5, 0.1), 0 0 0.05em 0.2em inset rgba(255, 255, 255, 0.25), 0.025em 0.05em 0.1em 0 inset rgba(255, 255, 255, 1), 0.12em 0.12em 0.12em inset rgba(255, 255, 255, 0.25), -0.075em -0.25em 0.25em 0.1em inset rgba(5, 5, 5, 0.25)',
|
|
71
|
-
},
|
|
72
|
-
'.button-inner span': {
|
|
73
|
-
position: 'relative',
|
|
74
|
-
zIndex: 4,
|
|
75
|
-
// fontFamily: 'Inter, sans-serif',
|
|
76
|
-
letterSpacing: '-0.05em',
|
|
77
|
-
// fontWeight: 500,
|
|
78
|
-
color: 'rgba(0, 0, 0, 0);',
|
|
79
|
-
backgroundImage: 'linear-gradient(135deg, rgba(25, 25, 25, 1), rgba(75, 75, 75, 1))',
|
|
80
|
-
backgroundClip: 'text',
|
|
81
|
-
transition: 'transform 250ms ease',
|
|
82
|
-
display: 'block',
|
|
83
|
-
willChange: 'transform',
|
|
84
|
-
textShadow: 'rgba(0, 0, 0, 0.1) 0 0 0.1em',
|
|
85
|
-
userSelect: 'none',
|
|
86
|
-
},
|
|
87
|
-
'&.button-ss': {
|
|
88
|
-
borderRadius: '2px',
|
|
89
|
-
},
|
|
90
|
-
'&.button-s': {
|
|
91
|
-
borderRadius: '3px',
|
|
92
|
-
},
|
|
93
|
-
'&.button-l': {
|
|
94
|
-
borderRadius: '6px',
|
|
95
|
-
},
|
|
96
|
-
'&.button-ll': {
|
|
97
|
-
borderRadius: '10px',
|
|
98
|
-
},
|
|
99
|
-
'&.button-ss .button-inner': {
|
|
100
|
-
padding: '0.1rem 0.3rem',
|
|
101
|
-
fontSize: '0.65rem',
|
|
102
|
-
},
|
|
103
|
-
'&.button-s .button-inner': {
|
|
104
|
-
padding: '0.2rem 0.5rem',
|
|
105
|
-
fontSize: '0.85rem',
|
|
106
|
-
},
|
|
107
|
-
'&.button-l .button-inner': {
|
|
108
|
-
padding: '0.4rem 1.2rem',
|
|
109
|
-
fontSize: '1.5rem',
|
|
110
|
-
},
|
|
111
|
-
'&.button-ll .button-inner': {
|
|
112
|
-
padding: '0.5rem 1.5rem',
|
|
113
|
-
fontSize: '2rem',
|
|
114
|
-
},
|
|
115
|
-
'&:active .button-outer': {
|
|
116
|
-
boxShadow: '0 0 0 0 rgba(5, 5, 5, 1), 0 0 0 0 rgba(5, 5, 5, 0.5), 0 0 0 0 rgba(5, 5, 5, 0.25)',
|
|
117
|
-
},
|
|
118
|
-
'&:active .button-inner': {
|
|
119
|
-
boxShadow: '0.1em 0.15em 0.05em 0 inset rgba(5, 5, 5, 0.75), -0.025em -0.03em 0.05em 0.025em inset rgba(5, 5, 5, 0.5), 0.25em 0.25em 0.2em 0 inset rgba(5, 5, 5, 0.5), 0 0 0.05em 0.5em inset rgba(255, 255, 255, 0.15), 0 0 0 0 inset rgba(255, 255, 255, 1), 0.12em 0.12em 0.12em inset rgba(255, 255, 255, 0.25), -0.075em -0.12em 0.2em 0.1em inset rgba(5, 5, 5, 0.25)',
|
|
120
|
-
},
|
|
121
|
-
'&:hover .button-inner': {
|
|
122
|
-
transform: 'scale(0.99)',
|
|
123
|
-
},
|
|
124
|
-
'&:hover .button-inner span': {
|
|
125
|
-
transform: 'scale(0.975)',
|
|
126
|
-
},
|
|
127
|
-
...props.css,
|
|
128
|
-
};
|
|
129
|
-
return (
|
|
130
|
-
<button ref={ref} css={css} class={['button-push-animation', props.size, props.class].join(' ')} disabled={disabled} onClick={onClick}>
|
|
131
|
-
<div class="button-outer">
|
|
132
|
-
<div class="button-inner">
|
|
133
|
-
<span>{props.text}</span>
|
|
134
|
-
</div>
|
|
135
|
-
</div>
|
|
136
|
-
</button>
|
|
137
|
-
);
|
|
138
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { CssProps, RefProps } from 'lupine.web';
|
|
2
|
-
|
|
3
|
-
export enum ButtonSize {
|
|
4
|
-
SmallLarge = 'button-ss',
|
|
5
|
-
Small = 'button-s',
|
|
6
|
-
Medium = 'button-m',
|
|
7
|
-
Large = 'button-l',
|
|
8
|
-
LargeLarge = 'button-ll',
|
|
9
|
-
}
|
|
10
|
-
export type ButtonHookProps = {
|
|
11
|
-
setEnabled?: (enabled: boolean) => void;
|
|
12
|
-
getEnabled?: () => boolean;
|
|
13
|
-
};
|
|
14
|
-
export type ButtonProps = {
|
|
15
|
-
text: string;
|
|
16
|
-
size: ButtonSize;
|
|
17
|
-
disabled?: boolean;
|
|
18
|
-
onClick?: () => void;
|
|
19
|
-
hook?: ButtonHookProps;
|
|
20
|
-
class?: string;
|
|
21
|
-
css?: CssProps;
|
|
22
|
-
};
|
|
23
|
-
export const Button = (props: ButtonProps) => {
|
|
24
|
-
let disabled = props.disabled || false;
|
|
25
|
-
const onClick = () => {
|
|
26
|
-
if (disabled) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (props.onClick) {
|
|
30
|
-
props.onClick();
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
if (props.hook) {
|
|
34
|
-
props.hook.setEnabled = (enabled: boolean) => {
|
|
35
|
-
disabled = !enabled;
|
|
36
|
-
ref.current.disabled = disabled;
|
|
37
|
-
};
|
|
38
|
-
props.hook.getEnabled = () => {
|
|
39
|
-
return !disabled;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const ref: RefProps = {};
|
|
44
|
-
return (
|
|
45
|
-
<button
|
|
46
|
-
ref={ref}
|
|
47
|
-
class={['button-base', props.size, props.class].join(' ')}
|
|
48
|
-
css={props.css}
|
|
49
|
-
disabled={disabled}
|
|
50
|
-
onClick={onClick}
|
|
51
|
-
>
|
|
52
|
-
{props.text}
|
|
53
|
-
</button>
|
|
54
|
-
);
|
|
55
|
-
};
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { CssProps, RefProps } from '../jsx';
|
|
2
|
-
import { Spinner02, SpinnerSize } from './spinner';
|
|
3
|
-
|
|
4
|
-
export type DragRefreshCloseProps = () => void;
|
|
5
|
-
|
|
6
|
-
export type DragRefreshProps = {
|
|
7
|
-
container: string;
|
|
8
|
-
onDragRefresh: (close: DragRefreshCloseProps) => Promise<void>;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const DragFresh = (props: DragRefreshProps) => {
|
|
12
|
-
const css: CssProps = {
|
|
13
|
-
display: 'flex',
|
|
14
|
-
flexDirection: 'column',
|
|
15
|
-
width: '100%',
|
|
16
|
-
height: '0px',
|
|
17
|
-
position: 'relative',
|
|
18
|
-
'.drag-spinner': {
|
|
19
|
-
position: 'fixed',
|
|
20
|
-
top: '0',
|
|
21
|
-
left: '0',
|
|
22
|
-
width: '100%',
|
|
23
|
-
zIndex: 3,
|
|
24
|
-
display: 'none',
|
|
25
|
-
justifyContent: 'center',
|
|
26
|
-
transition: 'opacity 0.5s ease',
|
|
27
|
-
alignItems: 'end',
|
|
28
|
-
backgroundImage: 'linear-gradient(to bottom, rgba(200,200,200,0.8), rgba(255,255,255,0))',
|
|
29
|
-
},
|
|
30
|
-
'&.show .drag-spinner': {
|
|
31
|
-
display: 'flex',
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const closeSpin = () => {
|
|
36
|
-
const spinnerDom = ref.$('.drag-spinner') as HTMLDivElement;
|
|
37
|
-
if (!spinnerDom) return;
|
|
38
|
-
spinnerDom.style.opacity = '0';
|
|
39
|
-
setTimeout(() => {
|
|
40
|
-
spinnerDom.style.opacity = '1';
|
|
41
|
-
spinnerDom.parentElement!.classList.remove('show');
|
|
42
|
-
}, 300);
|
|
43
|
-
};
|
|
44
|
-
const ref: RefProps = {
|
|
45
|
-
onLoad: async () => {
|
|
46
|
-
const container = document.querySelector(props.container) as HTMLDivElement;
|
|
47
|
-
const pullDom = ref.current as HTMLDivElement;
|
|
48
|
-
const spinnerDom = ref.$('.drag-spinner') as HTMLDivElement;
|
|
49
|
-
if (!container || !pullDom || !spinnerDom) return;
|
|
50
|
-
let touchstartY = 0;
|
|
51
|
-
let touchstartX = 0;
|
|
52
|
-
let direction = '';
|
|
53
|
-
let needRefresh = false;
|
|
54
|
-
const maxHeight = 150;
|
|
55
|
-
container.addEventListener('touchstart', (e: any) => {
|
|
56
|
-
touchstartY = e.touches[0].clientY;
|
|
57
|
-
touchstartX = e.touches[0].clientX;
|
|
58
|
-
direction = '';
|
|
59
|
-
needRefresh = false;
|
|
60
|
-
});
|
|
61
|
-
container.addEventListener('touchmove', (e: any) => {
|
|
62
|
-
console.log(`window.scrollY: ${window.scrollY}`);
|
|
63
|
-
const touchY = e.touches[0].clientY;
|
|
64
|
-
const touchX = e.touches[0].clientX;
|
|
65
|
-
const movedY = touchY - touchstartY;
|
|
66
|
-
const movedX = touchX - touchstartX;
|
|
67
|
-
if (direction === '') {
|
|
68
|
-
if (movedY > 0) {
|
|
69
|
-
direction = 'Y';
|
|
70
|
-
} else if (movedX > 0) {
|
|
71
|
-
direction = 'X';
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (direction === 'X') {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (window.scrollY === 0) {
|
|
78
|
-
needRefresh = movedY > 30;
|
|
79
|
-
if (movedY > 5) {
|
|
80
|
-
pullDom.classList.add('show');
|
|
81
|
-
spinnerDom.style.height = `${Math.min(maxHeight, movedY)}px`;
|
|
82
|
-
} else {
|
|
83
|
-
pullDom.classList.remove('show');
|
|
84
|
-
spinnerDom.style.height = '0';
|
|
85
|
-
}
|
|
86
|
-
} else if (window.scrollY > Math.min(maxHeight, movedY)) {
|
|
87
|
-
pullDom.classList.remove('show');
|
|
88
|
-
spinnerDom.style.height = '0';
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
container.addEventListener('touchend', (e) => {
|
|
92
|
-
if (direction === 'Y') {
|
|
93
|
-
if (needRefresh) {
|
|
94
|
-
props.onDragRefresh(closeSpin);
|
|
95
|
-
} else {
|
|
96
|
-
closeSpin();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
direction = '';
|
|
100
|
-
});
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
return (
|
|
104
|
-
<div css={css} ref={ref} class='drag-refresh-box'>
|
|
105
|
-
<div class='drag-spinner'>
|
|
106
|
-
<Spinner02 size={SpinnerSize.Large} />
|
|
107
|
-
</div>
|
|
108
|
-
</div>
|
|
109
|
-
);
|
|
110
|
-
};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { CssProps, RefProps } from '../jsx';
|
|
2
|
-
|
|
3
|
-
export type EditableLabelHookProps = {
|
|
4
|
-
updateValue?: (value: string) => void;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export type EditableLabelProps = {
|
|
8
|
-
text: string;
|
|
9
|
-
type?: 'text' | 'number';
|
|
10
|
-
mandtory?: boolean;
|
|
11
|
-
save?: (value: string) => void;
|
|
12
|
-
hook?: EditableLabelHookProps;
|
|
13
|
-
};
|
|
14
|
-
export const EditableLabel = (props: EditableLabelProps) => {
|
|
15
|
-
let editFlag = false;
|
|
16
|
-
let oldValue = props.text;
|
|
17
|
-
const onDblClick = () => {
|
|
18
|
-
if (editFlag) return;
|
|
19
|
-
editFlag = true;
|
|
20
|
-
const el = ref.$('input.editable-label');
|
|
21
|
-
oldValue = el.value;
|
|
22
|
-
el.removeAttribute('readonly');
|
|
23
|
-
el.classList.remove('not-editable');
|
|
24
|
-
el.setSelectionRange(0, 0);
|
|
25
|
-
};
|
|
26
|
-
const reset = () => {
|
|
27
|
-
const el = ref.$('input.editable-label');
|
|
28
|
-
el.setAttribute('readonly', 'readonly');
|
|
29
|
-
el.classList.add('not-editable');
|
|
30
|
-
oldValue = '';
|
|
31
|
-
editFlag = false;
|
|
32
|
-
return el;
|
|
33
|
-
};
|
|
34
|
-
const onKeyDown = (ev: KeyboardEvent) => {
|
|
35
|
-
if (!editFlag) return;
|
|
36
|
-
if (ev.key === 'Enter') {
|
|
37
|
-
onBlur();
|
|
38
|
-
} else if (ev.key === 'Escape') {
|
|
39
|
-
const el = ref.$('input.editable-label');
|
|
40
|
-
el.value = oldValue;
|
|
41
|
-
reset();
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const onBlur = () => {
|
|
45
|
-
const savedValue = oldValue;
|
|
46
|
-
const el = reset();
|
|
47
|
-
if (savedValue !== el.value) {
|
|
48
|
-
if (props.mandtory === true && !el.value) {
|
|
49
|
-
el.value = savedValue;
|
|
50
|
-
} else {
|
|
51
|
-
props.save?.(el.value);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
if (props.hook) {
|
|
56
|
-
props.hook.updateValue = (value: string) => {
|
|
57
|
-
const el = ref.$('input.editable-label');
|
|
58
|
-
el.value = value;
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
const css: CssProps = {
|
|
62
|
-
'.not-editable': {
|
|
63
|
-
borderColor: 'transparent',
|
|
64
|
-
boxShadow: 'unset',
|
|
65
|
-
},
|
|
66
|
-
'input.editable-label': {
|
|
67
|
-
width: '100%',
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
const ref: RefProps = {};
|
|
71
|
-
return (
|
|
72
|
-
<div css={css} ref={ref}>
|
|
73
|
-
<input
|
|
74
|
-
class='input-base editable-label not-editable'
|
|
75
|
-
onDblClick={onDblClick}
|
|
76
|
-
onKeyDown={onKeyDown}
|
|
77
|
-
value={props.text}
|
|
78
|
-
onBlur={onBlur}
|
|
79
|
-
readOnly
|
|
80
|
-
/>
|
|
81
|
-
</div>
|
|
82
|
-
);
|
|
83
|
-
};
|