origam 2.39.0 → 2.40.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/CHANGELOG.md +27 -0
- package/dist/src/assets/css/tokens/dark-pinned.css +3229 -0
- package/dist/src/assets/css/tokens/dark-system.css +3053 -0
- package/dist/src/components/Code/OrigamCode.vue +2 -1
- package/dist/src/composables/Icon/icon.composable.cjs +9 -2
- package/dist/src/composables/Icon/icon.composable.d.ts +10 -0
- package/dist/src/composables/Icon/icon.composable.js +6 -2
- package/dist/src/consts/Commons/mdi-core.const.cjs +61 -0
- package/dist/src/consts/Commons/mdi-core.const.d.ts +11 -0
- package/dist/src/consts/Commons/mdi-core.const.js +55 -0
- package/dist/src/consts/Commons/mdi.const.cjs +9 -54
- package/dist/src/consts/Commons/mdi.const.d.ts +2 -2
- package/dist/src/consts/Commons/mdi.const.js +3 -53
- package/dist/src/interfaces/Commons/nuxt-module.interface.d.ts +20 -0
- package/dist/src/interfaces/Commons/theme.interface.d.ts +13 -0
- package/dist/src/nuxt/create.core.cjs +12 -0
- package/dist/src/nuxt/create.core.d.ts +1 -0
- package/dist/src/nuxt/create.core.js +1 -0
- package/dist/src/nuxt/create.full.cjs +12 -0
- package/dist/src/nuxt/create.full.d.ts +7 -0
- package/dist/src/nuxt/create.full.js +1 -0
- package/dist/src/nuxt/module.cjs +84 -65
- package/dist/src/nuxt/module.js +78 -64
- package/dist/src/nuxt/plugin.client.cjs +2 -2
- package/dist/src/nuxt/plugin.client.js +1 -1
- package/dist/src/nuxt/plugin.server.cjs +6 -7
- package/dist/src/nuxt/plugin.server.js +6 -11
- package/dist/src/origam-core.cjs +153 -0
- package/dist/src/origam-core.d.ts +101 -0
- package/dist/src/origam-core.js +169 -0
- package/dist/src/origam.cjs +11 -133
- package/dist/src/origam.d.ts +14 -20
- package/dist/src/origam.js +7 -163
- package/dist/src/ssr.cjs +38 -0
- package/dist/src/ssr.d.ts +11 -0
- package/dist/src/ssr.js +3 -0
- package/dist/src/utils/Code/trim-blank-lines.util.cjs +13 -0
- package/dist/src/utils/Code/trim-blank-lines.util.d.ts +9 -0
- package/dist/src/utils/Code/trim-blank-lines.util.js +7 -0
- package/dist/src/utils/CodeGroup/code-group.util.cjs +2 -1
- package/dist/src/utils/CodeGroup/code-group.util.js +2 -1
- package/dist/src/utils/Commons/theme-ssr.util.cjs +20 -0
- package/dist/src/utils/Commons/theme-ssr.util.d.ts +17 -0
- package/dist/src/utils/Commons/theme-ssr.util.js +18 -0
- package/dist/src/utils/index.cjs +22 -0
- package/dist/src/utils/index.d.ts +2 -0
- package/dist/src/utils/index.js +2 -0
- package/package.json +5 -1
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createDate,
|
|
3
|
+
createDefaults,
|
|
4
|
+
createDisplay,
|
|
5
|
+
createGoTo,
|
|
6
|
+
createIconsCore,
|
|
7
|
+
createLocale,
|
|
8
|
+
installThemePropsResolver,
|
|
9
|
+
resolveVariantPresetRegistry,
|
|
10
|
+
themedPropKeysUnion
|
|
11
|
+
} from "./composables/index.js";
|
|
12
|
+
import {
|
|
13
|
+
IN_BROWSER,
|
|
14
|
+
ORIGAM_CODE_KEY,
|
|
15
|
+
ORIGAM_DATE_ADAPTER_KEY,
|
|
16
|
+
ORIGAM_DATE_OPTIONS_KEY,
|
|
17
|
+
ORIGAM_DEFAULTS_KEY,
|
|
18
|
+
ORIGAM_DISPLAY_KEY,
|
|
19
|
+
ORIGAM_GO_TO_KEY,
|
|
20
|
+
ORIGAM_ICONS_KEY,
|
|
21
|
+
ORIGAM_LOCALE_KEY,
|
|
22
|
+
ORIGAM_SSR_STYLES_KEY,
|
|
23
|
+
ORIGAM_THEME_DEFAULTS_KEY,
|
|
24
|
+
ORIGAM_THEMES_KEY,
|
|
25
|
+
VARIANT_PRESETS
|
|
26
|
+
} from "./consts/index.js";
|
|
27
|
+
import { setContrastConfig } from "./directives/Contrast/contrast.directive.js";
|
|
28
|
+
import { applyThemes, installedThemesFromList, mergeDeep, registerSsrStyleCollector } from "./utils/index.js";
|
|
29
|
+
import { defineComponent, effectScope, nextTick, reactive } from "vue";
|
|
30
|
+
function scheduleDisplayUpdate(app, display) {
|
|
31
|
+
const nuxt = app.$nuxt;
|
|
32
|
+
if (nuxt) {
|
|
33
|
+
nuxt.hook("app:suspense:resolve", () => display.update());
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const { mount } = app;
|
|
37
|
+
app.mount = (...args) => {
|
|
38
|
+
const vm = mount(...args);
|
|
39
|
+
nextTick(() => display.update());
|
|
40
|
+
app.mount = mount;
|
|
41
|
+
return vm;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function origamAccessor() {
|
|
45
|
+
return reactive({
|
|
46
|
+
display: inject.call(this, ORIGAM_DISPLAY_KEY),
|
|
47
|
+
icons: inject.call(this, ORIGAM_ICONS_KEY),
|
|
48
|
+
locale: inject.call(this, ORIGAM_LOCALE_KEY),
|
|
49
|
+
date: inject.call(this, ORIGAM_DATE_ADAPTER_KEY)
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function installOptionsApiMixin(app) {
|
|
53
|
+
app.mixin({ computed: { $origam: origamAccessor } });
|
|
54
|
+
}
|
|
55
|
+
export function createOrigamCore(origam = {}) {
|
|
56
|
+
const { blueprint, ...rest } = origam;
|
|
57
|
+
const options = mergeDeep(blueprint, rest);
|
|
58
|
+
const {
|
|
59
|
+
aliases = {},
|
|
60
|
+
components = {},
|
|
61
|
+
directives = {}
|
|
62
|
+
} = options;
|
|
63
|
+
const suppliedThemes = [
|
|
64
|
+
...options.theme ? [options.theme] : [],
|
|
65
|
+
...options.themes ?? []
|
|
66
|
+
];
|
|
67
|
+
const allThemes = [...suppliedThemes];
|
|
68
|
+
const installedThemes = installedThemesFromList(allThemes);
|
|
69
|
+
const defaultsRef = createDefaults({});
|
|
70
|
+
defaultsRef.value = activeDefaultsFor(allThemes, allThemes[0]?.name ?? "", void 0);
|
|
71
|
+
const themedKeysUnion = themedPropKeysUnion(
|
|
72
|
+
allThemes.map((theme) => theme.components).filter((components2) => !!components2)
|
|
73
|
+
);
|
|
74
|
+
const variantPresets = resolveVariantPresetRegistry(
|
|
75
|
+
VARIANT_PRESETS,
|
|
76
|
+
allThemes.map((theme) => theme.variants).filter((variants) => !!variants)
|
|
77
|
+
);
|
|
78
|
+
const scope = effectScope();
|
|
79
|
+
return scope.run(() => {
|
|
80
|
+
const icons = createIconsCore(options.icons);
|
|
81
|
+
const display = createDisplay(options.display, options.ssr);
|
|
82
|
+
const locale = createLocale(options.locale);
|
|
83
|
+
const date = createDate(options.date, locale);
|
|
84
|
+
const goTo = createGoTo(options.goTo, locale);
|
|
85
|
+
setContrastConfig(options.contrast);
|
|
86
|
+
const install = (app) => {
|
|
87
|
+
if (allThemes.length) {
|
|
88
|
+
applyThemes(allThemes);
|
|
89
|
+
}
|
|
90
|
+
for (const key in directives) {
|
|
91
|
+
app.directive(key, directives[key]);
|
|
92
|
+
}
|
|
93
|
+
for (const key in components) {
|
|
94
|
+
app.component(key, components[key]);
|
|
95
|
+
}
|
|
96
|
+
for (const key in aliases) {
|
|
97
|
+
app.component(key, defineComponent({
|
|
98
|
+
...aliases[key],
|
|
99
|
+
name: key,
|
|
100
|
+
aliasName: aliases[key].name
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
const appScope = effectScope();
|
|
104
|
+
app.onUnmount(() => appScope.stop());
|
|
105
|
+
app.provide(ORIGAM_ICONS_KEY, icons);
|
|
106
|
+
app.provide(ORIGAM_CODE_KEY, options.code ?? {});
|
|
107
|
+
app.provide(ORIGAM_DISPLAY_KEY, display);
|
|
108
|
+
app.provide(ORIGAM_LOCALE_KEY, locale);
|
|
109
|
+
app.provide(ORIGAM_DATE_OPTIONS_KEY, date.options);
|
|
110
|
+
app.provide(ORIGAM_DATE_ADAPTER_KEY, date.instance);
|
|
111
|
+
app.provide(ORIGAM_GO_TO_KEY, goTo);
|
|
112
|
+
app.provide(ORIGAM_THEMES_KEY, installedThemes);
|
|
113
|
+
app.provide(ORIGAM_DEFAULTS_KEY, defaultsRef);
|
|
114
|
+
if (!IN_BROWSER) {
|
|
115
|
+
app.provide(ORIGAM_SSR_STYLES_KEY, registerSsrStyleCollector(app));
|
|
116
|
+
}
|
|
117
|
+
installThemePropsResolver(app, themedKeysUnion, variantPresets);
|
|
118
|
+
app.provide(ORIGAM_THEME_DEFAULTS_KEY, (brand, mode) => activeDefaultsFor(allThemes, brand, mode));
|
|
119
|
+
if (IN_BROWSER && options.ssr) {
|
|
120
|
+
scheduleDisplayUpdate(app, display);
|
|
121
|
+
}
|
|
122
|
+
if (typeof __VUE_OPTIONS_API__ !== "boolean" || __VUE_OPTIONS_API__) {
|
|
123
|
+
installOptionsApiMixin(app);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
function unmount() {
|
|
127
|
+
scope.stop();
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
install,
|
|
131
|
+
unmount,
|
|
132
|
+
display,
|
|
133
|
+
icons,
|
|
134
|
+
locale,
|
|
135
|
+
date,
|
|
136
|
+
goTo,
|
|
137
|
+
themes: installedThemes,
|
|
138
|
+
// Reactive per-component DEFAULT PROPS map (provided under
|
|
139
|
+
// ORIGAM_DEFAULTS_KEY). The Nuxt plugins reassign `.value` (a NEW
|
|
140
|
+
// object) whenever the active brand / mode changes so `useDefaults`
|
|
141
|
+
// computeds re-run. NEVER mutate it in place.
|
|
142
|
+
_defaultsRef: defaultsRef,
|
|
143
|
+
// Re-export the collapse helper so the plugins can recompute the
|
|
144
|
+
// active defaults from the same install list on a theme switch.
|
|
145
|
+
_activeDefaultsFor: (brand, mode) => activeDefaultsFor(allThemes, brand, mode)
|
|
146
|
+
};
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
export function activeDefaultsFor(themes, brand, mode) {
|
|
150
|
+
let merged = {};
|
|
151
|
+
for (const theme of themes) {
|
|
152
|
+
if (!theme.components) continue;
|
|
153
|
+
const brandMatches = !theme.name || theme.name === brand;
|
|
154
|
+
const themeModeAgnostic = theme.mode === void 0 || theme.mode === "auto";
|
|
155
|
+
const modeMatches = themeModeAgnostic || mode === void 0 || theme.mode === mode;
|
|
156
|
+
if (brandMatches && modeMatches) {
|
|
157
|
+
merged = mergeDeep(merged, theme.components);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return merged;
|
|
161
|
+
}
|
|
162
|
+
function inject(key) {
|
|
163
|
+
const vm = this.$;
|
|
164
|
+
const parentProvides = vm.parent?.provides;
|
|
165
|
+
const provides = parentProvides ?? vm.vnode.appContext?.provides;
|
|
166
|
+
if (provides && key in provides) {
|
|
167
|
+
return provides[key];
|
|
168
|
+
}
|
|
169
|
+
}
|
package/dist/src/origam.cjs
CHANGED
|
@@ -3,16 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
Object.defineProperty(exports, "activeDefaultsFor", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _origamCore.activeDefaultsFor;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
7
12
|
exports.createOrigam = createOrigam;
|
|
8
13
|
var origamComponents = _interopRequireWildcard(require("./components/index.cjs"));
|
|
9
|
-
var _composables = require("./composables/index.cjs");
|
|
10
|
-
var _consts = require("./consts/index.cjs");
|
|
11
14
|
var origamDirectives = _interopRequireWildcard(require("./directives/index.cjs"));
|
|
12
|
-
var
|
|
15
|
+
var _origamCore = require("./origam-core.cjs");
|
|
13
16
|
var _utils = require("./utils/index.cjs");
|
|
14
17
|
require("@mdi/font/css/materialdesignicons.css");
|
|
15
|
-
var _vue = require("vue");
|
|
16
18
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
17
19
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
20
|
function createOrigam(origam = {}) {
|
|
@@ -21,133 +23,9 @@ function createOrigam(origam = {}) {
|
|
|
21
23
|
...rest
|
|
22
24
|
} = origam;
|
|
23
25
|
const options = (0, _utils.mergeDeep)(blueprint, rest);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
components
|
|
27
|
-
directives
|
|
28
|
-
} = options;
|
|
29
|
-
const suppliedThemes = [...(options.theme ? [options.theme] : []), ...(options.themes ?? [])];
|
|
30
|
-
const allThemes = [...suppliedThemes];
|
|
31
|
-
const installedThemes = (0, _utils.installedThemesFromList)(allThemes);
|
|
32
|
-
const defaultsRef = (0, _composables.createDefaults)({});
|
|
33
|
-
defaultsRef.value = activeDefaultsFor(allThemes, allThemes[0]?.name ?? "", void 0);
|
|
34
|
-
const themedKeysUnion = (0, _composables.themedPropKeysUnion)(allThemes.map(theme => theme.components).filter(components2 => !!components2));
|
|
35
|
-
const variantPresets = (0, _composables.resolveVariantPresetRegistry)(_consts.VARIANT_PRESETS, allThemes.map(theme => theme.variants).filter(variants => !!variants));
|
|
36
|
-
const scope = (0, _vue.effectScope)();
|
|
37
|
-
return scope.run(() => {
|
|
38
|
-
const icons = (0, _composables.createIcons)(options.icons);
|
|
39
|
-
const display = (0, _composables.createDisplay)(options.display, options.ssr);
|
|
40
|
-
const locale = (0, _composables.createLocale)(options.locale);
|
|
41
|
-
const date = (0, _composables.createDate)(options.date, locale);
|
|
42
|
-
const goTo = (0, _composables.createGoTo)(options.goTo, locale);
|
|
43
|
-
(0, _contrast.setContrastConfig)(options.contrast);
|
|
44
|
-
const install = app => {
|
|
45
|
-
if (allThemes.length) {
|
|
46
|
-
(0, _utils.applyThemes)(allThemes);
|
|
47
|
-
}
|
|
48
|
-
for (const key in directives) {
|
|
49
|
-
app.directive(key, directives[key]);
|
|
50
|
-
}
|
|
51
|
-
for (const key in components) {
|
|
52
|
-
app.component(key, components[key]);
|
|
53
|
-
}
|
|
54
|
-
for (const key in aliases) {
|
|
55
|
-
app.component(key, (0, _vue.defineComponent)({
|
|
56
|
-
...aliases[key],
|
|
57
|
-
name: key,
|
|
58
|
-
aliasName: aliases[key].name
|
|
59
|
-
}));
|
|
60
|
-
}
|
|
61
|
-
const appScope = (0, _vue.effectScope)();
|
|
62
|
-
app.onUnmount(() => appScope.stop());
|
|
63
|
-
app.provide(_consts.ORIGAM_ICONS_KEY, icons);
|
|
64
|
-
app.provide(_consts.ORIGAM_CODE_KEY, options.code ?? {});
|
|
65
|
-
app.provide(_consts.ORIGAM_DISPLAY_KEY, display);
|
|
66
|
-
app.provide(_consts.ORIGAM_LOCALE_KEY, locale);
|
|
67
|
-
app.provide(_consts.ORIGAM_DATE_OPTIONS_KEY, date.options);
|
|
68
|
-
app.provide(_consts.ORIGAM_DATE_ADAPTER_KEY, date.instance);
|
|
69
|
-
app.provide(_consts.ORIGAM_GO_TO_KEY, goTo);
|
|
70
|
-
app.provide(_consts.ORIGAM_THEMES_KEY, installedThemes);
|
|
71
|
-
app.provide(_consts.ORIGAM_DEFAULTS_KEY, defaultsRef);
|
|
72
|
-
if (!_consts.IN_BROWSER) {
|
|
73
|
-
app.provide(_consts.ORIGAM_SSR_STYLES_KEY, (0, _utils.registerSsrStyleCollector)(app));
|
|
74
|
-
}
|
|
75
|
-
(0, _composables.installThemePropsResolver)(app, themedKeysUnion, variantPresets);
|
|
76
|
-
app.provide(_consts.ORIGAM_THEME_DEFAULTS_KEY, (brand, mode) => activeDefaultsFor(allThemes, brand, mode));
|
|
77
|
-
if (_consts.IN_BROWSER && options.ssr) {
|
|
78
|
-
const nuxt = app.$nuxt;
|
|
79
|
-
if (nuxt) {
|
|
80
|
-
nuxt.hook("app:suspense:resolve", () => {
|
|
81
|
-
display.update();
|
|
82
|
-
});
|
|
83
|
-
} else {
|
|
84
|
-
const {
|
|
85
|
-
mount
|
|
86
|
-
} = app;
|
|
87
|
-
app.mount = (...args) => {
|
|
88
|
-
const vm = mount(...args);
|
|
89
|
-
(0, _vue.nextTick)(() => display.update());
|
|
90
|
-
app.mount = mount;
|
|
91
|
-
return vm;
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
if (typeof __VUE_OPTIONS_API__ !== "boolean" || __VUE_OPTIONS_API__) {
|
|
96
|
-
app.mixin({
|
|
97
|
-
computed: {
|
|
98
|
-
$origam() {
|
|
99
|
-
return (0, _vue.reactive)({
|
|
100
|
-
display: inject.call(this, _consts.ORIGAM_DISPLAY_KEY),
|
|
101
|
-
icons: inject.call(this, _consts.ORIGAM_ICONS_KEY),
|
|
102
|
-
locale: inject.call(this, _consts.ORIGAM_LOCALE_KEY),
|
|
103
|
-
date: inject.call(this, _consts.ORIGAM_DATE_ADAPTER_KEY)
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
function unmount() {
|
|
111
|
-
scope.stop();
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
install,
|
|
115
|
-
unmount,
|
|
116
|
-
display,
|
|
117
|
-
icons,
|
|
118
|
-
locale,
|
|
119
|
-
date,
|
|
120
|
-
goTo,
|
|
121
|
-
themes: installedThemes,
|
|
122
|
-
// Reactive per-component DEFAULT PROPS map (provided under
|
|
123
|
-
// ORIGAM_DEFAULTS_KEY). The Nuxt plugins reassign `.value` (a NEW
|
|
124
|
-
// object) whenever the active brand / mode changes so `useDefaults`
|
|
125
|
-
// computeds re-run. NEVER mutate it in place.
|
|
126
|
-
_defaultsRef: defaultsRef,
|
|
127
|
-
// Re-export the collapse helper so the plugins can recompute the
|
|
128
|
-
// active defaults from the same install list on a theme switch.
|
|
129
|
-
_activeDefaultsFor: (brand, mode) => activeDefaultsFor(allThemes, brand, mode)
|
|
130
|
-
};
|
|
26
|
+
return (0, _origamCore.createOrigamCore)({
|
|
27
|
+
...options,
|
|
28
|
+
components: options.components ?? origamComponents,
|
|
29
|
+
directives: options.directives ?? origamDirectives
|
|
131
30
|
});
|
|
132
|
-
}
|
|
133
|
-
function activeDefaultsFor(themes, brand, mode) {
|
|
134
|
-
let merged = {};
|
|
135
|
-
for (const theme of themes) {
|
|
136
|
-
if (!theme.components) continue;
|
|
137
|
-
const brandMatches = !theme.name || theme.name === brand;
|
|
138
|
-
const themeModeAgnostic = theme.mode === void 0 || theme.mode === "auto";
|
|
139
|
-
const modeMatches = themeModeAgnostic || mode === void 0 || theme.mode === mode;
|
|
140
|
-
if (brandMatches && modeMatches) {
|
|
141
|
-
merged = (0, _utils.mergeDeep)(merged, theme.components);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return merged;
|
|
145
|
-
}
|
|
146
|
-
function inject(key) {
|
|
147
|
-
const vm = this.$;
|
|
148
|
-
const parentProvides = vm.parent?.provides;
|
|
149
|
-
const provides = parentProvides ?? vm.vnode.appContext?.provides;
|
|
150
|
-
if (provides && key in provides) {
|
|
151
|
-
return provides[key];
|
|
152
|
-
}
|
|
153
31
|
}
|
package/dist/src/origam.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { TModeResolved } from './types';
|
|
1
|
+
import type { IOrigamOptions } from './interfaces';
|
|
3
2
|
import '@mdi/font/css/materialdesignicons.css';
|
|
4
|
-
|
|
3
|
+
export { activeDefaultsFor } from './origam-core';
|
|
4
|
+
/*********************************************************
|
|
5
|
+
* createOrigam
|
|
6
|
+
*
|
|
7
|
+
* @description
|
|
8
|
+
* Full entry: every component and directive plus the MDI stylesheet, unless
|
|
9
|
+
* the consumer passes its own `components` / `directives`. The install logic
|
|
10
|
+
* lives in `createOrigamCore` (origam-core.ts, #1384), which imports none of
|
|
11
|
+
* them — use it directly for a tree-shakable build.
|
|
12
|
+
********************************************************/
|
|
5
13
|
export declare function createOrigam(origam?: IOrigamOptions): {
|
|
6
|
-
install: (app: App) => void;
|
|
14
|
+
install: (app: import("vue").App) => void;
|
|
7
15
|
unmount: () => void;
|
|
8
16
|
display: import("./interfaces").IDisplayInstance;
|
|
9
17
|
icons: Record<string, unknown>;
|
|
@@ -68,20 +76,6 @@ export declare function createOrigam(origam?: IOrigamOptions): {
|
|
|
68
76
|
};
|
|
69
77
|
goTo: import("./interfaces").IGoToInstance;
|
|
70
78
|
themes: import("./types").TInstalledThemes;
|
|
71
|
-
_defaultsRef: import("vue").Ref<IDefault, IDefault>;
|
|
72
|
-
_activeDefaultsFor: (brand: string, mode?: TModeResolved) => IDefault;
|
|
79
|
+
_defaultsRef: import("vue").Ref<import("./interfaces").IDefault, import("./interfaces").IDefault>;
|
|
80
|
+
_activeDefaultsFor: (brand: string, mode?: import("./types").TModeResolved) => import("./interfaces").IDefault;
|
|
73
81
|
};
|
|
74
|
-
/**
|
|
75
|
-
* Collapse the per-component DEFAULT PROPS (`theme.components`) of the themes
|
|
76
|
-
* matching the ACTIVE brand×mode into a single `IDefault`. A theme matches when
|
|
77
|
-
* its `name` equals `brand` AND its `mode` is compatible with the active `mode`:
|
|
78
|
-
* - the theme is mode-agnostic (`mode` unset or `'auto'`), OR
|
|
79
|
-
* - the active `mode` is unset (match every mode of the brand — used for the
|
|
80
|
-
* mode-less install-time seed before the plugins resolve a concrete mode), OR
|
|
81
|
-
* - the theme's `mode` equals the active `mode`.
|
|
82
|
-
* Matching themes are deep-merged in install order (later wins) via the shared
|
|
83
|
-
* `mergeDeep` util — no hand-rolled merge.
|
|
84
|
-
*
|
|
85
|
-
* Pure (no DOM / Vue access) so it runs identically on the server and client.
|
|
86
|
-
*/
|
|
87
|
-
export declare function activeDefaultsFor(themes: IOrigamTheme[], brand: string, mode?: TModeResolved): IDefault;
|
package/dist/src/origam.js
CHANGED
|
@@ -1,171 +1,15 @@
|
|
|
1
1
|
import * as origamComponents from "./components/index.js";
|
|
2
|
-
import {
|
|
3
|
-
createDate,
|
|
4
|
-
createDefaults,
|
|
5
|
-
createDisplay,
|
|
6
|
-
createGoTo,
|
|
7
|
-
createIcons,
|
|
8
|
-
createLocale,
|
|
9
|
-
installThemePropsResolver,
|
|
10
|
-
resolveVariantPresetRegistry,
|
|
11
|
-
themedPropKeysUnion
|
|
12
|
-
} from "./composables/index.js";
|
|
13
|
-
import {
|
|
14
|
-
IN_BROWSER,
|
|
15
|
-
ORIGAM_CODE_KEY,
|
|
16
|
-
ORIGAM_DATE_ADAPTER_KEY,
|
|
17
|
-
ORIGAM_DATE_OPTIONS_KEY,
|
|
18
|
-
ORIGAM_DEFAULTS_KEY,
|
|
19
|
-
ORIGAM_DISPLAY_KEY,
|
|
20
|
-
ORIGAM_GO_TO_KEY,
|
|
21
|
-
ORIGAM_ICONS_KEY,
|
|
22
|
-
ORIGAM_LOCALE_KEY,
|
|
23
|
-
ORIGAM_SSR_STYLES_KEY,
|
|
24
|
-
ORIGAM_THEME_DEFAULTS_KEY,
|
|
25
|
-
ORIGAM_THEMES_KEY,
|
|
26
|
-
VARIANT_PRESETS
|
|
27
|
-
} from "./consts/index.js";
|
|
28
2
|
import * as origamDirectives from "./directives/index.js";
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
3
|
+
import { createOrigamCore } from "./origam-core.js";
|
|
4
|
+
import { mergeDeep } from "./utils/index.js";
|
|
31
5
|
import "@mdi/font/css/materialdesignicons.css";
|
|
32
|
-
|
|
6
|
+
export { activeDefaultsFor } from "./origam-core.js";
|
|
33
7
|
export function createOrigam(origam = {}) {
|
|
34
8
|
const { blueprint, ...rest } = origam;
|
|
35
9
|
const options = mergeDeep(blueprint, rest);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
components
|
|
39
|
-
directives
|
|
40
|
-
} = options;
|
|
41
|
-
const suppliedThemes = [
|
|
42
|
-
...options.theme ? [options.theme] : [],
|
|
43
|
-
...options.themes ?? []
|
|
44
|
-
];
|
|
45
|
-
const allThemes = [...suppliedThemes];
|
|
46
|
-
const installedThemes = installedThemesFromList(allThemes);
|
|
47
|
-
const defaultsRef = createDefaults({});
|
|
48
|
-
defaultsRef.value = activeDefaultsFor(allThemes, allThemes[0]?.name ?? "", void 0);
|
|
49
|
-
const themedKeysUnion = themedPropKeysUnion(
|
|
50
|
-
allThemes.map((theme) => theme.components).filter((components2) => !!components2)
|
|
51
|
-
);
|
|
52
|
-
const variantPresets = resolveVariantPresetRegistry(
|
|
53
|
-
VARIANT_PRESETS,
|
|
54
|
-
allThemes.map((theme) => theme.variants).filter((variants) => !!variants)
|
|
55
|
-
);
|
|
56
|
-
const scope = effectScope();
|
|
57
|
-
return scope.run(() => {
|
|
58
|
-
const icons = createIcons(options.icons);
|
|
59
|
-
const display = createDisplay(options.display, options.ssr);
|
|
60
|
-
const locale = createLocale(options.locale);
|
|
61
|
-
const date = createDate(options.date, locale);
|
|
62
|
-
const goTo = createGoTo(options.goTo, locale);
|
|
63
|
-
setContrastConfig(options.contrast);
|
|
64
|
-
const install = (app) => {
|
|
65
|
-
if (allThemes.length) {
|
|
66
|
-
applyThemes(allThemes);
|
|
67
|
-
}
|
|
68
|
-
for (const key in directives) {
|
|
69
|
-
app.directive(key, directives[key]);
|
|
70
|
-
}
|
|
71
|
-
for (const key in components) {
|
|
72
|
-
app.component(key, components[key]);
|
|
73
|
-
}
|
|
74
|
-
for (const key in aliases) {
|
|
75
|
-
app.component(key, defineComponent({
|
|
76
|
-
...aliases[key],
|
|
77
|
-
name: key,
|
|
78
|
-
aliasName: aliases[key].name
|
|
79
|
-
}));
|
|
80
|
-
}
|
|
81
|
-
const appScope = effectScope();
|
|
82
|
-
app.onUnmount(() => appScope.stop());
|
|
83
|
-
app.provide(ORIGAM_ICONS_KEY, icons);
|
|
84
|
-
app.provide(ORIGAM_CODE_KEY, options.code ?? {});
|
|
85
|
-
app.provide(ORIGAM_DISPLAY_KEY, display);
|
|
86
|
-
app.provide(ORIGAM_LOCALE_KEY, locale);
|
|
87
|
-
app.provide(ORIGAM_DATE_OPTIONS_KEY, date.options);
|
|
88
|
-
app.provide(ORIGAM_DATE_ADAPTER_KEY, date.instance);
|
|
89
|
-
app.provide(ORIGAM_GO_TO_KEY, goTo);
|
|
90
|
-
app.provide(ORIGAM_THEMES_KEY, installedThemes);
|
|
91
|
-
app.provide(ORIGAM_DEFAULTS_KEY, defaultsRef);
|
|
92
|
-
if (!IN_BROWSER) {
|
|
93
|
-
app.provide(ORIGAM_SSR_STYLES_KEY, registerSsrStyleCollector(app));
|
|
94
|
-
}
|
|
95
|
-
installThemePropsResolver(app, themedKeysUnion, variantPresets);
|
|
96
|
-
app.provide(ORIGAM_THEME_DEFAULTS_KEY, (brand, mode) => activeDefaultsFor(allThemes, brand, mode));
|
|
97
|
-
if (IN_BROWSER && options.ssr) {
|
|
98
|
-
const nuxt = app.$nuxt;
|
|
99
|
-
if (nuxt) {
|
|
100
|
-
nuxt.hook("app:suspense:resolve", () => {
|
|
101
|
-
display.update();
|
|
102
|
-
});
|
|
103
|
-
} else {
|
|
104
|
-
const { mount } = app;
|
|
105
|
-
app.mount = (...args) => {
|
|
106
|
-
const vm = mount(...args);
|
|
107
|
-
nextTick(() => display.update());
|
|
108
|
-
app.mount = mount;
|
|
109
|
-
return vm;
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (typeof __VUE_OPTIONS_API__ !== "boolean" || __VUE_OPTIONS_API__) {
|
|
114
|
-
app.mixin({
|
|
115
|
-
computed: {
|
|
116
|
-
$origam() {
|
|
117
|
-
return reactive({
|
|
118
|
-
display: inject.call(this, ORIGAM_DISPLAY_KEY),
|
|
119
|
-
icons: inject.call(this, ORIGAM_ICONS_KEY),
|
|
120
|
-
locale: inject.call(this, ORIGAM_LOCALE_KEY),
|
|
121
|
-
date: inject.call(this, ORIGAM_DATE_ADAPTER_KEY)
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
function unmount() {
|
|
129
|
-
scope.stop();
|
|
130
|
-
}
|
|
131
|
-
return {
|
|
132
|
-
install,
|
|
133
|
-
unmount,
|
|
134
|
-
display,
|
|
135
|
-
icons,
|
|
136
|
-
locale,
|
|
137
|
-
date,
|
|
138
|
-
goTo,
|
|
139
|
-
themes: installedThemes,
|
|
140
|
-
// Reactive per-component DEFAULT PROPS map (provided under
|
|
141
|
-
// ORIGAM_DEFAULTS_KEY). The Nuxt plugins reassign `.value` (a NEW
|
|
142
|
-
// object) whenever the active brand / mode changes so `useDefaults`
|
|
143
|
-
// computeds re-run. NEVER mutate it in place.
|
|
144
|
-
_defaultsRef: defaultsRef,
|
|
145
|
-
// Re-export the collapse helper so the plugins can recompute the
|
|
146
|
-
// active defaults from the same install list on a theme switch.
|
|
147
|
-
_activeDefaultsFor: (brand, mode) => activeDefaultsFor(allThemes, brand, mode)
|
|
148
|
-
};
|
|
10
|
+
return createOrigamCore({
|
|
11
|
+
...options,
|
|
12
|
+
components: options.components ?? origamComponents,
|
|
13
|
+
directives: options.directives ?? origamDirectives
|
|
149
14
|
});
|
|
150
15
|
}
|
|
151
|
-
export function activeDefaultsFor(themes, brand, mode) {
|
|
152
|
-
let merged = {};
|
|
153
|
-
for (const theme of themes) {
|
|
154
|
-
if (!theme.components) continue;
|
|
155
|
-
const brandMatches = !theme.name || theme.name === brand;
|
|
156
|
-
const themeModeAgnostic = theme.mode === void 0 || theme.mode === "auto";
|
|
157
|
-
const modeMatches = themeModeAgnostic || mode === void 0 || theme.mode === mode;
|
|
158
|
-
if (brandMatches && modeMatches) {
|
|
159
|
-
merged = mergeDeep(merged, theme.components);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return merged;
|
|
163
|
-
}
|
|
164
|
-
function inject(key) {
|
|
165
|
-
const vm = this.$;
|
|
166
|
-
const parentProvides = vm.parent?.provides;
|
|
167
|
-
const provides = parentProvides ?? vm.vnode.appContext?.provides;
|
|
168
|
-
if (provides && key in provides) {
|
|
169
|
-
return provides[key];
|
|
170
|
-
}
|
|
171
|
-
}
|
package/dist/src/ssr.cjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "getSsrStyles", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _ssrStyles.getSsrStyles;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "isModePinned", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _applyTheme.isModePinned;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "knownBrand", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _applyTheme.knownBrand;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "renderSsrStyles", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _ssrStyles.renderSsrStyles;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "renderThemeCss", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _themeSsr.renderThemeCss;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
var _themeSsr = require("./utils/Commons/theme-ssr.util.cjs");
|
|
37
|
+
var _ssrStyles = require("./utils/Commons/ssr-styles.util.cjs");
|
|
38
|
+
var _applyTheme = require("./utils/Commons/apply-theme.util.cjs");
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*********************************************************
|
|
2
|
+
* origam/ssr (#1386)
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* Documented, lean server-side theme/style helpers. Replaces the internal
|
|
6
|
+
* `origam/utils/Commons/{apply-theme,ssr-styles}.util.js` paths.
|
|
7
|
+
********************************************************/
|
|
8
|
+
export { renderThemeCss } from './utils/Commons/theme-ssr.util';
|
|
9
|
+
export { getSsrStyles, renderSsrStyles } from './utils/Commons/ssr-styles.util';
|
|
10
|
+
export { isModePinned, knownBrand } from './utils/Commons/apply-theme.util';
|
|
11
|
+
export type { IRenderThemeCssOptions } from './interfaces/Commons/theme.interface';
|
package/dist/src/ssr.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.trimBlankLines = trimBlankLines;
|
|
7
|
+
function trimBlankLines(text) {
|
|
8
|
+
let start = 0;
|
|
9
|
+
let end = text.length;
|
|
10
|
+
while (start < end && text[start] === "\n") start++;
|
|
11
|
+
while (end > start && text[end - 1] === "\n") end--;
|
|
12
|
+
return text.slice(start, end);
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*********************************************************
|
|
2
|
+
* trimBlankLines
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* Drops the leading and trailing line feeds of a code block given in a slot.
|
|
6
|
+
* Index scan rather than `/\n+$/`, whose backtracking is quadratic on a text
|
|
7
|
+
* holding many line feeds that are not at the end (Sonar S5852, #1388).
|
|
8
|
+
********************************************************/
|
|
9
|
+
export declare function trimBlankLines(text: string): string;
|
|
@@ -10,6 +10,7 @@ exports.resolveCodeGroupItems = resolveCodeGroupItems;
|
|
|
10
10
|
exports.resolveCodeGroupSlotItems = resolveCodeGroupSlotItems;
|
|
11
11
|
var _vue = require("vue");
|
|
12
12
|
var _codeGroup = require("../../consts/CodeGroup/code-group.const.cjs");
|
|
13
|
+
var _trimBlankLines = require("../Code/trim-blank-lines.util.cjs");
|
|
13
14
|
function flattenCodeGroupVNodes(nodes) {
|
|
14
15
|
const out = [];
|
|
15
16
|
for (const node of nodes ?? []) {
|
|
@@ -38,7 +39,7 @@ function extractCodeGroupText(node) {
|
|
|
38
39
|
visit(value.children);
|
|
39
40
|
};
|
|
40
41
|
visit(raw);
|
|
41
|
-
return parts.join("")
|
|
42
|
+
return (0, _trimBlankLines.trimBlankLines)(parts.join(""));
|
|
42
43
|
}
|
|
43
44
|
function resolveCodeGroupSlotItems(nodes) {
|
|
44
45
|
return flattenCodeGroupVNodes(nodes).map((vnode, index) => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cloneVNode, Comment, Fragment, h, Text } from "vue";
|
|
2
2
|
import { CODE_GROUP_EMBED_PROPS } from "../../consts/CodeGroup/code-group.const.js";
|
|
3
|
+
import { trimBlankLines } from "../Code/trim-blank-lines.util.js";
|
|
3
4
|
export function flattenCodeGroupVNodes(nodes) {
|
|
4
5
|
const out = [];
|
|
5
6
|
for (const node of nodes ?? []) {
|
|
@@ -28,7 +29,7 @@ export function extractCodeGroupText(node) {
|
|
|
28
29
|
visit(value.children);
|
|
29
30
|
};
|
|
30
31
|
visit(raw);
|
|
31
|
-
return parts.join("")
|
|
32
|
+
return trimBlankLines(parts.join(""));
|
|
32
33
|
}
|
|
33
34
|
export function resolveCodeGroupSlotItems(nodes) {
|
|
34
35
|
return flattenCodeGroupVNodes(nodes).map((vnode, index) => {
|