create-lupine 1.0.29 → 1.0.31

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 (111) hide show
  1. package/index.js +431 -411
  2. package/package.json +17 -17
  3. package/templates/common/.env.development +7 -7
  4. package/templates/common/.env.mobile +9 -9
  5. package/templates/common/.env.production +7 -7
  6. package/templates/common/_env +66 -58
  7. package/templates/common/_gitignore +25 -25
  8. package/templates/common/apps/server/src/index.ts +79 -76
  9. package/templates/common/apps/server/src/server-env-keys.ts +0 -9
  10. package/templates/common/dev/cp-folder.js +45 -45
  11. package/templates/common/tsconfig.json +128 -128
  12. package/templates/lupine-template-cv-starter/api/package.json +5 -5
  13. package/templates/lupine-template-cv-starter/api/resources/config_default.json +6 -6
  14. package/templates/lupine-template-cv-starter/api/resources/install.sqlite.sql +3 -3
  15. package/templates/lupine-template-cv-starter/api/src/index.ts +15 -15
  16. package/templates/lupine-template-cv-starter/lupine.json +39 -39
  17. package/templates/lupine-template-cv-starter/web/markdown/en/01-experience/index.md +32 -32
  18. package/templates/lupine-template-cv-starter/web/markdown/en/02-projects/index.md +36 -36
  19. package/templates/lupine-template-cv-starter/web/markdown/en/03-skills/index.md +28 -28
  20. package/templates/lupine-template-cv-starter/web/markdown/en/04-education/index.md +16 -16
  21. package/templates/lupine-template-cv-starter/web/markdown/en/index.md +41 -41
  22. package/templates/lupine-template-cv-starter/web/markdown/index.md +7 -7
  23. package/templates/lupine-template-cv-starter/web/markdown/zh/01-experience/index.md +32 -32
  24. package/templates/lupine-template-cv-starter/web/markdown/zh/02-projects/index.md +36 -36
  25. package/templates/lupine-template-cv-starter/web/markdown/zh/03-skills/index.md +28 -28
  26. package/templates/lupine-template-cv-starter/web/markdown/zh/04-education/index.md +17 -17
  27. package/templates/lupine-template-cv-starter/web/markdown/zh/index.md +41 -41
  28. package/templates/lupine-template-cv-starter/web/package.json +5 -5
  29. package/templates/lupine-template-cv-starter/web/src/client-env-keys.ts +5 -5
  30. package/templates/lupine-template-cv-starter/web/src/index.html +16 -16
  31. package/templates/lupine-template-cv-starter/web/src/index.tsx +28 -28
  32. package/templates/lupine-template-cv-starter/web/src/lupine-template-cv-starter/404.html +38 -38
  33. package/templates/lupine-template-cv-starter/web/src/lupine-template-cv-starter/index.html +73 -73
  34. package/templates/lupine-template-cv-starter/web/src/lupine-template-cv-starter/index.tsx +30 -30
  35. package/templates/lupine-template-cv-starter/web/src/markdown-built/en/01-experience/index.html +20 -20
  36. package/templates/lupine-template-cv-starter/web/src/markdown-built/en/02-projects/index.html +28 -28
  37. package/templates/lupine-template-cv-starter/web/src/markdown-built/en/03-skills/index.html +18 -18
  38. package/templates/lupine-template-cv-starter/web/src/markdown-built/en/04-education/index.html +10 -10
  39. package/templates/lupine-template-cv-starter/web/src/markdown-built/en/index.html +20 -20
  40. package/templates/lupine-template-cv-starter/web/src/markdown-built/zh/01-experience/index.html +20 -20
  41. package/templates/lupine-template-cv-starter/web/src/markdown-built/zh/02-projects/index.html +28 -28
  42. package/templates/lupine-template-cv-starter/web/src/markdown-built/zh/03-skills/index.html +18 -18
  43. package/templates/lupine-template-cv-starter/web/src/markdown-built/zh/04-education/index.html +11 -11
  44. package/templates/lupine-template-cv-starter/web/src/markdown-built/zh/index.html +20 -20
  45. package/templates/lupine-template-cv-starter/web/src/styles/base-css.ts +15 -15
  46. package/templates/lupine-template-doc-starter/api/package.json +5 -5
  47. package/templates/lupine-template-doc-starter/api/resources/config_default.json +6 -6
  48. package/templates/lupine-template-doc-starter/api/resources/install.sqlite.sql +3 -3
  49. package/templates/lupine-template-doc-starter/api/src/index.ts +15 -15
  50. package/templates/lupine-template-doc-starter/api/src/resources/config_default.json +6 -6
  51. package/templates/lupine-template-doc-starter/api/src/resources/install.sqlite.sql +3 -3
  52. package/templates/lupine-template-doc-starter/lupine.json +39 -39
  53. package/templates/lupine-template-doc-starter/web/markdown/en/essentials/index.md +6 -6
  54. package/templates/lupine-template-doc-starter/web/markdown/en/essentials/list.md +18 -18
  55. package/templates/lupine-template-doc-starter/web/markdown/en/guide/install.md +18 -18
  56. package/templates/lupine-template-doc-starter/web/markdown/en/guide/started.md +22 -22
  57. package/templates/lupine-template-doc-starter/web/markdown/en/index.md +42 -42
  58. package/templates/lupine-template-doc-starter/web/markdown/index.md +7 -7
  59. package/templates/lupine-template-doc-starter/web/markdown/zh/essentials/index.md +6 -6
  60. package/templates/lupine-template-doc-starter/web/markdown/zh/essentials/list.md +18 -18
  61. package/templates/lupine-template-doc-starter/web/markdown/zh/guide/install.md +18 -18
  62. package/templates/lupine-template-doc-starter/web/markdown/zh/guide/started.md +22 -22
  63. package/templates/lupine-template-doc-starter/web/markdown/zh/index.md +42 -42
  64. package/templates/lupine-template-doc-starter/web/package.json +5 -5
  65. package/templates/lupine-template-doc-starter/web/src/client-env-keys.ts +5 -5
  66. package/templates/lupine-template-doc-starter/web/src/index.html +16 -16
  67. package/templates/lupine-template-doc-starter/web/src/index.tsx +28 -28
  68. package/templates/lupine-template-doc-starter/web/src/lupine-template-doc-starter/404.html +38 -38
  69. package/templates/lupine-template-doc-starter/web/src/lupine-template-doc-starter/index.html +27 -27
  70. package/templates/lupine-template-doc-starter/web/src/lupine-template-doc-starter/index.tsx +30 -30
  71. package/templates/lupine-template-doc-starter/web/src/markdown-built/en/essentials/list.html +8 -8
  72. package/templates/lupine-template-doc-starter/web/src/markdown-built/en/guide/install.html +8 -8
  73. package/templates/lupine-template-doc-starter/web/src/markdown-built/en/guide/started.html +12 -12
  74. package/templates/lupine-template-doc-starter/web/src/markdown-built/zh/essentials/list.html +8 -8
  75. package/templates/lupine-template-doc-starter/web/src/markdown-built/zh/guide/install.html +8 -8
  76. package/templates/lupine-template-doc-starter/web/src/markdown-built/zh/guide/started.html +12 -12
  77. package/templates/lupine-template-doc-starter/web/src/styles/base-css.ts +15 -15
  78. package/templates/lupine-template-hello-world/api/resources/install.sqlite.sql +3 -3
  79. package/templates/lupine-template-hello-world/api/src/index.ts +4 -4
  80. package/templates/lupine-template-hello-world/api/src/service/root-api.ts +18 -18
  81. package/templates/lupine-template-hello-world/lupine.json +22 -22
  82. package/templates/lupine-template-hello-world/web/package.json +6 -6
  83. package/templates/lupine-template-hello-world/web/src/index.html +16 -16
  84. package/templates/lupine-template-hello-world/web/src/index.tsx +73 -73
  85. package/templates/lupine-template-responsive-starter/api/resources/install.sqlite.sql +3 -3
  86. package/templates/lupine-template-responsive-starter/api/src/index.ts +4 -4
  87. package/templates/lupine-template-responsive-starter/api/src/service/root-api.ts +18 -18
  88. package/templates/lupine-template-responsive-starter/web/src/app-icons.ts +76 -76
  89. package/templates/lupine-template-responsive-starter/web/src/components/input-history-component.tsx +93 -93
  90. package/templates/lupine-template-responsive-starter/web/src/components/mine-about-page.tsx +86 -86
  91. package/templates/lupine-template-responsive-starter/web/src/components/mine-premium-page.tsx +80 -80
  92. package/templates/lupine-template-responsive-starter/web/src/components/mine-settings-page.tsx +220 -219
  93. package/templates/lupine-template-responsive-starter/web/src/components/mobile-top-search-menu.tsx +119 -119
  94. package/templates/lupine-template-responsive-starter/web/src/components/note-detail.tsx +116 -116
  95. package/templates/lupine-template-responsive-starter/web/src/components/note-edit.tsx +154 -154
  96. package/templates/lupine-template-responsive-starter/web/src/components/note-search-page.tsx +193 -193
  97. package/templates/lupine-template-responsive-starter/web/src/components/search-input.tsx +95 -95
  98. package/templates/lupine-template-responsive-starter/web/src/components/side-menu-content.tsx +182 -182
  99. package/templates/lupine-template-responsive-starter/web/src/frames/app-responsive-frame.tsx +52 -52
  100. package/templates/lupine-template-responsive-starter/web/src/index.html +16 -16
  101. package/templates/lupine-template-responsive-starter/web/src/index.tsx +39 -39
  102. package/templates/lupine-template-responsive-starter/web/src/lupine-template-responsive-starter/404.html +35 -35
  103. package/templates/lupine-template-responsive-starter/web/src/lupine-template-responsive-starter/index.html +49 -49
  104. package/templates/lupine-template-responsive-starter/web/src/lupine-template-responsive-starter/index.tsx +32 -32
  105. package/templates/lupine-template-responsive-starter/web/src/pages/about-page.tsx +43 -43
  106. package/templates/lupine-template-responsive-starter/web/src/pages/finance-page.tsx +46 -46
  107. package/templates/lupine-template-responsive-starter/web/src/pages/home-page.tsx +452 -452
  108. package/templates/lupine-template-responsive-starter/web/src/pages/mine-page.tsx +325 -325
  109. package/templates/lupine-template-responsive-starter/web/src/pages/tools-page.tsx +46 -46
  110. package/templates/lupine-template-responsive-starter/web/src/services/local-notes-service.ts +87 -87
  111. package/templates/lupine-template-responsive-starter/web/src/services/mine-service.ts +45 -45
@@ -1,193 +1,193 @@
1
- import { CssProps, HeaderWithBackFrame, HtmlVar, RefProps, SliderFrame, SliderFrameHookProps } from 'lupine.components';
2
- import { SearchInput, SearchInputHookProps } from './search-input';
3
- import { InputHistoryComponent, addHistoryItem } from './input-history-component';
4
- import { LocalNoteProps, LocalNotesService } from '../services/local-notes-service';
5
- import { NoteDetailComponent } from './note-detail';
6
- import { clearHistoryList } from './input-history-component';
7
-
8
- const extractText = (html: string) => {
9
- const tmp = document.createElement('DIV');
10
- tmp.innerHTML = html;
11
- return tmp.textContent || tmp.innerText || '';
12
- };
13
-
14
- export const NoteSearchComponent = (props: { sliderFrameHook: SliderFrameHookProps }) => {
15
- const listDom = new HtmlVar('');
16
- const historyDom = new HtmlVar('');
17
-
18
- const searchInputHook: SearchInputHookProps = {};
19
- // this is the inner slide hook for editing from search results
20
- const subSliderHook: SliderFrameHookProps = {};
21
-
22
- const historyKey = 'note-search';
23
-
24
- const onSearch = (value?: string) => {
25
- const val = (value || '').trim();
26
- if (val) {
27
- addHistoryItem(historyKey, val);
28
- hideHistory();
29
- } else {
30
- showHistory();
31
- }
32
- refreshList(val);
33
- };
34
-
35
- const onClearSearch = () => {
36
- onSearch('');
37
- };
38
-
39
- const showHistory = () => {
40
- historyDom.value = (
41
- <InputHistoryComponent
42
- historyKey={historyKey}
43
- onClearHistory={() => {
44
- clearHistoryList(historyKey);
45
- showHistory();
46
- }}
47
- onItemClick={(item) => {
48
- searchInputHook.setValue!(item);
49
- onSearch(item);
50
- }}
51
- />
52
- );
53
- };
54
-
55
- const hideHistory = () => {
56
- historyDom.value = '';
57
- };
58
-
59
- const onViewNote = (note: LocalNoteProps) => {
60
- subSliderHook.load!(
61
- <NoteDetailComponent
62
- note={note}
63
- sliderFrameHook={subSliderHook}
64
- onSaved={() => {
65
- // We re-query the note values after saving. Easiest is to trigger search again.
66
- const val = document.querySelector('.search-input .search-in-input') as HTMLInputElement;
67
- if (val) onSearch(val.value);
68
- }}
69
- />
70
- );
71
- };
72
-
73
- const refreshList = (query: string) => {
74
- if (!query) {
75
- listDom.value = '';
76
- return;
77
- }
78
-
79
- const allNotes = LocalNotesService.getAllNotes();
80
- const filteredNotes = allNotes.filter(
81
- (n) =>
82
- n.title.toLowerCase().includes(query.toLowerCase()) || n.content.toLowerCase().includes(query.toLowerCase())
83
- );
84
-
85
- if (filteredNotes.length === 0) {
86
- listDom.value = (
87
- <div
88
- class='note-empty-state'
89
- style={{ marginTop: '40px', textAlign: 'center', color: 'var(--secondary-color)' }}
90
- >
91
- No search results
92
- </div>
93
- );
94
- return;
95
- }
96
-
97
- listDom.value = (
98
- <div class='note-list-container' style={{ paddingTop: '16px' }}>
99
- {filteredNotes.map((note) => (
100
- <div class='note-card-wrapper search-result-card-wrapper'>
101
- <div class='note-card row-box search-result-card' onClick={() => onViewNote(note)}>
102
- <div class='note-card-content flex-1'>
103
- <div class='note-card-title'>{note.title}</div>
104
- <div class='note-card-preview ellipsis'>{extractText(note.content)}</div>
105
- <div class='note-card-date'>{new Date(note.updatedAt).toLocaleString()}</div>
106
- </div>
107
- </div>
108
- </div>
109
- ))}
110
- </div>
111
- );
112
- };
113
-
114
- const css: CssProps = {
115
- height: '100%',
116
- display: 'flex',
117
- flexDirection: 'column',
118
- overflowY: 'auto',
119
- backgroundColor: 'var(--primary-bg-color)',
120
- padding: '0 16px',
121
-
122
- '.search-result-card-wrapper': {
123
- marginBottom: '16px',
124
- borderRadius: '12px',
125
- overflow: 'hidden',
126
- boxShadow: '0 4px 12px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05)',
127
- backgroundColor: 'var(--secondary-bg-color)',
128
- },
129
- '.search-result-card': {
130
- backgroundColor: 'var(--primary-bg-color)',
131
- borderRadius: '12px',
132
- padding: '16px',
133
- cursor: 'pointer',
134
- alignItems: 'center',
135
- transition: 'transform 0.2s ease, box-shadow 0.2s ease',
136
- '&:active': {
137
- transform: 'scale(0.98)',
138
- },
139
- },
140
- '.note-card-title': {
141
- fontSize: '16px',
142
- fontWeight: 'bold',
143
- color: 'var(--primary-color)',
144
- marginBottom: '4px',
145
- },
146
- '.note-card-preview': {
147
- fontSize: '14px',
148
- color: 'var(--secondary-color)',
149
- marginBottom: '6px',
150
- },
151
- '.note-card-date': {
152
- fontSize: '12px',
153
- color: 'var(--secondary-color)',
154
- opacity: 0.8,
155
- },
156
- };
157
-
158
- const ref: RefProps = {
159
- onLoad: async () => {
160
- showHistory();
161
- // focus input
162
- const input = ref.$('.search-in-input') as HTMLInputElement;
163
- if (input) {
164
- requestAnimationFrame(() => input.focus());
165
- }
166
- },
167
- };
168
-
169
- const headerTitle = (
170
- <SearchInput
171
- placeholder='Search title or content...'
172
- onSearch={onSearch}
173
- onClear={onClearSearch}
174
- onFocus={showHistory}
175
- class='w-100p'
176
- hook={searchInputHook}
177
- />
178
- );
179
-
180
- return (
181
- <HeaderWithBackFrame
182
- title={headerTitle}
183
- right={<span></span>}
184
- onBack={(event) => props.sliderFrameHook.close!(event)}
185
- >
186
- <div ref={ref} css={css} class='note-search-page'>
187
- <SliderFrame hook={subSliderHook} />
188
- {historyDom.node}
189
- {listDom.node}
190
- </div>
191
- </HeaderWithBackFrame>
192
- );
193
- };
1
+ import { CssProps, HeaderWithBackFrame, HtmlVar, RefProps, SliderFrame, SliderFrameHookProps } from 'lupine.components';
2
+ import { SearchInput, SearchInputHookProps } from './search-input';
3
+ import { InputHistoryComponent, addHistoryItem } from './input-history-component';
4
+ import { LocalNoteProps, LocalNotesService } from '../services/local-notes-service';
5
+ import { NoteDetailComponent } from './note-detail';
6
+ import { clearHistoryList } from './input-history-component';
7
+
8
+ const extractText = (html: string) => {
9
+ const tmp = document.createElement('DIV');
10
+ tmp.innerHTML = html;
11
+ return tmp.textContent || tmp.innerText || '';
12
+ };
13
+
14
+ export const NoteSearchComponent = (props: { sliderFrameHook: SliderFrameHookProps }) => {
15
+ const listDom = new HtmlVar('');
16
+ const historyDom = new HtmlVar('');
17
+
18
+ const searchInputHook: SearchInputHookProps = {};
19
+ // this is the inner slide hook for editing from search results
20
+ const subSliderHook: SliderFrameHookProps = {};
21
+
22
+ const historyKey = 'note-search';
23
+
24
+ const onSearch = (value?: string) => {
25
+ const val = (value || '').trim();
26
+ if (val) {
27
+ addHistoryItem(historyKey, val);
28
+ hideHistory();
29
+ } else {
30
+ showHistory();
31
+ }
32
+ refreshList(val);
33
+ };
34
+
35
+ const onClearSearch = () => {
36
+ onSearch('');
37
+ };
38
+
39
+ const showHistory = () => {
40
+ historyDom.value = (
41
+ <InputHistoryComponent
42
+ historyKey={historyKey}
43
+ onClearHistory={() => {
44
+ clearHistoryList(historyKey);
45
+ showHistory();
46
+ }}
47
+ onItemClick={(item) => {
48
+ searchInputHook.setValue!(item);
49
+ onSearch(item);
50
+ }}
51
+ />
52
+ );
53
+ };
54
+
55
+ const hideHistory = () => {
56
+ historyDom.value = '';
57
+ };
58
+
59
+ const onViewNote = (note: LocalNoteProps) => {
60
+ subSliderHook.load!(
61
+ <NoteDetailComponent
62
+ note={note}
63
+ sliderFrameHook={subSliderHook}
64
+ onSaved={() => {
65
+ // We re-query the note values after saving. Easiest is to trigger search again.
66
+ const val = document.querySelector('.search-input .search-in-input') as HTMLInputElement;
67
+ if (val) onSearch(val.value);
68
+ }}
69
+ />
70
+ );
71
+ };
72
+
73
+ const refreshList = (query: string) => {
74
+ if (!query) {
75
+ listDom.value = '';
76
+ return;
77
+ }
78
+
79
+ const allNotes = LocalNotesService.getAllNotes();
80
+ const filteredNotes = allNotes.filter(
81
+ (n) =>
82
+ n.title.toLowerCase().includes(query.toLowerCase()) || n.content.toLowerCase().includes(query.toLowerCase())
83
+ );
84
+
85
+ if (filteredNotes.length === 0) {
86
+ listDom.value = (
87
+ <div
88
+ class='note-empty-state'
89
+ style={{ marginTop: '40px', textAlign: 'center', color: 'var(--secondary-color)' }}
90
+ >
91
+ No search results
92
+ </div>
93
+ );
94
+ return;
95
+ }
96
+
97
+ listDom.value = (
98
+ <div class='note-list-container' style={{ paddingTop: '16px' }}>
99
+ {filteredNotes.map((note) => (
100
+ <div class='note-card-wrapper search-result-card-wrapper'>
101
+ <div class='note-card row-box search-result-card' onClick={() => onViewNote(note)}>
102
+ <div class='note-card-content flex-1'>
103
+ <div class='note-card-title'>{note.title}</div>
104
+ <div class='note-card-preview ellipsis'>{extractText(note.content)}</div>
105
+ <div class='note-card-date'>{new Date(note.updatedAt).toLocaleString()}</div>
106
+ </div>
107
+ </div>
108
+ </div>
109
+ ))}
110
+ </div>
111
+ );
112
+ };
113
+
114
+ const css: CssProps = {
115
+ height: '100%',
116
+ display: 'flex',
117
+ flexDirection: 'column',
118
+ overflowY: 'auto',
119
+ backgroundColor: 'var(--primary-bg-color)',
120
+ padding: '0 16px',
121
+
122
+ '.search-result-card-wrapper': {
123
+ marginBottom: '16px',
124
+ borderRadius: '12px',
125
+ overflow: 'hidden',
126
+ boxShadow: '0 4px 12px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05)',
127
+ backgroundColor: 'var(--secondary-bg-color)',
128
+ },
129
+ '.search-result-card': {
130
+ backgroundColor: 'var(--primary-bg-color)',
131
+ borderRadius: '12px',
132
+ padding: '16px',
133
+ cursor: 'pointer',
134
+ alignItems: 'center',
135
+ transition: 'transform 0.2s ease, box-shadow 0.2s ease',
136
+ '&:active': {
137
+ transform: 'scale(0.98)',
138
+ },
139
+ },
140
+ '.note-card-title': {
141
+ fontSize: '16px',
142
+ fontWeight: 'bold',
143
+ color: 'var(--primary-color)',
144
+ marginBottom: '4px',
145
+ },
146
+ '.note-card-preview': {
147
+ fontSize: '14px',
148
+ color: 'var(--secondary-color)',
149
+ marginBottom: '6px',
150
+ },
151
+ '.note-card-date': {
152
+ fontSize: '12px',
153
+ color: 'var(--secondary-color)',
154
+ opacity: 0.8,
155
+ },
156
+ };
157
+
158
+ const ref: RefProps = {
159
+ onLoad: async () => {
160
+ showHistory();
161
+ // focus input
162
+ const input = ref.$('.search-in-input') as HTMLInputElement;
163
+ if (input) {
164
+ requestAnimationFrame(() => input.focus());
165
+ }
166
+ },
167
+ };
168
+
169
+ const headerTitle = (
170
+ <SearchInput
171
+ placeholder='Search title or content...'
172
+ onSearch={onSearch}
173
+ onClear={onClearSearch}
174
+ onFocus={showHistory}
175
+ class='w-100p'
176
+ hook={searchInputHook}
177
+ />
178
+ );
179
+
180
+ return (
181
+ <HeaderWithBackFrame
182
+ title={headerTitle}
183
+ right={<span></span>}
184
+ onBack={(event) => props.sliderFrameHook.close!(event)}
185
+ >
186
+ <div ref={ref} css={css} class='note-search-page'>
187
+ <SliderFrame hook={subSliderHook} />
188
+ {historyDom.node}
189
+ {listDom.node}
190
+ </div>
191
+ </HeaderWithBackFrame>
192
+ );
193
+ };
@@ -1,95 +1,95 @@
1
- import { bindGlobalStyle, CssProps, RefProps } from 'lupine.components';
2
-
3
- export interface SearchInputHookProps {
4
- setValue?: (value: string) => void;
5
- }
6
-
7
- export interface InputWithClearProps {
8
- placeholder?: string;
9
- onSearch: (value: string) => void;
10
- onClear?: () => void;
11
- onFocus?: () => void;
12
- onBlur?: () => void;
13
- class?: string;
14
- searchIcon?: string;
15
- hook?: SearchInputHookProps;
16
- }
17
- export const SearchInput = (props: InputWithClearProps) => {
18
- const css: CssProps = {
19
- display: 'flex',
20
- flex: 1,
21
- position: 'relative',
22
- fontSize: '16px',
23
- '.search-in-input': {
24
- flex: 1,
25
- paddingRight: '30px',
26
- height: '32px',
27
- padding: '4px 30px 4px 12px',
28
- borderRadius: '16px',
29
- border: 'none',
30
- backgroundColor: 'var(--secondary-bg-color)',
31
- color: 'var(--primary-color)',
32
- outline: 'none',
33
- },
34
- '.search-in-search, .search-in-clear': {
35
- position: 'absolute',
36
- top: '50%',
37
- transform: 'translateY(-50%)',
38
- cursor: 'pointer',
39
- display: 'flex',
40
- alignItems: 'center',
41
- justifyContent: 'center',
42
- color: 'var(--secondary-color)',
43
- },
44
- '.search-in-search': {
45
- right: '12px',
46
- },
47
- '.search-in-clear': {
48
- display: 'none',
49
- right: '34px',
50
- },
51
- 'input.search-in-input:not(:placeholder-shown) + .search-in-clear': {
52
- display: 'flex',
53
- },
54
- };
55
- bindGlobalStyle('search-input-component', css);
56
-
57
- const ref: RefProps = {};
58
- const onSearch = () => {
59
- const value = ref.$('.search-in-input').value;
60
- props.onSearch(value);
61
- };
62
- const onClear = () => {
63
- ref.$('.search-in-input').value = '';
64
- props.onClear?.();
65
- };
66
- if (props.hook) {
67
- props.hook.setValue = (value: string) => {
68
- ref.$('input.search-in-input').value = value;
69
- };
70
- }
71
- return (
72
- <div ref={ref} class={'search-input-component ' + (props.class || '')}>
73
- <input
74
- type='text'
75
- maxLength={30}
76
- spellcheck={false}
77
- class='search-in-input input-base'
78
- placeholder={props.placeholder}
79
- onKeyDown={(e) => {
80
- if (e.key === 'Enter') {
81
- onSearch();
82
- }
83
- }}
84
- onBlur={() => props.onBlur?.()}
85
- onFocus={() => props.onFocus?.()}
86
- />
87
- <div class='search-in-clear' onClick={onClear}>
88
- <i class='ifc-icon ma-close' />
89
- </div>
90
- <div class='search-in-search' onClick={onSearch}>
91
- <i class={'ifc-icon ' + (props.searchIcon || 'bs-search')} />
92
- </div>
93
- </div>
94
- );
95
- };
1
+ import { bindGlobalStyle, CssProps, RefProps } from 'lupine.components';
2
+
3
+ export interface SearchInputHookProps {
4
+ setValue?: (value: string) => void;
5
+ }
6
+
7
+ export interface InputWithClearProps {
8
+ placeholder?: string;
9
+ onSearch: (value: string) => void;
10
+ onClear?: () => void;
11
+ onFocus?: () => void;
12
+ onBlur?: () => void;
13
+ class?: string;
14
+ searchIcon?: string;
15
+ hook?: SearchInputHookProps;
16
+ }
17
+ export const SearchInput = (props: InputWithClearProps) => {
18
+ const css: CssProps = {
19
+ display: 'flex',
20
+ flex: 1,
21
+ position: 'relative',
22
+ fontSize: '16px',
23
+ '.search-in-input': {
24
+ flex: 1,
25
+ paddingRight: '30px',
26
+ height: '32px',
27
+ padding: '4px 30px 4px 12px',
28
+ borderRadius: '16px',
29
+ border: 'none',
30
+ backgroundColor: 'var(--secondary-bg-color)',
31
+ color: 'var(--primary-color)',
32
+ outline: 'none',
33
+ },
34
+ '.search-in-search, .search-in-clear': {
35
+ position: 'absolute',
36
+ top: '50%',
37
+ transform: 'translateY(-50%)',
38
+ cursor: 'pointer',
39
+ display: 'flex',
40
+ alignItems: 'center',
41
+ justifyContent: 'center',
42
+ color: 'var(--secondary-color)',
43
+ },
44
+ '.search-in-search': {
45
+ right: '12px',
46
+ },
47
+ '.search-in-clear': {
48
+ display: 'none',
49
+ right: '34px',
50
+ },
51
+ 'input.search-in-input:not(:placeholder-shown) + .search-in-clear': {
52
+ display: 'flex',
53
+ },
54
+ };
55
+ bindGlobalStyle('search-input-component', css);
56
+
57
+ const ref: RefProps = {};
58
+ const onSearch = () => {
59
+ const value = ref.$('.search-in-input').value;
60
+ props.onSearch(value);
61
+ };
62
+ const onClear = () => {
63
+ ref.$('.search-in-input').value = '';
64
+ props.onClear?.();
65
+ };
66
+ if (props.hook) {
67
+ props.hook.setValue = (value: string) => {
68
+ ref.$('input.search-in-input').value = value;
69
+ };
70
+ }
71
+ return (
72
+ <div ref={ref} class={'search-input-component ' + (props.class || '')}>
73
+ <input
74
+ type='text'
75
+ maxLength={30}
76
+ spellcheck={false}
77
+ class='search-in-input input-base'
78
+ placeholder={props.placeholder}
79
+ onKeyDown={(e) => {
80
+ if (e.key === 'Enter') {
81
+ onSearch();
82
+ }
83
+ }}
84
+ onBlur={() => props.onBlur?.()}
85
+ onFocus={() => props.onFocus?.()}
86
+ />
87
+ <div class='search-in-clear' onClick={onClear}>
88
+ <i class='ifc-icon ma-close' />
89
+ </div>
90
+ <div class='search-in-search' onClick={onSearch}>
91
+ <i class={'ifc-icon ' + (props.searchIcon || 'bs-search')} />
92
+ </div>
93
+ </div>
94
+ );
95
+ };