lupine.web 1.0.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.
Files changed (94) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/jsx-runtime/index.js +14 -0
  4. package/jsx-runtime/package.json +16 -0
  5. package/jsx-runtime/src/index.d.ts +2 -0
  6. package/package.json +51 -0
  7. package/src/assets/themes/base-themes.ts +16 -0
  8. package/src/assets/themes/dark-themes.ts +85 -0
  9. package/src/assets/themes/index.ts +4 -0
  10. package/src/assets/themes/light-themes.ts +92 -0
  11. package/src/assets/themes/shared-themes.ts +50 -0
  12. package/src/components/button-push-animation.tsx +138 -0
  13. package/src/components/button.tsx +55 -0
  14. package/src/components/drag-refresh.tsx +110 -0
  15. package/src/components/editable-label.tsx +83 -0
  16. package/src/components/float-window.tsx +226 -0
  17. package/src/components/grid.tsx +18 -0
  18. package/src/components/html-var.tsx +41 -0
  19. package/src/components/index.ts +36 -0
  20. package/src/components/input-with-title.tsx +24 -0
  21. package/src/components/link-item.tsx +13 -0
  22. package/src/components/link-list.tsx +62 -0
  23. package/src/components/menu-bar.tsx +220 -0
  24. package/src/components/menu-item-props.tsx +10 -0
  25. package/src/components/menu-sidebar.tsx +289 -0
  26. package/src/components/message-box.tsx +44 -0
  27. package/src/components/meta-data.tsx +54 -0
  28. package/src/components/meta-description.tsx +19 -0
  29. package/src/components/meta-title.tsx +19 -0
  30. package/src/components/modal.tsx +29 -0
  31. package/src/components/notice-message.tsx +119 -0
  32. package/src/components/paging-link.tsx +100 -0
  33. package/src/components/panel.tsx +24 -0
  34. package/src/components/popup-menu.tsx +218 -0
  35. package/src/components/progress.tsx +91 -0
  36. package/src/components/redirect.tsx +19 -0
  37. package/src/components/resizable-splitter.tsx +129 -0
  38. package/src/components/select-with-title.tsx +37 -0
  39. package/src/components/spinner.tsx +100 -0
  40. package/src/components/svg.tsx +24 -0
  41. package/src/components/tabs.tsx +252 -0
  42. package/src/components/text-glow.tsx +36 -0
  43. package/src/components/text-wave.tsx +54 -0
  44. package/src/components/theme-selector.tsx +35 -0
  45. package/src/components/toggle-base.tsx +260 -0
  46. package/src/components/toggle-switch.tsx +156 -0
  47. package/src/core/bind-attributes.ts +58 -0
  48. package/src/core/bind-lang.ts +51 -0
  49. package/src/core/bind-links.ts +16 -0
  50. package/src/core/bind-ref.ts +33 -0
  51. package/src/core/bind-styles.ts +180 -0
  52. package/src/core/bind-theme.ts +51 -0
  53. package/src/core/camel-to-hyphens.ts +3 -0
  54. package/src/core/core.ts +179 -0
  55. package/src/core/index.ts +15 -0
  56. package/src/core/mount-components.ts +259 -0
  57. package/src/core/page-loaded-events.ts +16 -0
  58. package/src/core/page-router.ts +170 -0
  59. package/src/core/replace-innerhtml.ts +10 -0
  60. package/src/core/server-cookie.ts +22 -0
  61. package/src/core/web-version.ts +12 -0
  62. package/src/global.d.ts +66 -0
  63. package/src/index.ts +15 -0
  64. package/src/jsx.ts +1041 -0
  65. package/src/lib/date-utils.ts +317 -0
  66. package/src/lib/debug-watch.ts +31 -0
  67. package/src/lib/deep-merge.ts +37 -0
  68. package/src/lib/document-ready.ts +36 -0
  69. package/src/lib/dom/calculate-text-width.ts +13 -0
  70. package/src/lib/dom/cookie.ts +41 -0
  71. package/src/lib/dom/download-stream.ts +17 -0
  72. package/src/lib/dom/download.ts +12 -0
  73. package/src/lib/dom/index.ts +71 -0
  74. package/src/lib/dynamical-load.ts +138 -0
  75. package/src/lib/format-bytes.ts +11 -0
  76. package/src/lib/index.ts +17 -0
  77. package/src/lib/lite-dom.ts +227 -0
  78. package/src/lib/logger.ts +55 -0
  79. package/src/lib/message-hub.ts +105 -0
  80. package/src/lib/observable.ts +188 -0
  81. package/src/lib/promise-timeout.ts +1 -0
  82. package/src/lib/simple-storage.ts +40 -0
  83. package/src/lib/stop-propagation.ts +7 -0
  84. package/src/lib/unique-id.ts +39 -0
  85. package/src/lib/upload-file.ts +68 -0
  86. package/src/lib/web-env.ts +98 -0
  87. package/src/models/index.ts +2 -0
  88. package/src/models/simple-storage-props.ts +9 -0
  89. package/src/models/to-client-delivery-props.ts +8 -0
  90. package/src/types/css-styles.ts +814 -0
  91. package/src/types/css-types.ts +17 -0
  92. package/src/types/index.ts +6 -0
  93. package/src/types/media-query.ts +93 -0
  94. package/tsconfig.json +113 -0
@@ -0,0 +1,83 @@
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
+ };
@@ -0,0 +1,226 @@
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
+ }
@@ -0,0 +1,18 @@
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
+ };
@@ -0,0 +1,41 @@
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
+ };
@@ -0,0 +1,36 @@
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';
@@ -0,0 +1,24 @@
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
+ };
@@ -0,0 +1,13 @@
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
+ };
@@ -0,0 +1,62 @@
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
+ };