@rettangoli/ui 1.0.23 → 1.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rettangoli/ui",
3
- "version": "1.0.23",
3
+ "version": "1.1.0",
4
4
  "description": "A UI component library for building web interfaces.",
5
5
  "main": "dist/rettangoli-esm.min.js",
6
6
  "type": "module",
@@ -15,7 +15,7 @@ styles:
15
15
  color: inherit
16
16
  template:
17
17
  - rtgl-popover#popover ?open=${open} x=${x} y=${y} place=${place}:
18
- - rtgl-view w=${w} h=${h} sv g=xs slot=content bgc=mu br=md:
18
+ - rtgl-view w=${w} h=${h} sv g=xs slot=content bgc=bg pv=sm:
19
19
  - $for item, i in items:
20
20
  - $if item.isLabel:
21
21
  - rtgl-view w=f ph=lg pv=md:
@@ -21,7 +21,7 @@ template:
21
21
  - rtgl-view#textDisplay w=f cur=pointer:
22
22
  - rtgl-text c=${valueColor}: ${value}
23
23
  - rtgl-popover#popover ?open=${isOpen} x=${position.x} y=${position.y}:
24
- - rtgl-view g=md w=240 slot=content bgc=mu br=md:
24
+ - rtgl-view g=md w=240 slot=content bgc=bg br=md:
25
25
  - rtgl-text: ${label}
26
26
  - rtgl-input#input w=f placeholder=${placeholder} ?disabled=${disabled}: null
27
27
  - rtgl-view w=f ah=e:
@@ -41,10 +41,7 @@ export const handleButtonClick = (deps, payload) => {
41
41
  event.stopPropagation();
42
42
 
43
43
  const button = refs.selectButton;
44
-
45
- // Get first child's bounding rectangle (since button has display: contents)
46
- const firstChild = button.firstElementChild;
47
- const rect = firstChild ? firstChild.getBoundingClientRect() : button.getBoundingClientRect();
44
+ const rect = button.getBoundingClientRect();
48
45
 
49
46
  // Find the index of the currently selected option
50
47
  const storeSelectedValue = store.selectSelectedValue();
@@ -65,6 +62,16 @@ export const handleButtonClick = (deps, payload) => {
65
62
  render();
66
63
  }
67
64
 
65
+ export const handleButtonKeyDown = (deps, payload) => {
66
+ const event = payload._event;
67
+ if (event.key !== "Enter" && event.key !== " ") {
68
+ return;
69
+ }
70
+
71
+ event.preventDefault();
72
+ handleButtonClick(deps, payload);
73
+ }
74
+
68
75
  export const handleClickOptionsPopoverOverlay = (deps) => {
69
76
  const { store, render } = deps;
70
77
  store.closeOptionsPopover({});
@@ -75,6 +75,9 @@ export const selectViewData = ({ state, props }) => {
75
75
  selectedValue: currentValue,
76
76
  selectedLabel: displayLabel,
77
77
  selectedLabelColor: isPlaceholderLabel ? "mu-fg" : "fg",
78
+ selectButtonCursor: isDisabled ? "not-allowed" : "pointer",
79
+ selectButtonHoverBorderColor: isDisabled ? "bo" : "ac",
80
+ selectButtonTabIndex: isDisabled ? -1 : 0,
78
81
  hasValue: currentValue !== null && currentValue !== undefined,
79
82
  showClear: !isDisabled && !props.noClear && (currentValue !== null && currentValue !== undefined),
80
83
  showAddOption: !isDisabled && !!props.addOption,
@@ -3,6 +3,8 @@ refs:
3
3
  eventListeners:
4
4
  click:
5
5
  handler: handleButtonClick
6
+ keydown:
7
+ handler: handleButtonKeyDown
6
8
  clearButton:
7
9
  eventListeners:
8
10
  click:
@@ -28,14 +30,14 @@ refs:
28
30
  mouseleave:
29
31
  handler: handleAddOptionMouseLeave
30
32
  template:
31
- - rtgl-button#selectButton v=ol ${containerAttrString} ?disabled=${isDisabled} data-testid="select-button":
33
+ - 'rtgl-view#selectButton style="display: inline-flex;" d=h av=c h=32 ph=md bw=xs bc=bo h-bc=${selectButtonHoverBorderColor} br=md bgc=bg cur=${selectButtonCursor} ${containerAttrString} data-testid="select-button" role="button" tabindex=${selectButtonTabIndex} aria-disabled=${isDisabled}':
32
34
  - rtgl-view d=h av=c ah=s w=f:
33
35
  - rtgl-text w=1fg ta=s c=${selectedLabelColor} ellipsis: ${selectedLabel}
34
36
  - $if showClear:
35
37
  - rtgl-svg#clearButton ml=md svg=x wh=16 c=mu-fg cur=pointer data-testid="select-clear-button": null
36
38
  - rtgl-svg ml=md svg=chevronDown wh=16 c=mu-fg: null
37
- - 'rtgl-popover#popover ?open=${isOpen} x=${position.x} y=${position.y} place=rs style="--rtgl-popover-content-padding: var(--spacing-sm) 0"':
38
- - rtgl-view wh=300 g=xs slot=content bgc=mu sv=true:
39
+ - rtgl-popover#popover ?open=${isOpen} x=${position.x} y=${position.y} place=rs:
40
+ - rtgl-view wh=300 g=xs slot=content bgc=bg sv=true pv=sm:
39
41
  - $for option, i in options:
40
42
  - rtgl-view#option${i} w=f ph=lg pv=md cur=pointer bgc=${option.bgc} data-testid=${option.testId}:
41
43
  - rtgl-text s=sm: ${option.label}
@@ -35,6 +35,6 @@ export const selectViewData = ({ props }) => {
35
35
  textSize: preset.textSize,
36
36
  paddingX: preset.paddingX,
37
37
  paddingY: preset.paddingY,
38
- popoverStyle: `--rtgl-popover-content-padding: 0; --rtgl-popover-content-min-width: 0; --rtgl-popover-content-max-width: ${preset.maxWidth}`,
38
+ contentStyle: `padding: 0; min-width: 0; max-width: ${preset.maxWidth};`,
39
39
  };
40
40
  }
@@ -1,5 +1,6 @@
1
1
  template:
2
- - 'rtgl-popover#popover ?open=${open} x=${x} y=${y} place=${place} no-overlay style="${popoverStyle}"':
3
- - rtgl-view slot=content bc=bo br=md ph=${paddingX} pv=${paddingY} ah=s av=c:
4
- - rtgl-text ta=s s=${textSize} c=fg: ${content}
2
+ - rtgl-popover#popover ?open=${open} x=${x} y=${y} place=${place} no-overlay:
3
+ - 'rtgl-view slot=content style="${contentStyle}"':
4
+ - rtgl-view ph=${paddingX} pv=${paddingY} ah=s av=c:
5
+ - rtgl-text ta=s s=${textSize} c=fg: ${content}
5
6
  refs: {}
@@ -148,6 +148,10 @@ class RettangoliButtonElement extends HTMLElement {
148
148
  background-color: var(--accent);
149
149
  }
150
150
 
151
+ :host([v="ol"]) .surface:active {
152
+ background-color: var(--accent);
153
+ }
154
+
151
155
  :host([v="gh"]) .surface:hover {
152
156
  background-color: var(--accent);
153
157
  }
@@ -229,7 +229,10 @@ class RettangoliDialogElement extends HTMLElement {
229
229
 
230
230
  window.addEventListener("resize", this._onWindowResize);
231
231
  this._observeAssignedContent();
232
- this._scheduleAdaptiveCentering({ resetRetries: true });
232
+ this._layoutRetryCount = 0;
233
+ // Apply the first centering pass before paint so the enter animation
234
+ // starts from the final position instead of jumping after mount.
235
+ this._applyAdaptiveCentering();
233
236
  }
234
237
  }
235
238
 
@@ -53,13 +53,18 @@ class RettangoliPopoverElement extends HTMLElement {
53
53
  }
54
54
 
55
55
  slot[name="content"] {
56
+ display: contents;
57
+ }
58
+
59
+ ::slotted([slot="content"]) {
56
60
  display: block;
57
- background-color: var(--muted);
61
+ box-sizing: border-box;
62
+ background-color: var(--background);
58
63
  border: 1px solid var(--border);
59
- border-radius: var(--rtgl-popover-content-border-radius, var(--border-radius-md));
60
- padding: var(--rtgl-popover-content-padding, var(--spacing-md));
61
- min-width: var(--rtgl-popover-content-min-width, 200px);
62
- max-width: var(--rtgl-popover-content-max-width, 400px);
64
+ border-radius: var(--border-radius-md);
65
+ padding: var(--spacing-md);
66
+ min-width: 200px;
67
+ max-width: 400px;
63
68
  }
64
69
  `);
65
70
  }