bank20baht-ui 0.2.5 → 0.2.7
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/dist/chunks/index-BI-29Q8f.js +694 -0
- package/dist/components/primitives/baht-datepicker.d.ts +34 -2
- package/dist/core/dates.d.ts +29 -0
- package/dist/core/i18n.d.ts +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/types.d.ts +21 -0
- package/dist/custom-elements.json +106 -1
- package/dist/engine.js +22 -628
- package/dist/index.js +724 -640
- package/dist/react.d.ts +1 -0
- package/dist/tokens.css +170 -1
- package/dist/vscode.html-custom-data.json +1 -1
- package/dist/web-types.json +2 -2
- package/package.json +2 -1
|
@@ -1,6 +1,38 @@
|
|
|
1
|
-
import { TemplateResult } from 'lit';
|
|
1
|
+
import { PropertyValues, TemplateResult } from 'lit';
|
|
2
2
|
import { BahtFieldBase } from '../base.js';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Calendar field on top of flatpickr. The VALUE is always ISO `yyyy-mm-dd`
|
|
5
|
+
* regardless of `field.dateFormat` (display only):
|
|
6
|
+
* - `dateMode: 'single'` (default) -> `string | null`
|
|
7
|
+
* - `dateMode: 'range'` -> `[start, end] | null` (inclusive)
|
|
8
|
+
* - `dateMode: 'multiple'` -> `string[]`
|
|
9
|
+
* `min` / `max` bound the calendar; `disabledDates` (ISO days or `a/b`
|
|
10
|
+
* intervals) and `disabledWeekdays` (0 = Sun … 6 = Sat) grey days out — and
|
|
11
|
+
* the engine re-checks them on validate, so the calendar is UX, not the gate.
|
|
12
|
+
*
|
|
13
|
+
* The calendar renders INSIDE the element (flatpickr `static`), so it lives in
|
|
14
|
+
* light DOM like every other node and picks up a theme set on any ancestor.
|
|
15
|
+
* Give a clipping ancestor (`overflow: hidden`) room, or it hides the popup.
|
|
16
|
+
*/
|
|
4
17
|
export declare class BahtDatepicker extends BahtFieldBase {
|
|
18
|
+
private fp;
|
|
19
|
+
/**
|
|
20
|
+
* What we last told the host. A controlled host re-feeds `value` after the
|
|
21
|
+
* event, but a slow (or absent) re-feed must not make onClose re-emit the
|
|
22
|
+
* pick onChange already sent — compare against this until `value` catches up.
|
|
23
|
+
*/
|
|
24
|
+
private lastEmitted;
|
|
5
25
|
protected renderControl(): TemplateResult;
|
|
26
|
+
connectedCallback(): void;
|
|
27
|
+
disconnectedCallback(): void;
|
|
28
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
29
|
+
private teardown;
|
|
30
|
+
/** Push the host-fed `value` into the calendar without echoing an event. */
|
|
31
|
+
private syncValue;
|
|
32
|
+
private options;
|
|
33
|
+
private emitIfChanged;
|
|
34
|
+
/** Host value (any mode) -> the Date list flatpickr works with. */
|
|
35
|
+
private datesOf;
|
|
36
|
+
/** flatpickr's selection -> the value shape of the field's mode. */
|
|
37
|
+
private toValue;
|
|
6
38
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { DateMode, FieldDescriptor } from './types.js';
|
|
2
|
+
/** ISO day -> local Date at midnight, or null when malformed / not a real day. */
|
|
3
|
+
export declare function parseIsoDate(iso: unknown): Date | null;
|
|
4
|
+
/** Local Date -> ISO day. */
|
|
5
|
+
export declare function formatIsoDate(date: Date): string;
|
|
6
|
+
export declare const dateModeOf: (field: FieldDescriptor) => DateMode;
|
|
7
|
+
/**
|
|
8
|
+
* Every ISO day a date value holds, whatever the mode: a single string, a
|
|
9
|
+
* `[start, end]` range (both ends only — the interior is implied) or a list.
|
|
10
|
+
* Non-string entries are dropped; shape errors are the validator's job.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isoDaysOf(value: unknown): string[];
|
|
13
|
+
/**
|
|
14
|
+
* One `disabledDates` entry: an ISO day or an inclusive ISO interval
|
|
15
|
+
* `start/end`. Returns `[from, to]` (from === to for a single day) or null.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseDisabledEntry(entry: string): [Date, Date] | null;
|
|
18
|
+
/**
|
|
19
|
+
* True when `iso` falls on a disabled weekday or inside a disabled date /
|
|
20
|
+
* interval of the descriptor. Malformed entries never disable anything.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isDateDisabled(field: FieldDescriptor, iso: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Days between a range's ends (inclusive) that a picker would step over —
|
|
25
|
+
* so a range can be rejected when a holiday sits INSIDE it. Capped so a
|
|
26
|
+
* hostile `["1900-01-01","2999-12-31"]` submission cannot spin the server;
|
|
27
|
+
* beyond the cap only the ends are checked.
|
|
28
|
+
*/
|
|
29
|
+
export declare function rangeInteriorDays(start: string, end: string, cap?: number): string[];
|
package/dist/core/i18n.d.ts
CHANGED
package/dist/core/index.d.ts
CHANGED
|
@@ -11,3 +11,4 @@ export { resolveNext, walkPath } from './engine/graph.js';
|
|
|
11
11
|
export { evalCondition, readRef } from './engine/conditions.js';
|
|
12
12
|
export { evalValueExpr } from './engine/expressions.js';
|
|
13
13
|
export { displayValue, type DisplayValue } from './display.js';
|
|
14
|
+
export { formatIsoDate, isDateDisabled, parseDisabledEntry, parseIsoDate } from './dates.js';
|
package/dist/core/types.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/** Control types supported by v1 (spec 01 §2). */
|
|
2
2
|
export type FieldType = 'text' | 'textarea' | 'number' | 'email' | 'password' | 'dropdown' | 'multiselect' | 'checkbox' | 'radio' | 'toggle' | 'date' | 'file' | 'label' | 'section' | 'repeater';
|
|
3
3
|
export type FieldWidth = '1/4' | '1/2' | '3/4' | 'full';
|
|
4
|
+
/** `date` field selection mode (spec 01 §2). */
|
|
5
|
+
export type DateMode = 'single' | 'range' | 'multiple';
|
|
4
6
|
export interface FieldOption {
|
|
5
7
|
key: string;
|
|
6
8
|
label: string;
|
|
@@ -48,6 +50,25 @@ export interface FieldDescriptor {
|
|
|
48
50
|
minLength?: number;
|
|
49
51
|
min?: number | string;
|
|
50
52
|
max?: number | string;
|
|
53
|
+
/**
|
|
54
|
+
* date: selection mode. 'single' (default) -> value is one ISO string;
|
|
55
|
+
* 'range' -> value is `[start, end]` (both ISO, inclusive); 'multiple' ->
|
|
56
|
+
* value is an ISO string[] in pick order.
|
|
57
|
+
*/
|
|
58
|
+
dateMode?: DateMode;
|
|
59
|
+
/**
|
|
60
|
+
* date: DISPLAY format of the typed/rendered text (flatpickr tokens, e.g.
|
|
61
|
+
* 'd/m/Y', 'j M Y'). The VALUE stays ISO yyyy-mm-dd regardless.
|
|
62
|
+
*/
|
|
63
|
+
dateFormat?: string;
|
|
64
|
+
/**
|
|
65
|
+
* date: days that cannot be picked — each entry an ISO date ('2026-04-13')
|
|
66
|
+
* or an inclusive ISO interval ('2026-04-13/2026-04-15'). Enforced by the
|
|
67
|
+
* engine too, so a hand-crafted submission cannot bypass the calendar.
|
|
68
|
+
*/
|
|
69
|
+
disabledDates?: string[];
|
|
70
|
+
/** date: weekdays that cannot be picked, 0 = Sunday … 6 = Saturday. */
|
|
71
|
+
disabledWeekdays?: number[];
|
|
51
72
|
step?: number;
|
|
52
73
|
rows?: number;
|
|
53
74
|
accept?: string;
|
|
@@ -2515,9 +2515,27 @@
|
|
|
2515
2515
|
"declarations": [
|
|
2516
2516
|
{
|
|
2517
2517
|
"kind": "class",
|
|
2518
|
-
"description": "
|
|
2518
|
+
"description": "Calendar field on top of flatpickr. The VALUE is always ISO `yyyy-mm-dd`\nregardless of `field.dateFormat` (display only):\n - `dateMode: 'single'` (default) -> `string | null`\n - `dateMode: 'range'` -> `[start, end] | null` (inclusive)\n - `dateMode: 'multiple'` -> `string[]`\n`min` / `max` bound the calendar; `disabledDates` (ISO days or `a/b`\nintervals) and `disabledWeekdays` (0 = Sun … 6 = Sat) grey days out — and\nthe engine re-checks them on validate, so the calendar is UX, not the gate.\n\nThe calendar renders INSIDE the element (flatpickr `static`), so it lives in\nlight DOM like every other node and picks up a theme set on any ancestor.\nGive a clipping ancestor (`overflow: hidden`) room, or it hides the popup.",
|
|
2519
2519
|
"name": "BahtDatepicker",
|
|
2520
2520
|
"members": [
|
|
2521
|
+
{
|
|
2522
|
+
"kind": "field",
|
|
2523
|
+
"name": "fp",
|
|
2524
|
+
"type": {
|
|
2525
|
+
"text": "FlatpickrInstance | undefined"
|
|
2526
|
+
},
|
|
2527
|
+
"privacy": "private"
|
|
2528
|
+
},
|
|
2529
|
+
{
|
|
2530
|
+
"kind": "field",
|
|
2531
|
+
"name": "lastEmitted",
|
|
2532
|
+
"type": {
|
|
2533
|
+
"text": "Date[] | null"
|
|
2534
|
+
},
|
|
2535
|
+
"privacy": "private",
|
|
2536
|
+
"default": "null",
|
|
2537
|
+
"description": "What we last told the host. A controlled host re-feeds `value` after the\nevent, but a slow (or absent) re-feed must not make onClose re-emit the\npick onChange already sent — compare against this until `value` catches up."
|
|
2538
|
+
},
|
|
2521
2539
|
{
|
|
2522
2540
|
"kind": "method",
|
|
2523
2541
|
"name": "renderControl",
|
|
@@ -2532,6 +2550,93 @@
|
|
|
2532
2550
|
"module": "src/components/base.ts"
|
|
2533
2551
|
}
|
|
2534
2552
|
},
|
|
2553
|
+
{
|
|
2554
|
+
"kind": "method",
|
|
2555
|
+
"name": "teardown",
|
|
2556
|
+
"privacy": "private",
|
|
2557
|
+
"return": {
|
|
2558
|
+
"type": {
|
|
2559
|
+
"text": "void"
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
},
|
|
2563
|
+
{
|
|
2564
|
+
"kind": "method",
|
|
2565
|
+
"name": "syncValue",
|
|
2566
|
+
"privacy": "private",
|
|
2567
|
+
"return": {
|
|
2568
|
+
"type": {
|
|
2569
|
+
"text": "void"
|
|
2570
|
+
}
|
|
2571
|
+
},
|
|
2572
|
+
"description": "Push the host-fed `value` into the calendar without echoing an event."
|
|
2573
|
+
},
|
|
2574
|
+
{
|
|
2575
|
+
"kind": "method",
|
|
2576
|
+
"name": "options",
|
|
2577
|
+
"privacy": "private",
|
|
2578
|
+
"return": {
|
|
2579
|
+
"type": {
|
|
2580
|
+
"text": "FlatpickrOptions"
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
},
|
|
2584
|
+
{
|
|
2585
|
+
"kind": "method",
|
|
2586
|
+
"name": "emitIfChanged",
|
|
2587
|
+
"privacy": "private",
|
|
2588
|
+
"return": {
|
|
2589
|
+
"type": {
|
|
2590
|
+
"text": "void"
|
|
2591
|
+
}
|
|
2592
|
+
},
|
|
2593
|
+
"parameters": [
|
|
2594
|
+
{
|
|
2595
|
+
"name": "dates",
|
|
2596
|
+
"type": {
|
|
2597
|
+
"text": "Date[]"
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
]
|
|
2601
|
+
},
|
|
2602
|
+
{
|
|
2603
|
+
"kind": "method",
|
|
2604
|
+
"name": "datesOf",
|
|
2605
|
+
"privacy": "private",
|
|
2606
|
+
"return": {
|
|
2607
|
+
"type": {
|
|
2608
|
+
"text": "Date[]"
|
|
2609
|
+
}
|
|
2610
|
+
},
|
|
2611
|
+
"parameters": [
|
|
2612
|
+
{
|
|
2613
|
+
"name": "value",
|
|
2614
|
+
"type": {
|
|
2615
|
+
"text": "unknown"
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
],
|
|
2619
|
+
"description": "Host value (any mode) -> the Date list flatpickr works with."
|
|
2620
|
+
},
|
|
2621
|
+
{
|
|
2622
|
+
"kind": "method",
|
|
2623
|
+
"name": "toValue",
|
|
2624
|
+
"privacy": "private",
|
|
2625
|
+
"return": {
|
|
2626
|
+
"type": {
|
|
2627
|
+
"text": "unknown"
|
|
2628
|
+
}
|
|
2629
|
+
},
|
|
2630
|
+
"parameters": [
|
|
2631
|
+
{
|
|
2632
|
+
"name": "dates",
|
|
2633
|
+
"type": {
|
|
2634
|
+
"text": "Date[]"
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2637
|
+
],
|
|
2638
|
+
"description": "flatpickr's selection -> the value shape of the field's mode."
|
|
2639
|
+
},
|
|
2535
2640
|
{
|
|
2536
2641
|
"kind": "field",
|
|
2537
2642
|
"name": "uid",
|