@vobs/ui 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.
Files changed (48) hide show
  1. package/LICENSE +21 -0
  2. package/dist/app-shell-dom.d.ts +24 -0
  3. package/dist/app-shell-dom.js +573 -0
  4. package/dist/app-shell.d.ts +199 -0
  5. package/dist/app-shell.js +370 -0
  6. package/dist/base.css +52 -0
  7. package/dist/calendar-picker.d.ts +45 -0
  8. package/dist/calendar-picker.js +217 -0
  9. package/dist/calendar.d.ts +95 -0
  10. package/dist/calendar.js +194 -0
  11. package/dist/complex-inputs.d.ts +300 -0
  12. package/dist/complex-inputs.js +862 -0
  13. package/dist/components.css +4568 -0
  14. package/dist/data-display.d.ts +1063 -0
  15. package/dist/data-display.js +2298 -0
  16. package/dist/feedback.d.ts +88 -0
  17. package/dist/feedback.js +281 -0
  18. package/dist/forms.d.ts +378 -0
  19. package/dist/forms.js +1015 -0
  20. package/dist/icons-config.d.ts +25 -0
  21. package/dist/icons-config.js +14 -0
  22. package/dist/icons.d.ts +41 -0
  23. package/dist/icons.js +185 -0
  24. package/dist/index.d.ts +22 -0
  25. package/dist/index.js +32 -0
  26. package/dist/locale/en-US.d.ts +31 -0
  27. package/dist/locale/en-US.js +20 -0
  28. package/dist/locale/zh-CN.d.ts +31 -0
  29. package/dist/locale/zh-CN.js +20 -0
  30. package/dist/navigation.d.ts +609 -0
  31. package/dist/navigation.js +1707 -0
  32. package/dist/overlay.d.ts +304 -0
  33. package/dist/overlay.js +969 -0
  34. package/dist/primitives.d.ts +268 -0
  35. package/dist/primitives.js +764 -0
  36. package/dist/styles.css +3 -0
  37. package/dist/theme-data.d.ts +363 -0
  38. package/dist/theme-data.js +374 -0
  39. package/dist/theme.d.ts +79 -0
  40. package/dist/theme.js +262 -0
  41. package/dist/tokens.css +449 -0
  42. package/dist/tree.d.ts +144 -0
  43. package/dist/tree.js +469 -0
  44. package/dist/virtual-list.d.ts +190 -0
  45. package/dist/virtual-list.js +521 -0
  46. package/dist/workbench.d.ts +136 -0
  47. package/dist/workbench.js +156 -0
  48. package/package.json +113 -0
@@ -0,0 +1,25 @@
1
+ /** @license MIT
2
+ * Copyright (c) 2026 vobsjs
3
+ * @vobs/ui
4
+ */
5
+ export interface IconConfig {
6
+ readonly sources: Readonly<Record<string, SvgIconSource>>;
7
+ readonly shell?: IconShellManifest;
8
+ }
9
+ export interface IconShellManifest {
10
+ readonly topbar?: readonly string[];
11
+ readonly sidebar?: readonly string[];
12
+ readonly statusbar?: readonly string[];
13
+ }
14
+ export interface SvgIconSource {
15
+ readonly kind: 'vobs.svg-icon-source';
16
+ readonly packageName: string;
17
+ readonly options?: SvgIconSourceOptions;
18
+ }
19
+ export interface SvgIconSourceOptions {
20
+ readonly size?: 16 | 20 | 24 | (number & {});
21
+ readonly variant?: string;
22
+ readonly path?: string;
23
+ }
24
+ export declare function defineIconConfig<const Config extends IconConfig>(config: Config): Config;
25
+ export declare function svgIconSource(packageName: string, options?: SvgIconSourceOptions): SvgIconSource;
@@ -0,0 +1,14 @@
1
+ /** @license MIT
2
+ * Copyright (c) 2026 vobsjs
3
+ * @vobs/ui
4
+ */
5
+ export function defineIconConfig(config) {
6
+ return config;
7
+ }
8
+ export function svgIconSource(packageName, options) {
9
+ return {
10
+ kind: 'vobs.svg-icon-source',
11
+ packageName,
12
+ ...(options === undefined ? {} : { options }),
13
+ };
14
+ }
@@ -0,0 +1,41 @@
1
+ /** @license MIT
2
+ * Copyright (c) 2026 vobsjs
3
+ * @vobs/ui
4
+ */
5
+ import { createIconRegistry, type IconDefinition, type IconRegistry, type IconResolver } from '@vobs/icons';
6
+ import { type ComponentProps, type InjectionKey } from '@vobs/runtime-dom';
7
+ export interface UiIconEnvironment {
8
+ readonly icons?: IconRegistry | IconResolver;
9
+ }
10
+ export interface IconProps {
11
+ readonly name?: string;
12
+ readonly icon?: IconDefinition;
13
+ readonly title?: string;
14
+ readonly decorative?: boolean | string;
15
+ readonly size?: string | number;
16
+ readonly color?: string;
17
+ }
18
+ export interface UiIconRenderModel {
19
+ readonly icon: IconDefinition;
20
+ readonly title?: string;
21
+ readonly decorative?: boolean;
22
+ readonly size?: string | number;
23
+ readonly color?: string;
24
+ }
25
+ export type UiEnvironment = UiIconEnvironment;
26
+ export type CreateUiEnvironmentOptions = UiIconEnvironment;
27
+ export type UiIconSource = UiIconEnvironment | IconRegistry | IconResolver;
28
+ export interface UiIconProviderContext {
29
+ provide<T>(key: InjectionKey<T>, value: T): () => void;
30
+ }
31
+ export declare const UiIconEnvironmentKey: InjectionKey<UiIconEnvironment>;
32
+ export declare function createUiEnvironment(options?: CreateUiEnvironmentOptions): UiEnvironment;
33
+ export declare function provideUiIcons(context: UiIconProviderContext, source: UiIconSource): () => void;
34
+ export declare function resolveUiIcon(environment: UiIconEnvironment, icon: IconDefinition | string): IconDefinition | undefined;
35
+ export declare function createIconRenderModel(props: ComponentProps<IconProps>, environment: UiIconEnvironment): UiIconRenderModel;
36
+ export declare const Icon: import("@vobs/runtime-core").ComponentDefinition<IconProps, Record<string, never>, IconComponentScope, Readonly<Record<string, Readonly<Record<string, unknown>>>>>;
37
+ interface IconComponentScope {
38
+ readonly props: ComponentProps<IconProps>;
39
+ readonly environment: UiIconEnvironment;
40
+ }
41
+ export { createIconRegistry, type IconDefinition, type IconRegistry, type IconResolver };
package/dist/icons.js ADDED
@@ -0,0 +1,185 @@
1
+ /** @license MIT
2
+ * Copyright (c) 2026 vobsjs
3
+ * @vobs/ui
4
+ */
5
+ import { createIconElement, createIconRegistry, resolveIcon, } from '@vobs/icons';
6
+ import { effect } from '@vobs/reactivity';
7
+ import { createCompiledTemplate, createInjectionKey, createRuntimeError, defineComponent, } from '@vobs/runtime-dom';
8
+ export const UiIconEnvironmentKey = createInjectionKey('vobs.ui.icons');
9
+ export function createUiEnvironment(options = {}) {
10
+ return options.icons === undefined ? {} : { icons: options.icons };
11
+ }
12
+ export function provideUiIcons(context, source) {
13
+ return context.provide(UiIconEnvironmentKey, normalizeUiIconEnvironment(source));
14
+ }
15
+ export function resolveUiIcon(environment, icon) {
16
+ return resolveIcon(icon, environment.icons);
17
+ }
18
+ export function createIconRenderModel(props, environment) {
19
+ const icon = resolveIconProp(props, environment);
20
+ return {
21
+ icon,
22
+ ...readIconTitle(props),
23
+ ...readIconDecorative(props),
24
+ ...readIconSize(props),
25
+ ...readIconColor(props),
26
+ };
27
+ }
28
+ export const Icon = defineComponent({
29
+ template: createCompiledTemplate({
30
+ templateId: 'k-icon',
31
+ sourceId: '@vobs/ui/icons',
32
+ rootTag: 'svg',
33
+ mount(owner, scope, environment) {
34
+ const root = document.createElementNS(svgNamespace, 'svg');
35
+ applyProtocolAttributes(root);
36
+ applyBaseClass(root);
37
+ bindIconRoot(owner, root, scope, environment);
38
+ return { root, refs: {} };
39
+ },
40
+ hydrate(owner, root, scope, environment) {
41
+ const svg = root;
42
+ applyProtocolAttributes(svg);
43
+ applyBaseClass(svg);
44
+ bindIconRoot(owner, svg, scope, environment);
45
+ return { root: svg, refs: {} };
46
+ },
47
+ }),
48
+ props: ['name', 'icon', 'title', 'decorative', 'size', 'color'],
49
+ setup(context) {
50
+ return {
51
+ props: context.props,
52
+ environment: context.maybeInject(UiIconEnvironmentKey) ?? createUiEnvironment(),
53
+ };
54
+ },
55
+ });
56
+ const svgNamespace = 'http://www.w3.org/2000/svg';
57
+ function bindIconRoot(owner, root, scope, environment) {
58
+ owner.run(() => {
59
+ const stop = effect(() => {
60
+ const model = createIconRenderModel(scope.props, scope.environment);
61
+ renderIconRoot(root, model);
62
+ }, { scheduler: environment.scheduler });
63
+ owner.own(stop);
64
+ });
65
+ }
66
+ function renderIconRoot(root, model) {
67
+ const next = createIconElement(document, model.icon, toIconRenderOptions(model));
68
+ applyProtocolAttributes(next);
69
+ next.setAttribute('data-icon-name', model.icon.name);
70
+ root.replaceChildren(...Array.from(next.childNodes).map((node) => node.cloneNode(true)));
71
+ syncIconAttributes(root, next);
72
+ applyIconPresentation(root, model);
73
+ }
74
+ function syncIconAttributes(root, source) {
75
+ for (const attribute of controlledIconAttributes)
76
+ root.removeAttribute(attribute);
77
+ for (const attribute of Array.from(source.attributes)) {
78
+ root.setAttribute(attribute.name, attribute.value);
79
+ }
80
+ }
81
+ const controlledIconAttributes = [
82
+ 'xmlns',
83
+ 'viewBox',
84
+ 'width',
85
+ 'height',
86
+ 'fill',
87
+ 'aria-hidden',
88
+ 'role',
89
+ 'aria-label',
90
+ 'color',
91
+ 'data-icon-name',
92
+ 'data-vobs-template',
93
+ 'data-vobs-protocol',
94
+ ];
95
+ function toIconRenderOptions(model) {
96
+ return {
97
+ ...readDefined('title', model.title),
98
+ ...readDefined('decorative', model.decorative),
99
+ ...readDefined('size', normalizeIconSize(model.size)),
100
+ };
101
+ }
102
+ function resolveIconProp(props, environment) {
103
+ const direct = props.icon?.value;
104
+ if (direct !== undefined)
105
+ return direct;
106
+ const name = readOptionalString(props.name?.value);
107
+ if (name === undefined) {
108
+ throw createRuntimeError('KUI001', 'Icon requires either `name` or `icon`');
109
+ }
110
+ const icon = resolveUiIcon(environment, name);
111
+ if (icon === undefined) {
112
+ throw createRuntimeError('KUI002', `Icon is not registered: ${name}`);
113
+ }
114
+ return icon;
115
+ }
116
+ function normalizeUiIconEnvironment(source) {
117
+ if (typeof source === 'function')
118
+ return { icons: source };
119
+ if ('resolve' in source)
120
+ return { icons: source };
121
+ return source;
122
+ }
123
+ function readIconTitle(props) {
124
+ const title = readOptionalString(props.title?.value);
125
+ return title === undefined ? {} : { title };
126
+ }
127
+ function readIconDecorative(props) {
128
+ const decorative = readOptionalBoolean(props.decorative?.value);
129
+ return decorative === undefined ? {} : { decorative };
130
+ }
131
+ function readIconSize(props) {
132
+ const size = props.size?.value;
133
+ return typeof size === 'string' || typeof size === 'number' ? { size } : {};
134
+ }
135
+ function readIconColor(props) {
136
+ const color = readOptionalString(props.color?.value);
137
+ return color === undefined ? {} : { color };
138
+ }
139
+ function readOptionalString(value) {
140
+ return typeof value === 'string' && value.length > 0 ? value : undefined;
141
+ }
142
+ function readOptionalBoolean(value) {
143
+ if (typeof value === 'boolean')
144
+ return value;
145
+ if (value === '')
146
+ return true;
147
+ if (value === 'true')
148
+ return true;
149
+ if (value === 'false')
150
+ return false;
151
+ return undefined;
152
+ }
153
+ function readDefined(name, value) {
154
+ return (value === undefined ? {} : { [name]: value });
155
+ }
156
+ function applyProtocolAttributes(root) {
157
+ root.setAttribute('data-vobs-template', 'k-icon');
158
+ root.setAttribute('data-vobs-protocol', '1');
159
+ }
160
+ function applyBaseClass(root) {
161
+ root.classList.add('k-icon');
162
+ }
163
+ function applyIconPresentation(root, model) {
164
+ if (model.color === undefined)
165
+ root.removeAttribute('color');
166
+ else
167
+ root.setAttribute('color', model.color);
168
+ }
169
+ function normalizeIconSize(size) {
170
+ if (size === undefined || typeof size === 'number')
171
+ return size;
172
+ switch (size) {
173
+ case 'xs':
174
+ return 'var(--k-icon-xs)';
175
+ case 'sm':
176
+ return 'var(--k-icon-sm)';
177
+ case 'md':
178
+ return 'var(--k-icon-md)';
179
+ case 'lg':
180
+ return 'var(--k-icon-lg)';
181
+ default:
182
+ return /^\d+(?:\.\d+)?$/u.test(size) ? `${size}px` : size;
183
+ }
184
+ }
185
+ export { createIconRegistry };
@@ -0,0 +1,22 @@
1
+ /** @license MIT
2
+ * Copyright (c) 2026 vobsjs
3
+ * @vobs/ui
4
+ */
5
+ import { type ComponentRegistry, type InjectionScope } from '@vobs/runtime-dom';
6
+ import { type AppShellConfigInput } from './app-shell.js';
7
+ import { type UiIconSource } from './icons.js';
8
+ export * from './theme.js';
9
+ export * from './icons.js';
10
+ export * from './calendar.js';
11
+ export * from './calendar-picker.js';
12
+ export * from './workbench.js';
13
+ export { AppShell, UiAppShellEnvironmentKey, createAppShellRegistry, defineAppShell, defineAppShellConfig, provideUiAppShells, resolveActiveAppShellNavItemId, resolveAppShellState, resolveAppShellStatus, type AppShellAccountConfig, type AppShellAccountMenuItem, type AppShellAccountMenuItemKind, type AppShellAccountMenuItemTone, type AppShellAction, type AppShellBrandConfig, type AppShellConfigInput, type AppShellContentMode, type AppShellDefinition, type AppShellDefinitionRecord, type AppShellNavigationConfig, type AppShellNavItem, type AppShellNavItemTone, type AppShellPageHeaderConfig, type AppShellProps, type AppShellRegistry, type AppShellRouteConfig, type AppShellSidebarMode, type AppShellStatusbarConfig, type AppShellThemeIconConfig, type AppShellThemeConfig, type AppShellTopbarConfig, type ResolvedAppShellState, type ResolvedAppShellStatus, } from './app-shell.js';
14
+ export interface SetupUiOptions {
15
+ readonly icons?: true | UiIconSource;
16
+ readonly appShells?: AppShellConfigInput;
17
+ }
18
+ export interface UiSetupEnvironment {
19
+ readonly components: ComponentRegistry;
20
+ readonly injections?: InjectionScope;
21
+ }
22
+ export declare function setupUi(options?: SetupUiOptions): UiSetupEnvironment;
package/dist/index.js ADDED
@@ -0,0 +1,32 @@
1
+ /** @license MIT
2
+ * Copyright (c) 2026 vobsjs
3
+ * @vobs/ui
4
+ */
5
+ import { createInjectionScope, } from '@vobs/runtime-dom';
6
+ import { AppShell, provideUiAppShells } from './app-shell.js';
7
+ import { CalendarPicker } from './calendar-picker.js';
8
+ import { Icon, provideUiIcons } from './icons.js';
9
+ export * from './theme.js';
10
+ export * from './icons.js';
11
+ export * from './calendar.js';
12
+ export * from './calendar-picker.js';
13
+ export * from './workbench.js';
14
+ export { AppShell, UiAppShellEnvironmentKey, createAppShellRegistry, defineAppShell, defineAppShellConfig, provideUiAppShells, resolveActiveAppShellNavItemId, resolveAppShellState, resolveAppShellStatus, } from './app-shell.js';
15
+ export function setupUi(options = {}) {
16
+ const components = {
17
+ 'k-app-shell': AppShell,
18
+ 'k-icon': Icon,
19
+ 'k-calendar-picker': CalendarPicker,
20
+ };
21
+ const injections = createInjectionScope();
22
+ if (options.icons !== undefined && options.icons !== true) {
23
+ provideUiIcons(injections, options.icons);
24
+ }
25
+ if (options.appShells !== undefined) {
26
+ provideUiAppShells(injections, options.appShells);
27
+ }
28
+ if (options.icons === undefined || options.icons === true) {
29
+ return options.appShells === undefined ? { components } : { components, injections };
30
+ }
31
+ return { components, injections };
32
+ }
@@ -0,0 +1,31 @@
1
+ /** @license MIT
2
+ * Copyright (c) 2026 vobsjs
3
+ * @vobs/ui
4
+ */
5
+ export declare const enUSLocale = "en-US";
6
+ export declare const enUSMessages: {
7
+ close: string;
8
+ previous: string;
9
+ next: string;
10
+ noData: string;
11
+ loading: string;
12
+ chooseDate: string;
13
+ notification: string;
14
+ menu: string;
15
+ tabs: string;
16
+ };
17
+ declare const _default: {
18
+ locale: string;
19
+ messages: {
20
+ close: string;
21
+ previous: string;
22
+ next: string;
23
+ noData: string;
24
+ loading: string;
25
+ chooseDate: string;
26
+ notification: string;
27
+ menu: string;
28
+ tabs: string;
29
+ };
30
+ };
31
+ export default _default;
@@ -0,0 +1,20 @@
1
+ /** @license MIT
2
+ * Copyright (c) 2026 vobsjs
3
+ * @vobs/ui
4
+ */
5
+ export const enUSLocale = 'en-US';
6
+ export const enUSMessages = {
7
+ close: 'Close',
8
+ previous: 'Previous',
9
+ next: 'Next',
10
+ noData: 'No data',
11
+ loading: 'Loading',
12
+ chooseDate: 'Choose date',
13
+ notification: 'Notification',
14
+ menu: 'Menu',
15
+ tabs: 'Tabs',
16
+ };
17
+ export default {
18
+ locale: enUSLocale,
19
+ messages: enUSMessages,
20
+ };
@@ -0,0 +1,31 @@
1
+ /** @license MIT
2
+ * Copyright (c) 2026 vobsjs
3
+ * @vobs/ui
4
+ */
5
+ export declare const zhCNLocale = "zh-CN";
6
+ export declare const zhCNMessages: {
7
+ close: string;
8
+ previous: string;
9
+ next: string;
10
+ noData: string;
11
+ loading: string;
12
+ chooseDate: string;
13
+ notification: string;
14
+ menu: string;
15
+ tabs: string;
16
+ };
17
+ declare const _default: {
18
+ locale: string;
19
+ messages: {
20
+ close: string;
21
+ previous: string;
22
+ next: string;
23
+ noData: string;
24
+ loading: string;
25
+ chooseDate: string;
26
+ notification: string;
27
+ menu: string;
28
+ tabs: string;
29
+ };
30
+ };
31
+ export default _default;
@@ -0,0 +1,20 @@
1
+ /** @license MIT
2
+ * Copyright (c) 2026 vobsjs
3
+ * @vobs/ui
4
+ */
5
+ export const zhCNLocale = 'zh-CN';
6
+ export const zhCNMessages = {
7
+ close: '关闭',
8
+ previous: '上一页',
9
+ next: '下一页',
10
+ noData: '暂无数据',
11
+ loading: '加载中',
12
+ chooseDate: '选择日期',
13
+ notification: '通知',
14
+ menu: '菜单',
15
+ tabs: '标签页',
16
+ };
17
+ export default {
18
+ locale: zhCNLocale,
19
+ messages: zhCNMessages,
20
+ };