@umber-style/rtl 0.11.0 → 0.11.1

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <!-- gen:readme description start - regenerated by `pnpm gen:readmes`; do not edit by hand -->
4
4
 
5
- The plugin of the UmberStyle default style that writes both directions of a style in one class: each declaration that has a side under :dir(ltr) as written and under :dir(rtl) flipped.
5
+ The plugin of the UmberStyle default style that writes both directions of a style in one class: each declaration that has a side under :where(:dir(ltr)) as written and under :where(:dir(rtl)) flipped.
6
6
 
7
7
  <!-- gen:readme end -->
8
8
 
@@ -53,7 +53,7 @@ function List() {
53
53
 
54
54
  // Both items have one class, which holds both directions.
55
55
  const html = renderToString(<List />)
56
- const expectedClass = 'app-item-root-1wrr0da'
56
+ const expectedClass = 'app-item-root-kbbqj1'
57
57
  ```
58
58
 
59
59
  From the passing test [`rtl.react.test.tsx`](https://github.com/soroush-tech/umber-style/blob/main/packages/umber-style/readme-examples/rtl.react.test.tsx).
@@ -136,13 +136,13 @@ From the passing test [`rtl.react-native.test.tsx`](https://github.com/soroush-t
136
136
 
137
137
  <!-- gen:readme docs right-to-left.md#region:rtl-api start - regenerated by `pnpm gen:readmes`; do not edit by hand -->
138
138
 
139
- | Export | What it is |
140
- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
141
- | `rtl(options?)` | The plugin of `configure({ plugins })`, one object for every binding: each declaration that has a side is written under `:dir(ltr)` as it is and under `:dir(rtl)` flipped. `options` are the switches that turn each kind of flip off |
142
- | `dir({ ltr, rtl })` | A value of its own for each direction, written as given and never flipped; with `rtl()` or without it |
143
- | `keep(value)` | A value that is never flipped: one plain declaration as it is given, with `rtl()` or without it |
144
- | `RtlOptions`, `DirValues` | The types of the options of `rtl()` and of the argument of `dir()` |
145
- | `Direction` | Not in this package: `@umber-style/react`, `@umber-style/vue` and `@umber-style/react-native` export it |
139
+ | Export | What it is |
140
+ | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
141
+ | `rtl(options?)` | The plugin of `configure({ plugins })`, one object for every binding: each declaration that has a side is written under `:where(:dir(ltr))` as it is and under `:where(:dir(rtl))` flipped. `options` are the switches that turn each kind of flip off |
142
+ | `dir({ ltr, rtl })` | A value of its own for each direction, written as given and never flipped; with `rtl()` or without it |
143
+ | `keep(value)` | A value that is never flipped: one plain declaration as it is given, with `rtl()` or without it |
144
+ | `RtlOptions`, `DirValues` | The types of the options of `rtl()` and of the argument of `dir()` |
145
+ | `Direction` | Not in this package: `@umber-style/react`, `@umber-style/vue` and `@umber-style/react-native` export it |
146
146
 
147
147
  <!-- gen:readme end -->
148
148
 
@@ -152,7 +152,7 @@ From the passing test [`rtl.react-native.test.tsx`](https://github.com/soroush-t
152
152
 
153
153
  - `:dir()` is supported in every major browser from late 2023 (no version was checked here: see [Browser support](https://github.com/soroush-tech/umber-style/blob/main/docs/browser-support.md)). An older browser gets the left-to-right layout through the fallback, whatever `dir` says. A browser that knows neither `:dir()` nor `@supports selector()` gets neither the rules of a direction nor the fallback: no declaration with a side applies there.
154
154
  - One extra rule for each class that has a declaration with a side, and one for its fallback: a class with such declarations is four rules where it was one.
155
- - A declaration with a side has the specificity of two classes (`.class:dir(rtl)`): against a rule of your own CSS with the specificity of one class, in the same cascade layer, it wins where the plain declaration would have lost. The layers of the engine (`app-components`, `app-overrides`) order the engine's own classes as before.
155
+ - A direction rule adds no specificity (`.class:where(:dir(rtl))` is as strong as `.class`), so it never wins where the plain declaration would have lost. `:where()` is supported in Chrome 88, Firefox 78 and Safari 14, wider than `:dir()`.
156
156
 
157
157
  <!-- gen:readme end -->
158
158
 
package/dist/index.cjs CHANGED
@@ -221,10 +221,12 @@ function flipValue$1(key, value, direction, switches) {
221
221
  return flip !== void 0 && switches?.[flip[0]] ? flip[1](value) : value;
222
222
  }
223
223
  // src/dir.ts
224
- /** The condition of a declaration as it is written, for left to right. */
225
- const LTR = ":dir(ltr)";
226
- /** The condition of a declaration flipped, for right to left. */
227
- const RTL = ":dir(rtl)";
224
+ /** The condition of a declaration as it is written, for left to right: under `:where()`, which adds no specificity. */
225
+ const LTR = ":where(:dir(ltr))";
226
+ /** The condition of a declaration flipped, for right to left: under `:where()`, which adds no specificity. */
227
+ const RTL = ":where(:dir(rtl))";
228
+ /** What a browser must match for the rules that the conditions write: `:dir()` itself, for the fallback to ask about. */
229
+ const SUPPORTS_DIR = ":dir(ltr)";
228
230
  /** The declarations of a `dir()` value: each side it has, under its own condition, as it was given. */
229
231
  function toSides(property, value) {
230
232
  const { ltr, rtl } = value.values;
@@ -245,7 +247,7 @@ function toSides(property, value) {
245
247
  const DIR_HANDLER = {
246
248
  name: "rtl-dir",
247
249
  conditions: [LTR, RTL],
248
- fallback: `@supports not selector(${LTR})`,
250
+ fallback: `@supports not selector(${SUPPORTS_DIR})`,
249
251
  declaration(property, value) {
250
252
  const sides = value;
251
253
  const { ltr, rtl } = sides.values;
@@ -590,8 +592,8 @@ const RULES = /* @__PURE__ */ new Map([
590
592
  ]);
591
593
  /**
592
594
  * The plugin of the default style (`configure({ plugins: [rtl()] })`) that writes both directions of a
593
- * style in one class: a declaration that has a side is written as it is under `:dir(ltr)` and for the
594
- * other side under `:dir(rtl)` (`margin-left` is `margin-right`, never a logical property), and a value
595
+ * style in one class: a declaration that has a side is written as it is under `:where(:dir(ltr))` and for the
596
+ * other side under `:where(:dir(rtl))` (`margin-left` is `margin-right`, never a logical property), and a value
595
597
  * that names or measures a side is written for the other one; `@supports not selector(:dir(ltr))` gives
596
598
  * the left-to-right declarations to a browser without `:dir()`. A `dir()` value is written as it is given,
597
599
  * each side under its own condition. In development a rule whose selector names a direction (`[dir` or
@@ -605,7 +607,7 @@ function rtl(options = {}) {
605
607
  name: createName("rtl", switches),
606
608
  native: (style, { dir }) => transformNativeStyle(style, dir, switches),
607
609
  conditions: [LTR, RTL],
608
- fallback: `@supports not selector(${LTR})`,
610
+ fallback: `@supports not selector(${SUPPORTS_DIR})`,
609
611
  declaration(property, value, selector) {
610
612
  if (typeof value !== "string") return value.mark === "dir" ? toSides(property, value) : void 0;
611
613
  const rule = RULES.get(property);
package/dist/index.d.cts CHANGED
@@ -68,8 +68,8 @@ export interface RtlPlugin extends CachePlugin$1 {
68
68
  }
69
69
  /**
70
70
  * The plugin of the default style (`configure({ plugins: [rtl()] })`) that writes both directions of a
71
- * style in one class: a declaration that has a side is written as it is under `:dir(ltr)` and for the
72
- * other side under `:dir(rtl)` (`margin-left` is `margin-right`, never a logical property), and a value
71
+ * style in one class: a declaration that has a side is written as it is under `:where(:dir(ltr))` and for the
72
+ * other side under `:where(:dir(rtl))` (`margin-left` is `margin-right`, never a logical property), and a value
73
73
  * that names or measures a side is written for the other one; `@supports not selector(:dir(ltr))` gives
74
74
  * the left-to-right declarations to a browser without `:dir()`. A `dir()` value is written as it is given,
75
75
  * each side under its own condition. In development a rule whose selector names a direction (`[dir` or
package/dist/index.d.mts CHANGED
@@ -68,8 +68,8 @@ export interface RtlPlugin extends CachePlugin$1 {
68
68
  }
69
69
  /**
70
70
  * The plugin of the default style (`configure({ plugins: [rtl()] })`) that writes both directions of a
71
- * style in one class: a declaration that has a side is written as it is under `:dir(ltr)` and for the
72
- * other side under `:dir(rtl)` (`margin-left` is `margin-right`, never a logical property), and a value
71
+ * style in one class: a declaration that has a side is written as it is under `:where(:dir(ltr))` and for the
72
+ * other side under `:where(:dir(rtl))` (`margin-left` is `margin-right`, never a logical property), and a value
73
73
  * that names or measures a side is written for the other one; `@supports not selector(:dir(ltr))` gives
74
74
  * the left-to-right declarations to a browser without `:dir()`. A `dir()` value is written as it is given,
75
75
  * each side under its own condition. In development a rule whose selector names a direction (`[dir` or
package/dist/index.mjs CHANGED
@@ -220,10 +220,12 @@ function flipValue$1(key, value, direction, switches) {
220
220
  return flip !== void 0 && switches?.[flip[0]] ? flip[1](value) : value;
221
221
  }
222
222
  // src/dir.ts
223
- /** The condition of a declaration as it is written, for left to right. */
224
- const LTR = ":dir(ltr)";
225
- /** The condition of a declaration flipped, for right to left. */
226
- const RTL = ":dir(rtl)";
223
+ /** The condition of a declaration as it is written, for left to right: under `:where()`, which adds no specificity. */
224
+ const LTR = ":where(:dir(ltr))";
225
+ /** The condition of a declaration flipped, for right to left: under `:where()`, which adds no specificity. */
226
+ const RTL = ":where(:dir(rtl))";
227
+ /** What a browser must match for the rules that the conditions write: `:dir()` itself, for the fallback to ask about. */
228
+ const SUPPORTS_DIR = ":dir(ltr)";
227
229
  /** The declarations of a `dir()` value: each side it has, under its own condition, as it was given. */
228
230
  function toSides(property, value) {
229
231
  const { ltr, rtl } = value.values;
@@ -244,7 +246,7 @@ function toSides(property, value) {
244
246
  const DIR_HANDLER = {
245
247
  name: "rtl-dir",
246
248
  conditions: [LTR, RTL],
247
- fallback: `@supports not selector(${LTR})`,
249
+ fallback: `@supports not selector(${SUPPORTS_DIR})`,
248
250
  declaration(property, value) {
249
251
  const sides = value;
250
252
  const { ltr, rtl } = sides.values;
@@ -589,8 +591,8 @@ const RULES = /* @__PURE__ */ new Map([
589
591
  ]);
590
592
  /**
591
593
  * The plugin of the default style (`configure({ plugins: [rtl()] })`) that writes both directions of a
592
- * style in one class: a declaration that has a side is written as it is under `:dir(ltr)` and for the
593
- * other side under `:dir(rtl)` (`margin-left` is `margin-right`, never a logical property), and a value
594
+ * style in one class: a declaration that has a side is written as it is under `:where(:dir(ltr))` and for the
595
+ * other side under `:where(:dir(rtl))` (`margin-left` is `margin-right`, never a logical property), and a value
594
596
  * that names or measures a side is written for the other one; `@supports not selector(:dir(ltr))` gives
595
597
  * the left-to-right declarations to a browser without `:dir()`. A `dir()` value is written as it is given,
596
598
  * each side under its own condition. In development a rule whose selector names a direction (`[dir` or
@@ -604,7 +606,7 @@ function rtl(options = {}) {
604
606
  name: createName("rtl", switches),
605
607
  native: (style, { dir }) => transformNativeStyle(style, dir, switches),
606
608
  conditions: [LTR, RTL],
607
- fallback: `@supports not selector(${LTR})`,
609
+ fallback: `@supports not selector(${SUPPORTS_DIR})`,
608
610
  declaration(property, value, selector) {
609
611
  if (typeof value !== "string") return value.mark === "dir" ? toSides(property, value) : void 0;
610
612
  const rule = RULES.get(property);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@umber-style/rtl",
3
- "version": "0.11.0",
4
- "description": "The plugin of the UmberStyle default style that writes both directions of a style in one class: each declaration that has a side under :dir(ltr) as written and under :dir(rtl) flipped.",
3
+ "version": "0.11.1",
4
+ "description": "The plugin of the UmberStyle default style that writes both directions of a style in one class: each declaration that has a side under :where(:dir(ltr)) as written and under :where(:dir(rtl)) flipped.",
5
5
  "keywords": [
6
6
  "styling",
7
7
  "rtl",
@@ -42,7 +42,7 @@
42
42
  "access": "public"
43
43
  },
44
44
  "dependencies": {
45
- "@umber-style/core": "^0.11.0"
45
+ "@umber-style/core": "^0.11.1"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/node": "^26.6.6",