bitwrench 2.0.23 → 2.0.25
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 +8 -6
- package/dist/bitwrench-bccl.cjs.js +1 -1
- package/dist/bitwrench-bccl.cjs.min.js +1 -1
- package/dist/bitwrench-bccl.cjs.min.js.gz +0 -0
- package/dist/bitwrench-bccl.esm.js +1 -1
- package/dist/bitwrench-bccl.esm.min.js +1 -1
- package/dist/bitwrench-bccl.esm.min.js.gz +0 -0
- package/dist/bitwrench-bccl.umd.js +1 -1
- package/dist/bitwrench-bccl.umd.min.js +1 -1
- package/dist/bitwrench-bccl.umd.min.js.gz +0 -0
- package/dist/bitwrench-code-edit.cjs.js +1 -1
- package/dist/bitwrench-code-edit.cjs.min.js +1 -1
- package/dist/bitwrench-code-edit.es5.js +1 -1
- package/dist/bitwrench-code-edit.es5.min.js +1 -1
- package/dist/bitwrench-code-edit.esm.js +1 -1
- package/dist/bitwrench-code-edit.esm.min.js +1 -1
- package/dist/bitwrench-code-edit.umd.js +1 -1
- package/dist/bitwrench-code-edit.umd.min.js +1 -1
- package/dist/bitwrench-code-edit.umd.min.js.gz +0 -0
- package/dist/bitwrench-debug.js +1 -1
- package/dist/bitwrench-debug.min.js +1 -1
- package/dist/bitwrench-lean.cjs.js +41 -22
- package/dist/bitwrench-lean.cjs.min.js +4 -4
- package/dist/bitwrench-lean.cjs.min.js.gz +0 -0
- package/dist/bitwrench-lean.es5.js +43 -24
- package/dist/bitwrench-lean.es5.min.js +4 -4
- package/dist/bitwrench-lean.es5.min.js.gz +0 -0
- package/dist/bitwrench-lean.esm.js +41 -22
- package/dist/bitwrench-lean.esm.min.js +4 -4
- package/dist/bitwrench-lean.esm.min.js.gz +0 -0
- package/dist/bitwrench-lean.umd.js +41 -22
- package/dist/bitwrench-lean.umd.min.js +4 -4
- package/dist/bitwrench-lean.umd.min.js.gz +0 -0
- package/dist/bitwrench-util-css.cjs.js +1 -1
- package/dist/bitwrench-util-css.cjs.min.js +1 -1
- package/dist/bitwrench-util-css.es5.js +1 -1
- package/dist/bitwrench-util-css.es5.min.js +1 -1
- package/dist/bitwrench-util-css.esm.js +1 -1
- package/dist/bitwrench-util-css.esm.min.js +1 -1
- package/dist/bitwrench-util-css.umd.js +1 -1
- package/dist/bitwrench-util-css.umd.min.js +1 -1
- package/dist/bitwrench-util-css.umd.min.js.gz +0 -0
- package/dist/bitwrench.cjs.js +41 -22
- package/dist/bitwrench.cjs.min.js +6 -6
- package/dist/bitwrench.cjs.min.js.gz +0 -0
- package/dist/bitwrench.css +6 -6
- package/dist/bitwrench.d.ts +659 -0
- package/dist/bitwrench.es5.js +43 -24
- package/dist/bitwrench.es5.min.js +4 -4
- package/dist/bitwrench.es5.min.js.gz +0 -0
- package/dist/bitwrench.esm.js +41 -22
- package/dist/bitwrench.esm.min.js +4 -4
- package/dist/bitwrench.esm.min.js.gz +0 -0
- package/dist/bitwrench.min.css +1 -1
- package/dist/bitwrench.umd.js +41 -22
- package/dist/bitwrench.umd.min.js +6 -6
- package/dist/bitwrench.umd.min.js.gz +0 -0
- package/dist/builds.json +88 -88
- package/dist/bwserve.cjs.js +2 -2
- package/dist/bwserve.esm.js +2 -2
- package/dist/sri.json +46 -46
- package/docs/README.md +5 -3
- package/docs/bitwrench-mcp.md +1 -1
- package/docs/bitwrench-taco-schema-discussion.md +694 -0
- package/docs/bitwrench_api.md +4 -4
- package/docs/bitwrench_typescript_usage.md +441 -0
- package/docs/component-cheatsheet.md +1 -1
- package/docs/framework-translation-table.md +1 -1
- package/docs/llm-bitwrench-guide.md +28 -1
- package/docs/routing.md +1 -1
- package/docs/thinking-in-bitwrench.md +3 -3
- package/docs/tutorial-bwserve.md +1 -1
- package/docs/tutorial-website.md +1 -1
- package/package.json +7 -3
- package/readme.html +14 -8
- package/src/bitwrench-styles.js +17 -17
- package/src/bitwrench.d.ts +659 -0
- package/src/bitwrench.js +21 -2
- package/src/cli/serve.js +1 -0
- package/src/mcp/live.js +3 -1
- package/src/mcp/server.js +7 -7
- package/src/version.js +3 -3
|
@@ -0,0 +1,659 @@
|
|
|
1
|
+
// bitwrench TypeScript type definitions
|
|
2
|
+
// https://github.com/deftio/bitwrench
|
|
3
|
+
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// TACO format types
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
/** Raw HTML marker returned by bw.raw() */
|
|
9
|
+
export interface BwRaw {
|
|
10
|
+
__bw_raw: true;
|
|
11
|
+
v: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** TACO content: text, nested TACO, array of mixed, raw HTML, or null */
|
|
15
|
+
export type TacoContent =
|
|
16
|
+
| string
|
|
17
|
+
| number
|
|
18
|
+
| Taco
|
|
19
|
+
| TacoContent[]
|
|
20
|
+
| BwRaw
|
|
21
|
+
| null
|
|
22
|
+
| undefined;
|
|
23
|
+
|
|
24
|
+
/** TACO attributes object */
|
|
25
|
+
export interface TacoAttributes {
|
|
26
|
+
id?: string;
|
|
27
|
+
class?: string | string[];
|
|
28
|
+
style?: string | Record<string, string | number>;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
readonly?: boolean;
|
|
31
|
+
checked?: boolean;
|
|
32
|
+
selected?: boolean;
|
|
33
|
+
value?: string | number;
|
|
34
|
+
type?: string;
|
|
35
|
+
href?: string;
|
|
36
|
+
src?: string;
|
|
37
|
+
alt?: string;
|
|
38
|
+
title?: string;
|
|
39
|
+
name?: string;
|
|
40
|
+
placeholder?: string;
|
|
41
|
+
for?: string;
|
|
42
|
+
target?: string;
|
|
43
|
+
rel?: string;
|
|
44
|
+
role?: string;
|
|
45
|
+
tabindex?: number | string;
|
|
46
|
+
/** Event handlers: function or string */
|
|
47
|
+
onclick?: ((e: Event) => void) | string;
|
|
48
|
+
onchange?: ((e: Event) => void) | string;
|
|
49
|
+
oninput?: ((e: Event) => void) | string;
|
|
50
|
+
onsubmit?: ((e: Event) => void) | string;
|
|
51
|
+
onkeydown?: ((e: Event) => void) | string;
|
|
52
|
+
onkeyup?: ((e: Event) => void) | string;
|
|
53
|
+
onmouseover?: ((e: Event) => void) | string;
|
|
54
|
+
onmouseout?: ((e: Event) => void) | string;
|
|
55
|
+
onfocus?: ((e: Event) => void) | string;
|
|
56
|
+
onblur?: ((e: Event) => void) | string;
|
|
57
|
+
/** Any other HTML attribute */
|
|
58
|
+
[key: string]: any;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** TACO options object -- lifecycle, state, component handles */
|
|
62
|
+
export interface TacoOptions {
|
|
63
|
+
/** Component state, stored on el._bw_state */
|
|
64
|
+
state?: Record<string, any>;
|
|
65
|
+
/** Called after element created and in DOM */
|
|
66
|
+
mounted?: (el: HTMLElement, state?: Record<string, any>) => void;
|
|
67
|
+
/** Called on bw.cleanup() */
|
|
68
|
+
unmount?: (el: HTMLElement, state?: Record<string, any>) => void;
|
|
69
|
+
/** Called by bw.update(); stored on el._bw_render */
|
|
70
|
+
render?: (el: HTMLElement, state?: Record<string, any>) => void;
|
|
71
|
+
/** Methods attached to el.bw namespace */
|
|
72
|
+
handle?: Record<string, (el: HTMLElement, ...args: any[]) => any>;
|
|
73
|
+
/** Slot selectors: auto-generates el.bw.setName()/getName() */
|
|
74
|
+
slots?: Record<string, string>;
|
|
75
|
+
/** Component type identifier (used internally by BCCL) */
|
|
76
|
+
type?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* TACO object -- Tag, Attributes, Content, Options.
|
|
81
|
+
* The core UI primitive in bitwrench.
|
|
82
|
+
*/
|
|
83
|
+
export interface Taco {
|
|
84
|
+
/** HTML tag name */
|
|
85
|
+
t: string;
|
|
86
|
+
/** HTML attributes, event handlers, classes, styles */
|
|
87
|
+
a?: TacoAttributes;
|
|
88
|
+
/** Content: text, nested TACO, array, raw HTML */
|
|
89
|
+
c?: TacoContent;
|
|
90
|
+
/** Options: lifecycle hooks, state, component handles */
|
|
91
|
+
o?: TacoOptions;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ---------------------------------------------------------------------------
|
|
95
|
+
// Styles / theming types
|
|
96
|
+
// ---------------------------------------------------------------------------
|
|
97
|
+
|
|
98
|
+
/** Color shade object generated by bw.deriveShades() */
|
|
99
|
+
export interface ColorShades {
|
|
100
|
+
base: string;
|
|
101
|
+
hover: string;
|
|
102
|
+
active: string;
|
|
103
|
+
light: string;
|
|
104
|
+
darkText: string;
|
|
105
|
+
border: string;
|
|
106
|
+
focus: string;
|
|
107
|
+
textOn: string;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Full palette generated by bw.derivePalette() or bw.makeStyles() */
|
|
111
|
+
export interface Palette {
|
|
112
|
+
primary: ColorShades;
|
|
113
|
+
secondary: ColorShades;
|
|
114
|
+
tertiary: ColorShades;
|
|
115
|
+
success: ColorShades;
|
|
116
|
+
danger: ColorShades;
|
|
117
|
+
warning: ColorShades;
|
|
118
|
+
info: ColorShades;
|
|
119
|
+
light: ColorShades;
|
|
120
|
+
dark: ColorShades;
|
|
121
|
+
/** Plain string, not a ColorShades object */
|
|
122
|
+
background: string;
|
|
123
|
+
/** Plain string, not a ColorShades object */
|
|
124
|
+
surface: string;
|
|
125
|
+
/** Plain string, not a ColorShades object */
|
|
126
|
+
surfaceAlt: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Seed color config for bw.makeStyles() and bw.loadStyles() */
|
|
130
|
+
export interface StyleConfig {
|
|
131
|
+
primary?: string;
|
|
132
|
+
secondary?: string;
|
|
133
|
+
tertiary?: string;
|
|
134
|
+
success?: string;
|
|
135
|
+
danger?: string;
|
|
136
|
+
warning?: string;
|
|
137
|
+
info?: string;
|
|
138
|
+
light?: string;
|
|
139
|
+
dark?: string;
|
|
140
|
+
background?: string;
|
|
141
|
+
surface?: string;
|
|
142
|
+
surfaceAlt?: string;
|
|
143
|
+
palette?: Partial<Palette>;
|
|
144
|
+
spacing?: string;
|
|
145
|
+
radius?: string;
|
|
146
|
+
typeRatio?: string;
|
|
147
|
+
elevation?: string;
|
|
148
|
+
motion?: string;
|
|
149
|
+
compact?: boolean;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Result of bw.makeStyles() */
|
|
153
|
+
export interface StylesResult {
|
|
154
|
+
css: string;
|
|
155
|
+
alternateCss: string;
|
|
156
|
+
palette: Palette;
|
|
157
|
+
alternatePalette: Palette;
|
|
158
|
+
rules: Record<string, any>;
|
|
159
|
+
alternateRules: Record<string, any>;
|
|
160
|
+
isLightPrimary: boolean;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// ---------------------------------------------------------------------------
|
|
164
|
+
// Component config types (BCCL make*() factories)
|
|
165
|
+
// ---------------------------------------------------------------------------
|
|
166
|
+
|
|
167
|
+
export type Variant =
|
|
168
|
+
| 'primary' | 'secondary' | 'tertiary'
|
|
169
|
+
| 'success' | 'danger' | 'warning' | 'info'
|
|
170
|
+
| 'light' | 'dark';
|
|
171
|
+
|
|
172
|
+
export interface CardConfig {
|
|
173
|
+
title?: string | Taco;
|
|
174
|
+
content?: string | Taco | TacoContent[];
|
|
175
|
+
footer?: string | Taco;
|
|
176
|
+
image?: string;
|
|
177
|
+
variant?: Variant;
|
|
178
|
+
shadow?: boolean | string;
|
|
179
|
+
clickable?: boolean;
|
|
180
|
+
style?: Record<string, string | number>;
|
|
181
|
+
class?: string;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface ButtonConfig {
|
|
185
|
+
text?: string | Taco;
|
|
186
|
+
variant?: Variant;
|
|
187
|
+
size?: 'sm' | 'md' | 'lg';
|
|
188
|
+
outline?: boolean;
|
|
189
|
+
disabled?: boolean;
|
|
190
|
+
block?: boolean;
|
|
191
|
+
onclick?: (e: Event) => void;
|
|
192
|
+
type?: string;
|
|
193
|
+
style?: Record<string, string | number>;
|
|
194
|
+
class?: string;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export interface NavConfig {
|
|
198
|
+
items: Array<{ text: string; href?: string; active?: boolean; onclick?: (e: Event) => void }>;
|
|
199
|
+
variant?: Variant;
|
|
200
|
+
vertical?: boolean;
|
|
201
|
+
style?: Record<string, string | number>;
|
|
202
|
+
class?: string;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface TabsConfig {
|
|
206
|
+
tabs: Array<{ text: string; content: TacoContent; active?: boolean }>;
|
|
207
|
+
variant?: Variant;
|
|
208
|
+
style?: Record<string, string | number>;
|
|
209
|
+
class?: string;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export interface AccordionConfig {
|
|
213
|
+
items: Array<{ title: string; content: TacoContent }>;
|
|
214
|
+
multiple?: boolean;
|
|
215
|
+
variant?: Variant;
|
|
216
|
+
style?: Record<string, string | number>;
|
|
217
|
+
class?: string;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface ModalConfig {
|
|
221
|
+
title?: string | Taco;
|
|
222
|
+
content?: TacoContent;
|
|
223
|
+
footer?: TacoContent;
|
|
224
|
+
size?: 'sm' | 'md' | 'lg';
|
|
225
|
+
closable?: boolean;
|
|
226
|
+
variant?: Variant;
|
|
227
|
+
style?: Record<string, string | number>;
|
|
228
|
+
class?: string;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface AlertConfig {
|
|
232
|
+
content?: string | Taco;
|
|
233
|
+
variant?: Variant;
|
|
234
|
+
dismissible?: boolean;
|
|
235
|
+
style?: Record<string, string | number>;
|
|
236
|
+
class?: string;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export interface TableConfig {
|
|
240
|
+
columns?: Array<string | { key: string; label?: string; sortable?: boolean }>;
|
|
241
|
+
rows?: Array<Record<string, any>>;
|
|
242
|
+
data?: Array<Record<string, any>>;
|
|
243
|
+
sortable?: boolean;
|
|
244
|
+
striped?: boolean;
|
|
245
|
+
bordered?: boolean;
|
|
246
|
+
hover?: boolean;
|
|
247
|
+
style?: Record<string, string | number>;
|
|
248
|
+
class?: string;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export interface InputConfig {
|
|
252
|
+
type?: string;
|
|
253
|
+
label?: string;
|
|
254
|
+
placeholder?: string;
|
|
255
|
+
value?: string | number;
|
|
256
|
+
name?: string;
|
|
257
|
+
disabled?: boolean;
|
|
258
|
+
required?: boolean;
|
|
259
|
+
onchange?: (e: Event) => void;
|
|
260
|
+
oninput?: (e: Event) => void;
|
|
261
|
+
style?: Record<string, string | number>;
|
|
262
|
+
class?: string;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export interface CarouselConfig {
|
|
266
|
+
items: TacoContent[];
|
|
267
|
+
autoPlay?: boolean;
|
|
268
|
+
interval?: number;
|
|
269
|
+
indicators?: boolean;
|
|
270
|
+
controls?: boolean;
|
|
271
|
+
style?: Record<string, string | number>;
|
|
272
|
+
class?: string;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/** Generic config for BCCL components not individually typed */
|
|
276
|
+
export interface ComponentConfig {
|
|
277
|
+
[key: string]: any;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// ---------------------------------------------------------------------------
|
|
281
|
+
// Router types
|
|
282
|
+
// ---------------------------------------------------------------------------
|
|
283
|
+
|
|
284
|
+
export interface RouterConfig {
|
|
285
|
+
routes: Record<string, (params: Record<string, string>) => Taco>;
|
|
286
|
+
mode?: 'hash' | 'history';
|
|
287
|
+
base?: string;
|
|
288
|
+
target?: string;
|
|
289
|
+
before?: (path: string) => boolean | void;
|
|
290
|
+
after?: (path: string) => void;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export interface RouterHandle {
|
|
294
|
+
navigate: (path: string, opts?: { replace?: boolean }) => void;
|
|
295
|
+
current: () => string;
|
|
296
|
+
destroy: () => void;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// ---------------------------------------------------------------------------
|
|
300
|
+
// Main bw namespace
|
|
301
|
+
// ---------------------------------------------------------------------------
|
|
302
|
+
|
|
303
|
+
export interface Bitwrench {
|
|
304
|
+
// -- Version & Environment ------------------------------------------------
|
|
305
|
+
version: string;
|
|
306
|
+
versionInfo: { version: string; name: string; buildDate: string; gitHash: string };
|
|
307
|
+
readonly _isBrowser: boolean;
|
|
308
|
+
_isNode: boolean;
|
|
309
|
+
debug: boolean;
|
|
310
|
+
|
|
311
|
+
// -- TACO Construction & Rendering ----------------------------------------
|
|
312
|
+
/** Create TACO from positional args */
|
|
313
|
+
h(tag: string, attrs?: TacoAttributes | null, content?: TacoContent, options?: TacoOptions): Taco;
|
|
314
|
+
/** Render TACO to HTML string */
|
|
315
|
+
html(taco: Taco | TacoContent, options?: { raw?: boolean; state?: Record<string, any> }): string;
|
|
316
|
+
/** Generate complete HTML page string */
|
|
317
|
+
htmlPage(opts: { title?: string; css?: string; content?: TacoContent; favicon?: string; [key: string]: any }): string;
|
|
318
|
+
/** Create DOM element from TACO (browser only) */
|
|
319
|
+
createDOM(taco: Taco | TacoContent, options?: Record<string, any>): HTMLElement | DocumentFragment;
|
|
320
|
+
/** Mount TACO into target, replacing contents */
|
|
321
|
+
DOM(target: string | HTMLElement, taco: Taco | TacoContent, options?: Record<string, any>): void;
|
|
322
|
+
/** Mount TACO and return root element (for el.bw access) */
|
|
323
|
+
mount(target: string | HTMLElement, taco: Taco | TacoContent, options?: Record<string, any>): HTMLElement;
|
|
324
|
+
/** Mark string as pre-escaped HTML */
|
|
325
|
+
raw(str: string): BwRaw;
|
|
326
|
+
/** Escape HTML special characters */
|
|
327
|
+
escapeHTML(str: string): string;
|
|
328
|
+
|
|
329
|
+
// -- Lifecycle & State ----------------------------------------------------
|
|
330
|
+
/** Call el._bw_render to re-render element */
|
|
331
|
+
update(target: string | HTMLElement): void;
|
|
332
|
+
/** Quick-patch element content or attribute */
|
|
333
|
+
patch(id: string | HTMLElement, content?: TacoContent, attr?: string): HTMLElement | null;
|
|
334
|
+
/** Batch patch multiple elements */
|
|
335
|
+
patchAll(patches: Record<string, TacoContent> | Array<{ id: string; content?: TacoContent; attr?: string }>): Record<string, HTMLElement>;
|
|
336
|
+
/** Clean up lifecycle hooks, subscriptions, cache */
|
|
337
|
+
cleanup(element: HTMLElement): void;
|
|
338
|
+
|
|
339
|
+
// -- DOM Selection --------------------------------------------------------
|
|
340
|
+
/** CSS selector to array of elements */
|
|
341
|
+
$(selector: string | HTMLElement | HTMLElement[]): HTMLElement[];
|
|
342
|
+
/** Dispatch DOM event */
|
|
343
|
+
emit(target: string | HTMLElement, eventName: string, detail?: any): void;
|
|
344
|
+
/** Add event listener */
|
|
345
|
+
on(target: string | HTMLElement, eventName: string, handler: (e: Event) => void): void;
|
|
346
|
+
|
|
347
|
+
// -- Pub/Sub --------------------------------------------------------------
|
|
348
|
+
/** Publish to topic */
|
|
349
|
+
pub(topic: string, detail?: any): number;
|
|
350
|
+
/** Subscribe to topic; returns unsub() */
|
|
351
|
+
sub(topic: string, handler: (detail: any) => void, el?: HTMLElement): () => void;
|
|
352
|
+
/** Unsubscribe handler from topic */
|
|
353
|
+
unsub(topic: string, handler: Function): number;
|
|
354
|
+
|
|
355
|
+
// -- UUID & Identity ------------------------------------------------------
|
|
356
|
+
/** Generate unique ID */
|
|
357
|
+
uuid(prefix?: string): string;
|
|
358
|
+
/** Assign UUID class to TACO */
|
|
359
|
+
assignUUID(taco: Taco, forceNew?: boolean): string | null;
|
|
360
|
+
/** Read UUID from TACO or DOM element */
|
|
361
|
+
getUUID(tacoOrElement: Taco | HTMLElement): string | null;
|
|
362
|
+
|
|
363
|
+
// -- Component Messages ---------------------------------------------------
|
|
364
|
+
/** Call method on el.bw: el.bw[action](data) */
|
|
365
|
+
message(target: string | HTMLElement, action: string, data?: any): any;
|
|
366
|
+
/** Execute wire-protocol message object */
|
|
367
|
+
apply(msg: Record<string, any>): any;
|
|
368
|
+
/** Inspect element properties */
|
|
369
|
+
inspect(target: string | HTMLElement): Record<string, any>;
|
|
370
|
+
|
|
371
|
+
// -- Function Registry ----------------------------------------------------
|
|
372
|
+
funcRegister(fn: Function, name?: string): string;
|
|
373
|
+
funcGetById(name: string, errFn?: Function): Function | null;
|
|
374
|
+
funcGetDispatchStr(name: string, argStr?: string): string;
|
|
375
|
+
funcUnregister(name: string): void;
|
|
376
|
+
funcGetRegistry(): Record<string, Function>;
|
|
377
|
+
|
|
378
|
+
// -- Component Registry ---------------------------------------------------
|
|
379
|
+
render(element: HTMLElement, position: string, taco: Taco): string;
|
|
380
|
+
getComponent(id: string): Record<string, any> | null;
|
|
381
|
+
getAllComponents(): Map<string, any>;
|
|
382
|
+
|
|
383
|
+
// -- CSS & Styles ---------------------------------------------------------
|
|
384
|
+
/** Generate CSS string from JS object */
|
|
385
|
+
css(rules: Record<string, any>, options?: { scopeSelector?: string; selector?: string }): string;
|
|
386
|
+
/** Inject CSS into document */
|
|
387
|
+
injectCSS(css: string, options?: { id?: string; append?: boolean; scope?: string }): HTMLElement;
|
|
388
|
+
/** Responsive media query helper */
|
|
389
|
+
responsive(selector: string, breakpoints: Record<string, Record<string, any>>): string;
|
|
390
|
+
/** Generate styles from config */
|
|
391
|
+
makeStyles(config: StyleConfig): StylesResult;
|
|
392
|
+
/** Inject generated styles */
|
|
393
|
+
applyStyles(styles: StylesResult, scope?: string): void;
|
|
394
|
+
/** Generate + apply (no args = structural CSS only) */
|
|
395
|
+
loadStyles(config?: StyleConfig, scope?: string): StylesResult | void;
|
|
396
|
+
/** Load CSS reset */
|
|
397
|
+
loadReset(): void;
|
|
398
|
+
/** Switch primary/alternate palette */
|
|
399
|
+
toggleStyles(scope?: string): void;
|
|
400
|
+
/** Remove injected styles */
|
|
401
|
+
clearStyles(scope?: string): void;
|
|
402
|
+
/** Generate type scale from base + ratio */
|
|
403
|
+
generateTypeScale(baseSize: number, ratio: number, steps: number): Record<string, any>;
|
|
404
|
+
|
|
405
|
+
// -- Color Utilities ------------------------------------------------------
|
|
406
|
+
hexToHsl(hex: string): [number, number, number];
|
|
407
|
+
hslToHex(hsl: [number, number, number]): string;
|
|
408
|
+
adjustLightness(hex: string, amount: number): string;
|
|
409
|
+
mixColor(hex1: string, hex2: string, ratio: number): string;
|
|
410
|
+
relativeLuminance(hex: string): number;
|
|
411
|
+
textOnColor(hex: string): string;
|
|
412
|
+
deriveShades(hex: string): ColorShades;
|
|
413
|
+
derivePalette(config: StyleConfig): Palette;
|
|
414
|
+
harmonize(sourceHex: string, targetHex: string, amount: number): string;
|
|
415
|
+
deriveAlternateSeed(hex: string): string;
|
|
416
|
+
deriveAlternateConfig(config: StyleConfig): StyleConfig;
|
|
417
|
+
isLightPalette(config: StyleConfig): boolean;
|
|
418
|
+
colorParse(str: string, defAlpha?: number): [number, number, number, number, string];
|
|
419
|
+
colorRgbToHsl(r: number, g: number, b: number, a?: number, rnd?: boolean): [number, number, number, number];
|
|
420
|
+
colorHslToRgb(h: number, s: number, l: number, a?: number, rnd?: boolean): [number, number, number, number];
|
|
421
|
+
colorInterp(x: number, in0: number, in1: number, colors: string[], stretch?: boolean): string;
|
|
422
|
+
|
|
423
|
+
// -- Router ---------------------------------------------------------------
|
|
424
|
+
router(config: RouterConfig): RouterHandle;
|
|
425
|
+
navigate(path: string, opts?: { replace?: boolean }): void;
|
|
426
|
+
link(path: string, content: TacoContent, attrs?: TacoAttributes): Taco;
|
|
427
|
+
|
|
428
|
+
// -- BCCL Component Factories (all return Taco) ---------------------------
|
|
429
|
+
make(type: string, props?: ComponentConfig): Taco;
|
|
430
|
+
makeCard(config?: CardConfig | string): Taco;
|
|
431
|
+
makeButton(config?: ButtonConfig | string): Taco;
|
|
432
|
+
makeContainer(config?: ComponentConfig): Taco;
|
|
433
|
+
makeRow(config?: ComponentConfig): Taco;
|
|
434
|
+
makeCol(config?: ComponentConfig): Taco;
|
|
435
|
+
makeStack(config?: ComponentConfig): Taco;
|
|
436
|
+
makeSection(config?: ComponentConfig): Taco;
|
|
437
|
+
makeNav(config?: NavConfig): Taco;
|
|
438
|
+
makeNavbar(config?: ComponentConfig): Taco;
|
|
439
|
+
makeBreadcrumb(config?: ComponentConfig): Taco;
|
|
440
|
+
makeTabs(config?: TabsConfig): Taco;
|
|
441
|
+
makePagination(config?: ComponentConfig): Taco;
|
|
442
|
+
makeAlert(config?: AlertConfig | string): Taco;
|
|
443
|
+
makeBadge(config?: ComponentConfig | string): Taco;
|
|
444
|
+
makeProgress(config?: ComponentConfig): Taco;
|
|
445
|
+
makeSpinner(config?: ComponentConfig): Taco;
|
|
446
|
+
makeToast(config?: ComponentConfig): Taco;
|
|
447
|
+
makeTooltip(config?: ComponentConfig): Taco;
|
|
448
|
+
makePopover(config?: ComponentConfig): Taco;
|
|
449
|
+
makeListGroup(config?: ComponentConfig): Taco;
|
|
450
|
+
makeAccordion(config?: AccordionConfig): Taco;
|
|
451
|
+
makeCarousel(config?: CarouselConfig): Taco;
|
|
452
|
+
makeTimeline(config?: ComponentConfig): Taco;
|
|
453
|
+
makeStepper(config?: ComponentConfig): Taco;
|
|
454
|
+
makeChipInput(config?: ComponentConfig): Taco;
|
|
455
|
+
makeModal(config?: ModalConfig): Taco;
|
|
456
|
+
makeDropdown(config?: ComponentConfig): Taco;
|
|
457
|
+
makeForm(config?: ComponentConfig): Taco;
|
|
458
|
+
makeFormGroup(config?: ComponentConfig): Taco;
|
|
459
|
+
makeInput(config?: InputConfig): Taco;
|
|
460
|
+
makeTextarea(config?: ComponentConfig): Taco;
|
|
461
|
+
makeSelect(config?: ComponentConfig): Taco;
|
|
462
|
+
makeCheckbox(config?: ComponentConfig): Taco;
|
|
463
|
+
makeRadio(config?: ComponentConfig): Taco;
|
|
464
|
+
makeSwitch(config?: ComponentConfig): Taco;
|
|
465
|
+
makeRange(config?: ComponentConfig): Taco;
|
|
466
|
+
makeFileUpload(config?: ComponentConfig): Taco;
|
|
467
|
+
makeSearchInput(config?: ComponentConfig): Taco;
|
|
468
|
+
makeButtonGroup(config?: ComponentConfig): Taco;
|
|
469
|
+
makeHero(config?: ComponentConfig): Taco;
|
|
470
|
+
makeFeatureGrid(config?: ComponentConfig): Taco;
|
|
471
|
+
makeCTA(config?: ComponentConfig): Taco;
|
|
472
|
+
makeCodeDemo(config?: ComponentConfig): Taco;
|
|
473
|
+
makeSkeleton(config?: ComponentConfig): Taco;
|
|
474
|
+
makeAvatar(config?: ComponentConfig): Taco;
|
|
475
|
+
makeStatCard(config?: ComponentConfig): Taco;
|
|
476
|
+
makeMediaObject(config?: ComponentConfig): Taco;
|
|
477
|
+
makeTable(config?: TableConfig): Taco;
|
|
478
|
+
makeTableFromArray(config?: TableConfig): Taco;
|
|
479
|
+
makeDataTable(config?: TableConfig): Taco;
|
|
480
|
+
makeBarChart(config?: ComponentConfig): Taco;
|
|
481
|
+
|
|
482
|
+
// -- Corresponding create* (return DOM Element) ---------------------------
|
|
483
|
+
createCard(config?: CardConfig | string): HTMLElement;
|
|
484
|
+
createButton(config?: ButtonConfig | string): HTMLElement;
|
|
485
|
+
createContainer(config?: ComponentConfig): HTMLElement;
|
|
486
|
+
createRow(config?: ComponentConfig): HTMLElement;
|
|
487
|
+
createCol(config?: ComponentConfig): HTMLElement;
|
|
488
|
+
createStack(config?: ComponentConfig): HTMLElement;
|
|
489
|
+
createSection(config?: ComponentConfig): HTMLElement;
|
|
490
|
+
createNav(config?: NavConfig): HTMLElement;
|
|
491
|
+
createNavbar(config?: ComponentConfig): HTMLElement;
|
|
492
|
+
createBreadcrumb(config?: ComponentConfig): HTMLElement;
|
|
493
|
+
createTabs(config?: TabsConfig): HTMLElement;
|
|
494
|
+
createPagination(config?: ComponentConfig): HTMLElement;
|
|
495
|
+
createAlert(config?: AlertConfig | string): HTMLElement;
|
|
496
|
+
createBadge(config?: ComponentConfig | string): HTMLElement;
|
|
497
|
+
createProgress(config?: ComponentConfig): HTMLElement;
|
|
498
|
+
createSpinner(config?: ComponentConfig): HTMLElement;
|
|
499
|
+
createToast(config?: ComponentConfig): HTMLElement;
|
|
500
|
+
createTooltip(config?: ComponentConfig): HTMLElement;
|
|
501
|
+
createPopover(config?: ComponentConfig): HTMLElement;
|
|
502
|
+
createListGroup(config?: ComponentConfig): HTMLElement;
|
|
503
|
+
createAccordion(config?: AccordionConfig): HTMLElement;
|
|
504
|
+
createCarousel(config?: CarouselConfig): HTMLElement;
|
|
505
|
+
createTimeline(config?: ComponentConfig): HTMLElement;
|
|
506
|
+
createStepper(config?: ComponentConfig): HTMLElement;
|
|
507
|
+
createChipInput(config?: ComponentConfig): HTMLElement;
|
|
508
|
+
createModal(config?: ModalConfig): HTMLElement;
|
|
509
|
+
createDropdown(config?: ComponentConfig): HTMLElement;
|
|
510
|
+
createForm(config?: ComponentConfig): HTMLElement;
|
|
511
|
+
createFormGroup(config?: ComponentConfig): HTMLElement;
|
|
512
|
+
createInput(config?: InputConfig): HTMLElement;
|
|
513
|
+
createTextarea(config?: ComponentConfig): HTMLElement;
|
|
514
|
+
createSelect(config?: ComponentConfig): HTMLElement;
|
|
515
|
+
createCheckbox(config?: ComponentConfig): HTMLElement;
|
|
516
|
+
createRadio(config?: ComponentConfig): HTMLElement;
|
|
517
|
+
createSwitch(config?: ComponentConfig): HTMLElement;
|
|
518
|
+
createRange(config?: ComponentConfig): HTMLElement;
|
|
519
|
+
createFileUpload(config?: ComponentConfig): HTMLElement;
|
|
520
|
+
createSearchInput(config?: ComponentConfig): HTMLElement;
|
|
521
|
+
createButtonGroup(config?: ComponentConfig): HTMLElement;
|
|
522
|
+
createHero(config?: ComponentConfig): HTMLElement;
|
|
523
|
+
createFeatureGrid(config?: ComponentConfig): HTMLElement;
|
|
524
|
+
createCTA(config?: ComponentConfig): HTMLElement;
|
|
525
|
+
createCodeDemo(config?: ComponentConfig): HTMLElement;
|
|
526
|
+
createSkeleton(config?: ComponentConfig): HTMLElement;
|
|
527
|
+
createAvatar(config?: ComponentConfig): HTMLElement;
|
|
528
|
+
createStatCard(config?: ComponentConfig): HTMLElement;
|
|
529
|
+
createMediaObject(config?: ComponentConfig): HTMLElement;
|
|
530
|
+
createTable(config?: TableConfig): HTMLElement;
|
|
531
|
+
|
|
532
|
+
// -- Array Utilities ------------------------------------------------------
|
|
533
|
+
arrayUniq(arr: any[]): any[];
|
|
534
|
+
arrayBinA(a: any[], b: any[]): any[];
|
|
535
|
+
arrayBNotInA(a: any[], b: any[]): any[];
|
|
536
|
+
multiArray(value: any, dims: number[]): any[];
|
|
537
|
+
|
|
538
|
+
// -- Math -----------------------------------------------------------------
|
|
539
|
+
mapScale(x: number, in0: number, in1: number, out0: number, out1: number, options?: { clamp?: boolean; invert?: boolean; curve?: string }): number;
|
|
540
|
+
clip(value: number, min: number, max: number): number;
|
|
541
|
+
|
|
542
|
+
// -- Text & Selection -----------------------------------------------------
|
|
543
|
+
choice(x: any, choices: Record<string, any>, def?: any): any;
|
|
544
|
+
loremIpsum(numChars: number, startSpot?: number, startWithCapitalLetter?: boolean): string;
|
|
545
|
+
naturalCompare(a: string, b: string): number;
|
|
546
|
+
|
|
547
|
+
// -- Timing ---------------------------------------------------------------
|
|
548
|
+
setIntervalX(callback: Function, delay: number, repetitions: number): number;
|
|
549
|
+
repeatUntil(testFn: () => boolean, successFn: () => void, failFn?: () => void, delay?: number, maxReps?: number, lastFn?: () => void): void;
|
|
550
|
+
|
|
551
|
+
// -- Type Detection -------------------------------------------------------
|
|
552
|
+
typeOf(value: any, baseTypeOnly?: boolean): string;
|
|
553
|
+
isNodeJS(): boolean;
|
|
554
|
+
|
|
555
|
+
// -- File I/O -------------------------------------------------------------
|
|
556
|
+
saveClientFile(fname: string, data: any): void;
|
|
557
|
+
saveClientJSON(fname: string, data: any): void;
|
|
558
|
+
loadClientFile(fname: string, callback: (data: any, error?: any) => void, options?: { parser?: string }): string;
|
|
559
|
+
loadClientJSON(fname: string, callback: (data: any, error?: any) => void): string;
|
|
560
|
+
loadLocalFile(callback: (data: any, filename: string, error?: any) => void, options?: { parser?: string; accept?: string }): void;
|
|
561
|
+
loadLocalJSON(callback: (data: any, filename: string, error?: any) => void): void;
|
|
562
|
+
|
|
563
|
+
// -- Cookies & URL --------------------------------------------------------
|
|
564
|
+
setCookie(cname: string, cvalue: string, exdays: number, options?: { path?: string; domain?: string; secure?: boolean; sameSite?: string }): void;
|
|
565
|
+
getCookie(cname: string, defaultValue?: any): any;
|
|
566
|
+
getURLParam(key?: string, defaultValue?: any): any;
|
|
567
|
+
|
|
568
|
+
// -- Clipboard ------------------------------------------------------------
|
|
569
|
+
copyToClipboard(text: string): Promise<void>;
|
|
570
|
+
|
|
571
|
+
// -- JSON Parsing ---------------------------------------------------------
|
|
572
|
+
parseJSONFlex(str: string): any;
|
|
573
|
+
|
|
574
|
+
// -- Presets & Constants --------------------------------------------------
|
|
575
|
+
SPACING_PRESETS: Record<string, any>;
|
|
576
|
+
RADIUS_PRESETS: Record<string, any>;
|
|
577
|
+
TYPE_RATIO_PRESETS: Record<string, any>;
|
|
578
|
+
ELEVATION_PRESETS: Record<string, any>;
|
|
579
|
+
MOTION_PRESETS: Record<string, any>;
|
|
580
|
+
DEFAULT_PALETTE_CONFIG: StyleConfig;
|
|
581
|
+
THEME_PRESETS: Record<string, StyleConfig>;
|
|
582
|
+
BCCL: Record<string, any>;
|
|
583
|
+
|
|
584
|
+
// -- Variant helper -------------------------------------------------------
|
|
585
|
+
variantClass(variant: string): string;
|
|
586
|
+
|
|
587
|
+
// -- Internal (access at own risk) ----------------------------------------
|
|
588
|
+
_nodeMap: Record<string, HTMLElement>;
|
|
589
|
+
_el(id: string): HTMLElement | null;
|
|
590
|
+
_registerNode(el: HTMLElement, uuid: string): void;
|
|
591
|
+
_deregisterNode(el: HTMLElement, uuid: string): void;
|
|
592
|
+
_unmountCallbacks: Map<string, Function>;
|
|
593
|
+
_topics: Record<string, any[]>;
|
|
594
|
+
_fnRegistry: Record<string, Function>;
|
|
595
|
+
_componentRegistry: Map<string, any>;
|
|
596
|
+
_clientFunctions: Record<string, Function>;
|
|
597
|
+
_allowExec: boolean;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/** The bw namespace (default export) */
|
|
601
|
+
declare const bw: Bitwrench;
|
|
602
|
+
export default bw;
|
|
603
|
+
|
|
604
|
+
// Named BCCL exports for ESM tree-shaking:
|
|
605
|
+
// import { makeCard, makeButton } from 'bitwrench';
|
|
606
|
+
export function makeCard(config?: CardConfig | string): Taco;
|
|
607
|
+
export function makeButton(config?: ButtonConfig | string): Taco;
|
|
608
|
+
export function makeContainer(config?: ComponentConfig): Taco;
|
|
609
|
+
export function makeRow(config?: ComponentConfig): Taco;
|
|
610
|
+
export function makeCol(config?: ComponentConfig): Taco;
|
|
611
|
+
export function makeStack(config?: ComponentConfig): Taco;
|
|
612
|
+
export function makeSection(config?: ComponentConfig): Taco;
|
|
613
|
+
export function makeNav(config?: NavConfig): Taco;
|
|
614
|
+
export function makeNavbar(config?: ComponentConfig): Taco;
|
|
615
|
+
export function makeBreadcrumb(config?: ComponentConfig): Taco;
|
|
616
|
+
export function makeTabs(config?: TabsConfig): Taco;
|
|
617
|
+
export function makePagination(config?: ComponentConfig): Taco;
|
|
618
|
+
export function makeAlert(config?: AlertConfig | string): Taco;
|
|
619
|
+
export function makeBadge(config?: ComponentConfig | string): Taco;
|
|
620
|
+
export function makeProgress(config?: ComponentConfig): Taco;
|
|
621
|
+
export function makeSpinner(config?: ComponentConfig): Taco;
|
|
622
|
+
export function makeToast(config?: ComponentConfig): Taco;
|
|
623
|
+
export function makeTooltip(config?: ComponentConfig): Taco;
|
|
624
|
+
export function makePopover(config?: ComponentConfig): Taco;
|
|
625
|
+
export function makeListGroup(config?: ComponentConfig): Taco;
|
|
626
|
+
export function makeAccordion(config?: AccordionConfig): Taco;
|
|
627
|
+
export function makeCarousel(config?: CarouselConfig): Taco;
|
|
628
|
+
export function makeTimeline(config?: ComponentConfig): Taco;
|
|
629
|
+
export function makeStepper(config?: ComponentConfig): Taco;
|
|
630
|
+
export function makeChipInput(config?: ComponentConfig): Taco;
|
|
631
|
+
export function makeModal(config?: ModalConfig): Taco;
|
|
632
|
+
export function makeDropdown(config?: ComponentConfig): Taco;
|
|
633
|
+
export function makeForm(config?: ComponentConfig): Taco;
|
|
634
|
+
export function makeFormGroup(config?: ComponentConfig): Taco;
|
|
635
|
+
export function makeInput(config?: InputConfig): Taco;
|
|
636
|
+
export function makeTextarea(config?: ComponentConfig): Taco;
|
|
637
|
+
export function makeSelect(config?: ComponentConfig): Taco;
|
|
638
|
+
export function makeCheckbox(config?: ComponentConfig): Taco;
|
|
639
|
+
export function makeRadio(config?: ComponentConfig): Taco;
|
|
640
|
+
export function makeSwitch(config?: ComponentConfig): Taco;
|
|
641
|
+
export function makeRange(config?: ComponentConfig): Taco;
|
|
642
|
+
export function makeFileUpload(config?: ComponentConfig): Taco;
|
|
643
|
+
export function makeSearchInput(config?: ComponentConfig): Taco;
|
|
644
|
+
export function makeButtonGroup(config?: ComponentConfig): Taco;
|
|
645
|
+
export function makeHero(config?: ComponentConfig): Taco;
|
|
646
|
+
export function makeFeatureGrid(config?: ComponentConfig): Taco;
|
|
647
|
+
export function makeCTA(config?: ComponentConfig): Taco;
|
|
648
|
+
export function makeCodeDemo(config?: ComponentConfig): Taco;
|
|
649
|
+
export function makeSkeleton(config?: ComponentConfig): Taco;
|
|
650
|
+
export function makeAvatar(config?: ComponentConfig): Taco;
|
|
651
|
+
export function makeStatCard(config?: ComponentConfig): Taco;
|
|
652
|
+
export function makeMediaObject(config?: ComponentConfig): Taco;
|
|
653
|
+
export function makeTable(config?: TableConfig): Taco;
|
|
654
|
+
export function makeTableFromArray(config?: TableConfig): Taco;
|
|
655
|
+
export function makeDataTable(config?: TableConfig): Taco;
|
|
656
|
+
export function makeBarChart(config?: ComponentConfig): Taco;
|
|
657
|
+
export function make(type: string, props?: ComponentConfig): Taco;
|
|
658
|
+
export function variantClass(variant: string): string;
|
|
659
|
+
export const BCCL: Record<string, any>;
|
package/src/bitwrench.js
CHANGED
|
@@ -2478,7 +2478,8 @@ bw.applyStyles = function(styles, scope) {
|
|
|
2478
2478
|
*
|
|
2479
2479
|
* @param {Object} [config] - Style configuration (same as `makeStyles`)
|
|
2480
2480
|
* @param {string} [scope] - Scope selector (same as `applyStyles`)
|
|
2481
|
-
* @returns {
|
|
2481
|
+
* @returns {Object} The styles object (same as `makeStyles` return value:
|
|
2482
|
+
* `{css, alternateCss, palette, alternatePalette, rules, alternateRules, isLightPrimary}`)
|
|
2482
2483
|
* @category CSS & Styling
|
|
2483
2484
|
* @see bw.makeStyles
|
|
2484
2485
|
* @see bw.applyStyles
|
|
@@ -2496,9 +2497,27 @@ bw.loadStyles = function(config, scope) {
|
|
|
2496
2497
|
bw.injectCSS(structuralCSS, { id: 'bw_structural', append: false });
|
|
2497
2498
|
}
|
|
2498
2499
|
}
|
|
2499
|
-
|
|
2500
|
+
var styles = bw.makeStyles(config);
|
|
2501
|
+
bw.applyStyles(styles, scope);
|
|
2502
|
+
return styles;
|
|
2500
2503
|
};
|
|
2501
2504
|
|
|
2505
|
+
/**
|
|
2506
|
+
* Prefix every selector in a rules object with a scope selector.
|
|
2507
|
+
* Useful for wrapping site-level CSS under `.bw_theme_alt` for dark mode.
|
|
2508
|
+
*
|
|
2509
|
+
* @param {Object} rules - CSS rules object (selector -> declarations)
|
|
2510
|
+
* @param {string} prefix - Scope prefix (e.g. '.bw_theme_alt')
|
|
2511
|
+
* @returns {Object} New rules object with scoped selectors
|
|
2512
|
+
* @category CSS & Styling
|
|
2513
|
+
* @see bw.applyStyles
|
|
2514
|
+
* @see bw.css
|
|
2515
|
+
* @example
|
|
2516
|
+
* var altRules = bw.scopeRulesUnder(myRules, '.bw_theme_alt');
|
|
2517
|
+
* bw.injectCSS(bw.css(altRules));
|
|
2518
|
+
*/
|
|
2519
|
+
bw.scopeRulesUnder = scopeRulesUnder;
|
|
2520
|
+
|
|
2502
2521
|
/**
|
|
2503
2522
|
* Inject the CSS reset (box-sizing, html/body font, reduced-motion).
|
|
2504
2523
|
* Idempotent — if already injected, returns the existing `<style>` element.
|