@giddaa-housing/ui 3.5.0 → 3.7.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/css/components.css +13 -0
- package/css/generated/shared.css +1 -1
- package/css/theme.css +11 -8
- package/dist/badge.d.ts +5 -1
- package/dist/badge.js +19 -5
- package/dist/bar-chart.d.ts +1 -1
- package/dist/bullet-chart.d.ts +1 -1
- package/dist/button-BS5KCibF.d.ts +33 -0
- package/dist/button-group.d.ts +1 -1
- package/dist/button.d.ts +1 -1
- package/dist/button.js +49 -21
- package/dist/calendar.js +1 -1
- package/dist/carousel.d.ts +4 -2
- package/dist/carousel.js +11 -14
- package/dist/chart.d.ts +1 -1
- package/dist/chat.d.ts +1 -1
- package/dist/checkbox.d.ts +2 -2
- package/dist/checkbox.js +20 -6
- package/dist/{combobox-B7cKFJ9V.js → combobox-D70DFHoM.js} +55 -10
- package/dist/combobox.d.ts +8 -3
- package/dist/combobox.js +2 -2
- package/dist/cta.d.ts +1 -1
- package/dist/data-table.d.ts +2 -2
- package/dist/date-picker.d.ts +3 -3
- package/dist/date-picker.js +1 -1
- package/dist/dialog.d.ts +6 -2
- package/dist/dialog.js +15 -12
- package/dist/dropdown-menu.d.ts +1 -1
- package/dist/field.d.ts +4 -1
- package/dist/field.js +28 -11
- package/dist/footer.d.ts +2 -2
- package/dist/funnel-chart.d.ts +1 -1
- package/dist/heatmap-chart.d.ts +1 -1
- package/dist/infotip.js +0 -1
- package/dist/input-group.d.ts +6 -6
- package/dist/input-group.js +43 -18
- package/dist/input-otp.d.ts +2 -2
- package/dist/input-otp.js +31 -14
- package/dist/input-size-context-BMhves-J.d.ts +13 -0
- package/dist/input-size-context.d.ts +2 -2
- package/dist/input-size-context.js +9 -2
- package/dist/input.d.ts +20 -2
- package/dist/input.js +30 -11
- package/dist/line-chart.d.ts +1 -1
- package/dist/mask-input.d.ts +1 -1
- package/dist/match.d.ts +14 -2
- package/dist/match.js +221 -48
- package/dist/media-gallery-hero.js +9 -7
- package/dist/media-player.js +3 -3
- package/dist/mobile-sidebar.js +7 -6
- package/dist/number-input.d.ts +2 -2
- package/dist/number-input.js +2 -2
- package/dist/pagination.d.ts +1 -1
- package/dist/phone-input.d.ts +20 -3
- package/dist/phone-input.js +137 -67
- package/dist/picker-BTXBrsl4.js +62 -0
- package/dist/{picker-CsnHtbe4.d.ts → picker-j3txxA5t.d.ts} +2 -2
- package/dist/pie-chart.d.ts +1 -1
- package/dist/{popover-DSlPeH7x.d.ts → popover-CNymD33m.d.ts} +1 -1
- package/dist/popover.d.ts +1 -1
- package/dist/property-listing-card.d.ts +7 -3
- package/dist/property-listing-card.js +25 -8
- package/dist/radar-chart.d.ts +1 -1
- package/dist/radio-group.d.ts +2 -2
- package/dist/radio-group.js +23 -9
- package/dist/rating.d.ts +60 -0
- package/dist/rating.js +187 -0
- package/dist/rich-text-editor.d.ts +1 -1
- package/dist/scatter-chart.d.ts +1 -1
- package/dist/scroll-spy.d.ts +8 -2
- package/dist/scroll-spy.js +13 -13
- package/dist/section-jumper.d.ts +31 -0
- package/dist/section-jumper.js +276 -0
- package/dist/select.d.ts +9 -4
- package/dist/select.js +148 -20
- package/dist/sheet.d.ts +5 -1
- package/dist/sheet.js +15 -12
- package/dist/sidebar.d.ts +2 -2
- package/dist/sidebar.js +1 -0
- package/dist/size-context-BVhHduLi.d.ts +33 -0
- package/dist/size-context.d.ts +2 -2
- package/dist/size-context.js +30 -1
- package/dist/slider.d.ts +5 -3
- package/dist/slider.js +25 -10
- package/dist/sonar.d.ts +4 -2
- package/dist/sonar.js +116 -28
- package/dist/sparkline.d.ts +1 -1
- package/dist/styles.css +1674 -252
- package/dist/switch.d.ts +2 -2
- package/dist/switch.js +20 -6
- package/dist/tabs.d.ts +1 -1
- package/dist/tag.d.ts +1 -1
- package/dist/textarea.d.ts +17 -1
- package/dist/textarea.js +23 -9
- package/dist/time-picker.d.ts +3 -3
- package/dist/time-picker.js +1 -1
- package/dist/tree-map.d.ts +1 -1
- package/dist/video-player-dialog.js +4 -3
- package/dist/waterfall-chart.d.ts +1 -1
- package/package.json +9 -1
- package/dist/button-DW5OijoR.d.ts +0 -17
- package/dist/dialog-nesting.d.ts +0 -9
- package/dist/dialog-nesting.js +0 -27
- package/dist/input-CfoEJ8A6.d.ts +0 -12
- package/dist/input-size-context-C-SFx9sx.d.ts +0 -10
- package/dist/picker-DmIiQKLJ.js +0 -45
- package/dist/size-context-BX6kAdVj.d.ts +0 -11
- package/dist/textarea-IS_D8pXf.d.ts +0 -11
package/dist/sonar.js
CHANGED
|
@@ -18,13 +18,56 @@ const SQUARE = {
|
|
|
18
18
|
borderBottomLeftRadius: "0px"
|
|
19
19
|
};
|
|
20
20
|
function sameCorners(a, b) {
|
|
21
|
-
|
|
21
|
+
if (a === null || b === null) return a === b;
|
|
22
|
+
return a.borderTopLeftRadius === b.borderTopLeftRadius && a.borderTopRightRadius === b.borderTopRightRadius && a.borderBottomRightRadius === b.borderBottomRightRadius && a.borderBottomLeftRadius === b.borderBottomLeftRadius;
|
|
23
|
+
}
|
|
24
|
+
function sameMetrics(a, b) {
|
|
25
|
+
return a !== null && a.scaleX === b.scaleX && a.scaleY === b.scaleY && sameCorners(a.corners, b.corners);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The ring is painted at its full travel and scaled *back*, so this is where it
|
|
29
|
+
* starts: small enough that its outer edge lands exactly on the child's own,
|
|
30
|
+
* with nothing showing yet. Growing from there to scale 1 moves that edge out
|
|
31
|
+
* by `spread` — the same distance the old spread animation moved it.
|
|
32
|
+
*
|
|
33
|
+
* Worked out per axis on purpose: one factor for both would move a 200x40
|
|
34
|
+
* button's ring five times further sideways than vertically, and equal travel
|
|
35
|
+
* on every side is the whole look.
|
|
36
|
+
*/
|
|
37
|
+
function startScale(extent, spread) {
|
|
38
|
+
if (extent <= 0) return 1;
|
|
39
|
+
return Math.round(extent / (extent + 2 * spread) * 1e3) / 1e3;
|
|
40
|
+
}
|
|
41
|
+
function readCorners(target) {
|
|
42
|
+
if (!target) return SQUARE;
|
|
43
|
+
const computed = getComputedStyle(target);
|
|
44
|
+
return {
|
|
45
|
+
borderTopLeftRadius: computed.borderTopLeftRadius,
|
|
46
|
+
borderTopRightRadius: computed.borderTopRightRadius,
|
|
47
|
+
borderBottomRightRadius: computed.borderBottomRightRadius,
|
|
48
|
+
borderBottomLeftRadius: computed.borderBottomLeftRadius
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* `--sonar-spread` is authored in rem, and `getComputedStyle` hands custom
|
|
53
|
+
* properties back as written rather than resolved to pixels, so this does the
|
|
54
|
+
* one conversion the token is ever written to need. Reading it from the DOM
|
|
55
|
+
* rather than the map below keeps a `[--sonar-spread:…]` override on the
|
|
56
|
+
* wrapper driving the travel as well as the ring.
|
|
57
|
+
*/
|
|
58
|
+
function spreadInPixels(host) {
|
|
59
|
+
const raw = getComputedStyle(host).getPropertyValue("--sonar-spread").trim();
|
|
60
|
+
const value = Number.parseFloat(raw);
|
|
61
|
+
if (!Number.isFinite(value)) return 10;
|
|
62
|
+
if (!raw.endsWith("rem")) return value;
|
|
63
|
+
const root = Number.parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
64
|
+
return value * (Number.isFinite(root) ? root : 16);
|
|
22
65
|
}
|
|
23
66
|
/**
|
|
24
67
|
* Colour rides on `currentColor` so the keyframe stays tone-agnostic: one set
|
|
25
68
|
* of keyframes, one class per tone.
|
|
26
69
|
*/
|
|
27
|
-
const sonarWaveVariants = cva(cn("pointer-events-none absolute inset-0 animate-sonar-wave", "motion-reduce:animate-none motion-reduce:opacity-40 motion-reduce:shadow-[0_0_0_2px_currentColor]"), {
|
|
70
|
+
const sonarWaveVariants = cva(cn("pointer-events-none absolute inset-0 animate-sonar-wave opacity-0 shadow-[0_0_0_var(--sonar-spread,0.625rem)_currentColor] will-change-[transform,opacity] [backface-visibility:hidden]", "motion-reduce:animate-none motion-reduce:opacity-40 motion-reduce:shadow-[0_0_0_2px_currentColor]"), {
|
|
28
71
|
variants: { tone: {
|
|
29
72
|
brand: "text-fg-brand",
|
|
30
73
|
info: "text-status-info",
|
|
@@ -35,9 +78,46 @@ const sonarWaveVariants = cva(cn("pointer-events-none absolute inset-0 animate-s
|
|
|
35
78
|
defaultVariants: { tone: "brand" }
|
|
36
79
|
});
|
|
37
80
|
/**
|
|
81
|
+
* The cut-out the rings are painted through: everything from the child's own
|
|
82
|
+
* edge out to one `--sonar-spread`, and nothing inside it.
|
|
83
|
+
*
|
|
84
|
+
* A ring is painted at full spread and scaled back to start, which means that
|
|
85
|
+
* early in its travel it lies *within* the child rather than around it. Behind
|
|
86
|
+
* a child with a background of its own that goes unseen, but through an outline
|
|
87
|
+
* button it is a band sweeping across the middle. The child's shape is punched
|
|
88
|
+
* out of the rings here instead, so what shows is only ever the halo.
|
|
89
|
+
*
|
|
90
|
+
* A transparent border, rather than padding, because it is the padding box that
|
|
91
|
+
* absolutely positioned rings are laid out against: this way the border box is
|
|
92
|
+
* the far edge of the travel, the padding box is the child, and each ring can
|
|
93
|
+
* go on being `inset-0`. CSS shrinks the corner radii between the two boxes by
|
|
94
|
+
* the border width on its own, so the hole traces the child's corners exactly.
|
|
95
|
+
*/
|
|
96
|
+
const sonarRingsClass = cn("pointer-events-none absolute -z-10 [inset:calc(var(--sonar-spread,0.625rem)*-1)] [border:var(--sonar-spread,0.625rem)_solid_transparent]", "[mask-image:linear-gradient(#000,#000),linear-gradient(#000,#000)] [mask-clip:border-box,padding-box] [mask-composite:exclude]");
|
|
97
|
+
/**
|
|
98
|
+
* The child's corner, grown by one spread, for the box the cut-out is measured
|
|
99
|
+
* off. Written per token because a computed radius can be elliptical ("8px
|
|
100
|
+
* 4px") or, from the `radius` prop, a whole shorthand — each length grows, and
|
|
101
|
+
* the "/" between horizontal and vertical radii is passed through untouched.
|
|
102
|
+
*/
|
|
103
|
+
function growRadius(value) {
|
|
104
|
+
return value.trim().split(/\s+/).map((token) => token === "/" ? token : `calc(${token} + var(--sonar-spread, 0.625rem))`).join(" ");
|
|
105
|
+
}
|
|
106
|
+
/** The same shape as the rings, one spread wider on every side. */
|
|
107
|
+
function grownShape(shape) {
|
|
108
|
+
return Object.fromEntries(Object.entries(shape).map(([property, value]) => [property, growRadius(String(value))]));
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
38
111
|
* Rings evenly spaced across one cycle, so the last finishes just as the first
|
|
39
112
|
* comes round again. Doubles as each ring's key — the offsets are distinct by
|
|
40
113
|
* construction, which an index would only pretend to be.
|
|
114
|
+
*
|
|
115
|
+
* Applied as *negative* delays, which start every ring on the first frame at a
|
|
116
|
+
* different point in the cycle rather than holding it still until its turn
|
|
117
|
+
* comes round. A ring waiting out a positive delay shows the style it is
|
|
118
|
+
* animating from — here a finished, full-spread, fully opaque ring — so the
|
|
119
|
+
* sonar would open on a solid halo and snap into motion three quarters of a
|
|
120
|
+
* second later.
|
|
41
121
|
*/
|
|
42
122
|
function waveDelays(waves) {
|
|
43
123
|
return Array.from({ length: waves }, (_, index) => Math.round(index * SONAR_DURATION_MS / waves));
|
|
@@ -63,54 +143,62 @@ const sonarSpread = {
|
|
|
63
143
|
* child.
|
|
64
144
|
*
|
|
65
145
|
* The rings are painted with `box-shadow` spread, which lives outside the
|
|
66
|
-
* element's box, so an ancestor with `overflow: hidden` will clip them.
|
|
146
|
+
* element's box, so an ancestor with `overflow: hidden` will clip them. They
|
|
147
|
+
* sit behind the child with its shape punched out of them, so nothing paints
|
|
148
|
+
* inside it whatever background — or none — the child has of its own.
|
|
67
149
|
*/
|
|
68
150
|
function Sonar({ className, children, active = true, waves = 2, size, tone, radius, style, ...props }) {
|
|
69
151
|
const resolvedSize = useComponentSize(size);
|
|
70
152
|
const ref = React.useRef(null);
|
|
71
|
-
const [
|
|
153
|
+
const [metrics, setMetrics] = React.useState(null);
|
|
72
154
|
React.useEffect(() => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
setCorners(SQUARE);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
155
|
+
const host = ref.current;
|
|
156
|
+
if (!host || !active) return;
|
|
157
|
+
const target = radius === void 0 ? host.querySelector(":scope > :not([data-slot=\"sonar-rings\"])") : null;
|
|
79
158
|
const measure = () => {
|
|
80
|
-
const
|
|
159
|
+
const box = host.getBoundingClientRect();
|
|
160
|
+
const spread = spreadInPixels(host);
|
|
81
161
|
const next = {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
borderBottomLeftRadius: computed.borderBottomLeftRadius
|
|
162
|
+
corners: radius !== void 0 ? null : readCorners(target),
|
|
163
|
+
scaleX: startScale(box.width, spread),
|
|
164
|
+
scaleY: startScale(box.height, spread)
|
|
86
165
|
};
|
|
87
|
-
|
|
166
|
+
setMetrics((current) => sameMetrics(current, next) ? current : next);
|
|
88
167
|
};
|
|
89
168
|
measure();
|
|
90
169
|
if (typeof ResizeObserver === "undefined") return;
|
|
91
170
|
const observer = new ResizeObserver(measure);
|
|
92
|
-
observer.observe(
|
|
171
|
+
observer.observe(host);
|
|
93
172
|
return () => observer.disconnect();
|
|
94
173
|
}, [active, radius]);
|
|
95
|
-
const shape = radius !== void 0 ? { borderRadius: radius } : corners;
|
|
174
|
+
const shape = radius !== void 0 ? { borderRadius: radius } : metrics?.corners ?? null;
|
|
96
175
|
return /* @__PURE__ */ jsxs("span", {
|
|
97
176
|
ref,
|
|
98
177
|
"data-slot": "sonar",
|
|
99
178
|
"data-tone": tone ?? "brand",
|
|
100
179
|
"data-size": resolvedSize,
|
|
101
180
|
"data-active": active ? "" : void 0,
|
|
102
|
-
className: cn("relative inline-flex w-fit shrink-0", sonarSpread[resolvedSize], className),
|
|
103
|
-
style
|
|
181
|
+
className: cn("relative isolate inline-flex w-fit shrink-0", sonarSpread[resolvedSize], className),
|
|
182
|
+
style: metrics ? {
|
|
183
|
+
"--sonar-scale-x": metrics.scaleX,
|
|
184
|
+
"--sonar-scale-y": metrics.scaleY,
|
|
185
|
+
...style
|
|
186
|
+
} : style,
|
|
104
187
|
...props,
|
|
105
|
-
children: [children, active && shape ?
|
|
188
|
+
children: [children, active && shape ? /* @__PURE__ */ jsx("span", {
|
|
106
189
|
"aria-hidden": "true",
|
|
107
|
-
"data-slot": "sonar-
|
|
108
|
-
style:
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
190
|
+
"data-slot": "sonar-rings",
|
|
191
|
+
style: grownShape(shape),
|
|
192
|
+
className: sonarRingsClass,
|
|
193
|
+
children: waveDelays(waves).map((delay) => /* @__PURE__ */ jsx("span", {
|
|
194
|
+
"data-slot": "sonar-wave",
|
|
195
|
+
style: {
|
|
196
|
+
...shape,
|
|
197
|
+
animationDelay: delay === 0 ? void 0 : `-${delay}ms`
|
|
198
|
+
},
|
|
199
|
+
className: cn(sonarWaveVariants({ tone }), delay > 0 && "motion-reduce:hidden")
|
|
200
|
+
}, `sonar-wave-${delay}`))
|
|
201
|
+
}) : null]
|
|
114
202
|
});
|
|
115
203
|
}
|
|
116
204
|
//#endregion
|
package/dist/sparkline.d.ts
CHANGED