@ng-native/tailwind 0.8.0 → 0.10.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/flatten.cjs CHANGED
@@ -260,6 +260,12 @@ const RUNTIME_SUPPLIED =
260
260
  * per node: a transform, a shadow or a filter, or a part of a shadow slot, as `ring-blue-500` sets
261
261
  * the colour of `ring-2`'s. Anything else stays settled here.
262
262
  */
263
+ /** Whether a property of the rule with this selector has its `var()` resolved per node. */
264
+ function perNodeIn(selector) {
265
+ const framed = KEYFRAME.test(selector);
266
+ return (property) => framed || RESOLVED_PER_NODE.test(property) || SHADOW_SLOT.test(property);
267
+ }
268
+
263
269
  function crossRuleVariables(css) {
264
270
  const set = new Set();
265
271
  const setWithoutReading = new Set();
@@ -269,8 +275,9 @@ function crossRuleVariables(css) {
269
275
  if (selectorList(selector).some((one) => one.trim() === '*')) continue;
270
276
  const declared = new Set([...body.matchAll(/(--tw-[\w-]+)\s*:/g)].map((match) => match[1]));
271
277
  const read = new Set();
278
+ const settles = perNodeIn(selector);
272
279
  for (const [, property, value] of body.matchAll(/(-?-?[\w-]+)\s*:\s*([^;]+)/g)) {
273
- const perNode = RESOLVED_PER_NODE.test(property) || SHADOW_SLOT.test(property);
280
+ const perNode = settles(property);
274
281
  for (const [, name] of value.matchAll(/var\(\s*(--tw-[\w-]+)/g)) {
275
282
  if (perNode || REVERSE_SLOT.test(name)) read.add(name);
276
283
  }
@@ -310,8 +317,13 @@ function markUnitlessReverse(css) {
310
317
  }
311
318
 
312
319
  /** Properties whose `var()` the engine resolves per node, from the tokens in scope there. */
320
+ // An animation's times among them, and every property of a keyframe, which is settled against
321
+ // the element that plays it: `duration-300` times `animate-in`, and `fade-in-0` says where from.
313
322
  const RESOLVED_PER_NODE =
314
- /^(translate|scale|rotate|transform|box-shadow|text-shadow|filter|font-variant-numeric|touch-action)$/;
323
+ /^(translate|scale|rotate|transform|box-shadow|text-shadow|filter|font-variant-numeric|touch-action|animation)$/;
324
+
325
+ /** The selector of a keyframe: `from`, `to`, or the percentages it is at. */
326
+ const KEYFRAME = /^\s*(from|to|[\d.]+%)(\s*,\s*(from|to|[\d.]+%))*\s*$/;
315
327
 
316
328
  /**
317
329
  * A shadow slot, whose own parts another class may set: `ring-blue-500` its colour,
@@ -352,6 +364,9 @@ function substituteInRules(css, values, runtime) {
352
364
  });
353
365
  }
354
366
 
367
+ /** A value put in a token's place, apart from what is written straight after it: `var(--a)var(--b)` is two values. */
368
+ const apartFrom = (value, next) => (/[\w.#(%-]/.test(next ?? '') ? `${value} ` : value);
369
+
355
370
  function substituteVariables(css, values, runtime) {
356
371
  let out = css;
357
372
  for (let pass = 0; pass < 5; pass++) {
@@ -378,8 +393,9 @@ function substituteVariables(css, values, runtime) {
378
393
  from = found.end;
379
394
  continue;
380
395
  }
381
- out = out.slice(0, found.at) + value + out.slice(found.end);
382
- from = found.at + value.length;
396
+ const apart = apartFrom(value, out[found.end]);
397
+ out = out.slice(0, found.at) + apart + out.slice(found.end);
398
+ from = found.at + apart.length;
383
399
  changed = true;
384
400
  }
385
401
  if (!changed) break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-native/tailwind",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "Tailwind CSS preset for Angular Native: Tailwind 4 and Tailwind 3, on native and on the web.",
5
5
  "keywords": [
6
6
  "angular",
@@ -17,7 +17,7 @@
17
17
  "type": "commonjs",
18
18
  "main": "flatten.cjs",
19
19
  "dependencies": {
20
- "@ng-native/metro": "0.8.0",
20
+ "@ng-native/metro": "0.10.0",
21
21
  "lightningcss": "^1.30.2"
22
22
  },
23
23
  "nx": {
@@ -32,7 +32,7 @@
32
32
  "url": "https://github.com/ng-native/ng-native/issues"
33
33
  },
34
34
  "peerDependencies": {
35
- "@ng-native/metro": "0.8.0",
35
+ "@ng-native/metro": "0.10.0",
36
36
  "@tailwindcss/cli": "^4.3.3",
37
37
  "tailwindcss": "^3.4.1 || ^4.3.3"
38
38
  },
package/shared.css CHANGED
@@ -50,17 +50,18 @@
50
50
  * Tailwind's own `dark:` is `@media (prefers-color-scheme: dark)`, which the engine answers and
51
51
  * keeps in step with the system. That is one variant short of what a theme needs: a design system
52
52
  * ships its dark palette as `.dark { --background: ... }`, and an app wants a switcher that can
53
- * disagree with the OS. A class does both - put `dark` on the root and everything beneath it
54
- * flips, whatever the system thinks.
53
+ * disagree with the OS. A class does both - put `dark` on the root and it flips, along with
54
+ * everything beneath it, whatever the system thinks.
55
55
  *
56
56
  * Bind it from `ColorScheme` and the default behaviour is unchanged:
57
57
  *
58
58
  * <view [class]="scheme.colorScheme()" style="flex: 1">
59
59
  *
60
- * `.dark &` rather than `&:is(.dark *)`, for the same reason as the platform variants above: the
61
- * compiler refuses a combinator inside `:is()`, and a descendant selector says it plainly.
60
+ * Tailwind's own class-based form, so the view wearing `dark` matches as well as everything inside
61
+ * it, at the same specificity as on the web. The compiler reads the list as two rules, the view
62
+ * itself and an ancestor test.
62
63
  */
63
- @custom-variant dark (.dark &);
64
+ @custom-variant dark (&:where(.dark, .dark *));
64
65
 
65
66
  /*
66
67
  * The safe area, as utilities.
@@ -68,6 +68,12 @@ const STATES = {
68
68
  */
69
69
  const beneath = (platform, name) => (platform === 'web' ? `[class~="${name}"] &` : `.${name} &`);
70
70
 
71
+ /** The same, but matching the element wearing the class too: Tailwind's `&:where(.x, .x *)`. */
72
+ const selfOrBeneath = (platform, name) => {
73
+ const root = platform === 'web' ? `[class~="${name}"]` : `.${name}`;
74
+ return `&:where(${root}, ${root} *)`;
75
+ };
76
+
71
77
  /** `web.css`'s root tokens: the browser's own safe-area insets, and a hairline per density. */
72
78
  const WEB_BASE = {
73
79
  ':root': Object.fromEntries(
@@ -182,7 +188,7 @@ function presetPlugin(
182
188
  function tailwind3Preset(platform) {
183
189
  return {
184
190
  // A class seeded from the OS, so an app can disagree with it.
185
- darkMode: ['variant', beneath(platform, 'dark')],
191
+ darkMode: ['variant', selfOrBeneath(platform, 'dark')],
186
192
  // A browser reset in terms of `html` and `::before`. None of it means anything on a phone, and
187
193
  // in a browser the host's `reset.css` is the reset.
188
194
  corePlugins: { preflight: false },