@animus-ui/properties 0.1.21 → 0.1.23
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/dist/index.d.ts +16 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -85,6 +85,21 @@ export declare const isSpace: (value: ComponentValue | undefined) => boolean;
|
|
|
85
85
|
* first argument is a custom-property name.
|
|
86
86
|
*/
|
|
87
87
|
export declare function variableReads(values: readonly ComponentValue[]): VariableRead[];
|
|
88
|
+
/** How a value spells the `!important` it ends with: `hidden !important`,
|
|
89
|
+
* any case and spacing, or the shorthand `hidden!`. */
|
|
90
|
+
type ImportantSpelling = 'important' | 'shorthand';
|
|
91
|
+
interface ImportantPriority {
|
|
92
|
+
spelling: ImportantSpelling;
|
|
93
|
+
/** Where the value before the priority ends. */
|
|
94
|
+
end: number;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The `!important` `css` ends with; kept in step with `important_priority`
|
|
98
|
+
* in the Rust engine. The value has one `!`, a delim token, so a `!` inside
|
|
99
|
+
* a string, a `url()` or an escape is no priority, and neither is a lone `!`
|
|
100
|
+
* or `!important`.
|
|
101
|
+
*/
|
|
102
|
+
export declare function importantPriority(css: string): ImportantPriority | undefined;
|
|
88
103
|
//#endregion
|
|
89
104
|
//#region src/registration-values.d.ts
|
|
90
105
|
/**
|
|
@@ -141,5 +156,5 @@ type FoldedInitialValue =
|
|
|
141
156
|
*/
|
|
142
157
|
export declare function foldInitialValue(syntax: string, initialValue: string): FoldedInitialValue | undefined;
|
|
143
158
|
//#endregion
|
|
144
|
-
export type { ComponentValue, CssToken, FoldedInitialValue, VariableRead };
|
|
159
|
+
export type { ComponentValue, CssToken, FoldedInitialValue, ImportantPriority, ImportantSpelling, VariableRead };
|
|
145
160
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/shorthands.ts","../src/unitless.ts","../src/css-tokens.ts","../src/registration-values.ts"],"mappings":";;;;qBAGa;;;qBCHA,qBAAmB;;;wBAgHhB,mBAAmB;;;;;;;;;;KCxGvB;UA0BK;EACf,MAAM;EACN;EACA;;;EAGA;;EAEA;;;;wBAiFc,aACd,aACA;EACG;EAAc;;;wBAOH,kBAAkB;;wBAyFlB,SAAS,cAAc;;;KA0E3B;EAEN;;EAEA,MAAM;;EAEN,OAAO;EACP,UAAU;EACV;EACA;;EAEA;EAAe,OAAO;EAAU;EAAe;;;;;;;wBAgBrC,gBAAgB,iBAAiB,aAAa;;wBAoC9C,UACd,iBAAiB,kBACjB,OAAO,OAAO;;;;UAWC;EACf;EACA;EACA;EACA;IAAY;IAAe;IAAe;;;;qBAI/B,UAAO,OAAW;;;;;;wBAQf,cACd,iBAAiB,mBAChB;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/shorthands.ts","../src/unitless.ts","../src/css-tokens.ts","../src/registration-values.ts"],"mappings":";;;;qBAGa;;;qBCHA,qBAAmB;;;wBAgHhB,mBAAmB;;;;;;;;;;KCxGvB;UA0BK;EACf,MAAM;EACN;EACA;;;EAGA;;EAEA;;;;wBAiFc,aACd,aACA;EACG;EAAc;;;wBAOH,kBAAkB;;wBAyFlB,SAAS,cAAc;;;KA0E3B;EAEN;;EAEA,MAAM;;EAEN,OAAO;EACP,UAAU;EACV;EACA;;EAEA;EAAe,OAAO;EAAU;EAAe;;;;;;;wBAgBrC,gBAAgB,iBAAiB,aAAa;;wBAoC9C,UACd,iBAAiB,kBACjB,OAAO,OAAO;;;;UAWC;EACf;EACA;EACA;EACA;IAAY;IAAe;IAAe;;;;qBAI/B,UAAO,OAAW;;;;;;wBAQf,cACd,iBAAiB,mBAChB;;;KAiCS;UAEK;EACf,UAAU;;EAEV;;;;;;;;wBASc,kBAAkB,cAAc;;;;;;;;;;;;wBCtZhC,iBAAiB;;;wBA6BjB,iBAAiB;;UAWvB;EACR;EACA;;;KA+NU;;;;EAGN;EAAgB;;;;EAEhB;EAAkB;EAAc,MAAM;;;;EAEtC;EAAiB;;;;;EAGjB;;;;;;;;;;;;wBAYU,iBACd,gBACA,uBACC"}
|
package/dist/index.js
CHANGED
|
@@ -430,6 +430,39 @@ function variableReads(values) {
|
|
|
430
430
|
visit(values);
|
|
431
431
|
return reads;
|
|
432
432
|
}
|
|
433
|
+
/**
|
|
434
|
+
* The `!important` `css` ends with; kept in step with `important_priority`
|
|
435
|
+
* in the Rust engine. The value has one `!`, a delim token, so a `!` inside
|
|
436
|
+
* a string, a `url()` or an escape is no priority, and neither is a lone `!`
|
|
437
|
+
* or `!important`.
|
|
438
|
+
*/
|
|
439
|
+
function importantPriority(css) {
|
|
440
|
+
const trimmed = css.trimEnd();
|
|
441
|
+
const endsImportant = trimmed.length >= 9 && /^important$/i.test(trimmed.slice(-9));
|
|
442
|
+
if (!css.endsWith("!") && !endsImportant) return void 0;
|
|
443
|
+
const tokens = tokenize(css);
|
|
444
|
+
let bang = -1;
|
|
445
|
+
for (let index = 0; index < tokens.length; index += 1) {
|
|
446
|
+
if (tokens[index].type !== "delim" || tokens[index].value !== "!") continue;
|
|
447
|
+
if (bang !== -1) return void 0;
|
|
448
|
+
bang = index;
|
|
449
|
+
}
|
|
450
|
+
if (bang === -1) return void 0;
|
|
451
|
+
if (bang === tokens.length - 1) {
|
|
452
|
+
const previous = tokens[bang - 1];
|
|
453
|
+
return previous !== void 0 && previous.type !== "whitespace" && previous.end === tokens[bang].start ? {
|
|
454
|
+
spelling: "shorthand",
|
|
455
|
+
end: previous.end
|
|
456
|
+
} : void 0;
|
|
457
|
+
}
|
|
458
|
+
const after = tokens.slice(bang + 1).filter((t) => t.type !== "whitespace");
|
|
459
|
+
if (after.length !== 1 || after[0].type !== "ident" || !/^important$/i.test(after[0].value)) return;
|
|
460
|
+
const value = tokens.slice(0, bang).findLast((t) => t.type !== "whitespace");
|
|
461
|
+
return value && {
|
|
462
|
+
spelling: "important",
|
|
463
|
+
end: value.end
|
|
464
|
+
};
|
|
465
|
+
}
|
|
433
466
|
//#endregion
|
|
434
467
|
//#region src/registration-values.ts
|
|
435
468
|
/**
|
|
@@ -727,4 +760,4 @@ function written(computed) {
|
|
|
727
760
|
return `${Number(computed.value.toPrecision(12))}${CANONICAL_UNITS[computed.type]}`;
|
|
728
761
|
}
|
|
729
762
|
//#endregion
|
|
730
|
-
export { SHORTHAND_PROPERTIES, UNITLESS_PROPERTIES, componentValues, decodedIdentifier, dependsOnContext, foldInitialValue, identifierAt, isSpace, isUnitlessProperty, someValue, substitutesValue, tokenize, variableReads };
|
|
763
|
+
export { SHORTHAND_PROPERTIES, UNITLESS_PROPERTIES, componentValues, decodedIdentifier, dependsOnContext, foldInitialValue, identifierAt, importantPriority, isSpace, isUnitlessProperty, someValue, substitutesValue, tokenize, variableReads };
|