lkt-vue-kernel 1.0.2 → 1.0.4

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 (3) hide show
  1. package/dist/index.d.ts +457 -45
  2. package/dist/index.js +516 -27
  3. package/package.json +9 -2
package/dist/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
+ import { RouteLocationRaw } from 'vue-router';
2
+ import { VueElement } from 'vue';
3
+
1
4
  interface LktObject {
2
- [key: string]: any;
5
+ [key: string | number]: any;
3
6
  }
4
7
 
5
8
  declare enum FieldType {
@@ -37,28 +40,52 @@ interface OptionConfig {
37
40
  }
38
41
 
39
42
  declare class LktItem implements LktObject {
40
- lktDateProps: string[];
41
- lktStrictItem: boolean;
42
- feed(data?: LktObject): void;
43
+ static lktAllowUndefinedProps: string[];
44
+ static lktExcludedProps: string[];
45
+ static lktDateProps: string[];
46
+ static lktStrictItem: boolean;
47
+ static lktDefaultValues: (keyof LktObject)[];
48
+ constructor(data?: LktObject);
49
+ feed(data?: LktObject, target?: this): void;
43
50
  assignProp(key: string, value: any): void;
44
51
  }
45
52
 
53
+ type ValidModalName = string | Function | undefined;
54
+
46
55
  declare class Option extends LktItem implements OptionConfig {
47
56
  value: ValidOptionValue;
48
57
  label: string;
49
- data?: LktObject;
50
- disabled?: boolean;
51
- group?: string;
52
- icon?: string;
53
- modal?: string | Function;
58
+ data: LktObject;
59
+ disabled: boolean;
60
+ group: string;
61
+ icon: string;
62
+ modal: ValidModalName;
63
+ constructor(data?: LktObject);
54
64
  }
55
65
 
56
66
  type ValidFieldValue = string | number | boolean | LktObject | Option[];
57
67
 
68
+ declare enum MultipleOptionsDisplay {
69
+ List = "list",
70
+ Inline = "inline",
71
+ Count = "count"
72
+ }
73
+
74
+ type ValidTabIndex = string | number | undefined;
75
+
76
+ declare enum FieldAutoValidationTrigger {
77
+ None = "",
78
+ Focus = "focus",
79
+ Blur = "blur",
80
+ Always = "always"
81
+ }
82
+
83
+ type ValidFieldMinMax = number | string | undefined;
84
+
58
85
  interface FieldConfig {
59
- modelValue: ValidFieldValue;
86
+ modelValue?: ValidFieldValue;
60
87
  type?: FieldType;
61
- valid?: boolean;
88
+ valid?: boolean | undefined;
62
89
  placeholder?: string;
63
90
  searchPlaceholder?: string;
64
91
  label?: string;
@@ -70,7 +97,7 @@ interface FieldConfig {
70
97
  readonly?: boolean;
71
98
  readMode?: boolean;
72
99
  allowReadModeSwitch?: boolean;
73
- tabindex?: number;
100
+ tabindex?: ValidTabIndex;
74
101
  mandatory?: boolean;
75
102
  showPassword?: boolean;
76
103
  canClear?: boolean;
@@ -81,33 +108,33 @@ interface FieldConfig {
81
108
  mandatoryMessage?: string;
82
109
  infoMessage?: string;
83
110
  errorMessage?: string;
84
- min?: number | string | undefined;
85
- max?: number | string | undefined;
111
+ min?: ValidFieldMinMax;
112
+ max?: ValidFieldMinMax;
86
113
  step?: number | string;
87
114
  enableAutoNumberFix?: boolean;
88
115
  emptyValueSlot?: string;
89
- optionSlot?: string;
90
- valueSlot?: string;
91
- editSlot?: string;
116
+ optionSlot?: string | undefined;
117
+ valueSlot?: string | undefined;
118
+ editSlot?: string | undefined;
92
119
  slotData?: LktObject;
93
120
  resource?: string;
94
121
  resourceData?: LktObject;
95
122
  validationResource?: string;
96
123
  validationResourceData?: LktObject;
97
124
  autoValidation?: boolean;
98
- autoValidationType?: 'focus' | 'blur' | 'always';
125
+ autoValidationType?: FieldAutoValidationTrigger;
99
126
  validationStack?: string;
100
- minNumbers?: number | string | undefined;
101
- maxNumbers?: number | string | undefined;
102
- minChars?: number | string | undefined;
103
- maxChars?: number | string | undefined;
104
- minUpperChars?: number | string | undefined;
105
- maxUpperChars?: number | string | undefined;
106
- minLowerChars?: number | string | undefined;
107
- maxLowerChars?: number | string | undefined;
108
- minSpecialChars?: number | string | undefined;
109
- maxSpecialChars?: number | string | undefined;
110
- checkEqualTo?: number | string | undefined;
127
+ minNumbers?: ValidFieldMinMax;
128
+ maxNumbers?: ValidFieldMinMax;
129
+ minChars?: ValidFieldMinMax;
130
+ maxChars?: ValidFieldMinMax;
131
+ minUpperChars?: ValidFieldMinMax;
132
+ maxUpperChars?: ValidFieldMinMax;
133
+ minLowerChars?: ValidFieldMinMax;
134
+ maxLowerChars?: ValidFieldMinMax;
135
+ minSpecialChars?: ValidFieldMinMax;
136
+ maxSpecialChars?: ValidFieldMinMax;
137
+ checkEqualTo?: ValidFieldMinMax;
111
138
  featuredButton?: string;
112
139
  infoButtonEllipsis?: boolean;
113
140
  fileName?: string;
@@ -115,15 +142,15 @@ interface FieldConfig {
115
142
  customButtonClass?: string;
116
143
  options?: string | Option[];
117
144
  multiple?: boolean;
118
- multipleDisplay?: LktObject;
119
- multipleDisplayEdition?: LktObject;
145
+ multipleDisplay?: MultipleOptionsDisplay;
146
+ multipleDisplayEdition?: MultipleOptionsDisplay;
120
147
  searchable?: boolean;
121
148
  autoloadOptionsResource?: boolean | 'feed';
122
149
  optionsDownload?: string | Function;
123
150
  optionsModal?: string | Function;
124
151
  optionsModalData?: LktObject | Function;
125
152
  optionsIcon?: string | Function;
126
- optionsLabelFormatter?: Function;
153
+ optionsLabelFormatter?: Function | undefined;
127
154
  optionsResource?: string;
128
155
  optionsResourceData?: LktObject;
129
156
  icon?: string | Function;
@@ -138,24 +165,24 @@ interface FieldConfig {
138
165
 
139
166
  type EmptyModalKey = '_';
140
167
 
141
- type ValidModalKey = string | EmptyModalKey;
168
+ type ValidModalKey = string | Function | EmptyModalKey;
142
169
 
143
- interface ModalConfig {
170
+ interface ModalConfig extends LktObject {
144
171
  size?: string;
145
172
  preTitle?: string;
146
173
  preTitleIcon?: string;
147
174
  title?: string;
148
175
  closeIcon?: string;
149
- closeConfirm?: string;
150
- closeConfirmKey?: string;
176
+ closeConfirm?: ValidModalName;
177
+ closeConfirmKey?: ValidModalKey;
151
178
  showClose?: boolean;
152
179
  disabledClose?: boolean;
153
180
  disabledVeilClick?: boolean;
154
181
  hiddenFooter?: boolean;
155
- modalName?: string;
182
+ modalName?: ValidModalName;
156
183
  modalKey?: ValidModalKey;
157
184
  zIndex?: number;
158
- beforeClose?: Function;
185
+ beforeClose?: Function | undefined;
159
186
  item?: LktObject;
160
187
  }
161
188
 
@@ -190,22 +217,407 @@ interface TooltipConfig {
190
217
  referrerMargin?: number | string;
191
218
  windowMargin?: number | string;
192
219
  referrerWidth?: boolean;
193
- referrer: HTMLElement;
220
+ referrer?: HTMLElement | undefined;
194
221
  locationY?: TooltipLocationY;
195
222
  locationX?: TooltipLocationX;
196
223
  }
197
224
 
225
+ declare enum AnchorType {
226
+ Href = "href",// Vanilla JS+HTML anchor
227
+ RouterLink = "router-link",// For vue-router integration
228
+ RouterLinkBack = "router-link-back",// For vue-router back navigation
229
+ Mail = "mail",// Triggers OS mail integration
230
+ Tel = "tel",// Triggers OS phone integration
231
+ Tab = "tab",// New tab, similar to target="_blank"
232
+ Download = "download",// Download link
233
+ Action = "action",// Performs an action, without route changes
234
+ Legacy = ""
235
+ }
236
+
237
+ interface AnchorConfig {
238
+ type?: AnchorType;
239
+ to?: RouteLocationRaw | string;
240
+ class?: string;
241
+ isActive?: boolean;
242
+ downloadFileName?: string;
243
+ disabled?: boolean;
244
+ onClick?: Function | undefined;
245
+ confirmModal?: ValidModalName;
246
+ confirmModalKey?: ValidModalKey;
247
+ confirmData?: ModalConfig;
248
+ imposter?: boolean;
249
+ }
250
+
251
+ interface DragConfig {
252
+ isDraggable?: boolean | Function;
253
+ isValid?: Function;
254
+ canRender?: boolean | Function;
255
+ dragKey?: string;
256
+ }
257
+
258
+ declare const enum ButtonType {
259
+ Button = "button",// Default
260
+ Submit = "submit",// Form submit
261
+ Reset = "reset",
262
+ Anchor = "anchor",// Turns on anchor mode
263
+ Content = "content",// No click event
264
+ Switch = "switch",// Has a visible boolean state
265
+ HiddenSwitch = "hidden-switch",// Has a hidden boolean state
266
+ Split = "split",// Split button, content always generated
267
+ SplitLazy = "split-lazy",// Split button, contents generated after first open
268
+ SplitEver = "split-ever",// Split button, contents generated each time it's clicked
269
+ Tooltip = "tooltip",// Tooltip button, content always generated
270
+ TooltipLazy = "tooltip-lazy",// Tooltip button, contents generated after first open
271
+ TooltipEver = "tooltip-ever"
272
+ }
273
+
274
+ declare enum ToggleMode {
275
+ Lazy = "lazy",
276
+ Ever = "ever"
277
+ }
278
+
279
+ declare class Anchor extends LktItem implements AnchorConfig {
280
+ static lktAllowUndefinedProps: string[];
281
+ static lktDefaultValues: (keyof AnchorConfig)[];
282
+ type: AnchorType;
283
+ to?: RouteLocationRaw | string;
284
+ class: string;
285
+ isActive: boolean;
286
+ downloadFileName: string;
287
+ disabled: boolean;
288
+ onClick: Function | undefined;
289
+ confirmModal: ValidModalName;
290
+ confirmModalKey: ValidModalKey;
291
+ confirmData: LktObject;
292
+ imposter: boolean;
293
+ constructor(data?: Partial<AnchorConfig>);
294
+ getHref(): string;
295
+ }
296
+
297
+ interface ButtonConfig {
298
+ type?: ButtonType;
299
+ checked?: boolean;
300
+ openTooltip?: boolean;
301
+ name?: string;
302
+ text?: string | number;
303
+ icon?: string;
304
+ class?: string;
305
+ containerClass?: string;
306
+ palette?: string;
307
+ value?: string;
308
+ disabled?: boolean;
309
+ loading?: boolean;
310
+ wrapContent?: boolean;
311
+ anchor?: AnchorConfig | Anchor;
312
+ resource?: string;
313
+ resourceData?: LktObject;
314
+ modal?: ValidModalName;
315
+ modalKey?: ValidModalKey;
316
+ modalData?: ModalConfig;
317
+ confirmModal?: ValidModalName;
318
+ confirmModalKey?: ValidModalKey;
319
+ confirmData?: ModalConfig;
320
+ iconDot?: boolean | string | number;
321
+ iconEnd?: string;
322
+ img?: string;
323
+ split?: boolean | ToggleMode;
324
+ splitIcon?: string;
325
+ tooltip?: boolean | ToggleMode;
326
+ tooltipEngine?: TooltipPositionEngine;
327
+ showTooltipOnHover?: boolean;
328
+ showTooltipOnHoverDelay?: number;
329
+ hideTooltipOnLeave?: boolean;
330
+ tooltipWindowMargin?: number;
331
+ tooltipReferrerMargin?: number;
332
+ tooltipClass?: string;
333
+ tooltipLocationY?: string;
334
+ tooltipLocationX?: string;
335
+ splitClass?: string;
336
+ clickRef?: Element | VueElement;
337
+ tabindex?: ValidTabIndex;
338
+ isAnchor?: boolean;
339
+ onClickTo?: string;
340
+ onClickToExternal?: boolean;
341
+ download?: boolean;
342
+ downloadFileName?: string;
343
+ newTab?: boolean;
344
+ showSwitch?: boolean;
345
+ hiddenSwitch?: boolean;
346
+ }
347
+
198
348
  declare class LktStrictItem extends LktItem {
199
349
  lktStrictItem: boolean;
200
350
  }
201
351
 
202
- declare const enum ButtonType {
352
+ declare class Field extends LktItem implements FieldConfig {
353
+ modelValue: ValidFieldValue;
354
+ type: FieldType;
355
+ valid: boolean | undefined;
356
+ placeholder: string;
357
+ searchPlaceholder: string;
358
+ label: string;
359
+ labelIcon: string;
360
+ labelIconAtEnd: boolean;
361
+ name: string;
362
+ autocomplete: boolean;
363
+ disabled: boolean;
364
+ readonly: boolean;
365
+ readMode: boolean;
366
+ allowReadModeSwitch: boolean;
367
+ tabindex: ValidTabIndex;
368
+ mandatory: boolean;
369
+ showPassword: boolean;
370
+ canClear: boolean;
371
+ canUndo: boolean;
372
+ canI18n: boolean;
373
+ canStep: boolean;
374
+ mandatoryMessage: string;
375
+ infoMessage: string;
376
+ errorMessage: string;
377
+ min: ValidFieldMinMax;
378
+ max: ValidFieldMinMax;
379
+ step: number | string;
380
+ enableAutoNumberFix: boolean;
381
+ emptyValueSlot: string;
382
+ optionSlot: undefined;
383
+ valueSlot: undefined;
384
+ editSlot: undefined;
385
+ slotData: LktObject;
386
+ resource: string;
387
+ resourceData: LktObject;
388
+ validationResource: string;
389
+ validationResourceData: LktObject;
390
+ autoValidation: boolean;
391
+ autoValidationType: FieldAutoValidationTrigger;
392
+ validationStack: string;
393
+ minNumbers: ValidFieldMinMax;
394
+ maxNumbers: ValidFieldMinMax;
395
+ minChars: ValidFieldMinMax;
396
+ maxChars: ValidFieldMinMax;
397
+ minUpperChars: ValidFieldMinMax;
398
+ maxUpperChars: ValidFieldMinMax;
399
+ minLowerChars: ValidFieldMinMax;
400
+ maxLowerChars: ValidFieldMinMax;
401
+ minSpecialChars: ValidFieldMinMax;
402
+ maxSpecialChars: ValidFieldMinMax;
403
+ checkEqualTo: ValidFieldMinMax;
404
+ featuredButton: string;
405
+ infoButtonEllipsis: boolean;
406
+ fileName: string;
407
+ customButtonText: string;
408
+ customButtonClass: string;
409
+ options: string | Option[];
410
+ multiple: boolean;
411
+ multipleDisplay: MultipleOptionsDisplay;
412
+ multipleDisplayEdition: MultipleOptionsDisplay;
413
+ searchable: boolean;
414
+ autoloadOptionsResource: boolean | 'feed';
415
+ optionsDownload: string | Function;
416
+ optionsModal: string | Function;
417
+ optionsModalData: LktObject | Function;
418
+ optionsIcon: string | Function;
419
+ optionsLabelFormatter: undefined;
420
+ optionsResource: string;
421
+ optionsResourceData: LktObject;
422
+ icon: string | Function;
423
+ download: string | Function;
424
+ modal: string | Function;
425
+ modalKey: string | number | Function;
426
+ modalData: LktObject;
427
+ data: LktObject;
428
+ constructor(data?: FieldConfig);
429
+ }
430
+
431
+ declare enum ColumnType {
432
+ None = "",
433
+ Field = "field",
203
434
  Button = "button",
204
- Submit = "submit",
205
- Reset = "reset",
206
- Content = "content",
435
+ Anchor = "anchor",
436
+ Text = "text",
437
+ Number = "number",
438
+ Check = "check",
207
439
  Switch = "switch",
208
- HiddenSwitch = "hidden-switch"
440
+ Select = "select",
441
+ Email = "email",
442
+ Tel = "tel",
443
+ File = "file",
444
+ Link = "link",
445
+ Action = "action",
446
+ Integer = "int",
447
+ Float = "float"
448
+ }
449
+
450
+ type ValidSafeStringValue = string | ((...args: any[]) => string) | undefined | SafeString;
451
+
452
+ declare class SafeString {
453
+ private readonly value;
454
+ constructor(input: ValidSafeStringValue);
455
+ getValue(...args: any[]): string;
456
+ }
457
+
458
+ type ValidColSpan = Function | boolean | number | undefined;
459
+
460
+ declare class Button extends LktItem implements ButtonConfig {
461
+ lktAllowUndefinedProps: string[];
462
+ type: ButtonType;
463
+ name: string;
464
+ palette: string;
465
+ onClickTo: string;
466
+ onClickToExternal: boolean;
467
+ class: string;
468
+ containerClass: string;
469
+ value: string;
470
+ disabled: boolean;
471
+ loading: boolean;
472
+ wrapContent: boolean;
473
+ split: boolean;
474
+ splitIcon: string;
475
+ isAnchor: boolean;
476
+ resource: string;
477
+ resourceData: LktObject;
478
+ modal: ValidModalName;
479
+ modalKey: ValidModalKey;
480
+ modalData: ModalConfig;
481
+ confirmModal: ValidModalName;
482
+ confirmModalKey: ValidModalKey;
483
+ confirmData: ModalConfig;
484
+ text: string;
485
+ icon: string;
486
+ iconDot: boolean;
487
+ iconEnd: string;
488
+ img: string;
489
+ newTab: boolean;
490
+ download: boolean;
491
+ downloadFileName: string;
492
+ tooltip: boolean;
493
+ showTooltipOnHoverDelay: number;
494
+ tooltipWindowMargin: number;
495
+ tooltipReferrerMargin: number;
496
+ tooltipLocationY: string;
497
+ tooltipLocationX: string;
498
+ checked: boolean;
499
+ clickRef?: Element | VueElement;
500
+ openTooltip: boolean;
501
+ tabindex: ValidTabIndex;
502
+ anchor?: AnchorConfig | Anchor;
503
+ tooltipEngine?: TooltipPositionEngine;
504
+ showTooltipOnHover?: boolean;
505
+ hideTooltipOnLeave?: boolean;
506
+ tooltipClass?: string;
507
+ splitClass?: string;
508
+ constructor(data?: ButtonConfig);
209
509
  }
210
510
 
211
- export { ButtonType, type EmptyModalKey, type FieldConfig, FieldType, LktItem, type LktObject, LktStrictItem, type ModalConfig, Option, type OptionConfig, type TooltipConfig, TooltipLocationX, TooltipLocationY, TooltipPositionEngine, type ValidFieldValue, type ValidModalKey, type ValidOptionValue };
511
+ interface ColumnConfig {
512
+ type: ColumnType;
513
+ key: string;
514
+ label: string;
515
+ sortable: boolean;
516
+ hidden: boolean;
517
+ editable: boolean;
518
+ formatter?: Function | undefined;
519
+ checkEmpty?: Function | undefined;
520
+ colspan?: ValidColSpan;
521
+ preferSlot?: Function | boolean;
522
+ isForRowKey?: boolean;
523
+ extractTitleFromColumn?: string;
524
+ slotData?: LktObject;
525
+ field?: Field | FieldConfig | undefined;
526
+ anchor?: Anchor | AnchorConfig | undefined;
527
+ button?: Button | ButtonConfig | undefined;
528
+ link?: ValidSafeStringValue | SafeString;
529
+ action?: Function;
530
+ }
531
+
532
+ declare class Column extends LktItem implements ColumnConfig {
533
+ lktExcludedProps: string[];
534
+ lktAllowUndefinedProps: string[];
535
+ type: ColumnType;
536
+ key: string;
537
+ label: string;
538
+ sortable: boolean;
539
+ hidden: boolean;
540
+ editable: boolean;
541
+ formatter: Function | undefined;
542
+ checkEmpty: Function | undefined;
543
+ colspan: ValidColSpan;
544
+ preferSlot: Function | boolean;
545
+ isForRowKey: boolean;
546
+ extractTitleFromColumn: string;
547
+ slotData: LktObject;
548
+ field: Field | FieldConfig | undefined;
549
+ anchor: Anchor | AnchorConfig | undefined;
550
+ button: Button | ButtonConfig | undefined;
551
+ link: ValidSafeStringValue | SafeString | undefined;
552
+ action?: Function;
553
+ constructor(data: ColumnConfig);
554
+ getHref(item: LktObject): string;
555
+ doAction(item: LktObject): any;
556
+ }
557
+
558
+ declare class Tooltip extends LktItem implements TooltipConfig {
559
+ static lktDefaultValues: (keyof TooltipConfig)[];
560
+ modelValue: boolean;
561
+ alwaysOpen: boolean;
562
+ class: string;
563
+ text: string;
564
+ icon: string;
565
+ iconAtEnd: boolean;
566
+ engine: TooltipPositionEngine;
567
+ referrerWidth: boolean;
568
+ referrerMargin: number | string;
569
+ windowMargin: number | string;
570
+ referrer: HTMLElement | undefined;
571
+ locationY: TooltipLocationY;
572
+ locationX: TooltipLocationX;
573
+ constructor(data?: FieldConfig);
574
+ }
575
+
576
+ declare class Modal extends LktItem implements ModalConfig {
577
+ static lktDefaultValues: (keyof ModalConfig)[];
578
+ size: string;
579
+ preTitle: string;
580
+ preTitleIcon: string;
581
+ title: string;
582
+ closeIcon: string;
583
+ closeConfirm: ValidModalName;
584
+ closeConfirmKey: ValidModalKey;
585
+ showClose: boolean;
586
+ disabledClose: boolean;
587
+ disabledVeilClick: boolean;
588
+ hiddenFooter: boolean;
589
+ modalName: ValidModalName;
590
+ modalKey: ValidModalKey;
591
+ zIndex: number;
592
+ beforeClose: Function | undefined;
593
+ item: LktObject;
594
+ constructor(data?: FieldConfig);
595
+ }
596
+
597
+ declare enum ModalType {
598
+ Modal = "modal",
599
+ Confirm = "confirm"
600
+ }
601
+
602
+ declare enum SortDirection {
603
+ Asc = "asc",
604
+ Desc = "desc"
605
+ }
606
+
607
+ declare enum TableType {
608
+ Table = "table",
609
+ Item = "item",
610
+ Ul = "ul",
611
+ Ol = "ol"
612
+ }
613
+
614
+ /**
615
+ * Export common interfaces
616
+ */
617
+
618
+ declare function getDefaultValues<T>(cls: {
619
+ new (): T;
620
+ lktDefaultValues: (keyof T)[];
621
+ }): Partial<T>;
622
+
623
+ export { Anchor, type AnchorConfig, AnchorType, Button, type ButtonConfig, ButtonType, Column, ColumnType, type DragConfig, type EmptyModalKey, Field, FieldAutoValidationTrigger, type FieldConfig, FieldType, LktItem, type LktObject, LktStrictItem, Modal, type ModalConfig, ModalType, MultipleOptionsDisplay, Option, type OptionConfig, SafeString, SortDirection, TableType, ToggleMode, Tooltip, type TooltipConfig, TooltipLocationX, TooltipLocationY, TooltipPositionEngine, type ValidColSpan, type ValidFieldMinMax, type ValidFieldValue, type ValidModalKey, type ValidModalName, type ValidOptionValue, type ValidSafeStringValue, type ValidTabIndex, getDefaultValues };
package/dist/index.js CHANGED
@@ -1,18 +1,25 @@
1
1
  // src/instances/LktItem.ts
2
2
  var skipDataProps = [
3
3
  "lktDateProps",
4
- "lktStrictItem"
4
+ "lktStrictItem",
5
+ "lktExcludedProps"
5
6
  ];
6
- var LktItem = class {
7
- lktDateProps = [];
8
- lktStrictItem = false;
9
- feed(data = {}) {
10
- for (const [key, value] of Object.entries(data)) this.assignProp(key, value);
7
+ var LktItem = class _LktItem {
8
+ static lktAllowUndefinedProps = [];
9
+ static lktExcludedProps = [];
10
+ static lktDateProps = [];
11
+ static lktStrictItem = false;
12
+ static lktDefaultValues = [];
13
+ constructor(data) {
14
+ }
15
+ feed(data = {}, target = this) {
16
+ if (typeof data !== "object") return;
17
+ for (const [key, value] of Object.entries(data)) target.assignProp(key, value);
11
18
  }
12
19
  assignProp(key, value) {
13
- if (skipDataProps.includes(key)) return;
14
- if (this.lktStrictItem && !this.hasOwnProperty(key)) return;
15
- if (this.lktDateProps.includes(key)) {
20
+ if (skipDataProps.includes(key) || _LktItem.lktExcludedProps.includes(key)) return;
21
+ if (_LktItem.lktStrictItem && !this.hasOwnProperty(key)) return;
22
+ if (_LktItem.lktDateProps.includes(key)) {
16
23
  this[key] = new Date(value);
17
24
  return;
18
25
  }
@@ -34,19 +41,12 @@ var Option = class extends LktItem {
34
41
  group = "";
35
42
  icon = "";
36
43
  modal = "";
44
+ constructor(data = {}) {
45
+ super();
46
+ this.feed(data);
47
+ }
37
48
  };
38
49
 
39
- // src/enums/ButtonType.ts
40
- var ButtonType = /* @__PURE__ */ ((ButtonType2) => {
41
- ButtonType2["Button"] = "button";
42
- ButtonType2["Submit"] = "submit";
43
- ButtonType2["Reset"] = "reset";
44
- ButtonType2["Content"] = "content";
45
- ButtonType2["Switch"] = "switch";
46
- ButtonType2["HiddenSwitch"] = "hidden-switch";
47
- return ButtonType2;
48
- })(ButtonType || {});
49
-
50
50
  // src/enums/FieldType.ts
51
51
  var FieldType = /* @__PURE__ */ ((FieldType2) => {
52
52
  FieldType2["Text"] = "text";
@@ -71,6 +71,363 @@ var FieldType = /* @__PURE__ */ ((FieldType2) => {
71
71
  return FieldType2;
72
72
  })(FieldType || {});
73
73
 
74
+ // src/instances/Field.ts
75
+ import { generateRandomString } from "lkt-string-tools";
76
+
77
+ // src/enums/MultipleOptionsDisplay.ts
78
+ var MultipleOptionsDisplay = /* @__PURE__ */ ((MultipleOptionsDisplay2) => {
79
+ MultipleOptionsDisplay2["List"] = "list";
80
+ MultipleOptionsDisplay2["Inline"] = "inline";
81
+ MultipleOptionsDisplay2["Count"] = "count";
82
+ return MultipleOptionsDisplay2;
83
+ })(MultipleOptionsDisplay || {});
84
+
85
+ // src/enums/FieldAutoValidationTrigger.ts
86
+ var FieldAutoValidationTrigger = /* @__PURE__ */ ((FieldAutoValidationTrigger2) => {
87
+ FieldAutoValidationTrigger2["None"] = "";
88
+ FieldAutoValidationTrigger2["Focus"] = "focus";
89
+ FieldAutoValidationTrigger2["Blur"] = "blur";
90
+ FieldAutoValidationTrigger2["Always"] = "always";
91
+ return FieldAutoValidationTrigger2;
92
+ })(FieldAutoValidationTrigger || {});
93
+
94
+ // src/instances/Field.ts
95
+ var Field = class extends LktItem {
96
+ modelValue = "";
97
+ type = "text" /* Text */;
98
+ valid = void 0;
99
+ placeholder = "";
100
+ searchPlaceholder = "";
101
+ label = "";
102
+ labelIcon = "";
103
+ labelIconAtEnd = false;
104
+ name = generateRandomString(16);
105
+ autocomplete = false;
106
+ disabled = false;
107
+ readonly = false;
108
+ readMode = false;
109
+ allowReadModeSwitch = false;
110
+ tabindex = void 0;
111
+ mandatory = false;
112
+ showPassword = false;
113
+ canClear = false;
114
+ canUndo = false;
115
+ canI18n = false;
116
+ canStep = true;
117
+ mandatoryMessage = "";
118
+ infoMessage = "";
119
+ errorMessage = "";
120
+ min = void 0;
121
+ max = void 0;
122
+ step = 1;
123
+ enableAutoNumberFix = true;
124
+ emptyValueSlot = "";
125
+ optionSlot = void 0;
126
+ valueSlot = void 0;
127
+ editSlot = void 0;
128
+ slotData = {};
129
+ resource = "";
130
+ resourceData = {};
131
+ validationResource = "";
132
+ validationResourceData = {};
133
+ autoValidation = false;
134
+ autoValidationType = "blur" /* Blur */;
135
+ validationStack = "default";
136
+ minNumbers = void 0;
137
+ maxNumbers = void 0;
138
+ minChars = void 0;
139
+ maxChars = void 0;
140
+ minUpperChars = void 0;
141
+ maxUpperChars = void 0;
142
+ minLowerChars = void 0;
143
+ maxLowerChars = void 0;
144
+ minSpecialChars = void 0;
145
+ maxSpecialChars = void 0;
146
+ checkEqualTo = void 0;
147
+ featuredButton = "";
148
+ infoButtonEllipsis = false;
149
+ fileName = "";
150
+ customButtonText = "";
151
+ customButtonClass = "";
152
+ options = [];
153
+ multiple = false;
154
+ multipleDisplay = "list" /* List */;
155
+ multipleDisplayEdition = "inline" /* Inline */;
156
+ searchable = false;
157
+ autoloadOptionsResource = false;
158
+ optionsDownload = "";
159
+ optionsModal = "";
160
+ optionsModalData = {};
161
+ optionsIcon = "";
162
+ optionsLabelFormatter = void 0;
163
+ optionsResource = "";
164
+ optionsResourceData = {};
165
+ icon = "";
166
+ download = "";
167
+ modal = "";
168
+ modalKey = "";
169
+ modalData = {};
170
+ data = {};
171
+ constructor(data = {}) {
172
+ super();
173
+ this.feed(data);
174
+ }
175
+ };
176
+
177
+ // src/enums/ColumnType.ts
178
+ var ColumnType = /* @__PURE__ */ ((ColumnType2) => {
179
+ ColumnType2["None"] = "";
180
+ ColumnType2["Field"] = "field";
181
+ ColumnType2["Button"] = "button";
182
+ ColumnType2["Anchor"] = "anchor";
183
+ ColumnType2["Text"] = "text";
184
+ ColumnType2["Number"] = "number";
185
+ ColumnType2["Check"] = "check";
186
+ ColumnType2["Switch"] = "switch";
187
+ ColumnType2["Select"] = "select";
188
+ ColumnType2["Email"] = "email";
189
+ ColumnType2["Tel"] = "tel";
190
+ ColumnType2["File"] = "file";
191
+ ColumnType2["Link"] = "link";
192
+ ColumnType2["Action"] = "action";
193
+ ColumnType2["Integer"] = "int";
194
+ ColumnType2["Float"] = "float";
195
+ return ColumnType2;
196
+ })(ColumnType || {});
197
+
198
+ // src/value-objects/SafeString.ts
199
+ var SafeString = class _SafeString {
200
+ value;
201
+ constructor(input) {
202
+ this.value = input;
203
+ }
204
+ getValue(...args) {
205
+ if (typeof this.value === "function") {
206
+ return this.value(...args);
207
+ } else if (typeof this.value === "object" && typeof this.value === typeof _SafeString) {
208
+ return this.value.getValue(...args);
209
+ } else if (typeof this.value === "string") {
210
+ return this.value;
211
+ }
212
+ return "";
213
+ }
214
+ };
215
+
216
+ // src/enums/AnchorType.ts
217
+ var AnchorType = /* @__PURE__ */ ((AnchorType2) => {
218
+ AnchorType2["Href"] = "href";
219
+ AnchorType2["RouterLink"] = "router-link";
220
+ AnchorType2["RouterLinkBack"] = "router-link-back";
221
+ AnchorType2["Mail"] = "mail";
222
+ AnchorType2["Tel"] = "tel";
223
+ AnchorType2["Tab"] = "tab";
224
+ AnchorType2["Download"] = "download";
225
+ AnchorType2["Action"] = "action";
226
+ AnchorType2["Legacy"] = "";
227
+ return AnchorType2;
228
+ })(AnchorType || {});
229
+
230
+ // src/instances/Anchor.ts
231
+ var Anchor = class extends LktItem {
232
+ static lktAllowUndefinedProps = [
233
+ "onClick"
234
+ ];
235
+ static lktDefaultValues = [
236
+ "type",
237
+ "to",
238
+ "class",
239
+ "isActive",
240
+ "downloadFileName",
241
+ "disabled",
242
+ "onClick",
243
+ "confirmModal",
244
+ "confirmModalKey",
245
+ "confirmData",
246
+ "imposter"
247
+ ];
248
+ type = "router-link" /* RouterLink */;
249
+ to = "";
250
+ class = "";
251
+ isActive = false;
252
+ downloadFileName = "";
253
+ disabled = false;
254
+ onClick = void 0;
255
+ confirmModal = "";
256
+ confirmModalKey = "_";
257
+ confirmData = {};
258
+ imposter = false;
259
+ constructor(data = {}) {
260
+ super();
261
+ this.feed(data);
262
+ }
263
+ getHref() {
264
+ let href = "";
265
+ if (typeof this.to === "string") href = this.to;
266
+ if ("mail" /* Mail */ === this.type) return `mailto:${href}`;
267
+ if ("tel" /* Tel */ === this.type) return `tel:${href}`;
268
+ if ([
269
+ "href" /* Href */,
270
+ "mail" /* Mail */,
271
+ "tel" /* Tel */,
272
+ "tab" /* Tab */,
273
+ "download" /* Download */
274
+ ].includes(this.type)) {
275
+ return href;
276
+ }
277
+ if (typeof this.to === "string" && this.to !== "") return this.to;
278
+ return "";
279
+ }
280
+ };
281
+
282
+ // src/enums/ButtonType.ts
283
+ var ButtonType = /* @__PURE__ */ ((ButtonType2) => {
284
+ ButtonType2["Button"] = "button";
285
+ ButtonType2["Submit"] = "submit";
286
+ ButtonType2["Reset"] = "reset";
287
+ ButtonType2["Anchor"] = "anchor";
288
+ ButtonType2["Content"] = "content";
289
+ ButtonType2["Switch"] = "switch";
290
+ ButtonType2["HiddenSwitch"] = "hidden-switch";
291
+ ButtonType2["Split"] = "split";
292
+ ButtonType2["SplitLazy"] = "split-lazy";
293
+ ButtonType2["SplitEver"] = "split-ever";
294
+ ButtonType2["Tooltip"] = "tooltip";
295
+ ButtonType2["TooltipLazy"] = "tooltip-lazy";
296
+ ButtonType2["TooltipEver"] = "tooltip-ever";
297
+ return ButtonType2;
298
+ })(ButtonType || {});
299
+
300
+ // src/instances/Button.ts
301
+ import { generateRandomString as generateRandomString2 } from "lkt-string-tools";
302
+
303
+ // src/enums/TooltipPositionEngine.ts
304
+ var TooltipPositionEngine = /* @__PURE__ */ ((TooltipPositionEngine2) => {
305
+ TooltipPositionEngine2["Fixed"] = "fixed";
306
+ TooltipPositionEngine2["Absolute"] = "absolute";
307
+ return TooltipPositionEngine2;
308
+ })(TooltipPositionEngine || {});
309
+
310
+ // src/instances/Button.ts
311
+ var Button = class extends LktItem {
312
+ lktAllowUndefinedProps = [
313
+ "clickRef",
314
+ "tabindex",
315
+ "anchor",
316
+ "showTooltipOnHover",
317
+ "hideTooltipOnLeave"
318
+ ];
319
+ type = "button" /* Button */;
320
+ name = generateRandomString2(10);
321
+ palette = "";
322
+ onClickTo = "";
323
+ onClickToExternal = false;
324
+ class = "";
325
+ containerClass = "";
326
+ value = "";
327
+ disabled = false;
328
+ loading = false;
329
+ wrapContent = false;
330
+ split = false;
331
+ splitIcon = "";
332
+ isAnchor = false;
333
+ resource = "";
334
+ resourceData = () => ({});
335
+ modal = "";
336
+ modalKey = "_";
337
+ modalData = () => ({});
338
+ confirmModal = "";
339
+ confirmModalKey = "_";
340
+ confirmData = () => ({});
341
+ text = "";
342
+ icon = "";
343
+ iconDot = false;
344
+ iconEnd = "";
345
+ img = "";
346
+ newTab = false;
347
+ download = false;
348
+ downloadFileName = "";
349
+ tooltip = false;
350
+ showTooltipOnHoverDelay = 0;
351
+ tooltipWindowMargin = 0;
352
+ tooltipReferrerMargin = 0;
353
+ tooltipLocationY = "bottom";
354
+ tooltipLocationX = "left-corner";
355
+ checked = false;
356
+ clickRef = void 0;
357
+ openTooltip = false;
358
+ tabindex = void 0;
359
+ anchor = void 0;
360
+ tooltipEngine = "fixed" /* Fixed */;
361
+ showTooltipOnHover = void 0;
362
+ hideTooltipOnLeave = void 0;
363
+ tooltipClass = "";
364
+ splitClass = "";
365
+ constructor(data = {}) {
366
+ super();
367
+ this.feed(data);
368
+ this.anchor = new Anchor(data.anchor);
369
+ }
370
+ };
371
+
372
+ // src/instances/Column.ts
373
+ var Column = class extends LktItem {
374
+ lktExcludedProps = ["link", "field", "anchor", "button"];
375
+ lktAllowUndefinedProps = [
376
+ "formatter",
377
+ "checkEmpty",
378
+ "colspan",
379
+ "field",
380
+ "anchor",
381
+ "button",
382
+ "link",
383
+ "action"
384
+ ];
385
+ type = "" /* None */;
386
+ key = "";
387
+ label = "";
388
+ sortable = true;
389
+ hidden = false;
390
+ editable = false;
391
+ formatter = void 0;
392
+ checkEmpty = void 0;
393
+ colspan = void 0;
394
+ preferSlot = true;
395
+ isForRowKey = false;
396
+ extractTitleFromColumn = "";
397
+ slotData = {};
398
+ field = void 0;
399
+ anchor = void 0;
400
+ button = void 0;
401
+ link = void 0;
402
+ action = void 0;
403
+ constructor(data) {
404
+ super();
405
+ this.feed(data);
406
+ switch (this.type) {
407
+ case "field" /* Field */:
408
+ this.field = new Field(data.field);
409
+ break;
410
+ case "anchor" /* Anchor */:
411
+ this.anchor = new Anchor(data.anchor);
412
+ break;
413
+ case "button" /* Button */:
414
+ this.button = new Button(data.button);
415
+ break;
416
+ }
417
+ this.link = new SafeString(data.link);
418
+ }
419
+ getHref(item) {
420
+ if (typeof this.link !== "object") return "";
421
+ return this.link.getValue(item);
422
+ }
423
+ doAction(item) {
424
+ if (typeof this.action === "function") {
425
+ return this.action(item);
426
+ }
427
+ console.warn("No action defined");
428
+ }
429
+ };
430
+
74
431
  // src/enums/TooltipLocationY.ts
75
432
  var TooltipLocationY = /* @__PURE__ */ ((TooltipLocationY2) => {
76
433
  TooltipLocationY2["Top"] = "top";
@@ -90,19 +447,151 @@ var TooltipLocationX = /* @__PURE__ */ ((TooltipLocationX2) => {
90
447
  return TooltipLocationX2;
91
448
  })(TooltipLocationX || {});
92
449
 
93
- // src/enums/TooltipPositionEngine.ts
94
- var TooltipPositionEngine = /* @__PURE__ */ ((TooltipPositionEngine2) => {
95
- TooltipPositionEngine2["Fixed"] = "fixed";
96
- TooltipPositionEngine2["Absolute"] = "absolute";
97
- return TooltipPositionEngine2;
98
- })(TooltipPositionEngine || {});
450
+ // src/instances/Tooltip.ts
451
+ var Tooltip = class extends LktItem {
452
+ static lktDefaultValues = [
453
+ "modelValue",
454
+ "alwaysOpen",
455
+ "class",
456
+ "text",
457
+ "icon",
458
+ "iconAtEnd",
459
+ "engine",
460
+ "referrerWidth",
461
+ "referrerMargin",
462
+ "windowMargin",
463
+ "referrer",
464
+ "locationY",
465
+ "locationX"
466
+ ];
467
+ modelValue = false;
468
+ alwaysOpen = false;
469
+ class = "";
470
+ text = "";
471
+ icon = "";
472
+ iconAtEnd = false;
473
+ engine = "fixed" /* Fixed */;
474
+ referrerWidth = false;
475
+ referrerMargin = 0;
476
+ windowMargin = 0;
477
+ referrer = void 0;
478
+ locationY = "bottom" /* Bottom */;
479
+ locationX = "left-corner" /* LeftCorner */;
480
+ constructor(data = {}) {
481
+ super();
482
+ this.feed(data);
483
+ }
484
+ };
485
+
486
+ // src/instances/Modal.ts
487
+ var Modal = class extends LktItem {
488
+ static lktDefaultValues = [
489
+ "size",
490
+ "preTitle",
491
+ "preTitleIcon",
492
+ "title",
493
+ "closeIcon",
494
+ "closeConfirm",
495
+ "closeConfirmKey",
496
+ "showClose",
497
+ "disabledClose",
498
+ "disabledVeilClick",
499
+ "hiddenFooter",
500
+ "modalName",
501
+ "modalKey",
502
+ "zIndex",
503
+ "beforeClose",
504
+ "item"
505
+ ];
506
+ size = "";
507
+ preTitle = "";
508
+ preTitleIcon = "";
509
+ title = "";
510
+ closeIcon = "";
511
+ closeConfirm = "";
512
+ closeConfirmKey = "_";
513
+ showClose = true;
514
+ disabledClose = false;
515
+ disabledVeilClick = false;
516
+ hiddenFooter = false;
517
+ modalName = "";
518
+ modalKey = "_";
519
+ zIndex = 500;
520
+ beforeClose = void 0;
521
+ item = {};
522
+ constructor(data = {}) {
523
+ super();
524
+ this.feed(data);
525
+ }
526
+ };
527
+
528
+ // src/enums/ModalType.ts
529
+ var ModalType = /* @__PURE__ */ ((ModalType2) => {
530
+ ModalType2["Modal"] = "modal";
531
+ ModalType2["Confirm"] = "confirm";
532
+ return ModalType2;
533
+ })(ModalType || {});
534
+
535
+ // src/enums/SortDirection.ts
536
+ var SortDirection = /* @__PURE__ */ ((SortDirection2) => {
537
+ SortDirection2["Asc"] = "asc";
538
+ SortDirection2["Desc"] = "desc";
539
+ return SortDirection2;
540
+ })(SortDirection || {});
541
+
542
+ // src/enums/TableType.ts
543
+ var TableType = /* @__PURE__ */ ((TableType2) => {
544
+ TableType2["Table"] = "table";
545
+ TableType2["Item"] = "item";
546
+ TableType2["Ul"] = "ul";
547
+ TableType2["Ol"] = "ol";
548
+ return TableType2;
549
+ })(TableType || {});
550
+
551
+ // src/enums/ToggleMode.ts
552
+ var ToggleMode = /* @__PURE__ */ ((ToggleMode2) => {
553
+ ToggleMode2["Lazy"] = "lazy";
554
+ ToggleMode2["Ever"] = "ever";
555
+ return ToggleMode2;
556
+ })(ToggleMode || {});
557
+
558
+ // src/index.ts
559
+ function getDefaultValues(cls) {
560
+ const instance = new cls();
561
+ const result = {};
562
+ if (!Array.isArray(cls.lktDefaultValues)) {
563
+ throw new Error("lktDefaultValues must be a keys array.");
564
+ }
565
+ for (const key of cls.lktDefaultValues) {
566
+ if (key in instance) {
567
+ result[key] = instance[key];
568
+ }
569
+ }
570
+ return result;
571
+ }
99
572
  export {
573
+ Anchor,
574
+ AnchorType,
575
+ Button,
100
576
  ButtonType,
577
+ Column,
578
+ ColumnType,
579
+ Field,
580
+ FieldAutoValidationTrigger,
101
581
  FieldType,
102
582
  LktItem,
103
583
  LktStrictItem,
584
+ Modal,
585
+ ModalType,
586
+ MultipleOptionsDisplay,
104
587
  Option,
588
+ SafeString,
589
+ SortDirection,
590
+ TableType,
591
+ ToggleMode,
592
+ Tooltip,
105
593
  TooltipLocationX,
106
594
  TooltipLocationY,
107
- TooltipPositionEngine
595
+ TooltipPositionEngine,
596
+ getDefaultValues
108
597
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkt-vue-kernel",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "LKT Vue Kernel",
5
5
  "keywords": [
6
6
  "lkt",
@@ -13,7 +13,9 @@
13
13
  "type": "module",
14
14
  "module": "./dist/index.js",
15
15
  "types": "./dist/index.d.ts",
16
- "files": ["dist"],
16
+ "files": [
17
+ "dist"
18
+ ],
17
19
  "exports": {
18
20
  ".": {
19
21
  "import": "./dist/index.js"
@@ -31,5 +33,10 @@
31
33
  },
32
34
  "engines": {
33
35
  "node": ">=18"
36
+ },
37
+ "dependencies": {
38
+ "lkt-string-tools": "^1.0.8",
39
+ "vue": "^3.5.13",
40
+ "vue-router": "^4.5.0"
34
41
  }
35
42
  }