lupine.web 1.0.16 → 1.0.18

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 (71) hide show
  1. package/package.json +1 -5
  2. package/src/core/bind-lang.ts +6 -5
  3. package/src/core/bind-links.ts +2 -2
  4. package/src/core/bind-styles.ts +6 -5
  5. package/src/core/bind-theme.ts +6 -5
  6. package/src/core/export-lupine.ts +64 -0
  7. package/src/core/index.ts +2 -1
  8. package/src/core/{core.ts → initialize.ts} +9 -67
  9. package/src/core/page-router.ts +3 -2
  10. package/src/core/server-cookie.ts +5 -3
  11. package/src/index.ts +0 -1
  12. package/src/lib/index.ts +2 -13
  13. package/src/lib/is-frontend.ts +3 -0
  14. package/src/styles/index.ts +0 -5
  15. package/src/components/button-push-animation.tsx +0 -138
  16. package/src/components/button.tsx +0 -55
  17. package/src/components/drag-refresh.tsx +0 -110
  18. package/src/components/editable-label.tsx +0 -83
  19. package/src/components/float-window.tsx +0 -226
  20. package/src/components/grid.tsx +0 -18
  21. package/src/components/html-var.tsx +0 -41
  22. package/src/components/index.ts +0 -36
  23. package/src/components/input-with-title.tsx +0 -24
  24. package/src/components/link-item.tsx +0 -13
  25. package/src/components/link-list.tsx +0 -62
  26. package/src/components/menu-bar.tsx +0 -220
  27. package/src/components/menu-item-props.tsx +0 -10
  28. package/src/components/menu-sidebar.tsx +0 -289
  29. package/src/components/message-box.tsx +0 -44
  30. package/src/components/meta-data.tsx +0 -36
  31. package/src/components/meta-description.tsx +0 -12
  32. package/src/components/modal.tsx +0 -29
  33. package/src/components/notice-message.tsx +0 -119
  34. package/src/components/page-title.tsx +0 -6
  35. package/src/components/paging-link.tsx +0 -100
  36. package/src/components/panel.tsx +0 -21
  37. package/src/components/popup-menu.tsx +0 -218
  38. package/src/components/progress.tsx +0 -91
  39. package/src/components/redirect.tsx +0 -19
  40. package/src/components/resizable-splitter.tsx +0 -129
  41. package/src/components/select-with-title.tsx +0 -37
  42. package/src/components/spinner.tsx +0 -100
  43. package/src/components/svg.tsx +0 -24
  44. package/src/components/tabs.tsx +0 -252
  45. package/src/components/text-glow.tsx +0 -36
  46. package/src/components/text-wave.tsx +0 -54
  47. package/src/components/theme-selector.tsx +0 -32
  48. package/src/components/toggle-base.tsx +0 -260
  49. package/src/components/toggle-switch.tsx +0 -156
  50. package/src/lib/date-utils.ts +0 -317
  51. package/src/lib/deep-merge.ts +0 -37
  52. package/src/lib/document-ready.ts +0 -36
  53. package/src/lib/dom/calculate-text-width.ts +0 -13
  54. package/src/lib/dom/download-stream.ts +0 -17
  55. package/src/lib/dom/download.ts +0 -12
  56. package/src/lib/dom/index.ts +0 -71
  57. package/src/lib/dynamical-load.ts +0 -138
  58. package/src/lib/format-bytes.ts +0 -11
  59. package/src/lib/lite-dom.ts +0 -227
  60. package/src/lib/message-hub.ts +0 -105
  61. package/src/lib/observable.ts +0 -188
  62. package/src/lib/promise-timeout.ts +0 -1
  63. package/src/lib/simple-storage.ts +0 -40
  64. package/src/lib/stop-propagation.ts +0 -7
  65. package/src/lib/upload-file.ts +0 -68
  66. package/src/styles/base-themes.ts +0 -17
  67. package/src/styles/dark-themes.ts +0 -86
  68. package/src/styles/light-themes.ts +0 -93
  69. package/src/styles/media-query.ts +0 -93
  70. package/src/styles/shared-themes.ts +0 -52
  71. /package/src/lib/{dom/cookie.ts → cookie.ts} +0 -0
@@ -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
- };
@@ -1,226 +0,0 @@
1
- import { mountComponents } from '../core';
2
- import { CssProps, RefProps, VNode } from '../jsx';
3
- import { stopPropagation } from '../lib';
4
-
5
- export type FloatWindowCloseProps = () => void;
6
-
7
- export type FloatWindowShowProps = {
8
- title: string;
9
- children: VNode<any>;
10
- buttons?: string[];
11
- contentMaxHeight?: string;
12
- contentMinWidth?: string;
13
- noMoving?: boolean;
14
- noModal?: boolean;
15
- closeEvent?: () => void;
16
- handleClicked: (index: number, close: FloatWindowCloseProps) => void;
17
- closeWhenClickOutside?: boolean; // default false
18
- };
19
-
20
- // because it's over a mask, so it can use primary colors
21
- export class FloatWindow {
22
- static hostNode: HTMLElement;
23
-
24
- private static initialized = false;
25
- private static pressed = false;
26
- private static startX = 0;
27
- private static startY = 0;
28
- private static startTop = 0;
29
- private static startLeft = 0;
30
-
31
- static init() {
32
- window.addEventListener('mousemove', FloatWindow.onMousemove.bind(FloatWindow), false);
33
- document.documentElement.addEventListener('mouseup', FloatWindow.onMouseup.bind(FloatWindow), false);
34
- }
35
-
36
- static async show({
37
- title,
38
- children,
39
- contentMaxHeight,
40
- contentMinWidth,
41
- buttons,
42
- noMoving = false,
43
- noModal = false,
44
- closeEvent,
45
- handleClicked,
46
- closeWhenClickOutside = false,
47
- }: FloatWindowShowProps): Promise<FloatWindowCloseProps> {
48
- const onClickContainer = (event: any) => {
49
- if (closeWhenClickOutside !== false && event.target.className === 'fwin-box') {
50
- handleClose();
51
- }
52
- };
53
- const handleClose = () => {
54
- closeEvent?.();
55
- ref.current.classList.add('transition');
56
- ref.current.classList.remove('animation');
57
- setTimeout(() => {
58
- base.remove();
59
- }, 300);
60
- };
61
-
62
- const base = document.createElement('div');
63
- const onMousedown = (event: any) => {
64
- if (noMoving) return;
65
-
66
- if (!this.initialized) {
67
- this.initialized = true;
68
- this.init();
69
- }
70
-
71
- FloatWindow.hostNode = ref.current;
72
- FloatWindow.onMousedown.bind(FloatWindow)(event);
73
- };
74
-
75
- const newButtons = !buttons || buttons.length === 0 ? ['OK', 'Cancel'] : buttons;
76
- const onClickButtons = (index: number) => {
77
- handleClicked(index, handleClose);
78
- };
79
-
80
- const ref: RefProps = {
81
- onLoad: async () => {
82
- ref.current.classList.add('transition', 'animation');
83
- setTimeout(() => {
84
- // don't need transition for moving
85
- ref.current.classList.remove('transition');
86
- }, 300);
87
- },
88
- };
89
- const cssContainer: CssProps = {
90
- position: noModal ? '' : 'fixed',
91
- top: 0,
92
- left: 0,
93
- width: '100%',
94
- height: '100%',
95
- backgroundColor: noModal ? '' : 'var(--cover-mask-bg-color)',
96
- '.fwin-body': {
97
- position: 'fixed',
98
- top: '50%',
99
- left: '50%',
100
- transform: 'translate(-50%, -50%) scale(0.1)',
101
- color: 'var(--primary-color)',
102
- backgroundColor: 'var(--cover-bg-color)', //'#fefefe',
103
- border: 'var(--primary-border)', //'1px solid #888',
104
- borderRadius: '6px',
105
- minWidth: contentMinWidth ? contentMinWidth : '',
106
- maxWidth: '90%',
107
- boxShadow: 'var(--cover-box-shadow)', //'#0000004c 0px 19px 38px, #00000038 0px 15px 12px',
108
- opacity: 0,
109
- zIndex: 'var(--layer-float-window)',
110
- '&.transition': {
111
- transition: 'all 0.3s',
112
- },
113
- '&.animation': {
114
- transform: 'translate(-50%, -50%) scale(1)',
115
- opacity: 1,
116
- },
117
- '&.animation-close': {
118
- transition: 'all 0.3s',
119
- transform: 'translate(-50%, -50%) scale(0)',
120
- opacity: 0,
121
- },
122
- '.fwin-title': {
123
- padding: '10px 15px 5px',
124
- borderBottom: 'var(--primary-border)', //'1px solid #e9ecef',
125
- '.fwin-close': {
126
- color: '#aaaaaa',
127
- float: 'right',
128
- fontSize: '26px',
129
- fontWeight: 'bold',
130
- cursor: 'pointer',
131
- marginTop: '-8px',
132
- marginRight: '-10px',
133
- },
134
- '.fwin-close:hover': {
135
- transition: 'all 300ms ease',
136
- color: '#555555',
137
- },
138
- },
139
- '.fwin-content': {
140
- padding: '15px',
141
- maxHeight: contentMaxHeight ? `min(${contentMaxHeight}, calc(100% - 100px))` : 'calc(100% - 100px)',
142
- overflowY: 'auto',
143
- },
144
- '.fwin-bottom': {
145
- display: 'flex',
146
- padding: '5px 15px',
147
- borderTop: 'var(--primary-border)', //'1px solid #e9ecef',
148
- justifyContent: 'end',
149
- '>div': {
150
- marginLeft: '5px',
151
- },
152
- },
153
- },
154
- };
155
- const component = (
156
- <div css={cssContainer} class='fwin-box' onClick={onClickContainer}>
157
- <div ref={ref} class='fwin-body' onMouseDown={onMousedown}>
158
- <div class='fwin-title'>
159
- {title}
160
- <span class='fwin-close' onClick={handleClose}>
161
- ×
162
- </span>
163
- </div>
164
- <div class='fwin-content'>{children}</div>
165
- <div class='fwin-bottom'>
166
- {newButtons.map((i, index) => (
167
- <button
168
- class='button-base button-s mr-m'
169
- onClick={() => {
170
- onClickButtons(index);
171
- }}
172
- >
173
- {i}
174
- </button>
175
- ))}
176
- </div>
177
- </div>
178
- </div>
179
- );
180
- base.style.position = 'fixed';
181
- document.body.appendChild(base);
182
- await mountComponents(base, component);
183
- return handleClose;
184
- }
185
-
186
- static onMousedown(event: any) {
187
- if (event.buttons !== 1 || event.button !== 0) return;
188
- if (event.srcElement.className !== 'fwin-title') return;
189
-
190
- this.pressed = true;
191
- this.startX = event.clientX;
192
- this.startY = event.clientY;
193
- const nodeStyle = document.defaultView!.getComputedStyle(this.hostNode);
194
- this.startTop = parseInt(nodeStyle['top'], 10);
195
- this.startLeft = parseInt(nodeStyle['left'], 10);
196
- }
197
-
198
- static onMousemove(event: any) {
199
- if (!this.pressed || event.buttons !== 1 || event.button !== 0) {
200
- return;
201
- }
202
-
203
- // prevent text/element selection when drag
204
- stopPropagation(event);
205
- if (
206
- event.clientX < 0 ||
207
- event.clientY < 0 ||
208
- event.clientX > window.innerWidth ||
209
- event.clientY > window.innerHeight
210
- ) {
211
- return;
212
- }
213
-
214
- let movedX = this.startLeft + (event.clientX - this.startX);
215
- let movedY = this.startTop + (event.clientY - this.startY);
216
- if (movedY <= 0) movedY = 0;
217
- if (movedX <= 0) movedX = 0;
218
-
219
- this.hostNode.style.top = movedY + 'px';
220
- this.hostNode.style.left = movedX + 'px';
221
- }
222
-
223
- static onMouseup() {
224
- if (this.pressed) this.pressed = false;
225
- }
226
- }
@@ -1,18 +0,0 @@
1
- export const Grid = ({ gridOption }: { gridOption: any }) => {
2
- const cssContainer: any = {
3
- display: 'grid',
4
- ...gridOption.options,
5
- };
6
- const cells: any = [];
7
- gridOption.cells.forEach((cell: any, index: number) => {
8
- const name = cell.name || 'cell' + index;
9
- cssContainer[`.${name}`] = cell.option;
10
- cells.push(<div class={name}>{cell.component}</div>);
11
- });
12
- const className = 'grid-box' + (gridOption.className ? ` ${gridOption.className}` : '');
13
- return (
14
- <div css={cssContainer} class={className}>
15
- {cells}
16
- </div>
17
- );
18
- };
@@ -1,41 +0,0 @@
1
- import { mountComponents } from '../core/mount-components';
2
- import { RefProps, VNode } from '../jsx';
3
-
4
- export const HtmlVar = (initial?: string | VNode<any>) => {
5
- let _value: string | VNode<any> = initial || '';
6
- let _dirty = false;
7
- const waitUpdate = async (value: string | VNode<any>) => {
8
- if (!ref.current) return;
9
- if (typeof value === 'object' && value.type && value.props) {
10
- await mountComponents(ref.current, value);
11
- } else {
12
- ref.current.innerHTML = value;
13
- }
14
- _dirty = false;
15
- }
16
- const ref: RefProps = { onLoad: async (el: Element) => {
17
- _dirty && waitUpdate(_value);
18
- } };
19
- const FragmentRef = (props: any) => {
20
- return <>{props.children}</>;
21
- };
22
-
23
- return {
24
- set value(value: string | VNode<any>) {
25
- _value = value;
26
- _dirty = true;
27
- waitUpdate(value);
28
- },
29
- get value() {
30
- return ref.current ? ref.current.innerHTML : _value;
31
- },
32
- get ref() {
33
- return ref;
34
- },
35
- // _fragment_ref is a special id to add ref to a fragment and it is processed in mount-components
36
- get node() {
37
- _dirty = false;
38
- return <FragmentRef _fragment_ref={ref}>{_value}</FragmentRef>;
39
- },
40
- };
41
- };
@@ -1,36 +0,0 @@
1
-
2
- export * from './button-push-animation';
3
- export * from './button';
4
- export * from './drag-refresh';
5
- export * from './editable-label';
6
- export * from './float-window';
7
- export * from './grid';
8
- export * from './html-var';
9
- export * from './input-with-title';
10
- export * from './link-item';
11
- export * from './link-list';
12
- export * from './menu-bar';
13
- export * from './menu-item-props';
14
- export * from './menu-sidebar';
15
- export * from './message-box';
16
- export * from './meta-data';
17
- export * from './meta-title';
18
- export * from './meta-description';
19
- export * from './meta-title';
20
- export * from './modal';
21
- export * from './notice-message';
22
- export * from './paging-link';
23
- export * from './panel';
24
- export * from './popup-menu';
25
- export * from './progress';
26
- export * from './redirect';
27
- export * from './resizable-splitter';
28
- export * from './select-with-title';
29
- export * from './spinner';
30
- export * from './svg';
31
- export * from './text-glow';
32
- export * from './text-wave';
33
- export * from './tabs';
34
- export * from './theme-selector';
35
- export * from './toggle-base';
36
- export * from './toggle-switch';
@@ -1,24 +0,0 @@
1
- // used in MessageBox.show
2
- export const InputWithTitle = (
3
- title: string,
4
- defaultValue: string,
5
- onInputChanged?: (option: string) => void,
6
- onInputInputed?: (option: string) => void,
7
- className = 'input-base',
8
- width = '100%',
9
- ) => {
10
- return (
11
- <div>
12
- <div>{title}</div>
13
- <div>
14
- <input
15
- class={className}
16
- style={{ width }}
17
- onChange={(e: any) => onInputChanged?.(e?.target?.value)}
18
- onInput={(e: any) => onInputInputed?.(e?.target?.value)}
19
- value={defaultValue}
20
- />
21
- </div>
22
- </div>
23
- );
24
- };
@@ -1,13 +0,0 @@
1
- export type LinkItemProps = {
2
- className?: string;
3
- text: string;
4
- url: string;
5
- alt?: string;
6
- };
7
- export const LinkItem = (props: LinkItemProps) => {
8
- return (
9
- <a class={['link-item', props.className].join(' ')} href={props.url} alt={props.alt || props.text}>
10
- {props.text}
11
- </a>
12
- );
13
- };
@@ -1,62 +0,0 @@
1
- import { LinkItem } from './link-item';
2
- import { NestMenuItemProps } from './menu-item-props';
3
-
4
- export type LinkListProps = {
5
- title: string;
6
- items: NestMenuItemProps[];
7
- className?: string;
8
- textColor?: string;
9
- backgroundColor?: string;
10
- titleBackgroundColor?: string;
11
- };
12
- export const LinkList = ({
13
- title,
14
- items,
15
- className,
16
- textColor = 'black',
17
- backgroundColor = '#d3d3d3',
18
- titleBackgroundColor = '#b6b6b6',
19
- }: LinkListProps) => {
20
- const css: any = {
21
- width: '100%',
22
- margin: 'auto',
23
- height: 'auto',
24
- backgroundColor,
25
- '.link-list-title, .link-list-top': {
26
- display: 'flex',
27
- width: '100%',
28
- flexWrap: 'wrap',
29
- padding: '0 16px',
30
- },
31
- '.link-list-title': {
32
- backgroundColor: titleBackgroundColor,
33
- },
34
- '.link-list-item': {
35
- display: 'inline-block',
36
- color: textColor,
37
- padding: '8px 16px 8px 0',
38
- textDecoration: 'none',
39
- },
40
- '.link-list-item:last-child': {
41
- paddingRight: 'unset',
42
- },
43
- '.link-list-title .link-list-item': {
44
- fontSize: '18px',
45
- },
46
- };
47
-
48
- return (
49
- <div css={css} class={['link-list-box', className].join(' ')}>
50
- {title && (
51
- <div class='link-list-title'>
52
- <div class='link-list-item'>{title}</div>
53
- </div>
54
- )}
55
- <div class='link-list-top'>
56
- {items.map((item) => {
57
- return <LinkItem className='link-list-item' url={item.url} alt={item.alt} text={item.text} />;
58
- })}
59
- </div>
60
- </div>
61
- );
62
- };