lupine.components 1.1.11 → 1.1.14
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 -95
- package/src/components/mobile-components/mobile-header-with-back.tsx +127 -104
- 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 +269 -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 -0
- 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
- package/src/lib/escape-html.ts +0 -9
|
@@ -1,129 +1,129 @@
|
|
|
1
|
-
import { CssProps, RefProps } from 'lupine.web';
|
|
2
|
-
import { Spinner02, SpinnerSize } from './spinner';
|
|
3
|
-
|
|
4
|
-
export type DragRefreshCloseProps = () => void;
|
|
5
|
-
|
|
6
|
-
export type DragRefreshHookProps = {
|
|
7
|
-
setEnable: (enable: boolean) => void;
|
|
8
|
-
updateOnDragRefresh: (onDragRefresh: (close: DragRefreshCloseProps) => Promise<void>) => void;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type DragRefreshProps = {
|
|
12
|
-
container: string;
|
|
13
|
-
onDragRefresh: (close: DragRefreshCloseProps) => Promise<void>;
|
|
14
|
-
hook?: DragRefreshHookProps;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// globally there should be only one DragFresh
|
|
18
|
-
export const DragFresh = (props: DragRefreshProps) => {
|
|
19
|
-
const css: CssProps = {
|
|
20
|
-
display: 'flex',
|
|
21
|
-
flexDirection: 'column',
|
|
22
|
-
width: '100%',
|
|
23
|
-
height: '0px',
|
|
24
|
-
position: 'relative',
|
|
25
|
-
'.drag-spinner': {
|
|
26
|
-
position: 'fixed',
|
|
27
|
-
top: '0',
|
|
28
|
-
left: '0',
|
|
29
|
-
width: '100%',
|
|
30
|
-
zIndex: 'var(--layer-dragged-item)',
|
|
31
|
-
display: 'none',
|
|
32
|
-
justifyContent: 'center',
|
|
33
|
-
transition: 'opacity 0.5s ease',
|
|
34
|
-
alignItems: 'end',
|
|
35
|
-
backgroundImage: 'linear-gradient(to bottom, rgba(200,200,200,0.8), rgba(255,255,255,0))',
|
|
36
|
-
},
|
|
37
|
-
'&.show .drag-spinner': {
|
|
38
|
-
display: 'flex',
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
let isEnabled = true;
|
|
43
|
-
if (props.hook) {
|
|
44
|
-
props.hook.setEnable = (enable: boolean) => {
|
|
45
|
-
isEnabled = enable;
|
|
46
|
-
};
|
|
47
|
-
props.hook.updateOnDragRefresh = (onDragRefresh: (close: DragRefreshCloseProps) => Promise<void>) => {
|
|
48
|
-
props.onDragRefresh = onDragRefresh;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
const closeSpin = () => {
|
|
52
|
-
const spinnerDom = ref.$('.drag-spinner') as HTMLDivElement;
|
|
53
|
-
if (!spinnerDom) return;
|
|
54
|
-
spinnerDom.style.opacity = '0';
|
|
55
|
-
setTimeout(() => {
|
|
56
|
-
spinnerDom.style.opacity = '1';
|
|
57
|
-
spinnerDom.parentElement!.classList.remove('show');
|
|
58
|
-
}, 300);
|
|
59
|
-
};
|
|
60
|
-
const ref: RefProps = {
|
|
61
|
-
onLoad: async () => {
|
|
62
|
-
const container = document.querySelector(props.container) as HTMLDivElement;
|
|
63
|
-
const pullDom = ref.current as HTMLDivElement;
|
|
64
|
-
const spinnerDom = ref.$('.drag-spinner') as HTMLDivElement;
|
|
65
|
-
if (!container || !pullDom || !spinnerDom) return;
|
|
66
|
-
let touchstartY = 0;
|
|
67
|
-
let touchstartX = 0;
|
|
68
|
-
let direction: 'X' | 'Y' | '' = '';
|
|
69
|
-
let needRefresh = false;
|
|
70
|
-
const maxHeight = 150;
|
|
71
|
-
container.addEventListener('touchstart', (e: any) => {
|
|
72
|
-
if (!isEnabled) return;
|
|
73
|
-
touchstartY = e.touches[0].clientY;
|
|
74
|
-
touchstartX = e.touches[0].clientX;
|
|
75
|
-
direction = '';
|
|
76
|
-
needRefresh = false;
|
|
77
|
-
});
|
|
78
|
-
container.addEventListener('touchmove', (e: any) => {
|
|
79
|
-
if (!isEnabled) return;
|
|
80
|
-
const touchY = e.touches[0].clientY;
|
|
81
|
-
const touchX = e.touches[0].clientX;
|
|
82
|
-
const movedY = touchY - touchstartY;
|
|
83
|
-
const movedX = touchX - touchstartX;
|
|
84
|
-
if (direction === '') {
|
|
85
|
-
if (Math.abs(movedY) > Math.abs(movedX)) {
|
|
86
|
-
direction = 'Y';
|
|
87
|
-
} else {
|
|
88
|
-
direction = 'X';
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
// console.log(`direction: ${direction}, movedX: ${movedX}, movedY: ${movedY}, container.scrollTop: ${container.scrollTop}`);
|
|
92
|
-
if (direction !== 'Y') {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
if (container.scrollTop <= 0 && movedY > 5) {
|
|
96
|
-
needRefresh = movedY > 60;
|
|
97
|
-
if (movedY > 5) {
|
|
98
|
-
pullDom.classList.add('show');
|
|
99
|
-
spinnerDom.style.height = `${Math.min(maxHeight, movedY)}px`;
|
|
100
|
-
} else {
|
|
101
|
-
pullDom.classList.remove('show');
|
|
102
|
-
spinnerDom.style.height = '0';
|
|
103
|
-
}
|
|
104
|
-
} else {
|
|
105
|
-
pullDom.classList.remove('show');
|
|
106
|
-
spinnerDom.style.height = '0';
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
container.addEventListener('touchend', (e) => {
|
|
110
|
-
if (!isEnabled) return;
|
|
111
|
-
if (direction === 'Y') {
|
|
112
|
-
if (needRefresh) {
|
|
113
|
-
props.onDragRefresh(closeSpin);
|
|
114
|
-
} else {
|
|
115
|
-
closeSpin();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
direction = '';
|
|
119
|
-
});
|
|
120
|
-
},
|
|
121
|
-
};
|
|
122
|
-
return (
|
|
123
|
-
<div css={css} ref={ref} class='drag-refresh-box'>
|
|
124
|
-
<div class='drag-spinner'>
|
|
125
|
-
<Spinner02 size={SpinnerSize.Large} />
|
|
126
|
-
</div>
|
|
127
|
-
</div>
|
|
128
|
-
);
|
|
129
|
-
};
|
|
1
|
+
import { CssProps, RefProps } from 'lupine.web';
|
|
2
|
+
import { Spinner02, SpinnerSize } from './spinner';
|
|
3
|
+
|
|
4
|
+
export type DragRefreshCloseProps = () => void;
|
|
5
|
+
|
|
6
|
+
export type DragRefreshHookProps = {
|
|
7
|
+
setEnable: (enable: boolean) => void;
|
|
8
|
+
updateOnDragRefresh: (onDragRefresh: (close: DragRefreshCloseProps) => Promise<void>) => void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type DragRefreshProps = {
|
|
12
|
+
container: string;
|
|
13
|
+
onDragRefresh: (close: DragRefreshCloseProps) => Promise<void>;
|
|
14
|
+
hook?: DragRefreshHookProps;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// globally there should be only one DragFresh
|
|
18
|
+
export const DragFresh = (props: DragRefreshProps) => {
|
|
19
|
+
const css: CssProps = {
|
|
20
|
+
display: 'flex',
|
|
21
|
+
flexDirection: 'column',
|
|
22
|
+
width: '100%',
|
|
23
|
+
height: '0px',
|
|
24
|
+
position: 'relative',
|
|
25
|
+
'.drag-spinner': {
|
|
26
|
+
position: 'fixed',
|
|
27
|
+
top: '0',
|
|
28
|
+
left: '0',
|
|
29
|
+
width: '100%',
|
|
30
|
+
zIndex: 'var(--layer-dragged-item)',
|
|
31
|
+
display: 'none',
|
|
32
|
+
justifyContent: 'center',
|
|
33
|
+
transition: 'opacity 0.5s ease',
|
|
34
|
+
alignItems: 'end',
|
|
35
|
+
backgroundImage: 'linear-gradient(to bottom, rgba(200,200,200,0.8), rgba(255,255,255,0))',
|
|
36
|
+
},
|
|
37
|
+
'&.show .drag-spinner': {
|
|
38
|
+
display: 'flex',
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
let isEnabled = true;
|
|
43
|
+
if (props.hook) {
|
|
44
|
+
props.hook.setEnable = (enable: boolean) => {
|
|
45
|
+
isEnabled = enable;
|
|
46
|
+
};
|
|
47
|
+
props.hook.updateOnDragRefresh = (onDragRefresh: (close: DragRefreshCloseProps) => Promise<void>) => {
|
|
48
|
+
props.onDragRefresh = onDragRefresh;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const closeSpin = () => {
|
|
52
|
+
const spinnerDom = ref.$('.drag-spinner') as HTMLDivElement;
|
|
53
|
+
if (!spinnerDom) return;
|
|
54
|
+
spinnerDom.style.opacity = '0';
|
|
55
|
+
setTimeout(() => {
|
|
56
|
+
spinnerDom.style.opacity = '1';
|
|
57
|
+
spinnerDom.parentElement!.classList.remove('show');
|
|
58
|
+
}, 300);
|
|
59
|
+
};
|
|
60
|
+
const ref: RefProps = {
|
|
61
|
+
onLoad: async () => {
|
|
62
|
+
const container = document.querySelector(props.container) as HTMLDivElement;
|
|
63
|
+
const pullDom = ref.current as HTMLDivElement;
|
|
64
|
+
const spinnerDom = ref.$('.drag-spinner') as HTMLDivElement;
|
|
65
|
+
if (!container || !pullDom || !spinnerDom) return;
|
|
66
|
+
let touchstartY = 0;
|
|
67
|
+
let touchstartX = 0;
|
|
68
|
+
let direction: 'X' | 'Y' | '' = '';
|
|
69
|
+
let needRefresh = false;
|
|
70
|
+
const maxHeight = 150;
|
|
71
|
+
container.addEventListener('touchstart', (e: any) => {
|
|
72
|
+
if (!isEnabled) return;
|
|
73
|
+
touchstartY = e.touches[0].clientY;
|
|
74
|
+
touchstartX = e.touches[0].clientX;
|
|
75
|
+
direction = '';
|
|
76
|
+
needRefresh = false;
|
|
77
|
+
});
|
|
78
|
+
container.addEventListener('touchmove', (e: any) => {
|
|
79
|
+
if (!isEnabled) return;
|
|
80
|
+
const touchY = e.touches[0].clientY;
|
|
81
|
+
const touchX = e.touches[0].clientX;
|
|
82
|
+
const movedY = touchY - touchstartY;
|
|
83
|
+
const movedX = touchX - touchstartX;
|
|
84
|
+
if (direction === '') {
|
|
85
|
+
if (Math.abs(movedY) > Math.abs(movedX)) {
|
|
86
|
+
direction = 'Y';
|
|
87
|
+
} else {
|
|
88
|
+
direction = 'X';
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// console.log(`direction: ${direction}, movedX: ${movedX}, movedY: ${movedY}, container.scrollTop: ${container.scrollTop}`);
|
|
92
|
+
if (direction !== 'Y') {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (container.scrollTop <= 0 && movedY > 5) {
|
|
96
|
+
needRefresh = movedY > 60;
|
|
97
|
+
if (movedY > 5) {
|
|
98
|
+
pullDom.classList.add('show');
|
|
99
|
+
spinnerDom.style.height = `${Math.min(maxHeight, movedY)}px`;
|
|
100
|
+
} else {
|
|
101
|
+
pullDom.classList.remove('show');
|
|
102
|
+
spinnerDom.style.height = '0';
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
pullDom.classList.remove('show');
|
|
106
|
+
spinnerDom.style.height = '0';
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
container.addEventListener('touchend', (e) => {
|
|
110
|
+
if (!isEnabled) return;
|
|
111
|
+
if (direction === 'Y') {
|
|
112
|
+
if (needRefresh) {
|
|
113
|
+
props.onDragRefresh(closeSpin);
|
|
114
|
+
} else {
|
|
115
|
+
closeSpin();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
direction = '';
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
return (
|
|
123
|
+
<div css={css} ref={ref} class='drag-refresh-box'>
|
|
124
|
+
<div class='drag-spinner'>
|
|
125
|
+
<Spinner02 size={SpinnerSize.Large} />
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
};
|
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
import { CssProps, RefProps } from 'lupine.web';
|
|
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
|
-
};
|
|
1
|
+
import { CssProps, RefProps } from 'lupine.web';
|
|
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
|
+
};
|