@tldraw/editor 3.11.1 → 3.12.0-canary.0a56a15970b2

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.
Files changed (70) hide show
  1. package/CHANGELOG.md +0 -21
  2. package/dist-cjs/index.d.ts +5 -2
  3. package/dist-cjs/index.js +1 -1
  4. package/dist-cjs/lib/TldrawEditor.js.map +1 -1
  5. package/dist-cjs/lib/components/Shape.js +10 -14
  6. package/dist-cjs/lib/components/Shape.js.map +2 -2
  7. package/dist-cjs/lib/editor/Editor.js +9 -2
  8. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  9. package/dist-cjs/lib/editor/derivations/notVisibleShapes.js +1 -1
  10. package/dist-cjs/lib/editor/derivations/notVisibleShapes.js.map +2 -2
  11. package/dist-cjs/lib/editor/managers/FontManager.js +1 -1
  12. package/dist-cjs/lib/editor/managers/FontManager.js.map +2 -2
  13. package/dist-cjs/lib/editor/tools/StateNode.js +4 -1
  14. package/dist-cjs/lib/editor/tools/StateNode.js.map +2 -2
  15. package/dist-cjs/lib/exports/StyleEmbedder.js +5 -19
  16. package/dist-cjs/lib/exports/StyleEmbedder.js.map +2 -2
  17. package/dist-cjs/lib/exports/parseCss.js +69 -0
  18. package/dist-cjs/lib/exports/parseCss.js.map +2 -2
  19. package/dist-cjs/lib/hooks/useCanvasEvents.js +12 -7
  20. package/dist-cjs/lib/hooks/useCanvasEvents.js.map +3 -3
  21. package/dist-cjs/lib/primitives/geometry/Group2d.js +1 -1
  22. package/dist-cjs/lib/primitives/geometry/Group2d.js.map +2 -2
  23. package/dist-cjs/lib/utils/debug-flags.js +2 -1
  24. package/dist-cjs/lib/utils/debug-flags.js.map +2 -2
  25. package/dist-cjs/version.js +3 -3
  26. package/dist-cjs/version.js.map +1 -1
  27. package/dist-esm/index.d.mts +5 -2
  28. package/dist-esm/index.mjs +1 -1
  29. package/dist-esm/lib/TldrawEditor.mjs.map +1 -1
  30. package/dist-esm/lib/components/Shape.mjs +11 -15
  31. package/dist-esm/lib/components/Shape.mjs.map +2 -2
  32. package/dist-esm/lib/editor/Editor.mjs +9 -2
  33. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  34. package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs +1 -1
  35. package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs.map +2 -2
  36. package/dist-esm/lib/editor/managers/FontManager.mjs +1 -1
  37. package/dist-esm/lib/editor/managers/FontManager.mjs.map +2 -2
  38. package/dist-esm/lib/editor/tools/StateNode.mjs +4 -1
  39. package/dist-esm/lib/editor/tools/StateNode.mjs.map +2 -2
  40. package/dist-esm/lib/exports/StyleEmbedder.mjs +12 -21
  41. package/dist-esm/lib/exports/StyleEmbedder.mjs.map +2 -2
  42. package/dist-esm/lib/exports/parseCss.mjs +69 -0
  43. package/dist-esm/lib/exports/parseCss.mjs.map +2 -2
  44. package/dist-esm/lib/hooks/useCanvasEvents.mjs +12 -7
  45. package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +3 -3
  46. package/dist-esm/lib/primitives/geometry/Group2d.mjs +1 -1
  47. package/dist-esm/lib/primitives/geometry/Group2d.mjs.map +2 -2
  48. package/dist-esm/lib/utils/debug-flags.mjs +2 -1
  49. package/dist-esm/lib/utils/debug-flags.mjs.map +2 -2
  50. package/dist-esm/version.mjs +3 -3
  51. package/dist-esm/version.mjs.map +1 -1
  52. package/editor.css +17 -11
  53. package/package.json +7 -7
  54. package/src/lib/TldrawEditor.tsx +2 -2
  55. package/src/lib/components/Shape.tsx +15 -19
  56. package/src/lib/editor/Editor.ts +12 -3
  57. package/src/lib/editor/derivations/notVisibleShapes.ts +1 -1
  58. package/src/lib/editor/managers/FontManager.ts +1 -1
  59. package/src/lib/editor/tools/StateNode.ts +6 -1
  60. package/src/lib/exports/StyleEmbedder.ts +15 -25
  61. package/src/lib/exports/parseCss.ts +79 -0
  62. package/src/lib/hooks/useCanvasEvents.ts +14 -7
  63. package/src/lib/primitives/geometry/Group2d.ts +1 -1
  64. package/src/lib/utils/debug-flags.ts +1 -0
  65. package/src/version.ts +3 -3
  66. package/dist-cjs/lib/exports/cssRules.js +0 -127
  67. package/dist-cjs/lib/exports/cssRules.js.map +0 -7
  68. package/dist-esm/lib/exports/cssRules.mjs +0 -107
  69. package/dist-esm/lib/exports/cssRules.mjs.map +0 -7
  70. package/src/lib/exports/cssRules.ts +0 -126
@@ -1,127 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var cssRules_exports = {};
20
- __export(cssRules_exports, {
21
- cssRules: () => cssRules
22
- });
23
- module.exports = __toCommonJS(cssRules_exports);
24
- const isCoveredByCurrentColor = (value, property, { currentColor }) => {
25
- return value === "currentColor" || value === currentColor;
26
- };
27
- const isInherited = (value, property, { parentStyles }) => {
28
- return parentStyles[property] === value;
29
- };
30
- const isExcludedBorder = (borderDirection) => (value, property, { getStyle }) => {
31
- const borderWidth = getStyle(`border-${borderDirection}-width`);
32
- const borderStyle = getStyle(`border-${borderDirection}-style`);
33
- if (borderWidth === "0px") return true;
34
- if (borderStyle === "none") return true;
35
- return false;
36
- };
37
- const cssRules = {
38
- // currentColor properties:
39
- "border-block-end-color": isCoveredByCurrentColor,
40
- "border-block-start-color": isCoveredByCurrentColor,
41
- "border-bottom-color": isCoveredByCurrentColor,
42
- "border-inline-end-color": isCoveredByCurrentColor,
43
- "border-inline-start-color": isCoveredByCurrentColor,
44
- "border-left-color": isCoveredByCurrentColor,
45
- "border-right-color": isCoveredByCurrentColor,
46
- "border-top-color": isCoveredByCurrentColor,
47
- "caret-color": isCoveredByCurrentColor,
48
- "column-rule-color": isCoveredByCurrentColor,
49
- "outline-color": isCoveredByCurrentColor,
50
- "text-decoration": (value, property, { currentColor }) => {
51
- return value === "none solid currentColor" || value === "none solid " + currentColor;
52
- },
53
- "text-decoration-color": isCoveredByCurrentColor,
54
- "text-emphasis-color": isCoveredByCurrentColor,
55
- // inherited properties:
56
- "border-collapse": isInherited,
57
- "border-spacing": isInherited,
58
- "caption-side": isInherited,
59
- // N.B. We shouldn't inherit 'color' because there's some UA styling, e.g. `mark` elements
60
- // 'color': isInherited,
61
- cursor: isInherited,
62
- direction: isInherited,
63
- "empty-cells": isInherited,
64
- "font-family": isInherited,
65
- "font-size": isInherited,
66
- "font-style": isInherited,
67
- "font-variant": isInherited,
68
- "font-weight": isInherited,
69
- "font-size-adjust": isInherited,
70
- "font-stretch": isInherited,
71
- font: isInherited,
72
- "letter-spacing": isInherited,
73
- "line-height": isInherited,
74
- "list-style-image": isInherited,
75
- "list-style-position": isInherited,
76
- "list-style-type": isInherited,
77
- "list-style": isInherited,
78
- orphans: isInherited,
79
- "overflow-wrap": isInherited,
80
- quotes: isInherited,
81
- "stroke-linecap": isInherited,
82
- "stroke-linejoin": isInherited,
83
- "tab-size": isInherited,
84
- "text-align": isInherited,
85
- "text-align-last": isInherited,
86
- "text-indent": isInherited,
87
- "text-justify": isInherited,
88
- "text-shadow": isInherited,
89
- "text-transform": isInherited,
90
- visibility: isInherited,
91
- "white-space": isInherited,
92
- "white-space-collapse": isInherited,
93
- widows: isInherited,
94
- "word-break": isInherited,
95
- "word-spacing": isInherited,
96
- "word-wrap": isInherited,
97
- // special border cases - we have a weird case (tailwind seems to trigger this) where all
98
- // border-styles sometimes get set to 'solid', but the border-width is 0 so they don't render.
99
- // but in SVGs, **sometimes**, the border-width defaults (i think from a UA style-sheet? but
100
- // honestly can't tell) to 1.5px so the border displays. we work around this by only including
101
- // border styles at all if both the border-width and border-style are set to something that
102
- // would show a border.
103
- "border-top": isExcludedBorder("top"),
104
- "border-right": isExcludedBorder("right"),
105
- "border-bottom": isExcludedBorder("bottom"),
106
- "border-left": isExcludedBorder("left"),
107
- "border-block-end": isExcludedBorder("block-end"),
108
- "border-block-start": isExcludedBorder("block-start"),
109
- "border-inline-end": isExcludedBorder("inline-end"),
110
- "border-inline-start": isExcludedBorder("inline-start"),
111
- "border-top-style": isExcludedBorder("top"),
112
- "border-right-style": isExcludedBorder("right"),
113
- "border-bottom-style": isExcludedBorder("bottom"),
114
- "border-left-style": isExcludedBorder("left"),
115
- "border-block-end-style": isExcludedBorder("block-end"),
116
- "border-block-start-style": isExcludedBorder("block-start"),
117
- "border-inline-end-style": isExcludedBorder("inline-end"),
118
- "border-inline-start-style": isExcludedBorder("inline-start"),
119
- "border-top-width": isExcludedBorder("top"),
120
- "border-right-width": isExcludedBorder("right"),
121
- "border-bottom-width": isExcludedBorder("bottom"),
122
- "border-left-width": isExcludedBorder("left"),
123
- "border-block-end-width": isExcludedBorder("block-end"),
124
- "border-block-start-width": isExcludedBorder("block-start"),
125
- "border-inline-end-width": isExcludedBorder("inline-end")
126
- };
127
- //# sourceMappingURL=cssRules.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/lib/exports/cssRules.ts"],
4
- "sourcesContent": ["export type Styles = { [K in string]?: string }\nexport type ReadonlyStyles = { readonly [K in string]?: string }\n\ntype CanSkipRule = (\n\tvalue: string,\n\tproperty: string,\n\toptions: {\n\t\tgetStyle(property: string): string\n\t\tparentStyles: ReadonlyStyles\n\t\tdefaultStyles: ReadonlyStyles\n\t\tcurrentColor: string\n\t}\n) => boolean\n\nconst isCoveredByCurrentColor: CanSkipRule = (value, property, { currentColor }) => {\n\treturn value === 'currentColor' || value === currentColor\n}\n\nconst isInherited: CanSkipRule = (value, property, { parentStyles }) => {\n\treturn parentStyles[property] === value\n}\n\n// see comment below about why we exclude border styles\nconst isExcludedBorder =\n\t(borderDirection: string): CanSkipRule =>\n\t(value, property, { getStyle }) => {\n\t\tconst borderWidth = getStyle(`border-${borderDirection}-width`)\n\t\tconst borderStyle = getStyle(`border-${borderDirection}-style`)\n\n\t\tif (borderWidth === '0px') return true\n\t\tif (borderStyle === 'none') return true\n\t\treturn false\n\t}\n\nexport const cssRules = {\n\t// currentColor properties:\n\t'border-block-end-color': isCoveredByCurrentColor,\n\t'border-block-start-color': isCoveredByCurrentColor,\n\t'border-bottom-color': isCoveredByCurrentColor,\n\t'border-inline-end-color': isCoveredByCurrentColor,\n\t'border-inline-start-color': isCoveredByCurrentColor,\n\t'border-left-color': isCoveredByCurrentColor,\n\t'border-right-color': isCoveredByCurrentColor,\n\t'border-top-color': isCoveredByCurrentColor,\n\t'caret-color': isCoveredByCurrentColor,\n\t'column-rule-color': isCoveredByCurrentColor,\n\t'outline-color': isCoveredByCurrentColor,\n\t'text-decoration': (value, property, { currentColor }) => {\n\t\treturn value === 'none solid currentColor' || value === 'none solid ' + currentColor\n\t},\n\t'text-decoration-color': isCoveredByCurrentColor,\n\t'text-emphasis-color': isCoveredByCurrentColor,\n\n\t// inherited properties:\n\t'border-collapse': isInherited,\n\t'border-spacing': isInherited,\n\t'caption-side': isInherited,\n\t// N.B. We shouldn't inherit 'color' because there's some UA styling, e.g. `mark` elements\n\t// 'color': isInherited,\n\tcursor: isInherited,\n\tdirection: isInherited,\n\t'empty-cells': isInherited,\n\t'font-family': isInherited,\n\t'font-size': isInherited,\n\t'font-style': isInherited,\n\t'font-variant': isInherited,\n\t'font-weight': isInherited,\n\t'font-size-adjust': isInherited,\n\t'font-stretch': isInherited,\n\tfont: isInherited,\n\t'letter-spacing': isInherited,\n\t'line-height': isInherited,\n\t'list-style-image': isInherited,\n\t'list-style-position': isInherited,\n\t'list-style-type': isInherited,\n\t'list-style': isInherited,\n\torphans: isInherited,\n\t'overflow-wrap': isInherited,\n\tquotes: isInherited,\n\t'stroke-linecap': isInherited,\n\t'stroke-linejoin': isInherited,\n\t'tab-size': isInherited,\n\t'text-align': isInherited,\n\t'text-align-last': isInherited,\n\t'text-indent': isInherited,\n\t'text-justify': isInherited,\n\t'text-shadow': isInherited,\n\t'text-transform': isInherited,\n\tvisibility: isInherited,\n\t'white-space': isInherited,\n\t'white-space-collapse': isInherited,\n\twidows: isInherited,\n\t'word-break': isInherited,\n\t'word-spacing': isInherited,\n\t'word-wrap': isInherited,\n\n\t// special border cases - we have a weird case (tailwind seems to trigger this) where all\n\t// border-styles sometimes get set to 'solid', but the border-width is 0 so they don't render.\n\t// but in SVGs, **sometimes**, the border-width defaults (i think from a UA style-sheet? but\n\t// honestly can't tell) to 1.5px so the border displays. we work around this by only including\n\t// border styles at all if both the border-width and border-style are set to something that\n\t// would show a border.\n\t'border-top': isExcludedBorder('top'),\n\t'border-right': isExcludedBorder('right'),\n\t'border-bottom': isExcludedBorder('bottom'),\n\t'border-left': isExcludedBorder('left'),\n\t'border-block-end': isExcludedBorder('block-end'),\n\t'border-block-start': isExcludedBorder('block-start'),\n\t'border-inline-end': isExcludedBorder('inline-end'),\n\t'border-inline-start': isExcludedBorder('inline-start'),\n\t'border-top-style': isExcludedBorder('top'),\n\t'border-right-style': isExcludedBorder('right'),\n\t'border-bottom-style': isExcludedBorder('bottom'),\n\t'border-left-style': isExcludedBorder('left'),\n\t'border-block-end-style': isExcludedBorder('block-end'),\n\t'border-block-start-style': isExcludedBorder('block-start'),\n\t'border-inline-end-style': isExcludedBorder('inline-end'),\n\t'border-inline-start-style': isExcludedBorder('inline-start'),\n\t'border-top-width': isExcludedBorder('top'),\n\t'border-right-width': isExcludedBorder('right'),\n\t'border-bottom-width': isExcludedBorder('bottom'),\n\t'border-left-width': isExcludedBorder('left'),\n\t'border-block-end-width': isExcludedBorder('block-end'),\n\t'border-block-start-width': isExcludedBorder('block-start'),\n\t'border-inline-end-width': isExcludedBorder('inline-end'),\n} satisfies Record<string, CanSkipRule>\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAcA,MAAM,0BAAuC,CAAC,OAAO,UAAU,EAAE,aAAa,MAAM;AACnF,SAAO,UAAU,kBAAkB,UAAU;AAC9C;AAEA,MAAM,cAA2B,CAAC,OAAO,UAAU,EAAE,aAAa,MAAM;AACvE,SAAO,aAAa,QAAQ,MAAM;AACnC;AAGA,MAAM,mBACL,CAAC,oBACD,CAAC,OAAO,UAAU,EAAE,SAAS,MAAM;AAClC,QAAM,cAAc,SAAS,UAAU,eAAe,QAAQ;AAC9D,QAAM,cAAc,SAAS,UAAU,eAAe,QAAQ;AAE9D,MAAI,gBAAgB,MAAO,QAAO;AAClC,MAAI,gBAAgB,OAAQ,QAAO;AACnC,SAAO;AACR;AAEM,MAAM,WAAW;AAAA;AAAA,EAEvB,0BAA0B;AAAA,EAC1B,4BAA4B;AAAA,EAC5B,uBAAuB;AAAA,EACvB,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAC7B,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,oBAAoB;AAAA,EACpB,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,iBAAiB;AAAA,EACjB,mBAAmB,CAAC,OAAO,UAAU,EAAE,aAAa,MAAM;AACzD,WAAO,UAAU,6BAA6B,UAAU,gBAAgB;AAAA,EACzE;AAAA,EACA,yBAAyB;AAAA,EACzB,uBAAuB;AAAA;AAAA,EAGvB,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,gBAAgB;AAAA;AAAA;AAAA,EAGhB,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,eAAe;AAAA,EACf,eAAe;AAAA,EACf,aAAa;AAAA,EACb,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,oBAA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BAAqB,iBAAiB,MAAM;AAAA,EAC5C,0BAA0B,iBAAiB,WAAW;AAAA,EACtD,4BAA4B,iBAAiB,aAAa;AAAA,EAC1D,2BAA2B,iBAAiB,YAAY;AACzD;",
6
- "names": []
7
- }
@@ -1,107 +0,0 @@
1
- const isCoveredByCurrentColor = (value, property, { currentColor }) => {
2
- return value === "currentColor" || value === currentColor;
3
- };
4
- const isInherited = (value, property, { parentStyles }) => {
5
- return parentStyles[property] === value;
6
- };
7
- const isExcludedBorder = (borderDirection) => (value, property, { getStyle }) => {
8
- const borderWidth = getStyle(`border-${borderDirection}-width`);
9
- const borderStyle = getStyle(`border-${borderDirection}-style`);
10
- if (borderWidth === "0px") return true;
11
- if (borderStyle === "none") return true;
12
- return false;
13
- };
14
- const cssRules = {
15
- // currentColor properties:
16
- "border-block-end-color": isCoveredByCurrentColor,
17
- "border-block-start-color": isCoveredByCurrentColor,
18
- "border-bottom-color": isCoveredByCurrentColor,
19
- "border-inline-end-color": isCoveredByCurrentColor,
20
- "border-inline-start-color": isCoveredByCurrentColor,
21
- "border-left-color": isCoveredByCurrentColor,
22
- "border-right-color": isCoveredByCurrentColor,
23
- "border-top-color": isCoveredByCurrentColor,
24
- "caret-color": isCoveredByCurrentColor,
25
- "column-rule-color": isCoveredByCurrentColor,
26
- "outline-color": isCoveredByCurrentColor,
27
- "text-decoration": (value, property, { currentColor }) => {
28
- return value === "none solid currentColor" || value === "none solid " + currentColor;
29
- },
30
- "text-decoration-color": isCoveredByCurrentColor,
31
- "text-emphasis-color": isCoveredByCurrentColor,
32
- // inherited properties:
33
- "border-collapse": isInherited,
34
- "border-spacing": isInherited,
35
- "caption-side": isInherited,
36
- // N.B. We shouldn't inherit 'color' because there's some UA styling, e.g. `mark` elements
37
- // 'color': isInherited,
38
- cursor: isInherited,
39
- direction: isInherited,
40
- "empty-cells": isInherited,
41
- "font-family": isInherited,
42
- "font-size": isInherited,
43
- "font-style": isInherited,
44
- "font-variant": isInherited,
45
- "font-weight": isInherited,
46
- "font-size-adjust": isInherited,
47
- "font-stretch": isInherited,
48
- font: isInherited,
49
- "letter-spacing": isInherited,
50
- "line-height": isInherited,
51
- "list-style-image": isInherited,
52
- "list-style-position": isInherited,
53
- "list-style-type": isInherited,
54
- "list-style": isInherited,
55
- orphans: isInherited,
56
- "overflow-wrap": isInherited,
57
- quotes: isInherited,
58
- "stroke-linecap": isInherited,
59
- "stroke-linejoin": isInherited,
60
- "tab-size": isInherited,
61
- "text-align": isInherited,
62
- "text-align-last": isInherited,
63
- "text-indent": isInherited,
64
- "text-justify": isInherited,
65
- "text-shadow": isInherited,
66
- "text-transform": isInherited,
67
- visibility: isInherited,
68
- "white-space": isInherited,
69
- "white-space-collapse": isInherited,
70
- widows: isInherited,
71
- "word-break": isInherited,
72
- "word-spacing": isInherited,
73
- "word-wrap": isInherited,
74
- // special border cases - we have a weird case (tailwind seems to trigger this) where all
75
- // border-styles sometimes get set to 'solid', but the border-width is 0 so they don't render.
76
- // but in SVGs, **sometimes**, the border-width defaults (i think from a UA style-sheet? but
77
- // honestly can't tell) to 1.5px so the border displays. we work around this by only including
78
- // border styles at all if both the border-width and border-style are set to something that
79
- // would show a border.
80
- "border-top": isExcludedBorder("top"),
81
- "border-right": isExcludedBorder("right"),
82
- "border-bottom": isExcludedBorder("bottom"),
83
- "border-left": isExcludedBorder("left"),
84
- "border-block-end": isExcludedBorder("block-end"),
85
- "border-block-start": isExcludedBorder("block-start"),
86
- "border-inline-end": isExcludedBorder("inline-end"),
87
- "border-inline-start": isExcludedBorder("inline-start"),
88
- "border-top-style": isExcludedBorder("top"),
89
- "border-right-style": isExcludedBorder("right"),
90
- "border-bottom-style": isExcludedBorder("bottom"),
91
- "border-left-style": isExcludedBorder("left"),
92
- "border-block-end-style": isExcludedBorder("block-end"),
93
- "border-block-start-style": isExcludedBorder("block-start"),
94
- "border-inline-end-style": isExcludedBorder("inline-end"),
95
- "border-inline-start-style": isExcludedBorder("inline-start"),
96
- "border-top-width": isExcludedBorder("top"),
97
- "border-right-width": isExcludedBorder("right"),
98
- "border-bottom-width": isExcludedBorder("bottom"),
99
- "border-left-width": isExcludedBorder("left"),
100
- "border-block-end-width": isExcludedBorder("block-end"),
101
- "border-block-start-width": isExcludedBorder("block-start"),
102
- "border-inline-end-width": isExcludedBorder("inline-end")
103
- };
104
- export {
105
- cssRules
106
- };
107
- //# sourceMappingURL=cssRules.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/lib/exports/cssRules.ts"],
4
- "sourcesContent": ["export type Styles = { [K in string]?: string }\nexport type ReadonlyStyles = { readonly [K in string]?: string }\n\ntype CanSkipRule = (\n\tvalue: string,\n\tproperty: string,\n\toptions: {\n\t\tgetStyle(property: string): string\n\t\tparentStyles: ReadonlyStyles\n\t\tdefaultStyles: ReadonlyStyles\n\t\tcurrentColor: string\n\t}\n) => boolean\n\nconst isCoveredByCurrentColor: CanSkipRule = (value, property, { currentColor }) => {\n\treturn value === 'currentColor' || value === currentColor\n}\n\nconst isInherited: CanSkipRule = (value, property, { parentStyles }) => {\n\treturn parentStyles[property] === value\n}\n\n// see comment below about why we exclude border styles\nconst isExcludedBorder =\n\t(borderDirection: string): CanSkipRule =>\n\t(value, property, { getStyle }) => {\n\t\tconst borderWidth = getStyle(`border-${borderDirection}-width`)\n\t\tconst borderStyle = getStyle(`border-${borderDirection}-style`)\n\n\t\tif (borderWidth === '0px') return true\n\t\tif (borderStyle === 'none') return true\n\t\treturn false\n\t}\n\nexport const cssRules = {\n\t// currentColor properties:\n\t'border-block-end-color': isCoveredByCurrentColor,\n\t'border-block-start-color': isCoveredByCurrentColor,\n\t'border-bottom-color': isCoveredByCurrentColor,\n\t'border-inline-end-color': isCoveredByCurrentColor,\n\t'border-inline-start-color': isCoveredByCurrentColor,\n\t'border-left-color': isCoveredByCurrentColor,\n\t'border-right-color': isCoveredByCurrentColor,\n\t'border-top-color': isCoveredByCurrentColor,\n\t'caret-color': isCoveredByCurrentColor,\n\t'column-rule-color': isCoveredByCurrentColor,\n\t'outline-color': isCoveredByCurrentColor,\n\t'text-decoration': (value, property, { currentColor }) => {\n\t\treturn value === 'none solid currentColor' || value === 'none solid ' + currentColor\n\t},\n\t'text-decoration-color': isCoveredByCurrentColor,\n\t'text-emphasis-color': isCoveredByCurrentColor,\n\n\t// inherited properties:\n\t'border-collapse': isInherited,\n\t'border-spacing': isInherited,\n\t'caption-side': isInherited,\n\t// N.B. We shouldn't inherit 'color' because there's some UA styling, e.g. `mark` elements\n\t// 'color': isInherited,\n\tcursor: isInherited,\n\tdirection: isInherited,\n\t'empty-cells': isInherited,\n\t'font-family': isInherited,\n\t'font-size': isInherited,\n\t'font-style': isInherited,\n\t'font-variant': isInherited,\n\t'font-weight': isInherited,\n\t'font-size-adjust': isInherited,\n\t'font-stretch': isInherited,\n\tfont: isInherited,\n\t'letter-spacing': isInherited,\n\t'line-height': isInherited,\n\t'list-style-image': isInherited,\n\t'list-style-position': isInherited,\n\t'list-style-type': isInherited,\n\t'list-style': isInherited,\n\torphans: isInherited,\n\t'overflow-wrap': isInherited,\n\tquotes: isInherited,\n\t'stroke-linecap': isInherited,\n\t'stroke-linejoin': isInherited,\n\t'tab-size': isInherited,\n\t'text-align': isInherited,\n\t'text-align-last': isInherited,\n\t'text-indent': isInherited,\n\t'text-justify': isInherited,\n\t'text-shadow': isInherited,\n\t'text-transform': isInherited,\n\tvisibility: isInherited,\n\t'white-space': isInherited,\n\t'white-space-collapse': isInherited,\n\twidows: isInherited,\n\t'word-break': isInherited,\n\t'word-spacing': isInherited,\n\t'word-wrap': isInherited,\n\n\t// special border cases - we have a weird case (tailwind seems to trigger this) where all\n\t// border-styles sometimes get set to 'solid', but the border-width is 0 so they don't render.\n\t// but in SVGs, **sometimes**, the border-width defaults (i think from a UA style-sheet? but\n\t// honestly can't tell) to 1.5px so the border displays. we work around this by only including\n\t// border styles at all if both the border-width and border-style are set to something that\n\t// would show a border.\n\t'border-top': isExcludedBorder('top'),\n\t'border-right': isExcludedBorder('right'),\n\t'border-bottom': isExcludedBorder('bottom'),\n\t'border-left': isExcludedBorder('left'),\n\t'border-block-end': isExcludedBorder('block-end'),\n\t'border-block-start': isExcludedBorder('block-start'),\n\t'border-inline-end': isExcludedBorder('inline-end'),\n\t'border-inline-start': isExcludedBorder('inline-start'),\n\t'border-top-style': isExcludedBorder('top'),\n\t'border-right-style': isExcludedBorder('right'),\n\t'border-bottom-style': isExcludedBorder('bottom'),\n\t'border-left-style': isExcludedBorder('left'),\n\t'border-block-end-style': isExcludedBorder('block-end'),\n\t'border-block-start-style': isExcludedBorder('block-start'),\n\t'border-inline-end-style': isExcludedBorder('inline-end'),\n\t'border-inline-start-style': isExcludedBorder('inline-start'),\n\t'border-top-width': isExcludedBorder('top'),\n\t'border-right-width': isExcludedBorder('right'),\n\t'border-bottom-width': isExcludedBorder('bottom'),\n\t'border-left-width': isExcludedBorder('left'),\n\t'border-block-end-width': isExcludedBorder('block-end'),\n\t'border-block-start-width': isExcludedBorder('block-start'),\n\t'border-inline-end-width': isExcludedBorder('inline-end'),\n} satisfies Record<string, CanSkipRule>\n"],
5
- "mappings": "AAcA,MAAM,0BAAuC,CAAC,OAAO,UAAU,EAAE,aAAa,MAAM;AACnF,SAAO,UAAU,kBAAkB,UAAU;AAC9C;AAEA,MAAM,cAA2B,CAAC,OAAO,UAAU,EAAE,aAAa,MAAM;AACvE,SAAO,aAAa,QAAQ,MAAM;AACnC;AAGA,MAAM,mBACL,CAAC,oBACD,CAAC,OAAO,UAAU,EAAE,SAAS,MAAM;AAClC,QAAM,cAAc,SAAS,UAAU,eAAe,QAAQ;AAC9D,QAAM,cAAc,SAAS,UAAU,eAAe,QAAQ;AAE9D,MAAI,gBAAgB,MAAO,QAAO;AAClC,MAAI,gBAAgB,OAAQ,QAAO;AACnC,SAAO;AACR;AAEM,MAAM,WAAW;AAAA;AAAA,EAEvB,0BAA0B;AAAA,EAC1B,4BAA4B;AAAA,EAC5B,uBAAuB;AAAA,EACv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ACtC,oBAAoB,iBAAiB,WAAW;AAAA,EAChD,sBAAsB,iBAAiB,aAAa;AAAA,EACpD,qBAAqB,iBAAiB,YAAY;AAAA,EAClD,uBAAuB,iBAAiB,cAAc;AAAA,EACtD,oBAAoB,iBAAiB,KAAK;AAAA,EAC1C,sBAAsB,iBAAiB,OAAO;AAAA,EAC9C,uBAAuB,iBAAiB,QAAQ;AAAA,EAChD,qBAAqB,iBAAiB,MAAM;AAAA,EAC5C,0BAA0B,iBAAiB,WAAW;AAAA,EACtD,4BAA4B,iBAAiB,aAAa;AAAA,EAC1D,2BAA2B,iBAAiB,YAAY;AAAA,EACxD,6BAA6B,iBAAiB,cAAc;AAAA,EAC5D,oBAAoB,iBAAiB,KAAK;AAAA,EAC1C,sBAAsB,iBAAiB,OAAO;AAAA,EAC9C,uBAAuB,iBAAiB,QAAQ;AAAA,EAChD,qBAAqB,iBAAiB,MAAM;AAAA,EAC5C,0BAA0B,iBAAiB,WAAW;AAAA,EACtD,4BAA4B,iBAAiB,aAAa;AAAA,EAC1D,2BAA2B,iBAAiB,YAAY;AACzD;",
6
- "names": []
7
- }
@@ -1,126 +0,0 @@
1
- export type Styles = { [K in string]?: string }
2
- export type ReadonlyStyles = { readonly [K in string]?: string }
3
-
4
- type CanSkipRule = (
5
- value: string,
6
- property: string,
7
- options: {
8
- getStyle(property: string): string
9
- parentStyles: ReadonlyStyles
10
- defaultStyles: ReadonlyStyles
11
- currentColor: string
12
- }
13
- ) => boolean
14
-
15
- const isCoveredByCurrentColor: CanSkipRule = (value, property, { currentColor }) => {
16
- return value === 'currentColor' || value === currentColor
17
- }
18
-
19
- const isInherited: CanSkipRule = (value, property, { parentStyles }) => {
20
- return parentStyles[property] === value
21
- }
22
-
23
- // see comment below about why we exclude border styles
24
- const isExcludedBorder =
25
- (borderDirection: string): CanSkipRule =>
26
- (value, property, { getStyle }) => {
27
- const borderWidth = getStyle(`border-${borderDirection}-width`)
28
- const borderStyle = getStyle(`border-${borderDirection}-style`)
29
-
30
- if (borderWidth === '0px') return true
31
- if (borderStyle === 'none') return true
32
- return false
33
- }
34
-
35
- export const cssRules = {
36
- // currentColor properties:
37
- 'border-block-end-color': isCoveredByCurrentColor,
38
- 'border-block-start-color': isCoveredByCurrentColor,
39
- 'border-bottom-color': isCoveredByCurrentColor,
40
- 'border-inline-end-color': isCoveredByCurrentColor,
41
- 'border-inline-start-color': isCoveredByCurrentColor,
42
- 'border-left-color': isCoveredByCurrentColor,
43
- 'border-right-color': isCoveredByCurrentColor,
44
- 'border-top-color': isCoveredByCurrentColor,
45
- 'caret-color': isCoveredByCurrentColor,
46
- 'column-rule-color': isCoveredByCurrentColor,
47
- 'outline-color': isCoveredByCurrentColor,
48
- 'text-decoration': (value, property, { currentColor }) => {
49
- return value === 'none solid currentColor' || value === 'none solid ' + currentColor
50
- },
51
- 'text-decoration-color': isCoveredByCurrentColor,
52
- 'text-emphasis-color': isCoveredByCurrentColor,
53
-
54
- // inherited properties:
55
- 'border-collapse': isInherited,
56
- 'border-spacing': isInherited,
57
- 'caption-side': isInherited,
58
- // N.B. We shouldn't inherit 'color' because there's some UA styling, e.g. `mark` elements
59
- // 'color': isInherited,
60
- cursor: isInherited,
61
- direction: isInherited,
62
- 'empty-cells': isInherited,
63
- 'font-family': isInherited,
64
- 'font-size': isInherited,
65
- 'font-style': isInherited,
66
- 'font-variant': isInherited,
67
- 'font-weight': isInherited,
68
- 'font-size-adjust': isInherited,
69
- 'font-stretch': isInherited,
70
- font: isInherited,
71
- 'letter-spacing': isInherited,
72
- 'line-height': isInherited,
73
- 'list-style-image': isInherited,
74
- 'list-style-position': isInherited,
75
- 'list-style-type': isInherited,
76
- 'list-style': isInherited,
77
- orphans: isInherited,
78
- 'overflow-wrap': isInherited,
79
- quotes: isInherited,
80
- 'stroke-linecap': isInherited,
81
- 'stroke-linejoin': isInherited,
82
- 'tab-size': isInherited,
83
- 'text-align': isInherited,
84
- 'text-align-last': isInherited,
85
- 'text-indent': isInherited,
86
- 'text-justify': isInherited,
87
- 'text-shadow': isInherited,
88
- 'text-transform': isInherited,
89
- visibility: isInherited,
90
- 'white-space': isInherited,
91
- 'white-space-collapse': isInherited,
92
- widows: isInherited,
93
- 'word-break': isInherited,
94
- 'word-spacing': isInherited,
95
- 'word-wrap': isInherited,
96
-
97
- // special border cases - we have a weird case (tailwind seems to trigger this) where all
98
- // border-styles sometimes get set to 'solid', but the border-width is 0 so they don't render.
99
- // but in SVGs, **sometimes**, the border-width defaults (i think from a UA style-sheet? but
100
- // honestly can't tell) to 1.5px so the border displays. we work around this by only including
101
- // border styles at all if both the border-width and border-style are set to something that
102
- // would show a border.
103
- 'border-top': isExcludedBorder('top'),
104
- 'border-right': isExcludedBorder('right'),
105
- 'border-bottom': isExcludedBorder('bottom'),
106
- 'border-left': isExcludedBorder('left'),
107
- 'border-block-end': isExcludedBorder('block-end'),
108
- 'border-block-start': isExcludedBorder('block-start'),
109
- 'border-inline-end': isExcludedBorder('inline-end'),
110
- 'border-inline-start': isExcludedBorder('inline-start'),
111
- 'border-top-style': isExcludedBorder('top'),
112
- 'border-right-style': isExcludedBorder('right'),
113
- 'border-bottom-style': isExcludedBorder('bottom'),
114
- 'border-left-style': isExcludedBorder('left'),
115
- 'border-block-end-style': isExcludedBorder('block-end'),
116
- 'border-block-start-style': isExcludedBorder('block-start'),
117
- 'border-inline-end-style': isExcludedBorder('inline-end'),
118
- 'border-inline-start-style': isExcludedBorder('inline-start'),
119
- 'border-top-width': isExcludedBorder('top'),
120
- 'border-right-width': isExcludedBorder('right'),
121
- 'border-bottom-width': isExcludedBorder('bottom'),
122
- 'border-left-width': isExcludedBorder('left'),
123
- 'border-block-end-width': isExcludedBorder('block-end'),
124
- 'border-block-start-width': isExcludedBorder('block-start'),
125
- 'border-inline-end-width': isExcludedBorder('inline-end'),
126
- } satisfies Record<string, CanSkipRule>