@fremtind/jokul 5.0.0-next.8 → 5.0.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/build/build-stats.html +1 -1
- package/build/cjs/components/autosuggest/BaseAutosuggest.cjs +1 -1
- package/build/cjs/components/autosuggest/BaseAutosuggest.cjs.map +1 -1
- package/build/cjs/components/expander/Accordion.cjs +2 -0
- package/build/cjs/components/expander/Accordion.cjs.map +1 -0
- package/build/cjs/components/expander/Accordion.d.cts +2 -0
- package/build/cjs/components/expander/ExpandablePanel.cjs +1 -1
- package/build/cjs/components/expander/ExpandablePanel.cjs.map +1 -1
- package/build/cjs/components/expander/ExpandablePanelContent.cjs +1 -1
- package/build/cjs/components/expander/ExpandablePanelContent.cjs.map +1 -1
- package/build/cjs/components/expander/Expander.cjs +1 -1
- package/build/cjs/components/expander/Expander.cjs.map +1 -1
- package/build/cjs/components/expander/index.d.cts +1 -1
- package/build/cjs/components/expander/types.d.cts +5 -2
- package/build/cjs/components/icon/Icon.cjs +1 -1
- package/build/cjs/components/icon/Icon.cjs.map +1 -1
- package/build/cjs/components/icon/Icon.d.cts +2 -2
- package/build/cjs/components/icon/icons/GreenCheckIcon.cjs +1 -1
- package/build/cjs/components/icon/icons/GreenCheckIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/GreenCheckIcon.d.cts +2 -3
- package/build/cjs/components/icon/icons/RedCrossIcon.cjs +1 -1
- package/build/cjs/components/icon/icons/RedCrossIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/RedCrossIcon.d.cts +2 -3
- package/build/cjs/components/link-list/LinkList.cjs +1 -1
- package/build/cjs/components/link-list/LinkList.cjs.map +1 -1
- package/build/cjs/components/link-list/LinkList.d.cts +1 -1
- package/build/cjs/components/link-list/types.d.cts +1 -0
- package/build/cjs/components/number-input/NumberInput.cjs +2 -0
- package/build/cjs/components/number-input/NumberInput.cjs.map +1 -0
- package/build/cjs/components/number-input/NumberInput.d.cts +7 -0
- package/build/cjs/components/number-input/index.cjs +2 -0
- package/build/cjs/components/number-input/index.cjs.map +1 -0
- package/build/cjs/components/number-input/index.d.cts +2 -0
- package/build/cjs/components/number-input/types.cjs +2 -0
- package/build/cjs/components/number-input/types.cjs.map +1 -0
- package/build/cjs/components/number-input/types.d.cts +20 -0
- package/build/cjs/components/popover/Popover.cjs +1 -1
- package/build/cjs/components/popover/Popover.cjs.map +1 -1
- package/build/cjs/components/popover/types.d.cts +8 -1
- package/build/cjs/components/select/Select.cjs +1 -1
- package/build/cjs/components/select/Select.cjs.map +1 -1
- package/build/cjs/components/system-message/types.d.cts +7 -2
- package/build/cjs/hooks/useListNavigation/useListNavigation.cjs +1 -1
- package/build/cjs/hooks/useListNavigation/useListNavigation.cjs.map +1 -1
- package/build/cjs/hooks/useListNavigation/useListNavigation.d.cts +11 -2
- package/build/cjs/tokens.cjs +1 -1
- package/build/cjs/tokens.cjs.map +1 -1
- package/build/cjs/utilities/index.cjs +1 -1
- package/build/cjs/utilities/types.cjs +1 -1
- package/build/cjs/utilities/types.cjs.map +1 -1
- package/build/cjs/utilities/types.d.cts +2 -0
- package/build/es/components/autosuggest/BaseAutosuggest.js +1 -1
- package/build/es/components/autosuggest/BaseAutosuggest.js.map +1 -1
- package/build/es/components/datepicker/DatePicker.js +1 -1
- package/build/es/components/datepicker/internal/Calendar.js +1 -1
- package/build/es/components/datepicker/internal/useCalendar.js +1 -1
- package/build/es/components/datepicker/internal/utils.js +1 -1
- package/build/es/components/expander/Accordion.d.ts +2 -0
- package/build/es/components/expander/Accordion.js +2 -0
- package/build/es/components/expander/Accordion.js.map +1 -0
- package/build/es/components/expander/ExpandablePanel.js +1 -1
- package/build/es/components/expander/ExpandablePanel.js.map +1 -1
- package/build/es/components/expander/ExpandablePanelContent.js +1 -1
- package/build/es/components/expander/ExpandablePanelContent.js.map +1 -1
- package/build/es/components/expander/Expander.js +1 -1
- package/build/es/components/expander/Expander.js.map +1 -1
- package/build/es/components/expander/index.d.ts +1 -1
- package/build/es/components/expander/types.d.ts +5 -2
- package/build/es/components/icon/Icon.d.ts +2 -2
- package/build/es/components/icon/Icon.js +1 -1
- package/build/es/components/icon/Icon.js.map +1 -1
- package/build/es/components/icon/icons/GreenCheckIcon.d.ts +2 -3
- package/build/es/components/icon/icons/GreenCheckIcon.js +1 -1
- package/build/es/components/icon/icons/GreenCheckIcon.js.map +1 -1
- package/build/es/components/icon/icons/RedCrossIcon.d.ts +2 -3
- package/build/es/components/icon/icons/RedCrossIcon.js +1 -1
- package/build/es/components/icon/icons/RedCrossIcon.js.map +1 -1
- package/build/es/components/link-list/LinkList.d.ts +1 -1
- package/build/es/components/link-list/LinkList.js +1 -1
- package/build/es/components/link-list/LinkList.js.map +1 -1
- package/build/es/components/link-list/types.d.ts +1 -0
- package/build/es/components/menu/Menu.js +1 -1
- package/build/es/components/number-input/NumberInput.d.ts +7 -0
- package/build/es/components/number-input/NumberInput.js +2 -0
- package/build/es/components/number-input/NumberInput.js.map +1 -0
- package/build/es/components/number-input/index.d.ts +2 -0
- package/build/es/components/number-input/index.js +2 -0
- package/build/es/components/number-input/index.js.map +1 -0
- package/build/es/components/number-input/types.d.ts +20 -0
- package/build/es/components/number-input/types.js +2 -0
- package/build/es/components/number-input/types.js.map +1 -0
- package/build/es/components/popover/Popover.js +1 -1
- package/build/es/components/popover/Popover.js.map +1 -1
- package/build/es/components/popover/types.d.ts +8 -1
- package/build/es/components/select/Select.js +1 -1
- package/build/es/components/select/Select.js.map +1 -1
- package/build/es/components/system-message/types.d.ts +7 -2
- package/build/es/components/toast/toastContext.js +1 -1
- package/build/es/components/tooltip/Tooltip.js +1 -1
- package/build/es/hooks/stories/content.js +1 -1
- package/build/es/hooks/useListNavigation/useListNavigation.d.ts +11 -2
- package/build/es/hooks/useListNavigation/useListNavigation.js +1 -1
- package/build/es/hooks/useListNavigation/useListNavigation.js.map +1 -1
- package/build/es/tokens.js +1 -1
- package/build/es/tokens.js.map +1 -1
- package/build/es/utilities/constants/index.js +1 -1
- package/build/es/utilities/constants/unicode.js +1 -1
- package/build/es/utilities/formatters/bytes/formatBytes.js +1 -1
- package/build/es/utilities/formatters/fodselsnummer/formatFodselsnummer.js +1 -1
- package/build/es/utilities/formatters/kontonummer/formatKontonummer.js +1 -1
- package/build/es/utilities/formatters/kortnummer/formatKortnummer.js +1 -1
- package/build/es/utilities/formatters/organisasjonsnummer/formatOrganisasjonsnummer.js +1 -1
- package/build/es/utilities/formatters/telefonnummer/formatTelefonnummer.js +1 -1
- package/build/es/utilities/formatters/valuta/formatValuta.js +1 -1
- package/build/es/utilities/index.js +1 -1
- package/build/es/utilities/types.d.ts +2 -0
- package/build/es/utilities/types.js +1 -1
- package/build/es/utilities/types.js.map +1 -1
- package/build/{index-CWRMnfcx.js → index-C1iqmqvT.js} +2 -2
- package/build/{index-CWRMnfcx.js.map → index-C1iqmqvT.js.map} +1 -1
- package/build/{utils-CcE6HjQp.js → utils-CtwpNW4I.js} +2 -2
- package/build/{utils-CcE6HjQp.js.map → utils-CtwpNW4I.js.map} +1 -1
- package/codemods/CODEMODS.md +133 -0
- package/codemods/__tests__/import-paths.test.mjs +568 -94
- package/codemods/import-paths.mjs +34 -339
- package/codemods/transforms/color-tokens.mjs +102 -0
- package/codemods/transforms/expandable-panel.mjs +41 -0
- package/codemods/transforms/font-family.mjs +23 -0
- package/codemods/transforms/import-specifiers.mjs +226 -0
- package/codemods/transforms/warnings.mjs +41 -0
- package/codemods/utils.mjs +35 -0
- package/package.json +8 -4
- package/styles/base.css +180 -805
- package/styles/base.min.css +1 -1
- package/styles/components/autosuggest/autosuggest.css +4 -3
- package/styles/components/autosuggest/autosuggest.min.css +1 -1
- package/styles/components/autosuggest/autosuggest.scss +4 -3
- package/styles/components/button/button.css +9 -3
- package/styles/components/button/button.min.css +1 -1
- package/styles/components/button/button.scss +10 -3
- package/styles/components/checkbox/checkbox.css +1 -1
- package/styles/components/checkbox/checkbox.min.css +1 -1
- package/styles/components/checkbox/checkbox.scss +1 -1
- package/styles/components/checkbox-panel/checkbox-panel.css +1 -1
- package/styles/components/checkbox-panel/checkbox-panel.min.css +1 -1
- package/styles/components/combobox/combobox.css +4 -4
- package/styles/components/combobox/combobox.min.css +1 -1
- package/styles/components/combobox/combobox.scss +4 -4
- package/styles/components/countdown/countdown.css +2 -2
- package/styles/components/countdown/countdown.min.css +1 -1
- package/styles/components/expander/_index.scss +1 -0
- package/styles/components/expander/accordion.css +21 -0
- package/styles/components/expander/accordion.min.css +1 -0
- package/styles/components/expander/accordion.scss +24 -0
- package/styles/components/expander/expandable.css +32 -37
- package/styles/components/expander/expandable.min.css +1 -1
- package/styles/components/expander/expandable.scss +27 -36
- package/styles/components/feedback/feedback.css +2 -2
- package/styles/components/feedback/feedback.min.css +1 -1
- package/styles/components/feedback/feedback.scss +0 -1
- package/styles/components/file/file.css +1 -1
- package/styles/components/file/file.min.css +1 -1
- package/styles/components/file/file.scss +1 -1
- package/styles/components/file-input/file-input.css +19 -13
- package/styles/components/file-input/file-input.min.css +1 -1
- package/styles/components/icon/icon.scss +1 -1
- package/styles/components/input-group/input-group.css +2 -2
- package/styles/components/input-group/input-group.min.css +1 -1
- package/styles/components/link-list/link-list.css +7 -2
- package/styles/components/link-list/link-list.min.css +1 -1
- package/styles/components/link-list/link-list.scss +10 -3
- package/styles/components/list/list.css +33 -21
- package/styles/components/list/list.min.css +1 -1
- package/styles/components/list/list.scss +24 -24
- package/styles/components/loader/loader.css +6 -6
- package/styles/components/loader/loader.min.css +1 -1
- package/styles/components/loader/skeleton-loader.css +3 -3
- package/styles/components/loader/skeleton-loader.min.css +1 -1
- package/styles/components/menu/_menu-item.scss +1 -1
- package/styles/components/menu/menu.css +1 -1
- package/styles/components/menu/menu.min.css +1 -1
- package/styles/components/message/message.css +9 -9
- package/styles/components/message/message.min.css +1 -1
- package/styles/components/message/message.scss +7 -7
- package/styles/components/modal/_index.scss +7 -0
- package/styles/components/modal/_overlay.scss +4 -0
- package/styles/components/modal/modal.css +32 -116
- package/styles/components/modal/modal.min.css +1 -1
- package/styles/components/modal/modal.scss +96 -6
- package/styles/components/number-input/_index.scss +2 -0
- package/styles/components/number-input/number-input.css +214 -0
- package/styles/components/number-input/number-input.min.css +1 -0
- package/styles/components/number-input/number-input.scss +115 -0
- package/styles/components/progress-bar/progress-bar.css +1 -1
- package/styles/components/progress-bar/progress-bar.min.css +1 -1
- package/styles/components/radio-button/radio-button.css +1 -5
- package/styles/components/radio-button/radio-button.min.css +1 -1
- package/styles/components/radio-button/radio-button.scss +2 -7
- package/styles/components/segmented-control/segmented-control.css +3 -7
- package/styles/components/segmented-control/segmented-control.min.css +1 -1
- package/styles/components/select/select.css +65 -7
- package/styles/components/select/select.min.css +1 -1
- package/styles/components/select/select.scss +129 -18
- package/styles/components/system-message/system-message.css +9 -13
- package/styles/components/system-message/system-message.min.css +1 -1
- package/styles/components/system-message/system-message.scss +116 -123
- package/styles/components/tag/tag.css +4 -4
- package/styles/components/tag/tag.min.css +1 -1
- package/styles/components/tag/tag.scss +4 -4
- package/styles/components/toast/toast.css +4 -4
- package/styles/components/toast/toast.min.css +1 -1
- package/styles/components/typography/text.scss +2 -2
- package/styles/components/typography/title.scss +1 -1
- package/styles/components.css +524 -130
- package/styles/components.min.css +1 -1
- package/styles/components.scss +2 -1
- package/styles/jkl/_convert.scss +15 -6
- package/styles/jkl/_tokens.scss +4 -4
- package/styles/tailwind.css +97 -97
- package/styles/theme/_color-scheme.scss +95 -95
- package/styles/theme/_dynamic-spacing.scss +21 -15
- package/styles/theme/_fonts.scss +3 -12
- package/styles/theme/_index.scss +0 -4
- package/styles/theme/_size.scss +20 -20
- package/styles/theme/_tokens.scss +11 -11
- package/styles/core/utility/_paragraphs.scss +0 -39
- package/styles/theme/brands/dnb/_color-scheme.scss +0 -121
- package/styles/theme/brands/dnb/_fonts.scss +0 -46
- package/styles/theme/brands/dnb/_index.scss +0 -2
- package/styles/theme/brands/eika/_color-scheme.scss +0 -121
- package/styles/theme/brands/eika/_fonts.scss +0 -46
- package/styles/theme/brands/eika/_index.scss +0 -2
- package/styles/theme/brands/fremtind/_color-scheme.scss +0 -121
- package/styles/theme/brands/fremtind/_fonts.scss +0 -30
- package/styles/theme/brands/fremtind/_index.scss +0 -2
- package/styles/theme/brands/sparebank1/_color-scheme.scss +0 -121
- package/styles/theme/brands/sparebank1/_fonts.scss +0 -38
- package/styles/theme/brands/sparebank1/_index.scss +0 -2
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readFile, readdir, stat, writeFile } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
|
+
import {
|
|
5
|
+
applyCssTokenRenames,
|
|
6
|
+
applyTailwindColorRenames,
|
|
7
|
+
} from "./transforms/color-tokens.mjs";
|
|
8
|
+
import { applyExpandablePanelTransforms } from "./transforms/expandable-panel.mjs";
|
|
9
|
+
import { applyFontFamilyReplacements } from "./transforms/font-family.mjs";
|
|
10
|
+
import {
|
|
11
|
+
BASE_OR_COMPONENT_CSS_PATTERN,
|
|
12
|
+
applyBetaStyleReplacements,
|
|
13
|
+
applyDirectReplacements,
|
|
14
|
+
removeRedundantWebfontsCssImport,
|
|
15
|
+
reorderConfiguredFontImport,
|
|
16
|
+
} from "./transforms/import-specifiers.mjs";
|
|
17
|
+
import { collectManualMigrationWarnings } from "./transforms/warnings.mjs";
|
|
18
|
+
|
|
4
19
|
const TEXT_EXTENSIONS = new Set([
|
|
5
20
|
".cjs",
|
|
6
21
|
".css",
|
|
@@ -38,116 +53,8 @@ const IGNORED_FILE_PATTERNS = [
|
|
|
38
53
|
"/packages/jokul/codemods/",
|
|
39
54
|
];
|
|
40
55
|
|
|
41
|
-
const DIRECT_REPLACEMENTS = [
|
|
42
|
-
[
|
|
43
|
-
"@fremtind/jokul/styles/core/core.min.css",
|
|
44
|
-
"@fremtind/jokul/styles/base.min.css",
|
|
45
|
-
],
|
|
46
|
-
[
|
|
47
|
-
"@fremtind/jokul/styles/core/core.css",
|
|
48
|
-
"@fremtind/jokul/styles/base.css",
|
|
49
|
-
],
|
|
50
|
-
[
|
|
51
|
-
"@fremtind/jokul/styles/core/core.scss",
|
|
52
|
-
"@fremtind/jokul/styles/base.scss",
|
|
53
|
-
],
|
|
54
|
-
["@fremtind/jokul/styles/core/core", "@fremtind/jokul/styles/base"],
|
|
55
|
-
[
|
|
56
|
-
"@fremtind/jokul/styles/styles.min.css",
|
|
57
|
-
"@fremtind/jokul/styles/components.min.css",
|
|
58
|
-
],
|
|
59
|
-
["@fremtind/jokul/styles/styles.css", "@fremtind/jokul/styles/components.css"],
|
|
60
|
-
[
|
|
61
|
-
"@fremtind/jokul/styles/styles.scss",
|
|
62
|
-
"@fremtind/jokul/styles/components.scss",
|
|
63
|
-
],
|
|
64
|
-
["@fremtind/jokul/styles/styles", "@fremtind/jokul/styles/components"],
|
|
65
|
-
[
|
|
66
|
-
"@fremtind/jokul/styles/core/jkl/index",
|
|
67
|
-
"@fremtind/jokul/styles/jkl",
|
|
68
|
-
],
|
|
69
|
-
["@fremtind/jokul/styles/core/jkl", "@fremtind/jokul/styles/jkl"],
|
|
70
|
-
[
|
|
71
|
-
"@fremtind/jokul/styles/fonts/webfonts.scss",
|
|
72
|
-
"@fremtind/jokul/styles/theme/fonts",
|
|
73
|
-
],
|
|
74
|
-
[
|
|
75
|
-
"@fremtind/jokul/styles/fonts/webfonts",
|
|
76
|
-
"@fremtind/jokul/styles/theme/fonts",
|
|
77
|
-
],
|
|
78
|
-
["@fremtind/jokul/styles/fonts", "@fremtind/jokul/styles/theme/fonts"],
|
|
79
|
-
["../../../core/jkl/index", "../../../styles/jkl"],
|
|
80
|
-
["../../../core/jkl", "../../../styles/jkl"],
|
|
81
|
-
["../../core/jkl/index", "../../styles/jkl"],
|
|
82
|
-
["../../core/jkl", "../../styles/jkl"],
|
|
83
|
-
["../core/jkl/index", "../styles/jkl"],
|
|
84
|
-
["../core/jkl", "../styles/jkl"],
|
|
85
|
-
["@fremtind/jokul/tailwind/v4", "@fremtind/jokul/styles/tailwind"],
|
|
86
|
-
["@fremtind/jokul/styles/core", "@fremtind/jokul/styles/base.scss"],
|
|
87
|
-
["@fremtind/jokul/styles", "@fremtind/jokul/styles/components.scss"],
|
|
88
|
-
["@fremtind/jokul/core", "@fremtind/jokul/utilities"],
|
|
89
|
-
].sort(([a], [b]) => b.length - a.length);
|
|
90
|
-
|
|
91
|
-
const BETA_STYLE_MIGRATIONS = [
|
|
92
|
-
{
|
|
93
|
-
component: "DescriptionList",
|
|
94
|
-
betaIdentifiers: ["BETA_DescriptionList", "BETA_DescriptionListItem"],
|
|
95
|
-
replacements: [
|
|
96
|
-
[
|
|
97
|
-
"@fremtind/jokul/styles/components/description-list/_index.scss",
|
|
98
|
-
"@fremtind/jokul/styles/components/beta/description-list/_index.scss",
|
|
99
|
-
],
|
|
100
|
-
[
|
|
101
|
-
"@fremtind/jokul/styles/components/description-list/description-list.scss",
|
|
102
|
-
"@fremtind/jokul/styles/components/beta/description-list/description-list.scss",
|
|
103
|
-
],
|
|
104
|
-
[
|
|
105
|
-
"@fremtind/jokul/styles/components/description-list",
|
|
106
|
-
"@fremtind/jokul/styles/components/beta/description-list",
|
|
107
|
-
],
|
|
108
|
-
],
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
component: "NavLink",
|
|
112
|
-
betaIdentifiers: ["BETA_NavLink"],
|
|
113
|
-
replacements: [
|
|
114
|
-
[
|
|
115
|
-
"@fremtind/jokul/styles/components/nav-link/_index.scss",
|
|
116
|
-
"@fremtind/jokul/styles/components/beta/nav-link/_index.scss",
|
|
117
|
-
],
|
|
118
|
-
[
|
|
119
|
-
"@fremtind/jokul/styles/components/nav-link/nav-link.scss",
|
|
120
|
-
"@fremtind/jokul/styles/components/beta/nav-link/navlink.scss",
|
|
121
|
-
],
|
|
122
|
-
[
|
|
123
|
-
"@fremtind/jokul/styles/components/nav-link",
|
|
124
|
-
"@fremtind/jokul/styles/components/beta/nav-link",
|
|
125
|
-
],
|
|
126
|
-
],
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
component: "Select",
|
|
130
|
-
betaIdentifiers: ["BETA_Select"],
|
|
131
|
-
replacements: [
|
|
132
|
-
[
|
|
133
|
-
"@fremtind/jokul/styles/components/select/_index.scss",
|
|
134
|
-
"@fremtind/jokul/styles/components/beta/select/_index.scss",
|
|
135
|
-
],
|
|
136
|
-
[
|
|
137
|
-
"@fremtind/jokul/styles/components/select/select.scss",
|
|
138
|
-
"@fremtind/jokul/styles/components/beta/select/select.scss",
|
|
139
|
-
],
|
|
140
|
-
[
|
|
141
|
-
"@fremtind/jokul/styles/components/select",
|
|
142
|
-
"@fremtind/jokul/styles/components/beta/select",
|
|
143
|
-
],
|
|
144
|
-
],
|
|
145
|
-
},
|
|
146
|
-
];
|
|
147
|
-
|
|
148
56
|
function shouldIgnoreFile(filePath) {
|
|
149
57
|
const normalizedPath = filePath.split(path.sep).join("/");
|
|
150
|
-
|
|
151
58
|
return IGNORED_FILE_PATTERNS.some((pattern) =>
|
|
152
59
|
normalizedPath.includes(pattern),
|
|
153
60
|
);
|
|
@@ -157,225 +64,15 @@ function shouldIgnoreDirectory(directoryPath) {
|
|
|
157
64
|
return IGNORED_DIRECTORIES.has(path.basename(directoryPath));
|
|
158
65
|
}
|
|
159
66
|
|
|
160
|
-
function escapeRegExp(value) {
|
|
161
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function replaceSpecifier(text, from, to) {
|
|
165
|
-
const pattern = new RegExp(
|
|
166
|
-
`(?<![A-Za-z0-9_./-])${escapeRegExp(from)}(?![A-Za-z0-9_./-])`,
|
|
167
|
-
"g",
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
let count = 0;
|
|
171
|
-
const next = text.replace(pattern, () => {
|
|
172
|
-
count += 1;
|
|
173
|
-
return to;
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
return { text: next, count };
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function applyDirectReplacements(text) {
|
|
180
|
-
let next = text;
|
|
181
|
-
let replacements = 0;
|
|
182
|
-
|
|
183
|
-
for (const [from, to] of DIRECT_REPLACEMENTS) {
|
|
184
|
-
const result = replaceSpecifier(next, from, to);
|
|
185
|
-
next = result.text;
|
|
186
|
-
replacements += result.count;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return { text: next, replacements };
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function applyBetaStyleReplacements(text) {
|
|
193
|
-
let next = text;
|
|
194
|
-
let replacements = 0;
|
|
195
|
-
const warnings = [];
|
|
196
|
-
|
|
197
|
-
for (const migration of BETA_STYLE_MIGRATIONS) {
|
|
198
|
-
const mentionsBeta = migration.betaIdentifiers.some((identifier) =>
|
|
199
|
-
next.includes(identifier),
|
|
200
|
-
);
|
|
201
|
-
|
|
202
|
-
const hasOldSpecifier = migration.replacements.some(([from]) =>
|
|
203
|
-
new RegExp(
|
|
204
|
-
`(?<![A-Za-z0-9_./-])${escapeRegExp(from)}(?![A-Za-z0-9_./-])`,
|
|
205
|
-
).test(next),
|
|
206
|
-
);
|
|
207
|
-
|
|
208
|
-
if (!hasOldSpecifier) {
|
|
209
|
-
continue;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (!mentionsBeta) {
|
|
213
|
-
warnings.push(
|
|
214
|
-
`Manuell vurdering: gammel stilimport for ${migration.component} kan peke på enten stabil eller beta-variant.`,
|
|
215
|
-
);
|
|
216
|
-
continue;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
for (const [from, to] of migration.replacements) {
|
|
220
|
-
const result = replaceSpecifier(next, from, to);
|
|
221
|
-
next = result.text;
|
|
222
|
-
replacements += result.count;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
return { text: next, replacements, warnings };
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Font-family-navnet "Fremtind Material Symbols" (og tilhørende fallback) ble
|
|
231
|
-
* omdøpt til "Jokul Icons" i Jøkul 5. Konsumenter som har skrevet font-family
|
|
232
|
-
* direkte i sin egen CSS/SCSS får ellers en stille brutt referanse.
|
|
233
|
-
*
|
|
234
|
-
* Fallback-navnet erstattes først (lengst først), slik at det ikke blir
|
|
235
|
-
* delvis overskrevet av kortere mønster.
|
|
236
|
-
*/
|
|
237
|
-
const FONT_FAMILY_REPLACEMENTS = [
|
|
238
|
-
["Fremtind Material Symbols Fallback", "Jokul Icons Fallback"],
|
|
239
|
-
["Fremtind Material Symbols", "Jokul Icons"],
|
|
240
|
-
];
|
|
241
|
-
|
|
242
|
-
function applyFontFamilyReplacements(text) {
|
|
243
|
-
let next = text;
|
|
244
|
-
let count = 0;
|
|
245
|
-
|
|
246
|
-
for (const [from, to] of FONT_FAMILY_REPLACEMENTS) {
|
|
247
|
-
const pattern = new RegExp(escapeRegExp(from), "g");
|
|
248
|
-
next = next.replace(pattern, () => {
|
|
249
|
-
count += 1;
|
|
250
|
-
return to;
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
return { text: next, count };
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
const WEBFONTS_CSS_SPECIFIER =
|
|
258
|
-
"@fremtind/jokul/styles/fonts/webfonts(?:\\.min)?\\.css";
|
|
259
|
-
|
|
260
|
-
const BASE_OR_COMPONENT_CSS_PATTERN = new RegExp(
|
|
261
|
-
"@fremtind/jokul/styles/(?:base|components)(?:\\.min)?\\.css",
|
|
262
|
-
);
|
|
263
|
-
|
|
264
|
-
const WEBFONTS_CSS_REMOVAL_PATTERNS = [
|
|
265
|
-
// import "@fremtind/jokul/styles/fonts/webfonts.css"; (ESM)
|
|
266
|
-
new RegExp(
|
|
267
|
-
`^[ \\t]*import\\s+["']${WEBFONTS_CSS_SPECIFIER}["']\\s*;?[ \\t]*\\r?\\n?`,
|
|
268
|
-
"gm",
|
|
269
|
-
),
|
|
270
|
-
// require("@fremtind/jokul/styles/fonts/webfonts.css"); (CJS)
|
|
271
|
-
new RegExp(
|
|
272
|
-
`^[ \\t]*require\\(\\s*["']${WEBFONTS_CSS_SPECIFIER}["']\\s*\\)\\s*;?[ \\t]*\\r?\\n?`,
|
|
273
|
-
"gm",
|
|
274
|
-
),
|
|
275
|
-
// @import "@fremtind/jokul/styles/fonts/webfonts.css"; (CSS / SCSS)
|
|
276
|
-
new RegExp(
|
|
277
|
-
`^[ \\t]*@import\\s+["']${WEBFONTS_CSS_SPECIFIER}["']\\s*;?[ \\t]*\\r?\\n?`,
|
|
278
|
-
"gm",
|
|
279
|
-
),
|
|
280
|
-
];
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* I Jøkul 5 er `@font-face`-definisjonene flyttet inn i `styles/base.css`, og den
|
|
284
|
-
* frittstående `styles/fonts/webfonts.css` finnes ikke lenger i pakken. For
|
|
285
|
-
* .css-konsumenter betyr det at gamle `webfonts.css`-imports må fjernes – ellers
|
|
286
|
-
* blir bygget brutt fordi filen er borte. SCSS-konsumenter håndteres av
|
|
287
|
-
* `DIRECT_REPLACEMENTS` siden de kan ha behov for å overstyre `$webfonts-dir`.
|
|
288
|
-
*/
|
|
289
|
-
function removeRedundantWebfontsCssImport(text) {
|
|
290
|
-
let next = text;
|
|
291
|
-
let count = 0;
|
|
292
|
-
|
|
293
|
-
for (const pattern of WEBFONTS_CSS_REMOVAL_PATTERNS) {
|
|
294
|
-
next = next.replace(pattern, () => {
|
|
295
|
-
count += 1;
|
|
296
|
-
return "";
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
return { text: next, count };
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Patterns som ikke kan auto-erstattes, men som krever manuell migrering ved
|
|
305
|
-
* oppgradering fra Jøkul 4 til 5. Hvert mønster gir én advarsel per fil det
|
|
306
|
-
* matcher i (uavhengig av antall forekomster), med peker til hva man skal
|
|
307
|
-
* gjøre i stedet.
|
|
308
|
-
*/
|
|
309
|
-
const MANUAL_MIGRATION_WARNINGS = [
|
|
310
|
-
{
|
|
311
|
-
// jkl.$color-granitt, jkl.$color-varde, osv. Alle Sass-fargevariabler
|
|
312
|
-
// ble fjernet i Jøkul 5 til fordel for semantiske CSS-variabler.
|
|
313
|
-
pattern: /\bjkl\.\$color-[a-z][a-z0-9-]*/i,
|
|
314
|
-
message:
|
|
315
|
-
"Fjernede Sass-fargevariabler (jkl.$color-*). I Jøkul 5 er alle gamle fargenavn (granitt, varde, snohvit osv.) fjernet — bruk semantiske CSS-variabler, f.eks. var(--jkl-color-text-default). Se https://jokul-portal.intern.app.prodaws.fremtind.no/fundamenter/farger.",
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
// @include jkl.light-mode-variables { ... } / dark-mode-variables { ... }
|
|
319
|
-
pattern: /@include\s+jkl\.(?:light|dark)-mode-variables\b/,
|
|
320
|
-
message:
|
|
321
|
-
"Fjernede mixins for custom light/dark-farger (jkl.light-mode-variables / jkl.dark-mode-variables). I Jøkul 5 må du bruke semantiske CSS-variabler i stedet for å definere egne dark/light-varianter.",
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
// @include jkl.text-style("body") / text-style("small")
|
|
325
|
-
pattern: /\btext-style\(\s*["'](?:body|small)["']\s*\)/,
|
|
326
|
-
message:
|
|
327
|
-
'Fjernede tekststiler ("body", "small") i text-style-mixin. Foretrekk å bruke <Text>-komponenten der det er mulig (`import { Text } from "@fremtind/jokul/components/typography"`). Hvis du må sette stiler direkte, bytt til "paragraph-large/medium/small" eller "text-large/medium/small/micro" — se https://jokul-portal.intern.app.prodaws.fremtind.no/fundamenter/typografi.',
|
|
328
|
-
},
|
|
329
|
-
];
|
|
330
|
-
|
|
331
|
-
function collectManualMigrationWarnings(text) {
|
|
332
|
-
const warnings = [];
|
|
333
|
-
|
|
334
|
-
for (const { pattern, message } of MANUAL_MIGRATION_WARNINGS) {
|
|
335
|
-
if (pattern.test(text)) {
|
|
336
|
-
warnings.push(`Manuell vurdering: ${message}`);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
return warnings;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
function reorderConfiguredFontImport(text) {
|
|
344
|
-
const fontImportPattern =
|
|
345
|
-
/^@use\s+["']@fremtind\/jokul\/styles\/theme\/fonts["'][\s\S]*?;\s*/m;
|
|
346
|
-
const baseImportPattern =
|
|
347
|
-
/^@use\s+["']@fremtind\/jokul\/styles\/base(?:\.scss)?["'][^;]*;\s*/m;
|
|
348
|
-
|
|
349
|
-
const fontMatch = fontImportPattern.exec(text);
|
|
350
|
-
const baseMatch = baseImportPattern.exec(text);
|
|
351
|
-
|
|
352
|
-
if (!fontMatch || !baseMatch || fontMatch.index < baseMatch.index) {
|
|
353
|
-
return { text, reordered: false };
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
const withoutFontImport =
|
|
357
|
-
text.slice(0, fontMatch.index) +
|
|
358
|
-
text.slice(fontMatch.index + fontMatch[0].length);
|
|
359
|
-
const nextBaseMatch = baseImportPattern.exec(withoutFontImport);
|
|
360
|
-
|
|
361
|
-
if (!nextBaseMatch) {
|
|
362
|
-
return { text, reordered: false };
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
const nextText =
|
|
366
|
-
withoutFontImport.slice(0, nextBaseMatch.index) +
|
|
367
|
-
fontMatch[0] +
|
|
368
|
-
withoutFontImport.slice(nextBaseMatch.index);
|
|
369
|
-
|
|
370
|
-
return { text: nextText, reordered: true };
|
|
371
|
-
}
|
|
372
|
-
|
|
373
67
|
export function transformImportPaths(text, filePath = "") {
|
|
374
68
|
const webfontsRemoval = removeRedundantWebfontsCssImport(text);
|
|
375
69
|
const fontFamily = applyFontFamilyReplacements(webfontsRemoval.text);
|
|
376
70
|
const direct = applyDirectReplacements(fontFamily.text);
|
|
377
71
|
const beta = applyBetaStyleReplacements(direct.text);
|
|
378
|
-
|
|
72
|
+
const cssTokens = applyCssTokenRenames(beta.text);
|
|
73
|
+
const tailwindColors = applyTailwindColorRenames(cssTokens.text);
|
|
74
|
+
const expandablePanel = applyExpandablePanelTransforms(tailwindColors.text);
|
|
75
|
+
let next = expandablePanel.text;
|
|
379
76
|
let reordered = false;
|
|
380
77
|
|
|
381
78
|
if (/\.(sass|scss)$/i.test(filePath)) {
|
|
@@ -405,7 +102,10 @@ export function transformImportPaths(text, filePath = "") {
|
|
|
405
102
|
direct.replacements +
|
|
406
103
|
beta.replacements +
|
|
407
104
|
webfontsRemoval.count +
|
|
408
|
-
fontFamily.count
|
|
105
|
+
fontFamily.count +
|
|
106
|
+
cssTokens.count +
|
|
107
|
+
tailwindColors.count +
|
|
108
|
+
expandablePanel.count,
|
|
409
109
|
warnings,
|
|
410
110
|
reordered,
|
|
411
111
|
};
|
|
@@ -428,14 +128,16 @@ async function collectFiles(targetPath, collected) {
|
|
|
428
128
|
if (entry.isDirectory() && IGNORED_DIRECTORIES.has(entry.name)) {
|
|
429
129
|
continue;
|
|
430
130
|
}
|
|
431
|
-
|
|
432
131
|
await collectFiles(path.join(targetPath, entry.name), collected);
|
|
433
132
|
}
|
|
434
133
|
|
|
435
134
|
return collected;
|
|
436
135
|
}
|
|
437
136
|
|
|
438
|
-
if (
|
|
137
|
+
if (
|
|
138
|
+
TEXT_EXTENSIONS.has(path.extname(targetPath)) &&
|
|
139
|
+
!shouldIgnoreFile(targetPath)
|
|
140
|
+
) {
|
|
439
141
|
collected.push(targetPath);
|
|
440
142
|
}
|
|
441
143
|
|
|
@@ -443,10 +145,7 @@ async function collectFiles(targetPath, collected) {
|
|
|
443
145
|
}
|
|
444
146
|
|
|
445
147
|
function parseArguments(rawArgs) {
|
|
446
|
-
const options = {
|
|
447
|
-
dryRun: false,
|
|
448
|
-
verbose: false,
|
|
449
|
-
};
|
|
148
|
+
const options = { dryRun: false, verbose: false };
|
|
450
149
|
const targets = [];
|
|
451
150
|
|
|
452
151
|
for (const arg of rawArgs) {
|
|
@@ -454,25 +153,19 @@ function parseArguments(rawArgs) {
|
|
|
454
153
|
options.dryRun = true;
|
|
455
154
|
continue;
|
|
456
155
|
}
|
|
457
|
-
|
|
458
156
|
if (arg === "--verbose") {
|
|
459
157
|
options.verbose = true;
|
|
460
158
|
continue;
|
|
461
159
|
}
|
|
462
|
-
|
|
463
160
|
if (arg === "--help" || arg === "-h") {
|
|
464
161
|
throw new Error(
|
|
465
162
|
"Bruk: jokul codemod [import-paths] [sti ...] [--dry-run] [--verbose]",
|
|
466
163
|
);
|
|
467
164
|
}
|
|
468
|
-
|
|
469
165
|
targets.push(arg);
|
|
470
166
|
}
|
|
471
167
|
|
|
472
|
-
return {
|
|
473
|
-
options,
|
|
474
|
-
targets: targets.length > 0 ? targets : ["."],
|
|
475
|
-
};
|
|
168
|
+
return { options, targets: targets.length > 0 ? targets : ["."] };
|
|
476
169
|
}
|
|
477
170
|
|
|
478
171
|
export async function runImportPathsCodemod(rawArgs = []) {
|
|
@@ -510,7 +203,9 @@ export async function runImportPathsCodemod(rawArgs = []) {
|
|
|
510
203
|
}
|
|
511
204
|
|
|
512
205
|
if (options.verbose || options.dryRun) {
|
|
513
|
-
console.log(
|
|
206
|
+
console.log(
|
|
207
|
+
`${options.dryRun ? "Ville endret" : "Endret"} ${filePath}`,
|
|
208
|
+
);
|
|
514
209
|
}
|
|
515
210
|
}
|
|
516
211
|
|
|
@@ -522,6 +217,6 @@ export async function runImportPathsCodemod(rawArgs = []) {
|
|
|
522
217
|
}
|
|
523
218
|
|
|
524
219
|
console.log(
|
|
525
|
-
`\n${options.dryRun ? "Dry run ferdig" : "Codemod ferdig"}: ${changedFiles} filer, ${changedSpecifiers}
|
|
220
|
+
`\n${options.dryRun ? "Dry run ferdig" : "Codemod ferdig"}: ${changedFiles} filer, ${changedSpecifiers} erstatninger${reorderedFiles > 0 ? `, ${reorderedFiles} justerte font-importrekkefølger` : ""}.`,
|
|
526
221
|
);
|
|
527
222
|
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { replaceSpecifier, replaceTailwindClass } from "../utils.mjs";
|
|
2
|
+
|
|
3
|
+
// Sortert lengst-først: spesifikke tokens (f.eks. -alert-info) må ikke bli
|
|
4
|
+
// delvis matchet av kortere prefiks.
|
|
5
|
+
const CSS_TOKEN_RENAMES = [
|
|
6
|
+
[
|
|
7
|
+
"--jkl-color-background-alert-warning",
|
|
8
|
+
"--jkl-color-warning-background-container",
|
|
9
|
+
],
|
|
10
|
+
[
|
|
11
|
+
"--jkl-color-background-alert-success",
|
|
12
|
+
"--jkl-color-success-background-container",
|
|
13
|
+
],
|
|
14
|
+
[
|
|
15
|
+
"--jkl-color-background-alert-error",
|
|
16
|
+
"--jkl-color-error-background-container",
|
|
17
|
+
],
|
|
18
|
+
[
|
|
19
|
+
"--jkl-color-background-alert-info",
|
|
20
|
+
"--jkl-color-info-background-container",
|
|
21
|
+
],
|
|
22
|
+
[
|
|
23
|
+
"--jkl-color-background-container-high",
|
|
24
|
+
"--jkl-color-background-container",
|
|
25
|
+
],
|
|
26
|
+
[
|
|
27
|
+
"--jkl-color-background-container-low",
|
|
28
|
+
"--jkl-color-background-container",
|
|
29
|
+
],
|
|
30
|
+
[
|
|
31
|
+
"--jkl-color-background-container-inverted",
|
|
32
|
+
"--jkl-color-background-contrast",
|
|
33
|
+
],
|
|
34
|
+
["--jkl-color-background-action", "--jkl-color-background-contrast"],
|
|
35
|
+
["--jkl-color-text-on-action", "--jkl-color-text-on-contrast"],
|
|
36
|
+
["--jkl-color-text-inverted", "--jkl-color-text-on-contrast"],
|
|
37
|
+
].sort(([a], [b]) => b.length - a.length);
|
|
38
|
+
|
|
39
|
+
// Tilsvarende omdøyping for Tailwind --color-{nøkkel}-variablar.
|
|
40
|
+
const TAILWIND_COLOR_RENAMES = [
|
|
41
|
+
["background-alert-warning", "warning-background-container"],
|
|
42
|
+
["background-alert-success", "success-background-container"],
|
|
43
|
+
["background-alert-error", "error-background-container"],
|
|
44
|
+
["background-alert-info", "info-background-container"],
|
|
45
|
+
["background-container-high", "background-container"],
|
|
46
|
+
["background-container-low", "background-container"],
|
|
47
|
+
["background-container-inverted", "background-contrast"],
|
|
48
|
+
["background-action", "background-contrast"],
|
|
49
|
+
["text-on-action", "text-on-contrast"],
|
|
50
|
+
["text-inverted", "text-on-contrast"],
|
|
51
|
+
].sort(([a], [b]) => b.length - a.length);
|
|
52
|
+
|
|
53
|
+
const TAILWIND_COLOR_PREFIXES = [
|
|
54
|
+
"bg",
|
|
55
|
+
"text",
|
|
56
|
+
"border",
|
|
57
|
+
"ring",
|
|
58
|
+
"shadow",
|
|
59
|
+
"fill",
|
|
60
|
+
"stroke",
|
|
61
|
+
"accent",
|
|
62
|
+
"caret",
|
|
63
|
+
"outline",
|
|
64
|
+
"placeholder",
|
|
65
|
+
"divide",
|
|
66
|
+
"from",
|
|
67
|
+
"via",
|
|
68
|
+
"to",
|
|
69
|
+
"decoration",
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
export function applyCssTokenRenames(text) {
|
|
73
|
+
let next = text;
|
|
74
|
+
let count = 0;
|
|
75
|
+
|
|
76
|
+
for (const [from, to] of CSS_TOKEN_RENAMES) {
|
|
77
|
+
const result = replaceSpecifier(next, from, to);
|
|
78
|
+
next = result.text;
|
|
79
|
+
count += result.count;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return { text: next, count };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function applyTailwindColorRenames(text) {
|
|
86
|
+
let next = text;
|
|
87
|
+
let count = 0;
|
|
88
|
+
|
|
89
|
+
for (const [fromKey, toKey] of TAILWIND_COLOR_RENAMES) {
|
|
90
|
+
for (const prefix of TAILWIND_COLOR_PREFIXES) {
|
|
91
|
+
const result = replaceTailwindClass(
|
|
92
|
+
next,
|
|
93
|
+
`${prefix}-${fromKey}`,
|
|
94
|
+
`${prefix}-${toKey}`,
|
|
95
|
+
);
|
|
96
|
+
next = result.text;
|
|
97
|
+
count += result.count;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return { text: next, count };
|
|
102
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Variant-prop-endringer i ExpandablePanel:
|
|
2
|
+
// variant="fill" → fjernet (fill er default-atferd, prop eksisterer ikke lenger)
|
|
3
|
+
// variant="stroke" → outlined (boolean prop)
|
|
4
|
+
//
|
|
5
|
+
// CSS-klasseendring:
|
|
6
|
+
// jkl-expandable--stroke → jkl-expandable--outlined
|
|
7
|
+
|
|
8
|
+
const STROKE_PROP_PATTERN =
|
|
9
|
+
/variant=(?:"stroke"|'stroke'|\{"stroke"}|\{'stroke'})/;
|
|
10
|
+
|
|
11
|
+
const FILL_PROP_PATTERN = /\s+variant=(?:"fill"|'fill'|\{"fill"}|\{'fill'})/;
|
|
12
|
+
|
|
13
|
+
const CSS_CLASS_PATTERN = /\bjkl-expandable--stroke\b/g;
|
|
14
|
+
|
|
15
|
+
// Matches an ExpandablePanel opening or self-closing tag.
|
|
16
|
+
// [^>]* is safe for JSX since > in prop values must be escaped ({">"} or >).
|
|
17
|
+
const EXPANDABLE_PANEL_TAG = /<ExpandablePanel\b[^>]*>/g;
|
|
18
|
+
|
|
19
|
+
export function applyExpandablePanelTransforms(text) {
|
|
20
|
+
let next = text;
|
|
21
|
+
let count = 0;
|
|
22
|
+
|
|
23
|
+
next = next.replace(CSS_CLASS_PATTERN, () => {
|
|
24
|
+
count++;
|
|
25
|
+
return "jkl-expandable-panel--outlined";
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
next = next.replace(EXPANDABLE_PANEL_TAG, (tag) =>
|
|
29
|
+
tag
|
|
30
|
+
.replace(FILL_PROP_PATTERN, () => {
|
|
31
|
+
count++;
|
|
32
|
+
return "";
|
|
33
|
+
})
|
|
34
|
+
.replace(STROKE_PROP_PATTERN, () => {
|
|
35
|
+
count++;
|
|
36
|
+
return "outlined";
|
|
37
|
+
}),
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return { text: next, count };
|
|
41
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { escapeRegExp } from "../utils.mjs";
|
|
2
|
+
|
|
3
|
+
// Fallback-navnet kommer først (lengst-først) slik at det ikke blir delvis
|
|
4
|
+
// overskrevet av det kortere primærnavnet.
|
|
5
|
+
const FONT_FAMILY_REPLACEMENTS = [
|
|
6
|
+
["Fremtind Material Symbols Fallback", "Jokul Icons Fallback"],
|
|
7
|
+
["Fremtind Material Symbols", "Jokul Icons"],
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
export function applyFontFamilyReplacements(text) {
|
|
11
|
+
let next = text;
|
|
12
|
+
let count = 0;
|
|
13
|
+
|
|
14
|
+
for (const [from, to] of FONT_FAMILY_REPLACEMENTS) {
|
|
15
|
+
const pattern = new RegExp(escapeRegExp(from), "g");
|
|
16
|
+
next = next.replace(pattern, () => {
|
|
17
|
+
count += 1;
|
|
18
|
+
return to;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return { text: next, count };
|
|
23
|
+
}
|