tyrell-components 1.0.0-RC18 → 1.0.0-RC20

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.
@@ -52,6 +52,9 @@ export declare class TyModal extends HTMLElement {
52
52
  set open(v: boolean);
53
53
  get noBackdrop(): boolean;
54
54
  set noBackdrop(v: boolean);
55
+ /** Full screen on phones (below 768px), sliding up from the bottom. */
56
+ get sheet(): boolean;
57
+ set sheet(v: boolean);
55
58
  get noZoom(): boolean;
56
59
  set noZoom(v: boolean);
57
60
  get preventOutsideClick(): boolean;
@@ -65,6 +65,7 @@ const closeButton = document.createElement('button');
65
65
  const contentDiv = document.createElement('div');
66
66
  const slot = document.createElement('slot');
67
67
  dialog.className = 'ty-modal-dialog';
68
+ dialog.setAttribute('part', 'dialog');
68
69
  closeButton.className = 'close-button';
69
70
  closeButton.type = 'button';
70
71
  closeButton.setAttribute('aria-label', 'Close modal');
@@ -288,6 +289,7 @@ dialog.setAttribute('data-backdrop', 'true');
288
289
  else {
289
290
  dialog.removeAttribute('data-backdrop');
290
291
  }
292
+ dialog.toggleAttribute('data-sheet', parseBoolAttr(el, 'sheet'));
291
293
  const label = el.getAttribute('label');
292
294
  if (label) {
293
295
  dialog.setAttribute('aria-label', label);
@@ -400,7 +402,7 @@ hoverLeaveHandlers.delete(el);
400
402
  }
401
403
  export class TyModal extends HTMLElement {
402
404
  static get observedAttributes() {
403
- return ['open', 'no-backdrop', 'no-zoom', 'prevent-outside-click', 'prevent-escape', 'label'];
405
+ return ['open', 'no-backdrop', 'no-zoom', 'sheet', 'prevent-outside-click', 'prevent-escape', 'label'];
404
406
  }
405
407
  get open() { return parseBoolAttr(this, 'open'); }
406
408
  set open(v) { coerceBoolean(v) ? this.setAttribute('open', 'true') : this.removeAttribute('open'); }
@@ -408,6 +410,10 @@ get noBackdrop() { return parseBoolAttr(this, 'no-backdrop'); }
408
410
  set noBackdrop(v) {
409
411
  coerceBoolean(v) ? this.setAttribute('no-backdrop', '') : this.removeAttribute('no-backdrop');
410
412
  }
413
+ get sheet() { return parseBoolAttr(this, 'sheet'); }
414
+ set sheet(v) {
415
+ coerceBoolean(v) ? this.setAttribute('sheet', '') : this.removeAttribute('sheet');
416
+ }
411
417
  get noZoom() { return parseBoolAttr(this, 'no-zoom'); }
412
418
  set noZoom(v) {
413
419
  coerceBoolean(v) ? this.setAttribute('no-zoom', '') : this.removeAttribute('no-zoom');
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Sortable Component — reorder a container's element children, or move them
3
+ * into another ty-sortable of the same `group`, by pointer (mouse, touch,
4
+ * pen), keyboard, or the move() method.
5
+ *
6
+ * Controlled: ty-sortable never moves, inserts or removes light-DOM nodes.
7
+ * During a drag it draws a ghost and a drop indicator in the top layer; on
8
+ * drop it fires one `ty-sortable-change` on the destination and the app,
9
+ * framework or server renders the new order. Until that render lands the
10
+ * result is held on screen ("hold until morph"), so a server round trip
11
+ * doesn't snap the item back. A render that doesn't change the order (a
12
+ * rejected move) snaps it back.
13
+ */
14
+ /** Where an item is (from) or will be (to). prev/next exclude the item itself. */
15
+ export interface TySortablePos {
16
+ list: string | null;
17
+ index: number;
18
+ prev: string | null;
19
+ next: string | null;
20
+ }
21
+ export interface TySortableValue {
22
+ key: string | null;
23
+ group: string | null;
24
+ source: 'pointer' | 'keyboard' | 'api';
25
+ from: TySortablePos;
26
+ to: TySortablePos;
27
+ /** Resulting key order of every list the move touches, by container id. */
28
+ order: Record<string, (string | null)[]>;
29
+ }
30
+ /** `ty-sortable-change`, on the destination list. */
31
+ export interface TySortableChangeDetail {
32
+ value: TySortableValue;
33
+ item: HTMLElement;
34
+ fromContainer: TySortable;
35
+ toContainer: TySortable;
36
+ }
37
+ /** What a drag knows before it has a destination. */
38
+ export interface TySortableDragValue {
39
+ key: string | null;
40
+ group: string | null;
41
+ source: 'pointer' | 'keyboard' | 'api';
42
+ from: TySortablePos;
43
+ }
44
+ /** `ty-sortable-start`, on the source list. */
45
+ export interface TySortableStartDetail {
46
+ value: TySortableDragValue;
47
+ item: HTMLElement;
48
+ }
49
+ export type TySortableCancelReason = 'escape' | 'spill' | 'blocked' | 'pointercancel' | 'gone' | 'disabled' | 'blur';
50
+ /** `ty-sortable-cancel`, on the source list. */
51
+ export interface TySortableCancelDetail {
52
+ value: TySortableDragValue;
53
+ item: HTMLElement;
54
+ reason: TySortableCancelReason;
55
+ }
56
+ /**
57
+ * accepted: rendered where it was dropped. rejected: the order didn't
58
+ * change (preventDefault, or a request ended without a render).
59
+ * reconciled: rendered somewhere else, or removed. unknown: nothing
60
+ * answered before hold-timeout.
61
+ */
62
+ export type TySortableOutcome = 'accepted' | 'rejected' | 'reconciled' | 'unknown';
63
+ /** `ty-sortable-settle`, on the destination list, when a hold ends. */
64
+ export interface TySortableSettleDetail {
65
+ value: TySortableValue;
66
+ outcome: TySortableOutcome;
67
+ }
68
+ export interface TySortableDropContext {
69
+ item: HTMLElement;
70
+ key: string | null;
71
+ from: TySortable;
72
+ to: TySortable;
73
+ index: number;
74
+ }
75
+ export interface TySortableAttributes {
76
+ group?: string;
77
+ axis?: 'vertical' | 'horizontal';
78
+ handle?: string;
79
+ accepts?: string;
80
+ disabled?: boolean;
81
+ 'key-attr'?: string;
82
+ 'hold-timeout'?: number;
83
+ label?: string;
84
+ 'drop-line'?: boolean;
85
+ flash?: boolean;
86
+ }
87
+ /** Announcement templates: {item}, {position}, {total}, {list}. */
88
+ export interface TySortableStrings {
89
+ pickedUp: string;
90
+ moved: string;
91
+ blocked: string;
92
+ dropped: string;
93
+ rejected: string;
94
+ reconciled: string;
95
+ removed: string;
96
+ unknown: string;
97
+ cancelled: string;
98
+ pending: string;
99
+ }
100
+ export declare class TySortable extends HTMLElement {
101
+ static get observedAttributes(): string[];
102
+ /** @internal */
103
+ _states: CustomStateSet | null;
104
+ private _live;
105
+ private _press;
106
+ private _canDrop;
107
+ private _labels;
108
+ private _childObserver;
109
+ constructor();
110
+ get group(): string | null;
111
+ set group(v: string | null);
112
+ get axis(): 'vertical' | 'horizontal';
113
+ set axis(v: 'vertical' | 'horizontal');
114
+ get disabled(): boolean;
115
+ set disabled(v: boolean);
116
+ /** A drop line marks the slot and nothing moves. Off: siblings move aside while dragging. */
117
+ get dropLine(): boolean;
118
+ set dropLine(v: boolean);
119
+ /** Outline the item briefly where it lands. */
120
+ get flash(): boolean;
121
+ set flash(v: boolean);
122
+ get handleSelector(): string;
123
+ get accepts(): string | null;
124
+ set accepts(v: string | null);
125
+ get holdTimeout(): number;
126
+ /** Extra drop rule, per candidate slot: return false to block it. */
127
+ get canDrop(): ((ctx: TySortableDropContext) => boolean) | null;
128
+ set canDrop(fn: ((ctx: TySortableDropContext) => boolean) | null);
129
+ /** Announcement overrides (i18n). */
130
+ get labels(): Partial<TySortableStrings>;
131
+ set labels(v: Partial<TySortableStrings>);
132
+ /** The items, in order: element children except <template> and [data-sortable-ignore]. */
133
+ get items(): HTMLElement[];
134
+ /** An item's key: the `key-attr` attribute, else data-key, else id. */
135
+ keyOf(item: Element): string | null;
136
+ connectedCallback(): void;
137
+ disconnectedCallback(): void;
138
+ /** Moved with moveBefore() (Datastar morphs): stay as we are. */
139
+ connectedMoveCallback(): void;
140
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
141
+ private _onChildren;
142
+ private _syncStructure;
143
+ /**
144
+ * Move an item without dragging — for "Move to…" menus and other
145
+ * single-pointer alternatives. Fires the same `ty-sortable-change` (with
146
+ * `source: 'api'`) and holds the result until the app renders it.
147
+ */
148
+ move(itemOrKey: HTMLElement | string, opts?: {
149
+ to?: TySortable | string;
150
+ index?: number;
151
+ before?: string;
152
+ after?: string;
153
+ }): Promise<TySortableOutcome>;
154
+ /** End a pending hold: 'accepted' or 'rejected', or re-check the DOM. */
155
+ settle(outcome?: 'accepted' | 'rejected'): void;
156
+ /** @internal */
157
+ _announce(name: keyof TySortableStrings, vars?: Record<string, string | number>): void;
158
+ /** @internal The item an event happened in: a direct child that is an item. */
159
+ _itemFrom(e: Event): HTMLElement | null;
160
+ /** The grip an event started on, or null when it isn't one. */
161
+ private _gripFrom;
162
+ private _onPointerDown;
163
+ private _onPressMove;
164
+ private _onPressEnd;
165
+ private _endPress;
166
+ private _activate;
167
+ private _onKeyDown;
168
+ private _onKeyUp;
169
+ /**
170
+ * Screen readers in browse mode send a click, not keys: a keyboard-made
171
+ * click (detail 0) on a handle picks up or drops.
172
+ */
173
+ private _onClick;
174
+ private _onFocusOut;
175
+ }