@opkle/ui-core 0.1.0
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/LICENSE +21 -0
- package/README.md +484 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2386 -0
- package/dist/index.js.map +1 -0
- package/dist/publicDictionary.d.ts +76 -0
- package/dist/publicDictionary.d.ts.map +1 -0
- package/dist/publicDictionary.js +197 -0
- package/dist/publicDictionary.js.map +1 -0
- package/package.json +56 -0
- package/src/index.ts +2332 -0
- package/src/publicDictionary.ts +286 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Opkle
|
|
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,484 @@
|
|
|
1
|
+
# @opkle/ui-core
|
|
2
|
+
|
|
3
|
+
Vanilla TypeScript UI core and DOM utility layer extracted from Opkle editor.
|
|
4
|
+
|
|
5
|
+
Opkle is a software company building advanced ebook and web-content authoring tools. Its main product, Opkle editor, is a browser-based editor for creating EPUB and rich web documents with layout control, animation, media handling, local data workflows, and AI-assisted editing.
|
|
6
|
+
|
|
7
|
+
@opkle/ui-core is the public, framework-independent frontend core extracted from that editor runtime. It is not a marketing demo, a component skin, or a thin wrapper around another framework. It is a small TypeScript utility layer for building complex browser interfaces in a direct, object-oriented, event-driven style.
|
|
8
|
+
|
|
9
|
+
The representative production website built with the same design philosophy is https://opkle.app.
|
|
10
|
+
|
|
11
|
+
## Why This Exists
|
|
12
|
+
|
|
13
|
+
Many frontend frameworks are optimized around declarative component trees and repeated rendering. That model is excellent for many products, but complex editors often have a different shape:
|
|
14
|
+
|
|
15
|
+
- many small DOM nodes are created, moved, measured, styled, and removed directly;
|
|
16
|
+
- pointer, keyboard, hover, touch, drag, resize, and document events overlap;
|
|
17
|
+
- state often lives in editor objects, local storage, IndexedDB, documents, timelines, canvases, or worker pipelines;
|
|
18
|
+
- UI behavior is frequently procedural: create this node, attach these events, insert this child, update this style, continue the workflow.
|
|
19
|
+
|
|
20
|
+
@opkle/ui-core is designed for that kind of application. It lets frontend code read more like backend application logic: a clear sequence of operations, object methods, event handlers, and explicit data flow. For editor-class software, this can be easier to reason about than forcing every interaction through a component re-render model.
|
|
21
|
+
|
|
22
|
+
The goal is not to replace React, Vue, Svelte, or any other framework for every use case. The goal is to provide a compact vanilla TypeScript foundation for interfaces where direct DOM control, event composition, and OOP-style organization are strengths.
|
|
23
|
+
|
|
24
|
+
## Core Idea
|
|
25
|
+
|
|
26
|
+
The central API is a command-object based DOM builder.
|
|
27
|
+
|
|
28
|
+
Instead of writing scattered DOM calls:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
const box = document.createElement("div");
|
|
32
|
+
box.classList.add("notice");
|
|
33
|
+
box.style.display = "flex";
|
|
34
|
+
box.style.padding = "12px";
|
|
35
|
+
box.textContent = "Saved";
|
|
36
|
+
box.addEventListener("click", onClick);
|
|
37
|
+
document.body.appendChild(box);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
you describe the node as a single object:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import AbstractNode from "@opkle/ui-core";
|
|
44
|
+
|
|
45
|
+
const box = AbstractNode.createDom({
|
|
46
|
+
mother: document.body,
|
|
47
|
+
mode: "div",
|
|
48
|
+
class: [ "notice" ],
|
|
49
|
+
text: "Saved",
|
|
50
|
+
style: {
|
|
51
|
+
padding: 12,
|
|
52
|
+
borderRadius: 6,
|
|
53
|
+
background: "#f7f7f7",
|
|
54
|
+
},
|
|
55
|
+
event: {
|
|
56
|
+
click: () => {
|
|
57
|
+
console.log("clicked");
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
That command object can include children, styles, events, attributes, insertion position, text formatting helpers, SVG creation, and chained sibling creation. This is the style Opkle uses for complex editor surfaces where UI construction is part of the application logic.
|
|
64
|
+
|
|
65
|
+
## Features
|
|
66
|
+
|
|
67
|
+
### Object-Oriented Frontend Flow
|
|
68
|
+
|
|
69
|
+
@opkle/ui-core works well when your frontend is organized around classes and domain objects:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
class InspectorPanel {
|
|
73
|
+
public root: HTMLElement;
|
|
74
|
+
|
|
75
|
+
constructor(mother: HTMLElement) {
|
|
76
|
+
this.root = AbstractNode.createDom({
|
|
77
|
+
mother,
|
|
78
|
+
mode: "section",
|
|
79
|
+
class: [ "inspector-panel" ],
|
|
80
|
+
style: {
|
|
81
|
+
width: 320,
|
|
82
|
+
height: "100%",
|
|
83
|
+
background: "#ffffff",
|
|
84
|
+
},
|
|
85
|
+
children: [
|
|
86
|
+
{
|
|
87
|
+
mode: "h2",
|
|
88
|
+
text: "Inspector",
|
|
89
|
+
style: {
|
|
90
|
+
fontSizeWeight: [ 16, 700 ],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The code follows the same rhythm as backend or Node.js logic: construct an object, create resources, attach event behavior, and expose methods. This is especially useful when the UI is not just a view of state, but an active editing surface.
|
|
100
|
+
|
|
101
|
+
### Direct DOM Creation With Sensible Defaults
|
|
102
|
+
|
|
103
|
+
createDom applies practical defaults for application UI:
|
|
104
|
+
|
|
105
|
+
- default display is flex;
|
|
106
|
+
- default position is relative;
|
|
107
|
+
- flex containers default to column direction;
|
|
108
|
+
- transform origin is normalized;
|
|
109
|
+
- numeric style values become pixel values where appropriate;
|
|
110
|
+
- pure numeric CSS properties such as opacity and zIndex stay unitless;
|
|
111
|
+
- image nodes receive a fallback alt attribute;
|
|
112
|
+
- textareas default to spellcheck=false.
|
|
113
|
+
|
|
114
|
+
It also caches the first created element for each tag name and clones it for later calls, avoiding repeated fresh createElement calls for common node types.
|
|
115
|
+
|
|
116
|
+
### Command Object Children
|
|
117
|
+
|
|
118
|
+
Nested UI can be created in one flow:
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
AbstractNode.createDom({
|
|
122
|
+
mother: document.body,
|
|
123
|
+
mode: "div",
|
|
124
|
+
class: [ "toolbar" ],
|
|
125
|
+
children: [
|
|
126
|
+
{
|
|
127
|
+
mode: "button",
|
|
128
|
+
text: "Undo",
|
|
129
|
+
event: {
|
|
130
|
+
click: undo,
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
mode: "button",
|
|
135
|
+
text: "Redo",
|
|
136
|
+
event: {
|
|
137
|
+
click: redo,
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
This is intentionally simple. It does not introduce a virtual DOM, lifecycle system, compiler, JSX transform, or runtime scheduler. The result is the actual DOM node.
|
|
145
|
+
|
|
146
|
+
### Mixing DOM And SVG Children
|
|
147
|
+
|
|
148
|
+
createNode automatically routes a command with mode: "svg" to createSvg. That means SVG icons can be placed inside ordinary DOM children without switching mental models:
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
const closeIcon = "<svg viewBox='0 0 24 24'><path d='M6 6L18 18M18 6L6 18' /></svg>";
|
|
152
|
+
|
|
153
|
+
AbstractNode.createDom({
|
|
154
|
+
mother: document.body,
|
|
155
|
+
mode: "button",
|
|
156
|
+
class: [ "icon-button" ],
|
|
157
|
+
style: {
|
|
158
|
+
widthHeight: [ 40, 40 ],
|
|
159
|
+
alignItems: "center",
|
|
160
|
+
justifyContent: "center",
|
|
161
|
+
},
|
|
162
|
+
children: [
|
|
163
|
+
{
|
|
164
|
+
mode: "svg",
|
|
165
|
+
source: closeIcon,
|
|
166
|
+
attribute: {
|
|
167
|
+
"aria-hidden": "true",
|
|
168
|
+
},
|
|
169
|
+
style: {
|
|
170
|
+
width: 18,
|
|
171
|
+
height: 18,
|
|
172
|
+
stroke: "currentColor",
|
|
173
|
+
fill: "none",
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
event: {
|
|
178
|
+
click: closePanel,
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
For a single child, you can use child. For multiple children, use children:
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
AbstractNode.createDom({
|
|
187
|
+
mother: document.body,
|
|
188
|
+
mode: "label",
|
|
189
|
+
child: {
|
|
190
|
+
mode: "input",
|
|
191
|
+
attribute: {
|
|
192
|
+
type: "checkbox",
|
|
193
|
+
checked: "true",
|
|
194
|
+
},
|
|
195
|
+
event: {
|
|
196
|
+
change: toggleOption,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Event-Oriented UI Logic
|
|
203
|
+
|
|
204
|
+
The event map is built for rich interfaces:
|
|
205
|
+
|
|
206
|
+
```ts
|
|
207
|
+
AbstractNode.createDom({
|
|
208
|
+
mother: document.body,
|
|
209
|
+
mode: "button",
|
|
210
|
+
text: "Open",
|
|
211
|
+
event: {
|
|
212
|
+
click: openPanel,
|
|
213
|
+
hover: highlightButton,
|
|
214
|
+
"keydown$keyup": syncShortcutState,
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Notable event behavior:
|
|
220
|
+
|
|
221
|
+
- click handlers automatically get pointer cursor styling when no cursor is provided;
|
|
222
|
+
- hover stores the original style and restores it on mouseleave;
|
|
223
|
+
- touch is normalized for iOS-like pointer behavior;
|
|
224
|
+
- multiple events can be bound with a $ separated event key.
|
|
225
|
+
|
|
226
|
+
This event-first model is one of the main reasons @opkle/ui-core fits editor UI. Complex editors are often closer to event systems than page templates.
|
|
227
|
+
|
|
228
|
+
### Attributes, Inputs, And Form Controls
|
|
229
|
+
|
|
230
|
+
Attributes are set with the attribute object. This keeps element creation, configuration, and event wiring together:
|
|
231
|
+
|
|
232
|
+
```ts
|
|
233
|
+
const emailInput = AbstractNode.createDom({
|
|
234
|
+
mother: document.body,
|
|
235
|
+
mode: "input",
|
|
236
|
+
class: [ "email-input" ],
|
|
237
|
+
attribute: {
|
|
238
|
+
type: "email",
|
|
239
|
+
name: "email",
|
|
240
|
+
placeholder: "you@example.com",
|
|
241
|
+
autocomplete: "email",
|
|
242
|
+
value: "",
|
|
243
|
+
"aria-label": "Email address",
|
|
244
|
+
},
|
|
245
|
+
style: {
|
|
246
|
+
width: 320,
|
|
247
|
+
height: 42,
|
|
248
|
+
padding: "0 12px",
|
|
249
|
+
border: "1px solid #dddddd",
|
|
250
|
+
borderRadius: 6,
|
|
251
|
+
},
|
|
252
|
+
event: {
|
|
253
|
+
focus: (event) => {
|
|
254
|
+
const input = event.currentTarget as HTMLInputElement;
|
|
255
|
+
input.style.borderColor = "#006bd2";
|
|
256
|
+
},
|
|
257
|
+
blur: (event) => {
|
|
258
|
+
const input = event.currentTarget as HTMLInputElement;
|
|
259
|
+
input.style.borderColor = "#dddddd";
|
|
260
|
+
},
|
|
261
|
+
keyup: (event) => {
|
|
262
|
+
const input = event.currentTarget as HTMLInputElement;
|
|
263
|
+
console.log(input.value);
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
}) as HTMLInputElement;
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Input type is just an attribute, so the same pattern works for text, email, password, number, search, checkbox, radio, range, file, date, color, and other native input types.
|
|
270
|
+
|
|
271
|
+
Buttons, inputs, and panels can be wired in the same command flow:
|
|
272
|
+
|
|
273
|
+
```ts
|
|
274
|
+
AbstractNode.createDom({
|
|
275
|
+
mother: document.body,
|
|
276
|
+
mode: "div",
|
|
277
|
+
class: [ "login-row" ],
|
|
278
|
+
children: [
|
|
279
|
+
{
|
|
280
|
+
mode: "input",
|
|
281
|
+
attribute: {
|
|
282
|
+
type: "password",
|
|
283
|
+
placeholder: "Password",
|
|
284
|
+
},
|
|
285
|
+
event: {
|
|
286
|
+
keyup: validatePassword,
|
|
287
|
+
focus: openPasswordHelp,
|
|
288
|
+
blur: closePasswordHelp,
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
mode: "button",
|
|
293
|
+
text: "Sign in",
|
|
294
|
+
attribute: {
|
|
295
|
+
type: "button",
|
|
296
|
+
},
|
|
297
|
+
event: {
|
|
298
|
+
click: submitLogin,
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
],
|
|
302
|
+
});
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
This is a small detail, but it is important for editor and tool interfaces: DOM shape, attributes, and behavior can stay in one readable object instead of being split across templates, refs, effects, and separate event binding code.
|
|
306
|
+
|
|
307
|
+
### Style Shorthands For Dense UI Code
|
|
308
|
+
|
|
309
|
+
The style object supports practical shortcuts:
|
|
310
|
+
|
|
311
|
+
```ts
|
|
312
|
+
AbstractNode.createDom({
|
|
313
|
+
mother: document.body,
|
|
314
|
+
mode: "div",
|
|
315
|
+
text: "Title",
|
|
316
|
+
style: {
|
|
317
|
+
widthHeight: [ 240, 48 ],
|
|
318
|
+
fontSizeWeight: [ 18, 700 ],
|
|
319
|
+
fontColor: "#303030",
|
|
320
|
+
textGradient: "linear-gradient(90deg, #006bd2, #2fa678)",
|
|
321
|
+
},
|
|
322
|
+
});
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
Supported patterns include:
|
|
326
|
+
|
|
327
|
+
- widthHeight: set width and height together;
|
|
328
|
+
- fontSizeWeight: set font-size and font-weight together;
|
|
329
|
+
- fontColor: alias for color;
|
|
330
|
+
- textGradient: background-clipped gradient text;
|
|
331
|
+
- automatic camelCase to CSS property handling;
|
|
332
|
+
- numeric-to-unit conversion using the current unit system.
|
|
333
|
+
|
|
334
|
+
### Inline Text Formatting Helpers
|
|
335
|
+
|
|
336
|
+
createDom can apply inline formatting markers inside text while keeping the surrounding node creation in one command object. It supports separate style objects for bold, italic, underline, strike, code, reference, special, and anchor-like text regions.
|
|
337
|
+
|
|
338
|
+
This is useful in editor surfaces where generated UI labels, notices, or document-related controls need small pieces of styled inline text without manually building many nested nodes.
|
|
339
|
+
|
|
340
|
+
### SVG Utilities
|
|
341
|
+
|
|
342
|
+
@opkle/ui-core includes lightweight SVG helpers:
|
|
343
|
+
|
|
344
|
+
```ts
|
|
345
|
+
import AbstractNode, { SvgTong } from "@opkle/ui-core";
|
|
346
|
+
|
|
347
|
+
const icon = SvgTong.stringParsing("<svg viewBox='0 0 24 24'></svg>");
|
|
348
|
+
const ratio = icon.getRatio();
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
createSvg works with the same command-object style as createDom, so SVG nodes can be styled, attributed, and inserted with a similar flow:
|
|
352
|
+
|
|
353
|
+
```ts
|
|
354
|
+
const arrowSource = "<svg viewBox='0 0 24 24'><path d='M5 12H19M13 6L19 12L13 18' /></svg>";
|
|
355
|
+
|
|
356
|
+
const arrow = AbstractNode.createSvg({
|
|
357
|
+
mother: document.body,
|
|
358
|
+
mode: "svg",
|
|
359
|
+
source: arrowSource,
|
|
360
|
+
class: [ "arrow-icon" ],
|
|
361
|
+
attribute: {
|
|
362
|
+
role: "img",
|
|
363
|
+
"aria-label": "Next",
|
|
364
|
+
},
|
|
365
|
+
style: {
|
|
366
|
+
width: 24,
|
|
367
|
+
height: 24,
|
|
368
|
+
stroke: "#303030",
|
|
369
|
+
fill: "none",
|
|
370
|
+
},
|
|
371
|
+
event: {
|
|
372
|
+
click: goNext,
|
|
373
|
+
hover: (event) => {
|
|
374
|
+
const svg = event.currentTarget as SVGElement;
|
|
375
|
+
svg.style.stroke = "#006bd2";
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
document.body.appendChild(arrow.source);
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
When SVG is used inside children, createNode handles the createSvg branch for you. When you need the SvgDom wrapper directly, call createSvg.
|
|
384
|
+
|
|
385
|
+
### Responsive Value Helpers
|
|
386
|
+
|
|
387
|
+
The package includes media helpers for choosing values by viewport width:
|
|
388
|
+
|
|
389
|
+
```ts
|
|
390
|
+
const gap = AbstractNode.mediaNumber(32, 28, 24, 18, 12);
|
|
391
|
+
const width = AbstractNode.mediaString("1280px", "1024px", "900px", "720px", "100%");
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
This keeps responsive application code close to the logic that uses it.
|
|
395
|
+
|
|
396
|
+
### Utility Surface
|
|
397
|
+
|
|
398
|
+
The public API also includes:
|
|
399
|
+
|
|
400
|
+
- sleep for async workflow timing;
|
|
401
|
+
- setThrottle for event throttling;
|
|
402
|
+
- cssCalc for CSS calc expressions;
|
|
403
|
+
- pixelUnit and eaUnit helpers;
|
|
404
|
+
- MIME type maps and reverse lookup;
|
|
405
|
+
- a shared color token dictionary;
|
|
406
|
+
- SVG string makers for common icon shapes.
|
|
407
|
+
|
|
408
|
+
## When To Use It
|
|
409
|
+
|
|
410
|
+
Use @opkle/ui-core when you are building:
|
|
411
|
+
|
|
412
|
+
- browser-based editors;
|
|
413
|
+
- document tools;
|
|
414
|
+
- ebook or web-content authoring interfaces;
|
|
415
|
+
- animation or media-heavy tools;
|
|
416
|
+
- local-first web apps;
|
|
417
|
+
- UI systems where direct DOM control is a feature, not a problem;
|
|
418
|
+
- TypeScript applications organized around classes, modules, and explicit event flows.
|
|
419
|
+
|
|
420
|
+
It is probably not the first choice if you want a declarative component framework, server components, JSX-first rendering, or a large ecosystem of ready-made UI components.
|
|
421
|
+
|
|
422
|
+
## Relationship To Opkle Editor
|
|
423
|
+
|
|
424
|
+
Opkle editor is a production editor for EPUB and web-content workflows. It includes local document handling, rich layout editing, media insertion, animation features, AI-assisted text work, and publishing-oriented utilities.
|
|
425
|
+
|
|
426
|
+
@opkle/ui-core is the small public core extracted from that larger internal system. Business logic, private editor modules, server integration, and Opkle-specific application code are not included. The package is focused on reusable frontend primitives.
|
|
427
|
+
|
|
428
|
+
## Installation
|
|
429
|
+
|
|
430
|
+
```sh
|
|
431
|
+
npm install @opkle/ui-core
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
## Basic Usage
|
|
435
|
+
|
|
436
|
+
```ts
|
|
437
|
+
import AbstractNode from "@opkle/ui-core";
|
|
438
|
+
|
|
439
|
+
const app = AbstractNode.createDom({
|
|
440
|
+
mother: document.body,
|
|
441
|
+
mode: "main",
|
|
442
|
+
class: [ "app" ],
|
|
443
|
+
style: {
|
|
444
|
+
width: "100%",
|
|
445
|
+
minHeight: "100vh",
|
|
446
|
+
padding: 24,
|
|
447
|
+
background: "#ffffff",
|
|
448
|
+
},
|
|
449
|
+
children: [
|
|
450
|
+
{
|
|
451
|
+
mode: "h1",
|
|
452
|
+
text: "Opkle UI Core",
|
|
453
|
+
style: {
|
|
454
|
+
fontSizeWeight: [ 28, 800 ],
|
|
455
|
+
margin: 0,
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
mode: "p",
|
|
460
|
+
text: "Build complex frontend tools with direct DOM control.",
|
|
461
|
+
style: {
|
|
462
|
+
marginTop: 12,
|
|
463
|
+
fontSize: 16,
|
|
464
|
+
color: "#404040",
|
|
465
|
+
},
|
|
466
|
+
},
|
|
467
|
+
],
|
|
468
|
+
});
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
## Exports
|
|
472
|
+
|
|
473
|
+
```ts
|
|
474
|
+
import AbstractNode, { AbstractNode as NamedAbstractNode, SvgTong, SvgDom } from "@opkle/ui-core";
|
|
475
|
+
import type { DomCommand, DomStyle } from "@opkle/ui-core/publicDictionary";
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
## Status
|
|
479
|
+
|
|
480
|
+
This package is being prepared as the public UI core of Opkle's frontend tooling. The API is intentionally small and focused. More examples and documentation will be added as the open-source project grows.
|
|
481
|
+
|
|
482
|
+
## License
|
|
483
|
+
|
|
484
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { DomCommand, SvgTong, SvgDom } from "./publicDictionary.js";
|
|
2
|
+
declare class AbstractNode {
|
|
3
|
+
static timeouts: Record<string, ReturnType<typeof window.setTimeout> | null>;
|
|
4
|
+
static mimeTypes: Record<string, string>;
|
|
5
|
+
static mimeTypesToKind: Map<string, string>;
|
|
6
|
+
mimeTypes: Record<string, string>;
|
|
7
|
+
static colorExtended: Record<string, string>;
|
|
8
|
+
colorExtended: Record<string, string>;
|
|
9
|
+
static svgMaker: Record<string, (...args: any[]) => string>;
|
|
10
|
+
svgMaker: Record<string, (...args: any[]) => string>;
|
|
11
|
+
static mediaCondition: number[][];
|
|
12
|
+
static pureNumberProperty: string[];
|
|
13
|
+
private static elementCache;
|
|
14
|
+
private static cloneCachedElement;
|
|
15
|
+
mediaCondition: number[][];
|
|
16
|
+
static mediaStandardWidth: () => number;
|
|
17
|
+
static mediaConditionToArray: (booleanMode?: boolean) => Array<string | boolean>;
|
|
18
|
+
static mediaNumber: (bigDesktop: number, desktop: number, smallDesktop: number, tablet: number, mobile: number) => number;
|
|
19
|
+
static mediaString: (bigDesktop: string, desktop: string, smallDesktop: string, tablet: string, mobile: string) => string;
|
|
20
|
+
static mediaEa: () => string;
|
|
21
|
+
static createNode: (mode: DomCommand) => HTMLElement | SvgDom;
|
|
22
|
+
static createDom: (domCommandObject: DomCommand) => HTMLElement;
|
|
23
|
+
static createSvg: (domCommandObject: DomCommand) => SvgDom;
|
|
24
|
+
static withOut: (percent: number | string, num?: string | number, ea?: string) => string;
|
|
25
|
+
static sleep: (time: number) => Promise<string>;
|
|
26
|
+
static pixelUnit: (num: number | string) => string;
|
|
27
|
+
static eaUnit: (num: number) => string;
|
|
28
|
+
static cssCalc: (x: string | number, mode: string, y: string | number, prettyMode?: boolean) => string;
|
|
29
|
+
static setThrottle: (callback: () => unknown, ms?: number) => () => void;
|
|
30
|
+
mediaConditionToArray(): Array<string | boolean>;
|
|
31
|
+
mediaNumber(bigDesktop: number, desktop: number, smallDesktop: number, tablet: number, mobile: number): number;
|
|
32
|
+
mediaString(bigDesktop: string, desktop: string, smallDesktop: string, tablet: string, mobile: string): string;
|
|
33
|
+
mediaEa(): string;
|
|
34
|
+
createNode(domCommandObject: DomCommand): HTMLElement | SvgDom;
|
|
35
|
+
createDom(domCommandObject: DomCommand): HTMLElement;
|
|
36
|
+
createSvg(domCommandObject: DomCommand): SvgDom;
|
|
37
|
+
sleep(time: number): Promise<string>;
|
|
38
|
+
pixelUnit(num: number | string): string;
|
|
39
|
+
eaUnit(num: number): string;
|
|
40
|
+
cssCalc(x: string | number, mode: string, y: string | number): string;
|
|
41
|
+
setThrottle(callback: () => unknown, ms?: number): () => void;
|
|
42
|
+
}
|
|
43
|
+
export { AbstractNode, SvgTong, SvgDom, };
|
|
44
|
+
export default AbstractNode;
|
|
45
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAuB,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEzF,cAAM,YAAY;IAEhB,OAAc,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAM;IACzF,OAAc,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAa;IAC5D,OAAc,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAS7C;IACE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAA0B;IAClE,OAAc,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA0KjD;IACK,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAA8B;IAC1E,OAAc,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,CAAC,CA4kBjE;IACM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,CAAC,CAAyB;IACpF,OAAc,cAAc,EAAE,MAAM,EAAE,EAAE,CAMtC;IAEF,OAAc,kBAAkB,EAAE,MAAM,EAAE,CAYzC;IAED,OAAO,CAAC,MAAM,CAAC,YAAY,CAA8D;IAEzF,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAiBhC;IAEM,cAAc,EAAE,MAAM,EAAE,EAAE,CAA+B;IAEhE,OAAc,kBAAkB,QAAO,MAAM,CAO5C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