@assistant-wi/core 0.0.7 → 0.0.9

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,165 @@
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
+ pagination: t ?? (() => ({ items: [], hasMore: !1 }))
102
+ }, ["pagination", "title", "totalPages"], (e) => ({
103
+ staticPagination(a, o) {
104
+ const r = Math.max(1, Math.floor(o || 0)), s = Math.ceil(a.length / r);
105
+ e.totalPages = s, e.pagination = (l) => {
106
+ if (s === 0) return { items: [], hasMore: !1 };
107
+ const d = Math.max(1, Math.floor(l || 0)), c = Math.min(d, s);
108
+ return {
109
+ items: a.slice(
110
+ (c - 1) * r,
111
+ c * r
112
+ ),
113
+ hasMore: c < s
114
+ };
115
+ };
116
+ }
117
+ }));
118
+ }
119
+ function w(t) {
120
+ return i(
121
+ {
122
+ type: "text",
123
+ text: t,
124
+ animation: "none",
125
+ color: "primary",
126
+ weight: "normal",
127
+ size: "md"
128
+ },
129
+ ["text", "color", "weight", "size", "animation"],
130
+ (e) => ({
131
+ primary() {
132
+ e.color = "primary";
133
+ },
134
+ muted() {
135
+ e.color = "muted";
136
+ },
137
+ shimmering(a = {}) {
138
+ e.animation = {
139
+ type: "shimmering",
140
+ ...a
141
+ };
142
+ }
143
+ })
144
+ );
145
+ }
146
+ const P = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
147
+ __proto__: null,
148
+ block: u,
149
+ button: y,
150
+ col: g,
151
+ form: h,
152
+ list: v,
153
+ row: b,
154
+ text: w
155
+ }, Symbol.toStringTag, { value: "Module" }));
156
+ export {
157
+ y as a,
158
+ u as b,
159
+ g as c,
160
+ h as f,
161
+ P as i,
162
+ v as l,
163
+ b as r,
164
+ w as t
165
+ };
@@ -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 u(...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 u(...t).row()}function d(...t){return u(...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({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)),s=Math.min(y,c);return{items:n.slice((s-1)*r,s*r),hasMore:s<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:u,button:f,col:d,form:m,list:p,row:l,text:b},Symbol.toStringTag,{value:"Module"}));exports.block=u;exports.button=f;exports.col=d;exports.form=m;exports.index=P;exports.list=p;exports.row=l;exports.text=b;
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DMcbwFzr.cjs"),i=require("./index-du_6NCi7.cjs");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-YOKoR-uY.js");exports.tool=e.index;exports.ui=i.index;
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
- import { i } from "./index-BXj6EgSG.js";
2
- import { i as a } from "./index-CFIfaRxl.js";
1
+ import { i } from "./index-BXj6EgSG.mjs";
2
+ import { i as a } from "./index-CHJTMogj.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 e=require("../index-DMcbwFzr.cjs");exports.createTool=e.createTool;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../index-DMcbwFzr.js");exports.createTool=e.createTool;
@@ -1,4 +1,4 @@
1
- import { c as r } from "../index-BXj6EgSG.js";
1
+ import { c as r } from "../index-BXj6EgSG.mjs";
2
2
  export {
3
3
  r as createTool
4
4
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../index-du_6NCi7.cjs");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-YOKoR-uY.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-CFIfaRxl.js";
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-CHJTMogj.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,20 @@
1
+ export interface UIList {
2
+ pagination: UIListPagination;
3
+ title?: string;
4
+ totalPages?: number;
5
+ }
6
+ export interface UIListItem {
7
+ id: string;
8
+ title: string;
9
+ description?: string;
10
+ avatar?: string;
11
+ onClick?: () => void | Promise<void>;
12
+ }
13
+ export interface UIListPaginationResponse {
14
+ items: UIListItem[];
15
+ hasMore?: boolean;
16
+ }
17
+ export type UIListPagination = (page: number) => UIListPaginationResponse | Promise<UIListPaginationResponse>;
18
+ export declare function list(pagination?: UIListPagination): import('./builder').Builder<UIList, ("title" | "pagination" | "totalPages")[], {
19
+ staticPagination(items: UIListItem[], itemsPerPage: number): void;
20
+ }>;
@@ -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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@assistant-wi/core",
3
3
  "private": false,
4
- "version": "0.0.7",
4
+ "version": "0.0.9",
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(e, o, t) {
2
- const n = {};
3
- return c(n, e, o), s(n, e), l(n, e, t), n;
4
- }
5
- function c(e, o, t) {
6
- for (const n of t)
7
- Object.defineProperty(e, n, {
8
- value: (r) => (o[n] = r, e),
9
- enumerable: !1,
10
- writable: !1,
11
- configurable: !1
12
- });
13
- }
14
- function l(e, o, t) {
15
- if (!t) return;
16
- const n = t(o);
17
- for (const r of Object.keys(n))
18
- Object.defineProperty(e, r, {
19
- value: (...u) => (n[r]?.(...u), e),
20
- enumerable: !1,
21
- writable: !1,
22
- configurable: !1
23
- });
24
- }
25
- function s(e, o) {
26
- Object.defineProperty(e, "build", {
27
- value: () => o,
28
- enumerable: !1,
29
- writable: !1,
30
- configurable: !1
31
- });
32
- }
33
- function i(...e) {
34
- return a({ type: "block", nodes: e ?? [] }, ["direction", "gap", "nodes"], (t) => ({
35
- row() {
36
- t.direction = "row";
37
- },
38
- col() {
39
- t.direction = "col";
40
- },
41
- addNode(n) {
42
- t.nodes.push(n);
43
- }
44
- }));
45
- }
46
- function d(...e) {
47
- return i(...e).row();
48
- }
49
- function f(...e) {
50
- return i(...e).col();
51
- }
52
- function b(e) {
53
- return a({
54
- type: "button",
55
- text: e
56
- }, ["text", "variant", "onClick"], (t) => ({
57
- primary() {
58
- t.variant = "primary";
59
- },
60
- secondary() {
61
- t.variant = "secondary";
62
- },
63
- outline() {
64
- t.variant = "outline";
65
- },
66
- ghost() {
67
- t.variant = "ghost";
68
- },
69
- destructive() {
70
- t.variant = "destructive";
71
- }
72
- }));
73
- }
74
- function p(...e) {
75
- return console.log("nodes", e), a(
76
- {
77
- type: "form",
78
- nodes: e,
79
- submitTitle: "Submit"
80
- },
81
- ["title", "description", "submitTitle", "onSubmit"],
82
- (t) => ({
83
- addNode(n) {
84
- t.nodes.push(n);
85
- }
86
- })
87
- );
88
- }
89
- function y(e) {
90
- return {
91
- type: "text",
92
- text: e
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 console.log("nodes",t),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;
File without changes
File without changes