elements-kit 0.27.12 → 0.27.14

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.
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  //#region \0rolldown/runtime.js
2
3
  var __defProp = Object.defineProperty;
3
4
  var __exportAll = (all, no_symbols) => {
@@ -7,6 +7,7 @@ interface AstroRendererConfig {
7
7
  interface AstroConfigSetupApi {
8
8
  addRenderer(renderer: AstroRendererConfig): void;
9
9
  updateConfig(config: Record<string, unknown>): unknown;
10
+ config?: unknown;
10
11
  }
11
12
  interface ElementsKitAstroIntegration {
12
13
  name: string;
@@ -1,6 +1,32 @@
1
1
  import elementsKitHmr from "./vite.mjs";
2
+ import { createRequire } from "node:module";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
2
5
  //#region src/integrations/astro.ts
3
6
  /**
7
+ * The JSX transform config, under the key the installed Vite actually reads.
8
+ *
9
+ * Vite 8 (and rolldown-vite) transform with Oxc: `esbuild` options are ignored
10
+ * there, and setting both keys warns. Older Vite only understands `esbuild`.
11
+ * Vite is resolved from the project root — under isolated installs it is not
12
+ * reachable from this package's own directory.
13
+ */
14
+ function jsxTransformConfig(root) {
15
+ const from = root instanceof URL ? fileURLToPath(root) : typeof root === "string" ? root : process.cwd();
16
+ let oxc = false;
17
+ try {
18
+ const vite = createRequire(path.join(from, "noop.js"))("vite/package.json");
19
+ oxc = vite.name === "rolldown-vite" || Number.parseInt(vite.version ?? "", 10) >= 8;
20
+ } catch {}
21
+ return oxc ? { oxc: { jsx: {
22
+ runtime: "automatic",
23
+ importSource: "elements-kit"
24
+ } } } : { esbuild: {
25
+ jsx: "automatic",
26
+ jsxImportSource: "elements-kit"
27
+ } };
28
+ }
29
+ /**
4
30
  * Astro integration: use elements-kit components as Astro islands.
5
31
  *
6
32
  * Registers the elements-kit renderer pair — server rendering via
@@ -35,17 +61,14 @@ import elementsKitHmr from "./vite.mjs";
35
61
  function elementsKit() {
36
62
  return {
37
63
  name: "elements-kit",
38
- hooks: { "astro:config:setup": ({ addRenderer, updateConfig }) => {
64
+ hooks: { "astro:config:setup": ({ addRenderer, updateConfig, config }) => {
39
65
  addRenderer({
40
66
  name: "elements-kit",
41
67
  clientEntrypoint: "elements-kit/integrations/astro-client",
42
68
  serverEntrypoint: "elements-kit/integrations/astro-server"
43
69
  });
44
70
  updateConfig({ vite: {
45
- esbuild: {
46
- jsx: "automatic",
47
- jsxImportSource: "elements-kit"
48
- },
71
+ ...jsxTransformConfig(config?.root),
49
72
  optimizeDeps: { include: [
50
73
  "elements-kit",
51
74
  "elements-kit/jsx-runtime",
@@ -200,16 +200,18 @@ type PositionAreaValue = AreaKeyword | Unordered<BlockKeyword, InlineKeyword> |
200
200
  * anchor's near edge, spans its far edge, center is `anchor-center`. Not a
201
201
  * box: a pin per axis, with no geometry of its own.
202
202
  *
203
- * Parsed once, at construction; the pins read the anchor on every access, so
204
- * reading them in an `effect` tracks it.
203
+ * The area is assignable reassigning re-aims the region in place, so a menu
204
+ * can flip side without a new one. Parsed on assignment; the pins read the
205
+ * anchor on every access, so an `effect` tracks both.
205
206
  *
206
207
  * No gap parameter, for the same reason CSS has none: the offset off the
207
208
  * anchor is the overlay's own `margin`.
208
209
  */
209
210
  declare class PositionArea implements Region {
210
211
  #private;
211
- readonly anchor: ReadonlyBox;
212
- constructor(anchor: ReadonlyBox, area: PositionAreaValue);
212
+ area: PositionAreaValue;
213
+ anchor: ReadonlyBox & Partial<IDirection>;
214
+ constructor(anchor: ReadonlyBox & Partial<IDirection>, area: PositionAreaValue);
213
215
  /** The pin lines — the viewport point {@link origin} lands on. */
214
216
  get x(): number;
215
217
  get y(): number;
@@ -1,5 +1,5 @@
1
- import { t as __exportAll } from "../../chunk-CfYAbeIz.mjs";
2
- import { c as batch, u as effect, x as signal } from "../../lib-Dw0g-vex.mjs";
1
+ import { t as __exportAll } from "../../chunk-BpYLSNr0.mjs";
2
+ import { c as batch, l as computed, u as effect, x as signal } from "../../lib-Dw0g-vex.mjs";
3
3
  import { reactive, resolve } from "../../signals/index.mjs";
4
4
  import { t as scope } from "../../scope-B1kDu4YX.mjs";
5
5
  import { direction } from "../../utilities/direction.mjs";
@@ -104,11 +104,90 @@ var MutableRegion = class {
104
104
  };
105
105
  //#endregion
106
106
  //#region src/ui/overlay/anchor.ts
107
- /**
108
- * The reactive `anchor()` function: the viewport coordinate of an anchor line
109
- * on `box`, in the context of the inset property being computed. Reads the
110
- * box's reactive geometry, so calling it inside an `effect` tracks the anchor.
111
- */
107
+ var __create$2 = Object.create;
108
+ var __defProp$2 = Object.defineProperty;
109
+ var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
110
+ var __knownSymbol$2 = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
111
+ var __typeError$2 = (msg) => {
112
+ throw TypeError(msg);
113
+ };
114
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, {
115
+ enumerable: true,
116
+ configurable: true,
117
+ writable: true,
118
+ value
119
+ }) : obj[key] = value;
120
+ var __name$2 = (target, value) => __defProp$2(target, "name", {
121
+ value,
122
+ configurable: true
123
+ });
124
+ var __decoratorStart$2 = (base) => [
125
+ ,
126
+ ,
127
+ ,
128
+ __create$2(base?.[__knownSymbol$2("metadata")] ?? null)
129
+ ];
130
+ var __decoratorStrings$2 = [
131
+ "class",
132
+ "method",
133
+ "getter",
134
+ "setter",
135
+ "accessor",
136
+ "field",
137
+ "value",
138
+ "get",
139
+ "set"
140
+ ];
141
+ var __expectFn$2 = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError$2("Function expected") : fn;
142
+ var __decoratorContext$2 = (kind, name, done, metadata, fns) => ({
143
+ kind: __decoratorStrings$2[kind],
144
+ name,
145
+ metadata,
146
+ addInitializer: (fn) => done._ ? __typeError$2("Already initialized") : fns.push(__expectFn$2(fn || null))
147
+ });
148
+ var __decoratorMetadata$2 = (array, target) => __defNormalProp$2(target, __knownSymbol$2("metadata"), array[3]);
149
+ var __runInitializers$2 = (array, flags, self, value) => {
150
+ for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
151
+ return value;
152
+ };
153
+ var __decorateElement$2 = (array, flags, name, decorators, target, extra) => {
154
+ var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
155
+ var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings$2[k + 5];
156
+ var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
157
+ var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc$2(k < 4 ? target : {
158
+ get [name]() {
159
+ return __privateGet$2(this, extra);
160
+ },
161
+ set [name](x) {
162
+ return __privateSet$2(this, extra, x);
163
+ }
164
+ }, name));
165
+ k ? p && k < 4 && __name$2(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name$2(target, name);
166
+ for (var i = decorators.length - 1; i >= 0; i--) {
167
+ ctx = __decoratorContext$2(k, name, done = {}, array[3], extraInitializers);
168
+ if (k) {
169
+ ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn$2(target, x) : (x) => name in x };
170
+ if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet$2 : __privateMethod$2)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
171
+ if (k > 2) access.set = p ? (x, y) => __privateSet$2(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
172
+ }
173
+ it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : {
174
+ get: desc.get,
175
+ set: desc.set
176
+ } : target, ctx), done._ = 1;
177
+ if (k ^ 4 || it === void 0) __expectFn$2(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
178
+ else if (typeof it !== "object" || it === null) __typeError$2("Object expected");
179
+ else __expectFn$2(fn = it.get) && (desc.get = fn), __expectFn$2(fn = it.set) && (desc.set = fn), __expectFn$2(fn = it.init) && initializers.unshift(fn);
180
+ }
181
+ return k || __decoratorMetadata$2(array, target), desc && __defProp$2(target, name, desc), p ? k ^ 4 ? extra : desc : target;
182
+ };
183
+ var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
184
+ var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
185
+ var __privateIn$2 = (member, obj) => Object(obj) !== obj ? __typeError$2("Cannot use the \"in\" operator on this value") : member.has(obj);
186
+ var __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
187
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError$2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
188
+ var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
189
+ var __privateMethod$2 = (obj, member, method) => (__accessCheck$2(obj, member, "access private method"), method);
190
+ var _anchor_dec, _area_dec, _init$2, _resolved, _PositionArea_instances, px_get, py_get;
112
191
  function anchor_length(box, inset, side) {
113
192
  const physical = resolveInset(inset);
114
193
  const block = physical === "top" || physical === "bottom";
@@ -116,7 +195,6 @@ function anchor_length(box, inset, side) {
116
195
  const size = block ? box.h : box.w;
117
196
  return lo + fraction(box, block, physical, side) * size;
118
197
  }
119
- /** A side, as a fraction of the axis measured from its top/left edge. */
120
198
  function fraction(box, block, inset, side) {
121
199
  switch (side) {
122
200
  case "top":
@@ -131,12 +209,9 @@ function fraction(box, block, inset, side) {
131
209
  const rtl = side === "self-start" || side === "self-end" ? (box.direction ?? rootDirection()) === "rtl" : rootDirection() === "rtl";
132
210
  return !block && rtl ? 1 - logical : logical;
133
211
  }
134
- /** The document root's direction — the fallback when a box has no own. */
135
212
  function rootDirection() {
136
213
  return getComputedStyle(document.documentElement).direction === "rtl" ? "rtl" : "ltr";
137
214
  }
138
- /** A logical inset longhand → its physical side, through the containing
139
- * block's direction (horizontal writing modes — only inline flips). */
140
215
  function resolveInset(inset) {
141
216
  switch (inset) {
142
217
  case "inset-block-start": return "top";
@@ -164,8 +239,6 @@ const A = (region, self = false) => ({
164
239
  physical: false,
165
240
  self
166
241
  });
167
- /** The full `position-area` keyword grammar → axis + physical region. The
168
- * key type forces this table and {@link PositionAreaValue} to stay in step. */
169
242
  const KEYWORDS = {
170
243
  top: B("start", true),
171
244
  bottom: B("end", true),
@@ -216,18 +289,11 @@ const SPAN_ALL = KEYWORDS["span-all"];
216
289
  function flipRegion(r) {
217
290
  return r === "start" ? "end" : r === "end" ? "start" : r === "span-start" ? "span-end" : r === "span-end" ? "span-start" : r;
218
291
  }
219
- /** Resolve a keyword to a physical region: block never flips; inline flips
220
- * in RTL unless the keyword is physical. */
221
292
  function toPhysical(kw, axis, dir, selfDir) {
222
293
  const r = kw.region;
223
294
  if (r === "center" || r === "span-all" || axis === "block" || kw.physical) return r;
224
295
  return (kw.self ? selfDir : dir) === "rtl" ? flipRegion(r) : r;
225
296
  }
226
- /**
227
- * Parse a `position-area` value into a physical {@link Area}. One or two
228
- * keywords, order-independent; an axis-specific single keyword spans the
229
- * other axis, an ambiguous one applies to both. Unknown/empty → `block-end`.
230
- */
231
297
  function resolveArea(area, dir = "ltr", selfDir = dir) {
232
298
  const tokens = area.trim().toLowerCase().split(/\s+/).filter(Boolean);
233
299
  const fallback = () => ({
@@ -263,59 +329,54 @@ function resolveArea(area, dir = "ltr", selfDir = dir) {
263
329
  inline: inline ? toPhysical(inline, "inline", dir, selfDir) : "center"
264
330
  };
265
331
  }
266
- /**
267
- * The reactive `position-area` property: which of the anchor's edges a box
268
- * pins to, and the self-alignment that follows — outward regions hug the
269
- * anchor's near edge, spans its far edge, center is `anchor-center`. Not a
270
- * box: a pin per axis, with no geometry of its own.
271
- *
272
- * Parsed once, at construction; the pins read the anchor on every access, so
273
- * reading them in an `effect` tracks it.
274
- *
275
- * No gap parameter, for the same reason CSS has none: the offset off the
276
- * anchor is the overlay's own `margin`.
277
- */
332
+ _area_dec = [reactive()], _anchor_dec = [reactive()];
278
333
  var PositionArea = class {
279
- anchor;
280
- #area;
281
334
  constructor(anchor, area) {
335
+ __privateAdd(this, _PositionArea_instances);
336
+ __publicField$2(this, "area", __runInitializers$2(_init$2, 8, this)), __runInitializers$2(_init$2, 11, this);
337
+ __publicField$2(this, "anchor", __runInitializers$2(_init$2, 12, this)), __runInitializers$2(_init$2, 15, this);
338
+ __privateAdd(this, _resolved);
282
339
  this.anchor = anchor;
283
- this.#area = resolveArea(area, rootDirection());
284
- }
285
- get #px() {
286
- const a = this.anchor;
287
- return pinOf(this.#area.inline, a.x, a.x + a.w);
288
- }
289
- get #py() {
290
- const a = this.anchor;
291
- return pinOf(this.#area.block, a.y, a.y + a.h);
340
+ this.area = area;
341
+ __privateSet$2(this, _resolved, computed(() => resolveArea(this.area, this.anchor.direction ?? rootDirection())));
292
342
  }
293
343
  /** The pin lines — the viewport point {@link origin} lands on. */
294
344
  get x() {
295
- return this.#px.at;
345
+ return __privateGet$2(this, _PositionArea_instances, px_get).at;
296
346
  }
297
347
  get y() {
298
- return this.#py.at;
348
+ return __privateGet$2(this, _PositionArea_instances, py_get).at;
299
349
  }
300
350
  /** The box point landing on ({@link x}, {@link y}). Two axes, not one
301
351
  * side: a corner area pins a corner. */
302
352
  get origin() {
303
353
  return {
304
- x: originX(this.#px),
305
- y: originY(this.#py)
354
+ x: originX(__privateGet$2(this, _PositionArea_instances, px_get)),
355
+ y: originY(__privateGet$2(this, _PositionArea_instances, py_get))
306
356
  };
307
357
  }
308
358
  /** Every axis is pinned, so only the box's size is read. */
309
359
  place(box) {
310
360
  return {
311
- x: placePinned(this.#px, box.w),
312
- y: placePinned(this.#py, box.h)
361
+ x: placePinned(__privateGet$2(this, _PositionArea_instances, px_get), box.w),
362
+ y: placePinned(__privateGet$2(this, _PositionArea_instances, py_get), box.h)
313
363
  };
314
364
  }
315
365
  };
316
- /** A region's default self-alignment as a pin on the anchor's `[lo, hi]` —
317
- * outward regions hug the anchor's near edge, spans its far edge; `center`
318
- * and `span-all` are `anchor-center`, which may overflow the rect. */
366
+ _init$2 = __decoratorStart$2(null);
367
+ _resolved = /* @__PURE__ */ new WeakMap();
368
+ _PositionArea_instances = /* @__PURE__ */ new WeakSet();
369
+ px_get = function() {
370
+ const a = this.anchor;
371
+ return pinOf(__privateGet$2(this, _resolved).call(this).inline, a.x, a.x + a.w);
372
+ };
373
+ py_get = function() {
374
+ const a = this.anchor;
375
+ return pinOf(__privateGet$2(this, _resolved).call(this).block, a.y, a.y + a.h);
376
+ };
377
+ __decorateElement$2(_init$2, 5, "area", _area_dec, PositionArea);
378
+ __decorateElement$2(_init$2, 5, "anchor", _anchor_dec, PositionArea);
379
+ __decoratorMetadata$2(_init$2, PositionArea);
319
380
  function pinOf(region, lo, hi) {
320
381
  switch (region) {
321
382
  case "start": return {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "elements-kit",
3
3
  "type": "module",
4
- "version": "0.27.12",
4
+ "version": "0.27.14",
5
5
  "description": "A lightweight reactive UI library that transforms native HTMLElements into reactive components with signals. Ideal for framework-agnostic applications and web components.",
6
6
  "keywords": [
7
7
  "webcomponents",