@assistant-wi/core 0.0.8 → 0.0.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.
@@ -0,0 +1 @@
1
+ "use strict";function i(t,o,e){const n={};return h(n,t,o),w(n,t),v(n,t,e),n}function h(t,o,e){for(const n of e)Object.defineProperty(t,n,{value:a=>(o[n]=a,t),enumerable:!1,writable:!1,configurable:!1})}function v(t,o,e){if(!e)return;const n=e(o);for(const a of Object.keys(n))Object.defineProperty(t,a,{value:(...r)=>(n[a]?.(...r),t),enumerable:!1,writable:!1,configurable:!1})}function w(t,o){Object.defineProperty(t,"build",{value:()=>o,enumerable:!1,writable:!1,configurable:!1})}function s(...t){return i({type:"block",nodes:t,width:"auto",align:"start",justify:"start"},["direction","gap","nodes","width","align","justify"],e=>({row(){e.direction="row"},col(){e.direction="col"},addNode(n){e.nodes.push(n)}}))}function l(...t){return s(...t).row()}function d(...t){return s(...t).col()}function f(t){return i({type:"button",text:t},["text","variant","onClick"],e=>({primary(){e.variant="primary"},secondary(){e.variant="secondary"},outline(){e.variant="outline"},ghost(){e.variant="ghost"},destructive(){e.variant="destructive"}}))}function m(...t){return i({type:"form",nodes:t,submitTitle:"Submit"},["title","description","submitTitle","onSubmit","nodes"],e=>({addNode(n){e.nodes.push(n)}}))}function p(t){return i({type:"list",pagination:t??(()=>({items:[],hasMore:!1}))},["pagination","title","totalPages"],e=>({staticPagination(n,a){const r=Math.max(1,Math.floor(a||0)),c=Math.ceil(n.length/r);e.totalPages=c,e.pagination=g=>{if(c===0)return{items:[],hasMore:!1};const y=Math.max(1,Math.floor(g||0)),u=Math.min(y,c);return{items:n.slice((u-1)*r,u*r),hasMore:u<c}}}}))}function b(t){return i({type:"text",text:t,animation:"none",color:"primary",weight:"normal",size:"md"},["text","color","weight","size","animation"],e=>({primary(){e.color="primary"},muted(){e.color="muted"},shimmering(n={}){e.animation={type:"shimmering",...n}}}))}const P=Object.freeze(Object.defineProperty({__proto__:null,block:s,button:f,col:d,form:m,list:p,row:l,text:b},Symbol.toStringTag,{value:"Module"}));exports.block=s;exports.button=f;exports.col=d;exports.form=m;exports.index=P;exports.list=p;exports.row=l;exports.text=b;
@@ -0,0 +1,166 @@
1
+ function i(t, n, e) {
2
+ const a = {};
3
+ return f(a, t, n), p(a, t), m(a, t, e), a;
4
+ }
5
+ function f(t, n, e) {
6
+ for (const a of e)
7
+ Object.defineProperty(t, a, {
8
+ value: (o) => (n[a] = o, t),
9
+ enumerable: !1,
10
+ writable: !1,
11
+ configurable: !1
12
+ });
13
+ }
14
+ function m(t, n, e) {
15
+ if (!e) return;
16
+ const a = e(n);
17
+ for (const o of Object.keys(a))
18
+ Object.defineProperty(t, o, {
19
+ value: (...r) => (a[o]?.(...r), t),
20
+ enumerable: !1,
21
+ writable: !1,
22
+ configurable: !1
23
+ });
24
+ }
25
+ function p(t, n) {
26
+ Object.defineProperty(t, "build", {
27
+ value: () => n,
28
+ enumerable: !1,
29
+ writable: !1,
30
+ configurable: !1
31
+ });
32
+ }
33
+ function u(...t) {
34
+ return i(
35
+ {
36
+ type: "block",
37
+ nodes: t,
38
+ width: "auto",
39
+ align: "start",
40
+ justify: "start"
41
+ },
42
+ ["direction", "gap", "nodes", "width", "align", "justify"],
43
+ (e) => ({
44
+ row() {
45
+ e.direction = "row";
46
+ },
47
+ col() {
48
+ e.direction = "col";
49
+ },
50
+ addNode(a) {
51
+ e.nodes.push(a);
52
+ }
53
+ })
54
+ );
55
+ }
56
+ function b(...t) {
57
+ return u(...t).row();
58
+ }
59
+ function g(...t) {
60
+ return u(...t).col();
61
+ }
62
+ function y(t) {
63
+ return i({
64
+ type: "button",
65
+ text: t
66
+ }, ["text", "variant", "onClick"], (e) => ({
67
+ primary() {
68
+ e.variant = "primary";
69
+ },
70
+ secondary() {
71
+ e.variant = "secondary";
72
+ },
73
+ outline() {
74
+ e.variant = "outline";
75
+ },
76
+ ghost() {
77
+ e.variant = "ghost";
78
+ },
79
+ destructive() {
80
+ e.variant = "destructive";
81
+ }
82
+ }));
83
+ }
84
+ function h(...t) {
85
+ return i(
86
+ {
87
+ type: "form",
88
+ nodes: t,
89
+ submitTitle: "Submit"
90
+ },
91
+ ["title", "description", "submitTitle", "onSubmit", "nodes"],
92
+ (e) => ({
93
+ addNode(a) {
94
+ e.nodes.push(a);
95
+ }
96
+ })
97
+ );
98
+ }
99
+ function v(t) {
100
+ return i({
101
+ type: "list",
102
+ pagination: t ?? (() => ({ items: [], hasMore: !1 }))
103
+ }, ["pagination", "title", "totalPages"], (e) => ({
104
+ staticPagination(a, o) {
105
+ const r = Math.max(1, Math.floor(o || 0)), s = Math.ceil(a.length / r);
106
+ e.totalPages = s, e.pagination = (l) => {
107
+ if (s === 0) return { items: [], hasMore: !1 };
108
+ const d = Math.max(1, Math.floor(l || 0)), c = Math.min(d, s);
109
+ return {
110
+ items: a.slice(
111
+ (c - 1) * r,
112
+ c * r
113
+ ),
114
+ hasMore: c < s
115
+ };
116
+ };
117
+ }
118
+ }));
119
+ }
120
+ function w(t) {
121
+ return i(
122
+ {
123
+ type: "text",
124
+ text: t,
125
+ animation: "none",
126
+ color: "primary",
127
+ weight: "normal",
128
+ size: "md"
129
+ },
130
+ ["text", "color", "weight", "size", "animation"],
131
+ (e) => ({
132
+ primary() {
133
+ e.color = "primary";
134
+ },
135
+ muted() {
136
+ e.color = "muted";
137
+ },
138
+ shimmering(a = {}) {
139
+ e.animation = {
140
+ type: "shimmering",
141
+ ...a
142
+ };
143
+ }
144
+ })
145
+ );
146
+ }
147
+ const P = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
148
+ __proto__: null,
149
+ block: u,
150
+ button: y,
151
+ col: g,
152
+ form: h,
153
+ list: v,
154
+ row: b,
155
+ text: w
156
+ }, Symbol.toStringTag, { value: "Module" }));
157
+ export {
158
+ y as a,
159
+ u as b,
160
+ g as c,
161
+ h as f,
162
+ P as i,
163
+ v as l,
164
+ b as r,
165
+ w as t
166
+ };
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DMcbwFzr.js"),i=require("./index-DjmSSUD0.js");exports.tool=e.index;exports.ui=i.index;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DMcbwFzr.js"),i=require("./index-CuC3Zv7t.js");exports.tool=e.index;exports.ui=i.index;
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { i } from "./index-BXj6EgSG.mjs";
2
- import { i as a } from "./index-Csxo4340.mjs";
2
+ import { i as a } from "./index-KeJx8f_d.mjs";
3
3
  export {
4
4
  i as tool,
5
5
  a as ui
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../index-DjmSSUD0.js");exports.block=o.block;exports.button=o.button;exports.col=o.col;exports.form=o.form;exports.row=o.row;exports.text=o.text;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../index-CuC3Zv7t.js");exports.block=t.block;exports.button=t.button;exports.col=t.col;exports.form=t.form;exports.list=t.list;exports.row=t.row;exports.text=t.text;
@@ -2,4 +2,5 @@ export * from './ui';
2
2
  export * from './ui-block';
3
3
  export * from './ui-button';
4
4
  export * from './ui-form';
5
+ export * from './ui-list';
5
6
  export * from './ui-text';
@@ -1,9 +1,10 @@
1
- import { b as s, a as t, c as r, f as b, r as c, t as f } from "../index-Csxo4340.mjs";
1
+ import { b as o, a as t, c as r, f as l, l as b, r as c, t as f } from "../index-KeJx8f_d.mjs";
2
2
  export {
3
- s as block,
3
+ o as block,
4
4
  t as button,
5
5
  r as col,
6
- b as form,
6
+ l as form,
7
+ b as list,
7
8
  c as row,
8
9
  f as text
9
10
  };
@@ -2,20 +2,23 @@ import { UI } from './ui';
2
2
  export interface UIBlock {
3
3
  type: 'block';
4
4
  nodes: UI[];
5
+ width?: 'auto' | 'full' | `${number}%` | undefined;
5
6
  direction?: 'row' | 'col' | undefined;
6
7
  gap?: number | undefined;
8
+ align?: 'start' | 'center' | 'end' | undefined;
9
+ justify?: 'start' | 'center' | 'end' | undefined;
7
10
  }
8
- export declare function block(...nodes: UI[]): import('./builder').Builder<UIBlock, ("direction" | "gap" | "nodes")[], {
11
+ export declare function block(...nodes: UI[]): import('./builder').Builder<UIBlock, ("direction" | "gap" | "nodes" | "width" | "align" | "justify")[], {
9
12
  row(): void;
10
13
  col(): void;
11
14
  addNode(node: UI): void;
12
15
  }>;
13
- export declare function row(...nodes: UI[]): import('./builder').Builder<UIBlock, ("direction" | "gap" | "nodes")[], {
16
+ export declare function row(...nodes: UI[]): import('./builder').Builder<UIBlock, ("direction" | "gap" | "nodes" | "width" | "align" | "justify")[], {
14
17
  row(): void;
15
18
  col(): void;
16
19
  addNode(node: UI): void;
17
20
  }>;
18
- export declare function col(...nodes: UI[]): import('./builder').Builder<UIBlock, ("direction" | "gap" | "nodes")[], {
21
+ export declare function col(...nodes: UI[]): import('./builder').Builder<UIBlock, ("direction" | "gap" | "nodes" | "width" | "align" | "justify")[], {
19
22
  row(): void;
20
23
  col(): void;
21
24
  addNode(node: UI): void;
@@ -2,7 +2,7 @@ export interface UIButton {
2
2
  type: 'button';
3
3
  text: string;
4
4
  variant?: 'primary' | 'secondary' | 'outline' | 'ghost' | 'destructive';
5
- onClick?: () => void;
5
+ onClick?: () => void | Promise<void>;
6
6
  }
7
7
  export declare function button(text: string): import('./builder').Builder<UIButton, ("text" | "variant" | "onClick")[], {
8
8
  primary(): void;
@@ -4,7 +4,7 @@ export interface UIForm {
4
4
  description?: string;
5
5
  nodes: UIFormNode[];
6
6
  submitTitle?: string;
7
- onSubmit?: (values: Record<string, string>) => Promise<void>;
7
+ onSubmit?: (values: Record<string, string>) => void | Promise<void>;
8
8
  }
9
9
  export interface UIFormNode {
10
10
  type: 'text' | 'number' | 'email' | 'tel' | 'url' | 'password';
@@ -15,6 +15,6 @@ export interface UIFormNode {
15
15
  value?: string;
16
16
  onChange?: (value: string) => void;
17
17
  }
18
- export declare function form(...nodes: UIFormNode[]): import('./builder').Builder<UIForm, ("title" | "description" | "submitTitle" | "onSubmit")[], {
18
+ export declare function form(...nodes: UIFormNode[]): import('./builder').Builder<UIForm, ("nodes" | "title" | "description" | "submitTitle" | "onSubmit")[], {
19
19
  addNode(node: UIFormNode): void;
20
20
  }>;
@@ -0,0 +1,21 @@
1
+ export interface UIList {
2
+ type: 'list';
3
+ pagination: UIListPagination;
4
+ title?: string;
5
+ totalPages?: number;
6
+ }
7
+ export interface UIListItem {
8
+ id: string;
9
+ title: string;
10
+ description?: string;
11
+ avatar?: string;
12
+ onClick?: () => void | Promise<void>;
13
+ }
14
+ export interface UIListPaginationResponse {
15
+ items: UIListItem[];
16
+ hasMore?: boolean;
17
+ }
18
+ export type UIListPagination = (page: number) => UIListPaginationResponse | Promise<UIListPaginationResponse>;
19
+ export declare function list(pagination?: UIListPagination): import('./builder').Builder<UIList, ("title" | "pagination" | "totalPages")[], {
20
+ staticPagination(items: UIListItem[], itemsPerPage: number): void;
21
+ }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,17 @@
1
1
  export interface UIText {
2
2
  type: 'text';
3
3
  text: string;
4
+ color?: 'primary' | 'muted';
5
+ weight?: 'normal' | 'medium' | 'semibold' | 'bold' | 'extrabold';
6
+ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
7
+ animation?: 'none' | UITextAnimationShimmering;
4
8
  }
5
- export declare function text(text: string): UIText;
9
+ export type UITextAnimationShimmering = {
10
+ type: 'shimmering';
11
+ duration?: number;
12
+ };
13
+ export declare function text(text: string): import('./builder').Builder<UIText, ("text" | "color" | "weight" | "size" | "animation")[], {
14
+ primary(): void;
15
+ muted(): void;
16
+ shimmering(props?: Omit<UITextAnimationShimmering, "type">): void;
17
+ }>;
@@ -0,0 +1 @@
1
+ export {};
package/dist/ui/ui.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { UIBlock } from './ui-block';
2
2
  import { UIButton } from './ui-button';
3
3
  import { UIForm } from './ui-form';
4
+ import { UIList } from './ui-list';
4
5
  import { UIText } from './ui-text';
5
6
  export type UI = UIObject | {
6
7
  build(): UIObject;
7
8
  };
8
- export type UIObject = UIBlock | UIText | UIButton | UIForm;
9
+ export type UIObject = UIBlock | UIText | UIButton | UIForm | UIList;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@assistant-wi/core",
3
3
  "private": false,
4
- "version": "0.0.8",
4
+ "version": "0.0.10",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.es.js",
7
7
  "types": "./dist/index.d.ts",
@@ -34,9 +34,11 @@
34
34
  }
35
35
  },
36
36
  "scripts": {
37
+ "b": "tsc -b && vite build -c vite.config.ts",
37
38
  "build": "tsc -b && vite build -c vite.config.ts",
38
39
  "lint": "eslint .",
39
- "fmt": "prettier --write ."
40
+ "fmt": "prettier --write .",
41
+ "test": "vitest"
40
42
  },
41
43
  "devDependencies": {
42
44
  "@tsconfig/strictest": "^2.0.5",
@@ -1,112 +0,0 @@
1
- function a(t, r, e) {
2
- const n = {};
3
- return c(n, t, r), l(n, t), s(n, t, e), n;
4
- }
5
- function c(t, r, e) {
6
- for (const n of e)
7
- Object.defineProperty(t, n, {
8
- value: (o) => (r[n] = o, t),
9
- enumerable: !1,
10
- writable: !1,
11
- configurable: !1
12
- });
13
- }
14
- function s(t, r, e) {
15
- if (!e) return;
16
- const n = e(r);
17
- for (const o of Object.keys(n))
18
- Object.defineProperty(t, o, {
19
- value: (...u) => (n[o]?.(...u), t),
20
- enumerable: !1,
21
- writable: !1,
22
- configurable: !1
23
- });
24
- }
25
- function l(t, r) {
26
- Object.defineProperty(t, "build", {
27
- value: () => r,
28
- enumerable: !1,
29
- writable: !1,
30
- configurable: !1
31
- });
32
- }
33
- function i(...t) {
34
- return a({ type: "block", nodes: t ?? [] }, ["direction", "gap", "nodes"], (e) => ({
35
- row() {
36
- e.direction = "row";
37
- },
38
- col() {
39
- e.direction = "col";
40
- },
41
- addNode(n) {
42
- e.nodes.push(n);
43
- }
44
- }));
45
- }
46
- function d(...t) {
47
- return i(...t).row();
48
- }
49
- function f(...t) {
50
- return i(...t).col();
51
- }
52
- function b(t) {
53
- return a({
54
- type: "button",
55
- text: t
56
- }, ["text", "variant", "onClick"], (e) => ({
57
- primary() {
58
- e.variant = "primary";
59
- },
60
- secondary() {
61
- e.variant = "secondary";
62
- },
63
- outline() {
64
- e.variant = "outline";
65
- },
66
- ghost() {
67
- e.variant = "ghost";
68
- },
69
- destructive() {
70
- e.variant = "destructive";
71
- }
72
- }));
73
- }
74
- function p(...t) {
75
- return a(
76
- {
77
- type: "form",
78
- nodes: t,
79
- submitTitle: "Submit"
80
- },
81
- ["title", "description", "submitTitle", "onSubmit"],
82
- (e) => ({
83
- addNode(n) {
84
- e.nodes.push(n);
85
- }
86
- })
87
- );
88
- }
89
- function y(t) {
90
- return {
91
- type: "text",
92
- text: t
93
- };
94
- }
95
- const m = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
96
- __proto__: null,
97
- block: i,
98
- button: b,
99
- col: f,
100
- form: p,
101
- row: d,
102
- text: y
103
- }, Symbol.toStringTag, { value: "Module" }));
104
- export {
105
- b as a,
106
- i as b,
107
- f as c,
108
- p as f,
109
- m as i,
110
- d as r,
111
- y as t
112
- };
@@ -1 +0,0 @@
1
- "use strict";function a(t,o,e){const n={};return b(n,t,o),y(n,t),p(n,t,e),n}function b(t,o,e){for(const n of e)Object.defineProperty(t,n,{value:r=>(o[n]=r,t),enumerable:!1,writable:!1,configurable:!1})}function p(t,o,e){if(!e)return;const n=e(o);for(const r of Object.keys(n))Object.defineProperty(t,r,{value:(...f)=>(n[r]?.(...f),t),enumerable:!1,writable:!1,configurable:!1})}function y(t,o){Object.defineProperty(t,"build",{value:()=>o,enumerable:!1,writable:!1,configurable:!1})}function i(...t){return a({type:"block",nodes:t??[]},["direction","gap","nodes"],e=>({row(){e.direction="row"},col(){e.direction="col"},addNode(n){e.nodes.push(n)}}))}function u(...t){return i(...t).row()}function c(...t){return i(...t).col()}function l(t){return a({type:"button",text:t},["text","variant","onClick"],e=>({primary(){e.variant="primary"},secondary(){e.variant="secondary"},outline(){e.variant="outline"},ghost(){e.variant="ghost"},destructive(){e.variant="destructive"}}))}function d(...t){return a({type:"form",nodes:t,submitTitle:"Submit"},["title","description","submitTitle","onSubmit"],e=>({addNode(n){e.nodes.push(n)}}))}function s(t){return{type:"text",text:t}}const m=Object.freeze(Object.defineProperty({__proto__:null,block:i,button:l,col:c,form:d,row:u,text:s},Symbol.toStringTag,{value:"Module"}));exports.block=i;exports.button=l;exports.col=c;exports.form=d;exports.index=m;exports.row=u;exports.text=s;