@clickhouse/click-ui 0.0.234-sc-deprecation.8 → 0.0.234-sc-deprecation.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -152
- package/bin/commands/init.js +78 -115
- package/dist/click-ui.bundled.es.js +3580 -3627
- package/dist/click-ui.bundled.umd.js +31 -31
- package/dist/click-ui.es.js +3580 -3627
- package/dist/click-ui.umd.js +31 -31
- package/dist/config/core.d.ts +49 -0
- package/dist/config/core.d.ts.map +1 -0
- package/dist/config/core.js +180 -0
- package/dist/config/core.js.map +1 -0
- package/dist/config/index.d.ts +51 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +53 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/next.d.ts +8 -0
- package/dist/config/next.d.ts.map +1 -0
- package/dist/config/next.js +61 -0
- package/dist/config/next.js.map +1 -0
- package/dist/config/rollup.d.ts +8 -0
- package/dist/config/rollup.d.ts.map +1 -0
- package/dist/config/rollup.js +75 -0
- package/dist/config/rollup.js.map +1 -0
- package/dist/config/types.d.ts +34 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +5 -0
- package/dist/config/types.js.map +1 -0
- package/dist/config/vite.d.ts +8 -0
- package/dist/config/vite.d.ts.map +1 -0
- package/dist/config/vite.js +69 -0
- package/dist/config/vite.js.map +1 -0
- package/dist/config/webpack.d.ts +8 -0
- package/dist/config/webpack.d.ts.map +1 -0
- package/dist/config/webpack.js +68 -0
- package/dist/config/webpack.js.map +1 -0
- package/dist/theme/ClickUIProvider/ServerClickUIProvider.d.ts +3 -4
- package/dist/theme/config.d.ts +1 -1
- package/dist/theme/index.d.ts +2 -2
- package/dist/theme/types.d.ts +13 -6
- package/dist/theme/utils.d.ts +7 -0
- package/package.json +30 -3
package/README.md
CHANGED
|
@@ -47,171 +47,45 @@ Click UI has been tested in NextJS, Gatsby, and Vite. If you run into problems u
|
|
|
47
47
|
|
|
48
48
|
### Customizing Your Theme
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
For detailed theming and configuration options, see:
|
|
51
|
+
- **[Theme System Documentation](src/theme/index.md)** - Complete theme system overview
|
|
52
|
+
- **[Build-Time Configuration](BUILD_TIME_CONFIG_CLICK_UI.md)** - Build-time optimization guide
|
|
53
|
+
- **[Bundler Plugins](config/README.md)** - Vite, Webpack, Rollup, and Next.js plugins
|
|
51
54
|
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
npx @clickhouse/click-ui init
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
This creates a `click-ui.config.ts` file in your project root.
|
|
58
|
-
|
|
59
|
-
2. **Setup Vite alias** to enable auto-discovery
|
|
60
|
-
|
|
61
|
-
In your `vite.config.ts`:
|
|
62
|
-
```ts
|
|
63
|
-
import { defineConfig } from 'vite';
|
|
64
|
-
import path from 'path';
|
|
65
|
-
|
|
66
|
-
export default defineConfig({
|
|
67
|
-
resolve: {
|
|
68
|
-
alias: {
|
|
69
|
-
'click-ui-config': path.resolve(__dirname, './click-ui.config.ts'),
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
3. **Customize the generated config file**
|
|
76
|
-
|
|
77
|
-
```typescript
|
|
78
|
-
import type { ThemeConfig } from '@clickhouse/click-ui/theme';
|
|
79
|
-
|
|
80
|
-
const config: ThemeConfig = {
|
|
81
|
-
theme: {
|
|
82
|
-
global: {
|
|
83
|
-
color: {
|
|
84
|
-
brand: '#FFCC00',
|
|
85
|
-
background: {
|
|
86
|
-
default: '#FFFFFF'
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
button: {
|
|
91
|
-
primary: {
|
|
92
|
-
background: {
|
|
93
|
-
default: '#FFCC00',
|
|
94
|
-
hover: '#FFD700'
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export default config;
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
4. **That's it!** Your custom theme will be automatically loaded by ClickUIProvider.
|
|
105
|
-
|
|
106
|
-
#### CLI Options
|
|
107
|
-
|
|
108
|
-
```bash
|
|
109
|
-
# Create TypeScript config (default)
|
|
110
|
-
npx @clickhouse/click-ui init
|
|
111
|
-
|
|
112
|
-
# Create JavaScript config
|
|
113
|
-
npx @clickhouse/click-ui init -f js
|
|
114
|
-
|
|
115
|
-
# Overwrite existing config
|
|
116
|
-
npx @clickhouse/click-ui init --force
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### Advanced Configuration Options
|
|
120
|
-
|
|
121
|
-
The generated config file supports extensive customization:
|
|
122
|
-
|
|
123
|
-
#### System Mode Overrides
|
|
124
|
-
|
|
125
|
-
Define different styles for light and dark modes:
|
|
55
|
+
**Quick example:**
|
|
126
56
|
|
|
127
57
|
```typescript
|
|
128
|
-
|
|
129
|
-
systemModeOverrides: {
|
|
130
|
-
light: {
|
|
131
|
-
global: {
|
|
132
|
-
color: {
|
|
133
|
-
background: { default: '#FFFFFF' }
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
dark: {
|
|
138
|
-
global: {
|
|
139
|
-
color: {
|
|
140
|
-
background: { default: '#0D1117' },
|
|
141
|
-
text: { default: '#F0F6FC' }
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
#### Component-Specific Styling
|
|
58
|
+
import type { ThemeConfig } from '@clickhouse/click-ui/theme';
|
|
150
59
|
|
|
151
|
-
Customize individual components:
|
|
152
|
-
|
|
153
|
-
```typescript
|
|
154
60
|
const config: ThemeConfig = {
|
|
155
61
|
theme: {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
62
|
+
global: {
|
|
63
|
+
color: {
|
|
64
|
+
brand: '#FFCC00',
|
|
65
|
+
background: { default: '#FFFFFF' }
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
// Dark mode overrides
|
|
70
|
+
dark: {
|
|
71
|
+
global: {
|
|
72
|
+
color: {
|
|
73
|
+
background: { default: '#0D1117' },
|
|
74
|
+
text: { default: '#F0F6FC' }
|
|
164
75
|
}
|
|
165
76
|
}
|
|
166
77
|
}
|
|
167
78
|
};
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
### Manual Theme Control
|
|
171
|
-
|
|
172
|
-
You can manually control the theme at runtime:
|
|
173
79
|
|
|
174
|
-
|
|
175
|
-
import { ClickUIProvider, useCUITheme, Switch } from '@clickhouse/click-ui'
|
|
176
|
-
|
|
177
|
-
function ThemeToggle() {
|
|
178
|
-
const { themeName, toggleTheme } = useCUITheme();
|
|
179
|
-
|
|
180
|
-
return (
|
|
181
|
-
<Switch
|
|
182
|
-
checked={themeName === 'dark'}
|
|
183
|
-
onClick={toggleTheme}
|
|
184
|
-
/>
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function App() {
|
|
189
|
-
return (
|
|
190
|
-
<ClickUIProvider theme="dark">
|
|
191
|
-
<ThemeToggle />
|
|
192
|
-
<Title type='h1'>Click UI Example</Title>
|
|
193
|
-
</ClickUIProvider>
|
|
194
|
-
)
|
|
195
|
-
}
|
|
80
|
+
export default config;
|
|
196
81
|
```
|
|
197
82
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
### Troubleshooting
|
|
206
|
-
|
|
207
|
-
**Config not loading?**
|
|
208
|
-
- Verify the Vite alias is correctly set up in `vite.config.ts`
|
|
209
|
-
- Ensure `click-ui.config.ts` is in your project root
|
|
210
|
-
- Restart your dev server after adding the alias
|
|
211
|
-
|
|
212
|
-
**TypeScript errors?**
|
|
213
|
-
- Import types from: `import type { ThemeConfig } from '@clickhouse/click-ui/theme';`
|
|
214
|
-
- Your IDE will provide autocomplete for all config options
|
|
83
|
+
See the full documentation for advanced features including:
|
|
84
|
+
- CLI tools for config generation
|
|
85
|
+
- Multiple bundler support
|
|
86
|
+
- SSR/RSC compatibility
|
|
87
|
+
- Theme switching and persistence
|
|
88
|
+
- Performance optimization
|
|
215
89
|
|
|
216
90
|
## To develop this library locally 🚀
|
|
217
91
|
|
package/bin/commands/init.js
CHANGED
|
@@ -1,124 +1,84 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import fs from
|
|
4
|
-
import path from
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import path from "path";
|
|
6
5
|
|
|
7
|
-
const
|
|
8
|
-
|
|
6
|
+
const CONFIG_BODY = ` // Optional: Customize the storage key for theme persistence
|
|
7
|
+
// storageKey: 'click-ui-theme',
|
|
8
|
+
|
|
9
|
+
// Optional: Customize light mode theme
|
|
10
|
+
// theme: {
|
|
11
|
+
// global: {
|
|
12
|
+
// color: {
|
|
13
|
+
// brand: '#FFCC00',
|
|
14
|
+
// background: {
|
|
15
|
+
// default: '#FFFFFF'
|
|
16
|
+
// }
|
|
17
|
+
// }
|
|
18
|
+
// },
|
|
19
|
+
// button: {
|
|
20
|
+
// space: {
|
|
21
|
+
// x: '1rem',
|
|
22
|
+
// y: '0.5rem'
|
|
23
|
+
// },
|
|
24
|
+
// radii: {
|
|
25
|
+
// all: '0.375rem'
|
|
26
|
+
// }
|
|
27
|
+
// }
|
|
28
|
+
// },
|
|
29
|
+
|
|
30
|
+
// Optional: Dark mode overrides
|
|
31
|
+
// If not defined, theme values are used for dark mode too
|
|
32
|
+
// dark: {
|
|
33
|
+
// global: {
|
|
34
|
+
// color: {
|
|
35
|
+
// background: {
|
|
36
|
+
// default: '#0D1117'
|
|
37
|
+
// },
|
|
38
|
+
// text: {
|
|
39
|
+
// default: '#F0F6FC'
|
|
40
|
+
// }
|
|
41
|
+
// }
|
|
42
|
+
// }
|
|
43
|
+
// },
|
|
44
|
+
|
|
45
|
+
// Optional: Tooltip configuration
|
|
46
|
+
// tooltipConfig: {
|
|
47
|
+
// delayDuration: 100,
|
|
48
|
+
// skipDelayDuration: 300,
|
|
49
|
+
// disableHoverableContent: false,
|
|
50
|
+
// },
|
|
51
|
+
|
|
52
|
+
// Optional: Toast configuration
|
|
53
|
+
// toastConfig: {
|
|
54
|
+
// duration: 4000,
|
|
55
|
+
// swipeDirection: 'right',
|
|
56
|
+
// swipeThreshold: 50,
|
|
57
|
+
// },`;
|
|
9
58
|
|
|
10
59
|
const CONFIG_TEMPLATES = {
|
|
11
60
|
ts: `import type { ThemeConfig } from '@clickhouse/click-ui/theme';
|
|
12
61
|
|
|
13
62
|
const config: ThemeConfig = {
|
|
14
|
-
|
|
15
|
-
storageKey: 'click-ui-theme',
|
|
16
|
-
|
|
17
|
-
theme: {
|
|
18
|
-
global: {
|
|
19
|
-
color: {
|
|
20
|
-
brand: '#FFCC00',
|
|
21
|
-
background: {
|
|
22
|
-
default: '#FFFFFF'
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
button: {
|
|
27
|
-
space: {
|
|
28
|
-
x: '1rem',
|
|
29
|
-
y: '0.5rem'
|
|
30
|
-
},
|
|
31
|
-
radii: {
|
|
32
|
-
all: '0.375rem'
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
systemModeOverrides: {
|
|
38
|
-
light: {
|
|
39
|
-
global: {
|
|
40
|
-
color: {
|
|
41
|
-
background: {
|
|
42
|
-
default: '#FFFFFF'
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
dark: {
|
|
48
|
-
global: {
|
|
49
|
-
color: {
|
|
50
|
-
background: {
|
|
51
|
-
default: '#0D1117'
|
|
52
|
-
},
|
|
53
|
-
text: {
|
|
54
|
-
default: '#F0F6FC'
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
63
|
+
${CONFIG_BODY}
|
|
60
64
|
};
|
|
61
65
|
|
|
62
66
|
export default config;
|
|
63
67
|
`,
|
|
64
68
|
js: `/** @type {import('@clickhouse/click-ui/theme').ThemeConfig} */
|
|
65
69
|
const config = {
|
|
66
|
-
|
|
67
|
-
storageKey: 'click-ui-theme',
|
|
68
|
-
|
|
69
|
-
theme: {
|
|
70
|
-
global: {
|
|
71
|
-
color: {
|
|
72
|
-
brand: '#FFCC00',
|
|
73
|
-
background: {
|
|
74
|
-
default: '#FFFFFF'
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
button: {
|
|
79
|
-
space: {
|
|
80
|
-
x: '1rem',
|
|
81
|
-
y: '0.5rem'
|
|
82
|
-
},
|
|
83
|
-
radii: {
|
|
84
|
-
all: '0.375rem'
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
systemModeOverrides: {
|
|
90
|
-
light: {
|
|
91
|
-
global: {
|
|
92
|
-
color: {
|
|
93
|
-
background: {
|
|
94
|
-
default: '#FFFFFF'
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
dark: {
|
|
100
|
-
global: {
|
|
101
|
-
color: {
|
|
102
|
-
background: {
|
|
103
|
-
default: '#0D1117'
|
|
104
|
-
},
|
|
105
|
-
text: {
|
|
106
|
-
default: '#F0F6FC'
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
70
|
+
${CONFIG_BODY}
|
|
112
71
|
};
|
|
113
72
|
|
|
114
73
|
export default config;
|
|
115
74
|
`
|
|
116
75
|
};
|
|
117
76
|
|
|
118
|
-
export const initCommand =
|
|
119
|
-
const format = options.format ===
|
|
77
|
+
export const initCommand = options => {
|
|
78
|
+
const format = options.format === "js" ? "js" : "ts";
|
|
120
79
|
const filename = `click-ui.config.${format}`;
|
|
121
80
|
const targetPath = path.join(process.cwd(), filename);
|
|
81
|
+
const configExt = format === "ts" ? "ts" : "js";
|
|
122
82
|
|
|
123
83
|
// Check if config already exists
|
|
124
84
|
if (fs.existsSync(targetPath) && !options.force) {
|
|
@@ -128,22 +88,25 @@ export const initCommand = (options) => {
|
|
|
128
88
|
|
|
129
89
|
// Write config file
|
|
130
90
|
try {
|
|
131
|
-
fs.writeFileSync(targetPath, CONFIG_TEMPLATES[format],
|
|
132
|
-
console.log(`✅ Created ${filename}`);
|
|
133
|
-
console.log(
|
|
134
|
-
console.log(` 1. Customize your theme in ${filename}`);
|
|
135
|
-
console.log(
|
|
136
|
-
console.log(
|
|
137
|
-
console.log(
|
|
138
|
-
console.log(
|
|
139
|
-
console.log(
|
|
140
|
-
console.log(
|
|
141
|
-
console.log(
|
|
142
|
-
console.log(
|
|
143
|
-
console.log(
|
|
144
|
-
console.log(
|
|
145
|
-
console.log(
|
|
146
|
-
console.log(
|
|
91
|
+
fs.writeFileSync(targetPath, CONFIG_TEMPLATES[format], "utf-8");
|
|
92
|
+
console.log(`✅ Created ${filename}\n`);
|
|
93
|
+
console.log("📝 Next steps:\n");
|
|
94
|
+
console.log(` 1. Customize your theme in ${filename}\n`);
|
|
95
|
+
console.log(" 2. Add plugin to your bundler config:\n");
|
|
96
|
+
console.log(` // vite.config.${configExt}`);
|
|
97
|
+
console.log(" import { clickUIConfig } from '@clickhouse/click-ui/config';\n");
|
|
98
|
+
console.log(" export default defineConfig({");
|
|
99
|
+
console.log(" plugins: [");
|
|
100
|
+
console.log(" react(),");
|
|
101
|
+
console.log(` clickUIConfig(), // Loads ${filename}`);
|
|
102
|
+
console.log(" ],");
|
|
103
|
+
console.log(" });\n");
|
|
104
|
+
console.log(" 3. Use ClickUIProvider in your app:\n");
|
|
105
|
+
console.log(" import { ClickUIProvider } from '@clickhouse/click-ui';\n");
|
|
106
|
+
console.log(" <ClickUIProvider>");
|
|
107
|
+
console.log(" {/* Your app */}");
|
|
108
|
+
console.log(" </ClickUIProvider>\n");
|
|
109
|
+
console.log(" 🎨 Your custom theme will be applied!");
|
|
147
110
|
} catch (error) {
|
|
148
111
|
console.error(`❌ Failed to create config file: ${error.message}`);
|
|
149
112
|
process.exit(1);
|