@ktjs/shortcuts 0.6.6 → 0.19.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/README.md CHANGED
@@ -2,10 +2,14 @@
2
2
 
3
3
  <img src="https://raw.githubusercontent.com/baendlorel/kt.js/dev/.assets/ktjs-0.0.1.svg" alt="KT.js Logo" width="150"/>
4
4
 
5
- > 📦 Part of [KT.js](https://raw.githubusercontent.com/baendlorel/kt.js/dev/README.md) - A simple and easy-to-use web framework that never re-renders.
5
+ [![npm version](https://img.shields.io/npm/v/@ktjs/shortcuts.svg)](https://www.npmjs.com/package/@ktjs/shortcuts)
6
+
7
+ > 📦 Part of [KT.js](https://github.com/baendlorel/kt.js) - A simple and easy-to-use web framework that never re-renders.
6
8
 
7
9
  Convenient shortcut functions for common DOM operations in KT.js.
8
10
 
11
+ **Current Version:** 0.7.3
12
+
9
13
  ## Overview
10
14
 
11
15
  `@ktjs/shortcuts` provides convenient shorthand functions and utilities to make working with KT.js even more productive. It includes shortcuts for all HTML elements, form helpers, layout utilities, and the powerful `withDefaults` function for creating element factories with predefined properties.
package/dist/index.d.ts CHANGED
@@ -24,86 +24,7 @@ declare const tbody: (attr?: _ktjs_core.KTRawAttr, content?: _ktjs_core.KTRawCon
24
24
  declare const tr: (attr?: _ktjs_core.KTRawAttr, content?: _ktjs_core.KTRawContent) => HTMLTableRowElement;
25
25
  declare const th: (attr?: _ktjs_core.KTRawAttr, content?: _ktjs_core.KTRawContent) => HTMLTableCellElement;
26
26
  declare const td: (attr?: _ktjs_core.KTRawAttr, content?: _ktjs_core.KTRawContent) => HTMLTableCellElement;
27
- declare const a: (attr?: _ktjs_core.KTRawAttr, content?: _ktjs_core.KTRawContent) => HTMLAnchorElement;
27
+ declare const a: (attr?: _ktjs_core.KTRawAttr, content?: _ktjs_core.KTRawContent) => SVGAElement;
28
28
  declare const img: (attr?: _ktjs_core.KTRawAttr, content?: _ktjs_core.KTRawContent) => HTMLImageElement;
29
29
 
30
- type otherstring = string & {};
31
-
32
- /**
33
- * Used to create enhanced HTML elements
34
- */
35
- interface KTBaseAttribute {
36
- [k: string]: any;
37
-
38
- id?: string;
39
- class?: string;
40
- style?: string | Partial<CSSStyleDeclaration>;
41
-
42
- type?:
43
- | 'text'
44
- | 'password'
45
- | 'email'
46
- | 'number'
47
- | 'tel'
48
- | 'url'
49
- | 'search'
50
- | 'date'
51
- | 'datetime-local'
52
- | 'time'
53
- | 'month'
54
- | 'week'
55
- | 'color'
56
- | 'range'
57
- | 'file'
58
- | 'checkbox'
59
- | 'radio'
60
- | 'hidden'
61
- | 'submit'
62
- | 'reset'
63
- | 'button'
64
- | 'image'
65
- | otherstring;
66
- for?: string;
67
-
68
- name?: string;
69
- value?: string;
70
- valueAsDate?: Date;
71
- valueAsNumber?: number;
72
- label?: string;
73
- disabled?: boolean;
74
-
75
- min?: string | number;
76
- max?: string | number;
77
- step?: string | number;
78
-
79
- selected?: boolean;
80
- checked?: boolean;
81
-
82
- action?: string;
83
- method?: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'CONNECT' | 'TRACE' | otherstring;
84
- }
85
-
86
- type KTEventHandlersOrAttribute = {
87
- [EventName in keyof HTMLElementEventMap]?: ((ev: HTMLElementEventMap[EventName]) => void) | string;
88
- };
89
-
90
- /**
91
- * Event handlers with @ prefix (e.g., @click, @input)
92
- * When key starts with @, it's always registered as an event handler
93
- */
94
- type KTPrefixedEventHandlers = {
95
- [EventName in keyof HTMLElementEventMap as `@${EventName}`]?: (ev: HTMLElementEventMap[EventName]) => void;
96
- };
97
-
98
- type KTAttribute = KTBaseAttribute & KTEventHandlersOrAttribute & KTPrefixedEventHandlers;
99
-
100
- /**
101
- * Wrap `h`(or its shortcuts) with default attributes.
102
- * - `defaultAttr.class` will be merged with the provided `class` attribute.
103
- * @param func `h` or its shortcuts.
104
- * @param defaultAttr default KTAttribute, must be an object.
105
- * @returns new h function with default attributes.
106
- */
107
- declare const withDefaults: <F extends (...args: any) => any>(func: F, defaultAttr: KTAttribute) => F;
108
-
109
- export { a, btn, div, form, h1, h2, h3, h4, h5, h6, img, input, label, li, ol, option, p, select, span, table, tbody, td, th, thead, tr, ul, withDefaults };
30
+ export { a, btn, div, form, h1, h2, h3, h4, h5, h6, img, input, label, li, ol, option, p, select, span, table, tbody, td, th, thead, tr, ul };
@@ -1 +1,62 @@
1
- var __ktjs_shortcuts__=function(t,o){"use strict";const n=t=>{const n=(n,e)=>o.h(t,n,e);return window.__ktjs__.mark(n,t),n},e=n("div"),s=n("span"),i=n("label"),r=n("p"),c=n("h1"),u=n("h2"),_=n("h3"),h=n("h4"),l=n("h5"),a=n("h6"),f=n("ul"),b=n("ol"),d=n("li"),p=n("button"),w=n("form"),y=n("input"),j=n("select"),g=n("option"),k=n("table"),m=n("thead"),v=n("tbody"),A=n("tr"),D=n("th"),q=n("td"),x=n("a"),z=n("img");return t.a=x,t.btn=p,t.div=e,t.form=w,t.h1=c,t.h2=u,t.h3=_,t.h4=h,t.h5=l,t.h6=a,t.img=z,t.input=y,t.label=i,t.li=d,t.ol=b,t.option=g,t.p=r,t.select=j,t.span=s,t.table=k,t.tbody=v,t.td=q,t.th=D,t.thead=m,t.tr=A,t.ul=f,t.withDefaults=(t,o)=>{"t"in t==!1&&window.__ktjs__.throws("withDefaults can only be used with h function or its alias"),null!==o&&"object"==typeof o||window.__ktjs__.throws("defaultAttr must be an object");const n="string"==typeof o.class?t=>{if("string"==typeof t){const n={...o};return n.class=t+" "+o.class,n}if(t&&"object"==typeof t){const n={...o,...t};return n.class=(t.class??"")+" "+o.class,n}}:t=>"string"==typeof t?{...o,class:t}:t&&"object"==typeof t?{...o,...t}:void 0;return"h"===t.t?(o,e,s)=>t(o,n(e),s):(o,e)=>t(n(o),e)},t}({},__ktjs_core__);
1
+ var __ktjs_shortcuts__ = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ const aliasH = (tag) => (attr, content) => core.h(tag, attr, content);
5
+
6
+ const div = aliasH('div');
7
+ const span = aliasH('span');
8
+ const label = aliasH('label');
9
+ const p = aliasH('p');
10
+ const h1 = aliasH('h1');
11
+ const h2 = aliasH('h2');
12
+ const h3 = aliasH('h3');
13
+ const h4 = aliasH('h4');
14
+ const h5 = aliasH('h5');
15
+ const h6 = aliasH('h6');
16
+ const ul = aliasH('ul');
17
+ const ol = aliasH('ol');
18
+ const li = aliasH('li');
19
+ const btn = aliasH('button');
20
+ const form = aliasH('form');
21
+ const input = aliasH('input');
22
+ const select = aliasH('select');
23
+ const option = aliasH('option');
24
+ const table = aliasH('table');
25
+ const thead = aliasH('thead');
26
+ const tbody = aliasH('tbody');
27
+ const tr = aliasH('tr');
28
+ const th = aliasH('th');
29
+ const td = aliasH('td');
30
+ const a = aliasH('a');
31
+ const img = aliasH('img');
32
+
33
+ exports.a = a;
34
+ exports.btn = btn;
35
+ exports.div = div;
36
+ exports.form = form;
37
+ exports.h1 = h1;
38
+ exports.h2 = h2;
39
+ exports.h3 = h3;
40
+ exports.h4 = h4;
41
+ exports.h5 = h5;
42
+ exports.h6 = h6;
43
+ exports.img = img;
44
+ exports.input = input;
45
+ exports.label = label;
46
+ exports.li = li;
47
+ exports.ol = ol;
48
+ exports.option = option;
49
+ exports.p = p;
50
+ exports.select = select;
51
+ exports.span = span;
52
+ exports.table = table;
53
+ exports.tbody = tbody;
54
+ exports.td = td;
55
+ exports.th = th;
56
+ exports.thead = thead;
57
+ exports.tr = tr;
58
+ exports.ul = ul;
59
+
60
+ return exports;
61
+
62
+ })({}, __ktjs_core__);
@@ -1 +1,66 @@
1
- var __ktjs_shortcuts__=function(t,n){"use strict";var r=function(t){var r=function(r,o){return n.h(t,r,o)};return window.__ktjs__.mark(r,t),r},o=r("div"),e=r("span"),u=r("label"),i=r("p"),c=r("h1"),f=r("h2"),s=r("h3"),a=r("h4"),l=r("h5"),h=r("h6"),p=r("ul"),_=r("ol"),d=r("li"),b=r("button"),v=r("form"),j=r("input"),y=r("select"),w=r("option"),g=r("table"),k=r("thead"),m=r("tbody"),E=r("tr"),O=r("th"),S=r("td"),A=r("a"),D=r("img"),q=function(){return q=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++)for(var e in n=arguments[r])Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e]);return t},q.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;return t.a=A,t.btn=b,t.div=o,t.form=v,t.h1=c,t.h2=f,t.h3=s,t.h4=a,t.h5=l,t.h6=h,t.img=D,t.input=j,t.label=u,t.li=d,t.ol=_,t.option=w,t.p=i,t.select=y,t.span=e,t.table=g,t.tbody=m,t.td=S,t.th=O,t.thead=k,t.tr=E,t.ul=p,t.withDefaults=function(t,n){"t"in t==!1&&window.__ktjs__.throws("withDefaults can only be used with h function or its alias"),null!==n&&"object"==typeof n||window.__ktjs__.throws("defaultAttr must be an object");var r="string"==typeof n.class?function(t){var r,o;return"string"==typeof t?((o=q({},n)).class=t+" "+n.class,o):t&&"object"==typeof t?((o=q(q({},n),t)).class=(null!==(r=t.class)&&void 0!==r?r:"")+" "+n.class,o):void 0}:function(t){return"string"==typeof t?q(q({},n),{class:t}):t&&"object"==typeof t?q(q({},n),t):void 0};return"h"===t.t?function(n,o,e){return t(n,r(o),e)}:function(n,o){return t(r(n),o)}},t}({},__ktjs_core__);
1
+ var __ktjs_shortcuts__ = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ var aliasH = function (tag) {
5
+ return function (attr, content) {
6
+ return core.h(tag, attr, content);
7
+ };
8
+ };
9
+
10
+ var div = aliasH('div');
11
+ var span = aliasH('span');
12
+ var label = aliasH('label');
13
+ var p = aliasH('p');
14
+ var h1 = aliasH('h1');
15
+ var h2 = aliasH('h2');
16
+ var h3 = aliasH('h3');
17
+ var h4 = aliasH('h4');
18
+ var h5 = aliasH('h5');
19
+ var h6 = aliasH('h6');
20
+ var ul = aliasH('ul');
21
+ var ol = aliasH('ol');
22
+ var li = aliasH('li');
23
+ var btn = aliasH('button');
24
+ var form = aliasH('form');
25
+ var input = aliasH('input');
26
+ var select = aliasH('select');
27
+ var option = aliasH('option');
28
+ var table = aliasH('table');
29
+ var thead = aliasH('thead');
30
+ var tbody = aliasH('tbody');
31
+ var tr = aliasH('tr');
32
+ var th = aliasH('th');
33
+ var td = aliasH('td');
34
+ var a = aliasH('a');
35
+ var img = aliasH('img');
36
+
37
+ exports.a = a;
38
+ exports.btn = btn;
39
+ exports.div = div;
40
+ exports.form = form;
41
+ exports.h1 = h1;
42
+ exports.h2 = h2;
43
+ exports.h3 = h3;
44
+ exports.h4 = h4;
45
+ exports.h5 = h5;
46
+ exports.h6 = h6;
47
+ exports.img = img;
48
+ exports.input = input;
49
+ exports.label = label;
50
+ exports.li = li;
51
+ exports.ol = ol;
52
+ exports.option = option;
53
+ exports.p = p;
54
+ exports.select = select;
55
+ exports.span = span;
56
+ exports.table = table;
57
+ exports.tbody = tbody;
58
+ exports.td = td;
59
+ exports.th = th;
60
+ exports.thead = thead;
61
+ exports.tr = tr;
62
+ exports.ul = ul;
63
+
64
+ return exports;
65
+
66
+ })({}, __ktjs_core__);
package/dist/index.mjs CHANGED
@@ -1 +1,32 @@
1
- import{h as t}from"@ktjs/core";const o=o=>{const e=(e,n)=>t(o,e,n);return window.__ktjs__.mark(e,o),e},e=o("div"),n=o("span"),i=o("label"),r=o("p"),s=o("h1"),c=o("h2"),l=o("h3"),f=o("h4"),h=o("h5"),u=o("h6"),a=o("ul"),p=o("ol"),b=o("li"),d=o("button"),w=o("form"),y=o("input"),j=o("select"),m=o("option"),_=o("table"),g=o("thead"),k=o("tbody"),v=o("tr"),x=o("th"),A=o("td"),D=o("a"),q=o("img"),z=(t,o)=>{"t"in t==!1&&window.__ktjs__.throws("withDefaults can only be used with h function or its alias"),null!==o&&"object"==typeof o||window.__ktjs__.throws("defaultAttr must be an object");const e="string"==typeof o.class?t=>{if("string"==typeof t){const e={...o};return e.class=t+" "+o.class,e}if(t&&"object"==typeof t){const e={...o,...t};return e.class=(t.class??"")+" "+o.class,e}}:t=>"string"==typeof t?{...o,class:t}:t&&"object"==typeof t?{...o,...t}:void 0;return"h"===t.t?(o,n,i)=>t(o,e(n),i):(o,n)=>t(e(o),n)};export{D as a,d as btn,e as div,w as form,s as h1,c as h2,l as h3,f as h4,h as h5,u as h6,q as img,y as input,i as label,b as li,p as ol,m as option,r as p,j as select,n as span,_ as table,k as tbody,A as td,x as th,g as thead,v as tr,a as ul,z as withDefaults};
1
+ import { h } from '@ktjs/core';
2
+
3
+ const aliasH = (tag) => (attr, content) => h(tag, attr, content);
4
+
5
+ const div = aliasH('div');
6
+ const span = aliasH('span');
7
+ const label = aliasH('label');
8
+ const p = aliasH('p');
9
+ const h1 = aliasH('h1');
10
+ const h2 = aliasH('h2');
11
+ const h3 = aliasH('h3');
12
+ const h4 = aliasH('h4');
13
+ const h5 = aliasH('h5');
14
+ const h6 = aliasH('h6');
15
+ const ul = aliasH('ul');
16
+ const ol = aliasH('ol');
17
+ const li = aliasH('li');
18
+ const btn = aliasH('button');
19
+ const form = aliasH('form');
20
+ const input = aliasH('input');
21
+ const select = aliasH('select');
22
+ const option = aliasH('option');
23
+ const table = aliasH('table');
24
+ const thead = aliasH('thead');
25
+ const tbody = aliasH('tbody');
26
+ const tr = aliasH('tr');
27
+ const th = aliasH('th');
28
+ const td = aliasH('td');
29
+ const a = aliasH('a');
30
+ const img = aliasH('img');
31
+
32
+ export { a, btn, div, form, h1, h2, h3, h4, h5, h6, img, input, label, li, ol, option, p, select, span, table, tbody, td, th, thead, tr, ul };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ktjs/shortcuts",
3
- "version": "0.6.6",
3
+ "version": "0.19.0",
4
4
  "description": "Shortcut functions for kt.js - common DOM operations",
5
5
  "type": "module",
6
6
  "module": "./dist/index.mjs",
@@ -30,7 +30,7 @@
30
30
  "directory": "packages/shortcuts"
31
31
  },
32
32
  "dependencies": {
33
- "@ktjs/core": "0.6.6"
33
+ "@ktjs/core": "0.19.0"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "rollup -c rollup.config.mjs",