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.
Files changed (48) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/src/assets/css/tokens/dark-pinned.css +3229 -0
  3. package/dist/src/assets/css/tokens/dark-system.css +3053 -0
  4. package/dist/src/components/Code/OrigamCode.vue +2 -1
  5. package/dist/src/composables/Icon/icon.composable.cjs +9 -2
  6. package/dist/src/composables/Icon/icon.composable.d.ts +10 -0
  7. package/dist/src/composables/Icon/icon.composable.js +6 -2
  8. package/dist/src/consts/Commons/mdi-core.const.cjs +61 -0
  9. package/dist/src/consts/Commons/mdi-core.const.d.ts +11 -0
  10. package/dist/src/consts/Commons/mdi-core.const.js +55 -0
  11. package/dist/src/consts/Commons/mdi.const.cjs +9 -54
  12. package/dist/src/consts/Commons/mdi.const.d.ts +2 -2
  13. package/dist/src/consts/Commons/mdi.const.js +3 -53
  14. package/dist/src/interfaces/Commons/nuxt-module.interface.d.ts +20 -0
  15. package/dist/src/interfaces/Commons/theme.interface.d.ts +13 -0
  16. package/dist/src/nuxt/create.core.cjs +12 -0
  17. package/dist/src/nuxt/create.core.d.ts +1 -0
  18. package/dist/src/nuxt/create.core.js +1 -0
  19. package/dist/src/nuxt/create.full.cjs +12 -0
  20. package/dist/src/nuxt/create.full.d.ts +7 -0
  21. package/dist/src/nuxt/create.full.js +1 -0
  22. package/dist/src/nuxt/module.cjs +84 -65
  23. package/dist/src/nuxt/module.js +78 -64
  24. package/dist/src/nuxt/plugin.client.cjs +2 -2
  25. package/dist/src/nuxt/plugin.client.js +1 -1
  26. package/dist/src/nuxt/plugin.server.cjs +6 -7
  27. package/dist/src/nuxt/plugin.server.js +6 -11
  28. package/dist/src/origam-core.cjs +153 -0
  29. package/dist/src/origam-core.d.ts +101 -0
  30. package/dist/src/origam-core.js +169 -0
  31. package/dist/src/origam.cjs +11 -133
  32. package/dist/src/origam.d.ts +14 -20
  33. package/dist/src/origam.js +7 -163
  34. package/dist/src/ssr.cjs +38 -0
  35. package/dist/src/ssr.d.ts +11 -0
  36. package/dist/src/ssr.js +3 -0
  37. package/dist/src/utils/Code/trim-blank-lines.util.cjs +13 -0
  38. package/dist/src/utils/Code/trim-blank-lines.util.d.ts +9 -0
  39. package/dist/src/utils/Code/trim-blank-lines.util.js +7 -0
  40. package/dist/src/utils/CodeGroup/code-group.util.cjs +2 -1
  41. package/dist/src/utils/CodeGroup/code-group.util.js +2 -1
  42. package/dist/src/utils/Commons/theme-ssr.util.cjs +20 -0
  43. package/dist/src/utils/Commons/theme-ssr.util.d.ts +17 -0
  44. package/dist/src/utils/Commons/theme-ssr.util.js +18 -0
  45. package/dist/src/utils/index.cjs +22 -0
  46. package/dist/src/utils/index.d.ts +2 -0
  47. package/dist/src/utils/index.js +2 -0
  48. package/package.json +5 -1
@@ -1,6 +1,6 @@
1
1
  import { readdirSync, readFileSync, statSync } from "node:fs";
2
- import { join } from "node:path";
3
- import { addComponentsDir, addImports, addPlugin, createResolver, defineNuxtModule } from "@nuxt/kit";
2
+ import { basename, join } from "node:path";
3
+ import { addComponent, addComponentsDir, addImports, addPlugin, createResolver, defineNuxtModule } from "@nuxt/kit";
4
4
  import { origamTheme } from "../themes/origam.theme.js";
5
5
  const MODULE_NAME = "origam-nuxt";
6
6
  const CONFIG_KEY = "origam";
@@ -24,7 +24,9 @@ const DEFAULTS = {
24
24
  includeUtilities: true,
25
25
  prefix: "Origam",
26
26
  locale: {},
27
- icons: {}
27
+ icons: {},
28
+ lite: false,
29
+ include: []
28
30
  };
29
31
  const SCALAR_DEFAULTS = {
30
32
  defaultTheme: DEFAULTS.defaultTheme,
@@ -36,6 +38,73 @@ const SCALAR_DEFAULTS = {
36
38
  includeUtilities: DEFAULTS.includeUtilities,
37
39
  prefix: DEFAULTS.prefix
38
40
  };
41
+ function registerStyleSheets(nuxt, includeUtilities) {
42
+ nuxt.options.css = nuxt.options.css || [];
43
+ const sheets = [
44
+ "origam/tokens/css/light",
45
+ "origam/tokens/css/dark",
46
+ ...includeUtilities ? ["origam/tokens/css/utilities"] : []
47
+ ];
48
+ if (!nuxt.options.css.includes("origam/tokens/css/primitive")) {
49
+ nuxt.options.css.unshift("origam/tokens/css/primitive");
50
+ }
51
+ for (const sheet of sheets) {
52
+ if (!nuxt.options.css.includes(sheet)) {
53
+ nuxt.options.css.push(sheet);
54
+ }
55
+ }
56
+ }
57
+ const EXPORT_NAME_REGEX = /export\s+(?:async\s+)?(?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/g;
58
+ function safely(fn, fallback) {
59
+ try {
60
+ return fn();
61
+ } catch {
62
+ return fallback;
63
+ }
64
+ }
65
+ function exportedNames(file) {
66
+ const src = safely(() => readFileSync(file, "utf-8"), "");
67
+ return [...src.matchAll(EXPORT_NAME_REGEX)].map((m) => m[1]).filter((name) => !NUXT_COMPOSABLES_BLOCKLIST.has(name));
68
+ }
69
+ function collectComposableImports(dir, acc) {
70
+ for (const entry of safely(() => readdirSync(dir), [])) {
71
+ const full = join(dir, entry);
72
+ const stat = safely(() => statSync(full), null);
73
+ if (!stat) continue;
74
+ if (stat.isDirectory()) {
75
+ collectComposableImports(full, acc);
76
+ } else if (/\.(?:m?js|ts)$/.test(entry) && !entry.endsWith(".d.ts")) {
77
+ acc.push(...exportedNames(full).map((name) => ({ name, from: full })));
78
+ }
79
+ }
80
+ }
81
+ function registerComposableImports(composablesRoot) {
82
+ const imports = [];
83
+ collectComposableImports(composablesRoot, imports);
84
+ if (imports.length) {
85
+ addImports(imports);
86
+ }
87
+ }
88
+ function collectVueFiles(dir, files) {
89
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
90
+ const full = join(dir, entry.name);
91
+ if (entry.isDirectory()) collectVueFiles(full, files);
92
+ else if (entry.name.endsWith(".vue") && !entry.name.endsWith(".story.vue")) files.set(basename(entry.name, ".vue"), full);
93
+ }
94
+ }
95
+ function registerComponents(componentsRoot, lite, include) {
96
+ if (!(lite && include.length)) {
97
+ addComponentsDir({ path: componentsRoot, prefix: "", pathPrefix: false, global: false });
98
+ return;
99
+ }
100
+ const files = /* @__PURE__ */ new Map();
101
+ collectVueFiles(componentsRoot, files);
102
+ for (const name of include) {
103
+ const filePath = files.get(name);
104
+ if (!filePath) throw new Error(`[origam] \`include\`: unknown component "${name}"`);
105
+ addComponent({ name, filePath });
106
+ }
107
+ }
39
108
  const origamNuxtModule = defineNuxtModule({
40
109
  meta: {
41
110
  name: MODULE_NAME,
@@ -56,18 +125,10 @@ const origamNuxtModule = defineNuxtModule({
56
125
  const cookieMaxAge = options.cookieMaxAge ?? DEFAULTS.cookieMaxAge;
57
126
  const autoImport = options.autoImport ?? DEFAULTS.autoImport;
58
127
  const includeUtilities = options.includeUtilities ?? DEFAULTS.includeUtilities;
59
- nuxt.options.css = nuxt.options.css || [];
60
- if (!nuxt.options.css.includes("origam/tokens/css/primitive")) {
61
- nuxt.options.css.unshift("origam/tokens/css/primitive");
62
- }
63
- for (const sheet of ["origam/tokens/css/light", "origam/tokens/css/dark"]) {
64
- if (!nuxt.options.css.includes(sheet)) {
65
- nuxt.options.css.push(sheet);
66
- }
67
- }
68
- if (includeUtilities && !nuxt.options.css.includes("origam/tokens/css/utilities")) {
69
- nuxt.options.css.push("origam/tokens/css/utilities");
70
- }
128
+ registerStyleSheets(nuxt, includeUtilities);
129
+ const lite = options.lite ?? DEFAULTS.lite;
130
+ nuxt.options.alias = nuxt.options.alias || {};
131
+ nuxt.options.alias["#origam-create"] = resolver.resolve(lite ? "./create.core" : "./create.full");
71
132
  addPlugin({
72
133
  src: resolver.resolve("./plugin.server"),
73
134
  mode: "server"
@@ -77,55 +138,8 @@ const origamNuxtModule = defineNuxtModule({
77
138
  mode: "client"
78
139
  });
79
140
  if (autoImport) {
80
- const composablesRoot = resolver.resolve("../composables");
81
- const exportNameRegex = /export\s+(?:async\s+)?(?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/g;
82
- const collect = (dir, acc) => {
83
- let entries;
84
- try {
85
- entries = readdirSync(dir);
86
- } catch {
87
- return;
88
- }
89
- for (const entry of entries) {
90
- const full = join(dir, entry);
91
- let s;
92
- try {
93
- s = statSync(full);
94
- } catch {
95
- continue;
96
- }
97
- if (s.isDirectory()) {
98
- collect(full, acc);
99
- continue;
100
- }
101
- if (!/\.(?:m?js|ts)$/.test(entry)) continue;
102
- if (entry.endsWith(".d.ts")) continue;
103
- let src = "";
104
- try {
105
- src = readFileSync(full, "utf-8");
106
- } catch {
107
- continue;
108
- }
109
- let m;
110
- exportNameRegex.lastIndex = 0;
111
- while (m = exportNameRegex.exec(src)) {
112
- const name = m[1];
113
- if (NUXT_COMPOSABLES_BLOCKLIST.has(name)) continue;
114
- acc.push({ name, from: full });
115
- }
116
- }
117
- };
118
- const imports = [];
119
- collect(composablesRoot, imports);
120
- if (imports.length) {
121
- addImports(imports);
122
- }
123
- addComponentsDir({
124
- path: resolver.resolve("../components"),
125
- prefix: "",
126
- pathPrefix: false,
127
- global: false
128
- });
141
+ registerComposableImports(resolver.resolve("../composables"));
142
+ registerComponents(resolver.resolve("../components"), lite, options.include ?? DEFAULTS.include);
129
143
  }
130
144
  nuxt.options.runtimeConfig.public = nuxt.options.runtimeConfig.public || {};
131
145
  nuxt.options.runtimeConfig.public.origam = {
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
 
7
7
  var _vue = require("vue");
8
8
  var _theme = require("../composables/Commons/theme.composable.cjs");
9
- var _origam = require("../origam.cjs");
9
+ var _origamCreate = require("#origam-create");
10
10
  var _nuxtIcons = require("../utils/Commons/nuxt-icons.util.cjs");
11
11
  var _nuxtLocale = require("../utils/Commons/nuxt-locale.util.cjs");
12
12
  var _applyTheme = require("../utils/Commons/apply-theme.util.cjs");
@@ -31,7 +31,7 @@ module.exports = (0, _app.defineNuxtPlugin)({
31
31
  const initialTheme = (0, _applyTheme.knownBrand)(themeFromDom, config.themes) ?? (0, _applyTheme.knownBrand)(themeCookie.value, config.themes) ?? config.defaultTheme;
32
32
  const initialMode = modeCookie.value ?? config.defaultMode;
33
33
  const themes = config.themes ?? [];
34
- const origam = (0, _origam.createOrigam)({
34
+ const origam = (0, _origamCreate.createOrigamForNuxt)({
35
35
  themes,
36
36
  ssr: true,
37
37
  ...(0, _nuxtLocale.nuxtLocaleOptions)(config),
@@ -1,6 +1,6 @@
1
1
  import { ref, watch } from "vue";
2
2
  import { useTheme } from "../composables/Commons/theme.composable.js";
3
- import { createOrigam } from "../origam.js";
3
+ import { createOrigamForNuxt as createOrigam } from "#origam-create";
4
4
  import { nuxtIconsOptions } from "../utils/Commons/nuxt-icons.util.js";
5
5
  import { nuxtLocaleOptions } from "../utils/Commons/nuxt-locale.util.js";
6
6
  import { isModePinned, knownBrand } from "../utils/Commons/apply-theme.util.js";
@@ -4,10 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var _origam = require("../origam.cjs");
7
+ var _origamCreate = require("#origam-create");
8
8
  var _nuxtIcons = require("../utils/Commons/nuxt-icons.util.cjs");
9
9
  var _nuxtLocale = require("../utils/Commons/nuxt-locale.util.cjs");
10
10
  var _applyTheme = require("../utils/Commons/apply-theme.util.cjs");
11
+ var _themeSsr = require("../utils/Commons/theme-ssr.util.cjs");
11
12
  var _ssrStyles = require("../utils/Commons/ssr-styles.util.cjs");
12
13
  var _theme = require("../consts/Commons/theme.const.cjs");
13
14
  var _app = require("#app");
@@ -54,12 +55,10 @@ module.exports = (0, _app.defineNuxtPlugin)({
54
55
  htmlAttrs[_theme.ORIGAM_THEME_ATTR] = resolvedTheme;
55
56
  }
56
57
  const themes = config.themes ?? [];
57
- const activeThemes = themes.filter(theme => {
58
- const brandMatches = resolvedTheme === _theme.ORIGAM_THEME_AUTO ? theme.name === void 0 || theme.name === "" : theme.name === resolvedTheme;
59
- const modeMatches = !modePinned || theme.mode === void 0 || theme.mode === "auto" || theme.mode === resolvedMode;
60
- return brandMatches && modeMatches;
58
+ const ssrThemeCss = (0, _themeSsr.renderThemeCss)(themes, {
59
+ theme: resolvedTheme,
60
+ mode: modePinned ? resolvedMode : "auto"
61
61
  });
62
- const ssrThemeCss = modePinned ? activeThemes.map(_applyTheme.themeToCss).join("\n") : [...activeThemes.filter(t => t.mode !== "light" && t.mode !== "dark").map(_applyTheme.themeToCss), ...activeThemes.filter(t => t.mode === "light").map(_applyTheme.themeToUnpinnedCss), ...activeThemes.filter(t => t.mode === "dark").map(_applyTheme.themeToUnpinnedCss)].join("\n");
63
62
  (0, _app.useHead)({
64
63
  htmlAttrs,
65
64
  style: ssrThemeCss ? [{
@@ -68,7 +67,7 @@ module.exports = (0, _app.defineNuxtPlugin)({
68
67
  innerHTML: ssrThemeCss
69
68
  }] : []
70
69
  });
71
- const origam = (0, _origam.createOrigam)({
70
+ const origam = (0, _origamCreate.createOrigamForNuxt)({
72
71
  themes,
73
72
  ssr: true,
74
73
  ...(0, _nuxtLocale.nuxtLocaleOptions)(config),
@@ -1,7 +1,8 @@
1
- import { createOrigam } from "../origam.js";
1
+ import { createOrigamForNuxt as createOrigam } from "#origam-create";
2
2
  import { nuxtIconsOptions } from "../utils/Commons/nuxt-icons.util.js";
3
3
  import { nuxtLocaleOptions } from "../utils/Commons/nuxt-locale.util.js";
4
- import { isModePinned, knownBrand, themeToCss, themeToUnpinnedCss } from "../utils/Commons/apply-theme.util.js";
4
+ import { isModePinned, knownBrand } from "../utils/Commons/apply-theme.util.js";
5
+ import { renderThemeCss } from "../utils/Commons/theme-ssr.util.js";
5
6
  import { getSsrStyles } from "../utils/Commons/ssr-styles.util.js";
6
7
  import { ORIGAM_MODE_ATTR, ORIGAM_MODE_DARK, ORIGAM_MODE_LIGHT, ORIGAM_THEME_ATTR, ORIGAM_THEME_AUTO } from "../consts/Commons/theme.const.js";
7
8
  import { defineNuxtPlugin, useCookie, useHead, useRuntimeConfig } from "#app";
@@ -48,16 +49,10 @@ export default defineNuxtPlugin({
48
49
  htmlAttrs[ORIGAM_THEME_ATTR] = resolvedTheme;
49
50
  }
50
51
  const themes = config.themes ?? [];
51
- const activeThemes = themes.filter((theme) => {
52
- const brandMatches = resolvedTheme === ORIGAM_THEME_AUTO ? theme.name === void 0 || theme.name === "" : theme.name === resolvedTheme;
53
- const modeMatches = !modePinned || theme.mode === void 0 || theme.mode === "auto" || theme.mode === resolvedMode;
54
- return brandMatches && modeMatches;
52
+ const ssrThemeCss = renderThemeCss(themes, {
53
+ theme: resolvedTheme,
54
+ mode: modePinned ? resolvedMode : "auto"
55
55
  });
56
- const ssrThemeCss = modePinned ? activeThemes.map(themeToCss).join("\n") : [
57
- ...activeThemes.filter((t) => t.mode !== "light" && t.mode !== "dark").map(themeToCss),
58
- ...activeThemes.filter((t) => t.mode === "light").map(themeToUnpinnedCss),
59
- ...activeThemes.filter((t) => t.mode === "dark").map(themeToUnpinnedCss)
60
- ].join("\n");
61
56
  useHead({
62
57
  htmlAttrs,
63
58
  style: ssrThemeCss ? [{ id: "origam-theme-ssr", key: "origam-theme-ssr", innerHTML: ssrThemeCss }] : []
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.activeDefaultsFor = activeDefaultsFor;
7
+ exports.createOrigamCore = createOrigamCore;
8
+ var _composables = require("./composables/index.cjs");
9
+ var _consts = require("./consts/index.cjs");
10
+ var _contrast = require("./directives/Contrast/contrast.directive.cjs");
11
+ var _utils = require("./utils/index.cjs");
12
+ var _vue = require("vue");
13
+ function scheduleDisplayUpdate(app, display) {
14
+ const nuxt = app.$nuxt;
15
+ if (nuxt) {
16
+ nuxt.hook("app:suspense:resolve", () => display.update());
17
+ return;
18
+ }
19
+ const {
20
+ mount
21
+ } = app;
22
+ app.mount = (...args) => {
23
+ const vm = mount(...args);
24
+ (0, _vue.nextTick)(() => display.update());
25
+ app.mount = mount;
26
+ return vm;
27
+ };
28
+ }
29
+ function origamAccessor() {
30
+ return (0, _vue.reactive)({
31
+ display: inject.call(this, _consts.ORIGAM_DISPLAY_KEY),
32
+ icons: inject.call(this, _consts.ORIGAM_ICONS_KEY),
33
+ locale: inject.call(this, _consts.ORIGAM_LOCALE_KEY),
34
+ date: inject.call(this, _consts.ORIGAM_DATE_ADAPTER_KEY)
35
+ });
36
+ }
37
+ function installOptionsApiMixin(app) {
38
+ app.mixin({
39
+ computed: {
40
+ $origam: origamAccessor
41
+ }
42
+ });
43
+ }
44
+ function createOrigamCore(origam = {}) {
45
+ const {
46
+ blueprint,
47
+ ...rest
48
+ } = origam;
49
+ const options = (0, _utils.mergeDeep)(blueprint, rest);
50
+ const {
51
+ aliases = {},
52
+ components = {},
53
+ directives = {}
54
+ } = options;
55
+ const suppliedThemes = [...(options.theme ? [options.theme] : []), ...(options.themes ?? [])];
56
+ const allThemes = [...suppliedThemes];
57
+ const installedThemes = (0, _utils.installedThemesFromList)(allThemes);
58
+ const defaultsRef = (0, _composables.createDefaults)({});
59
+ defaultsRef.value = activeDefaultsFor(allThemes, allThemes[0]?.name ?? "", void 0);
60
+ const themedKeysUnion = (0, _composables.themedPropKeysUnion)(allThemes.map(theme => theme.components).filter(components2 => !!components2));
61
+ const variantPresets = (0, _composables.resolveVariantPresetRegistry)(_consts.VARIANT_PRESETS, allThemes.map(theme => theme.variants).filter(variants => !!variants));
62
+ const scope = (0, _vue.effectScope)();
63
+ return scope.run(() => {
64
+ const icons = (0, _composables.createIconsCore)(options.icons);
65
+ const display = (0, _composables.createDisplay)(options.display, options.ssr);
66
+ const locale = (0, _composables.createLocale)(options.locale);
67
+ const date = (0, _composables.createDate)(options.date, locale);
68
+ const goTo = (0, _composables.createGoTo)(options.goTo, locale);
69
+ (0, _contrast.setContrastConfig)(options.contrast);
70
+ const install = app => {
71
+ if (allThemes.length) {
72
+ (0, _utils.applyThemes)(allThemes);
73
+ }
74
+ for (const key in directives) {
75
+ app.directive(key, directives[key]);
76
+ }
77
+ for (const key in components) {
78
+ app.component(key, components[key]);
79
+ }
80
+ for (const key in aliases) {
81
+ app.component(key, (0, _vue.defineComponent)({
82
+ ...aliases[key],
83
+ name: key,
84
+ aliasName: aliases[key].name
85
+ }));
86
+ }
87
+ const appScope = (0, _vue.effectScope)();
88
+ app.onUnmount(() => appScope.stop());
89
+ app.provide(_consts.ORIGAM_ICONS_KEY, icons);
90
+ app.provide(_consts.ORIGAM_CODE_KEY, options.code ?? {});
91
+ app.provide(_consts.ORIGAM_DISPLAY_KEY, display);
92
+ app.provide(_consts.ORIGAM_LOCALE_KEY, locale);
93
+ app.provide(_consts.ORIGAM_DATE_OPTIONS_KEY, date.options);
94
+ app.provide(_consts.ORIGAM_DATE_ADAPTER_KEY, date.instance);
95
+ app.provide(_consts.ORIGAM_GO_TO_KEY, goTo);
96
+ app.provide(_consts.ORIGAM_THEMES_KEY, installedThemes);
97
+ app.provide(_consts.ORIGAM_DEFAULTS_KEY, defaultsRef);
98
+ if (!_consts.IN_BROWSER) {
99
+ app.provide(_consts.ORIGAM_SSR_STYLES_KEY, (0, _utils.registerSsrStyleCollector)(app));
100
+ }
101
+ (0, _composables.installThemePropsResolver)(app, themedKeysUnion, variantPresets);
102
+ app.provide(_consts.ORIGAM_THEME_DEFAULTS_KEY, (brand, mode) => activeDefaultsFor(allThemes, brand, mode));
103
+ if (_consts.IN_BROWSER && options.ssr) {
104
+ scheduleDisplayUpdate(app, display);
105
+ }
106
+ if (typeof __VUE_OPTIONS_API__ !== "boolean" || __VUE_OPTIONS_API__) {
107
+ installOptionsApiMixin(app);
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
+ };
131
+ });
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
+ }
@@ -0,0 +1,101 @@
1
+ import type { IDefault, IDisplayInstance, IOrigamOptions, IOrigamTheme } from './interfaces';
2
+ import type { TModeResolved } from './types';
3
+ import { App } from 'vue';
4
+ /*********************************************************
5
+ * createOrigamCore (#1384)
6
+ *
7
+ * @description
8
+ * Lightweight entry of `createOrigam`: same options, same install (themes,
9
+ * PROPS-FIRST resolver, defaults, locale, display, SSR styles) but it imports
10
+ * NEITHER the component/directive namespaces NOR the MDI stylesheet. Components
11
+ * and directives are registered only when passed in `options.components` /
12
+ * `options.directives`, so the bundler keeps what the app imports and nothing
13
+ * else. Icons are opt-in: the app imports `@mdi/font/css/materialdesignicons.css`
14
+ * itself (or passes SVG icons).
15
+ * @description
16
+ * `createOrigam` (origam.ts) is this function plus the full components,
17
+ * directives and the MDI stylesheet as defaults.
18
+ ********************************************************/
19
+ export declare function createOrigamCore(origam?: IOrigamOptions): {
20
+ install: (app: App) => void;
21
+ unmount: () => void;
22
+ display: IDisplayInstance;
23
+ icons: Record<string, unknown>;
24
+ locale: {
25
+ isRtl: import("vue").Ref<boolean>;
26
+ rtl: import("vue").Ref<Record<string, boolean>>;
27
+ name: string;
28
+ messages: import("vue").ComputedRef<import("./interfaces").ILocaleMessages>;
29
+ current: import("vue").Ref<string>;
30
+ fallback: import("vue").Ref<string>;
31
+ t: (key: string, ...params: unknown[]) => string;
32
+ n: (value: number) => string;
33
+ provide: (props: import("./interfaces").ILocaleProps) => import("./interfaces").ILocaleInstance;
34
+ };
35
+ date: {
36
+ options: import("./interfaces").IDateOptions;
37
+ instance: {
38
+ locale?: any;
39
+ date: (value?: any) => unknown;
40
+ format: (date: unknown, formatString: string) => string;
41
+ toJsDate: (value: unknown) => Date;
42
+ parseISO: (date: string) => unknown;
43
+ toISO: (date: unknown) => string;
44
+ startOfDay: (date: unknown) => unknown;
45
+ endOfDay: (date: unknown) => unknown;
46
+ startOfWeek: (date: unknown, firstDayOfWeek?: number | string) => unknown;
47
+ endOfWeek: (date: unknown) => unknown;
48
+ startOfMonth: (date: unknown) => unknown;
49
+ endOfMonth: (date: unknown) => unknown;
50
+ startOfYear: (date: unknown) => unknown;
51
+ endOfYear: (date: unknown) => unknown;
52
+ isAfter: (date: unknown, comparing: unknown) => boolean;
53
+ isAfterDay: (value: unknown, comparing: unknown) => boolean;
54
+ isSameDay: (date: unknown, comparing: unknown) => boolean;
55
+ isSameMonth: (date: unknown, comparing: unknown) => boolean;
56
+ isSameYear: (value: unknown, comparing: unknown) => boolean;
57
+ isBefore: (date: unknown, comparing: unknown) => boolean;
58
+ isEqual: (date: unknown, comparing: unknown) => boolean;
59
+ isValid: (date: any) => boolean;
60
+ isWithinRange: (date: unknown, range: [unknown, unknown]) => boolean;
61
+ addMinutes: (date: unknown, amount: number) => unknown;
62
+ addHours: (date: unknown, amount: number) => unknown;
63
+ addDays: (date: unknown, amount: number) => unknown;
64
+ addWeeks: (date: unknown, amount: number) => unknown;
65
+ addMonths: (date: unknown, amount: number) => unknown;
66
+ getYear: (date: unknown) => number;
67
+ setYear: (date: unknown, year: number) => unknown;
68
+ getDiff: (date: unknown, comparing: unknown, unit?: string) => number;
69
+ getWeekArray: (date: unknown, firstDayOfWeek?: number | string) => unknown[][];
70
+ getWeekdays: (firstDayOfWeek?: number | string) => string[];
71
+ getMonth: (date: unknown) => number;
72
+ setMonth: (date: unknown, month: number) => unknown;
73
+ getDate: (date: unknown) => number;
74
+ setDate: (date: unknown, day: number) => unknown;
75
+ getNextMonth: (date: unknown) => unknown;
76
+ getPreviousMonth: (date: unknown) => unknown;
77
+ getHours: (date: unknown) => number;
78
+ setHours: (date: unknown, hours: number) => unknown;
79
+ getMinutes: (date: unknown) => number;
80
+ setMinutes: (date: unknown, minutes: number) => unknown;
81
+ };
82
+ };
83
+ goTo: import("./interfaces").IGoToInstance;
84
+ themes: import("./types").TInstalledThemes;
85
+ _defaultsRef: import("vue").Ref<IDefault, IDefault>;
86
+ _activeDefaultsFor: (brand: string, mode?: TModeResolved) => IDefault;
87
+ };
88
+ /**
89
+ * Collapse the per-component DEFAULT PROPS (`theme.components`) of the themes
90
+ * matching the ACTIVE brand×mode into a single `IDefault`. A theme matches when
91
+ * its `name` equals `brand` AND its `mode` is compatible with the active `mode`:
92
+ * - the theme is mode-agnostic (`mode` unset or `'auto'`), OR
93
+ * - the active `mode` is unset (match every mode of the brand — used for the
94
+ * mode-less install-time seed before the plugins resolve a concrete mode), OR
95
+ * - the theme's `mode` equals the active `mode`.
96
+ * Matching themes are deep-merged in install order (later wins) via the shared
97
+ * `mergeDeep` util — no hand-rolled merge.
98
+ *
99
+ * Pure (no DOM / Vue access) so it runs identically on the server and client.
100
+ */
101
+ export declare function activeDefaultsFor(themes: IOrigamTheme[], brand: string, mode?: TModeResolved): IDefault;