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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 uuware
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # lupine.js
2
+
3
+ LupineJs is a React-like, extremely fast, small size and lightweight frontend framework.
@@ -0,0 +1,14 @@
1
+ /**
2
+ * JSX.Element factory used by Typescript's JSX transform
3
+ * @param type
4
+ * @param props
5
+ */
6
+ function jsx(type, props) {
7
+ return { type, props };
8
+ }
9
+
10
+ function Fragment(props) {
11
+ return { type: 'Fragment', props };
12
+ }
13
+
14
+ export { jsx as jsx, jsx as jsxs, jsx as jsxDEV, Fragment };
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "jsx-runtime",
3
+ "amdName": "jsxRuntime",
4
+ "version": "1.0.0",
5
+ "private": true,
6
+ "description": "Lupine.js JSX runtime",
7
+ "main": "index.js",
8
+ "module": "index.js",
9
+ "umd:main": "index.js",
10
+ "source": "index.js",
11
+ "types": "src/index.d.ts",
12
+ "license": "MIT",
13
+ "peerDependencies": {
14
+ "lupine.js": "^1.0.0"
15
+ }
16
+ }
@@ -0,0 +1,2 @@
1
+ import { JSXInternal } from '../../src/jsx';
2
+ export { JSXInternal as JSX };
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "lupine.web",
3
+ "version": "1.0.14",
4
+ "license": "MIT",
5
+ "author": "uuware.com",
6
+ "homepage": "https://uuware.com/",
7
+ "description": "lupine.web is a extremely fast, small size and lightweight frontend framework, using React TSX syntax.",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/uuware/lupine.web.git"
11
+ },
12
+ "main": "src/index.ts",
13
+ "source": "src/index.ts",
14
+ "types": "src/index.ts",
15
+ "engines": {
16
+ "node": ">= 20"
17
+ },
18
+ "exports": {
19
+ ".": {
20
+ "types": "./src/index.ts",
21
+ "browser": "./src/index.ts",
22
+ "umd": "./src/index.ts",
23
+ "import": "./src/index.ts",
24
+ "require": "./src/index.ts"
25
+ },
26
+ "./jsx-runtime": {
27
+ "types": "./jsx-runtime/src/index.d.ts",
28
+ "browser": "./jsx-runtime/index.js",
29
+ "umd": "./jsx-runtime/index.js",
30
+ "import": "./jsx-runtime/index.js",
31
+ "require": "./jsx-runtime/index.js"
32
+ }
33
+ },
34
+ "keywords": [
35
+ "frontend",
36
+ "responsive",
37
+ "lightweight",
38
+ "grid"
39
+ ],
40
+ "scripts": {
41
+ "note": "echo 'build is not needed as the typescript code is supposed to be referred directly from other projects'",
42
+ "npm-publish": "npm publish --access public",
43
+ "build": "tsc"
44
+ },
45
+ "peerDependencies": {
46
+ "jsx-runtime": "^1.0.0"
47
+ },
48
+ "devDependencies": {
49
+ "@types/node": "^22.10.5"
50
+ }
51
+ }
@@ -0,0 +1,16 @@
1
+ import { darkThemes } from './dark-themes';
2
+ import { lightThemes } from './light-themes';
3
+
4
+ export const baseThemes: { [key: string]: { [key: string]: string } } = {
5
+ light: lightThemes,
6
+ dark: darkThemes,
7
+ lightGreen: {
8
+ ...lightThemes,
9
+ '--background-primary': '#d8ffe3', // Primary background
10
+ '--color-primary': '#303030', // Primary text color
11
+ backgroundPrimary: '', // Primary background
12
+ backgroundOnPrimary: '', // Background for surfaces on top of primary background
13
+ backgroundSecondary: '#f5f5f7', // Secondary background
14
+ backgroundOnSecondary: '#e5e5e7', // Background for surfaces on top of secondary background
15
+ },
16
+ };
@@ -0,0 +1,85 @@
1
+ import { sharedThemes } from './shared-themes';
2
+
3
+ export const darkThemes: { [key: string]: string } = {
4
+ ...sharedThemes,
5
+ '--theme-name': 'dark',
6
+
7
+ '--scrollbar-bg': '#1c1c1c',
8
+ '--scrollbar-thumb-bg': '#373636',
9
+ '--scrollbar-active-thumb-bg': '#5b5b5b',
10
+
11
+ '--primary-color': '#aeaeae',
12
+ '--primary-color-disabled': '#7d7d7d',
13
+ '--primary-bg-color': '#000000',
14
+ '--primary-border-color': '#aeaeae',
15
+ '--primary-border': '1px solid var(--primary-border-color)',
16
+ // '--secondary-color': '#b3b3b3',
17
+ // '--secondary-bg-color': '#151515',
18
+ // '--secondary-border': '1px solid #303030',
19
+ '--primary-opacity': '0.5', // used for dark theme
20
+ '--primary-disabled-opacity': '0.7', // used for dark theme
21
+ '--primary-accent-color': '#0c3c63', // used for radio and checkbox's background color
22
+
23
+ // including menus, tabs
24
+ '--activatable-color-normal': 'var(--primary-color)',
25
+ '--activatable-bg-color-normal': 'var(--primary-bg-color)',
26
+ '--activatable-color-hover': '#e2e2e2',
27
+ '--activatable-bg-color-hover': '#6d6d6d',
28
+ '--activatable-color-selected': '#c2c2c2',
29
+ '--activatable-bg-color-selected': '#5d5d5d',
30
+ // '--menu-color-hover': '#303030',
31
+ // '--menu-color': 'var(--primary-color)', //'#2a2a2a',
32
+ // '--menu-bg-color': 'var(--primary-bg-color)', //'#2a2a2a',
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': '#000000',
40
+ // '--sidebar-sub-color': 'var(--sidebar-color)',
41
+ // '--sidebar-sub-bg-color': '#000000',
42
+ '--sidebar-border': '1px solid #303030',
43
+ // '--sidebar-hover-color': 'var(--sidebar-color)',
44
+ // '--sidebar-hover-bg-color': '#000000',
45
+
46
+ '--row-1-bg-color': '#212121',
47
+ '--row-2-bg-color': '#303030',
48
+ '--row-hover-bg-color': '#383838',
49
+
50
+ '--success-color': '#04AA6D',
51
+ '--info-color': '#2196F3',
52
+ '--warning-color': '#ff9800',
53
+ '--error-color': '#f44336',
54
+ '--success-bg-color': '#10553b',
55
+ '--info-bg-color': '#1a588a',
56
+ '--warning-bg-color': '#a36305',
57
+ '--error-bg-color': '#882c25',
58
+ '--notice-color-with-bg': '#ececec',
59
+
60
+ '--cover-mask-bg-color': '#878a9460',
61
+ '--cover-bg-color': '#202020',
62
+ '--cover-box-shadow': '1px 1px 4px #c6c6c6',
63
+
64
+ '--input-color': '#bdbdbd',
65
+ '--input-bg-color': '#000000',
66
+ '--input-box-shadow': '0px 0px 0px #000000, 1px 1px 0px 0px #50505045',
67
+ '--input-border-focus': '1px solid #0074d9',
68
+
69
+ '--button-color': '#bdbdbd',
70
+ '--button-bg': '-webkit-linear-gradient(top, #282828 0%, #212223 74%, #1a1a1a 100%)', // darker
71
+ '--button-bg-hover': '-webkit-linear-gradient(top, #282828 0%, #313233 74%, #252525 100%)', // darker
72
+ // '--button-bg': '-webkit-linear-gradient(top, #414141 0%, #373e48 74%, #434242 100%)',
73
+ '--button-border': '1px solid #373e48',
74
+ '--button-box-shadow': 'unset',
75
+
76
+ '--header-color': '#000080',
77
+ '--header-bg-color': '#000000',
78
+
79
+ // '--background-primary': '#353536', // Primary background
80
+ // '--color-primary': '#e0e0e0', // Primary text color
81
+ // backgroundPrimary: '', // Primary background
82
+ // backgroundOnPrimary: '', // Background for surfaces on top of primary background
83
+ // backgroundSecondary: '#f5f5f6', // Secondary background
84
+ // backgroundOnSecondary: '#e5e5e6', // Background for surfaces on top of secondary background
85
+ };
@@ -0,0 +1,4 @@
1
+ export * from './shared-themes';
2
+ export * from './dark-themes';
3
+ export * from './light-themes';
4
+ export * from './base-themes';
@@ -0,0 +1,92 @@
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
+ };
@@ -0,0 +1,50 @@
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
+ };
@@ -0,0 +1,138 @@
1
+ import { CssProps, RefProps } from 'lupine.js';
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
+ };
@@ -0,0 +1,55 @@
1
+ import { CssProps, RefProps } from 'lupine.js';
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
+ };
@@ -0,0 +1,110 @@
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
+ };