origam 2.38.2 → 2.39.1

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 (63) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/src/assets/css/main.css +1 -1
  3. package/dist/src/assets/css/tokens/dark.css +10 -0
  4. package/dist/src/assets/css/tokens/light.css +5 -0
  5. package/dist/src/assets/scss/tokens/_dark.scss +10 -0
  6. package/dist/src/assets/scss/tokens/_light.scss +5 -0
  7. package/dist/src/components/Card/OrigamCard.vue +12 -5
  8. package/dist/src/components/Code/OrigamCode.vue +2 -1
  9. package/dist/src/components/Dialog/OrigamDialog.vue +8 -4
  10. package/dist/src/components/Dialog/OrigamDialogConfirmation.vue +8 -4
  11. package/dist/src/components/Form/OrigamForm.vue +20 -1
  12. package/dist/src/composables/Commons/content.composable.cjs +20 -0
  13. package/dist/src/composables/Commons/content.composable.d.ts +14 -0
  14. package/dist/src/composables/Commons/content.composable.js +9 -0
  15. package/dist/src/composables/Icon/icon.composable.cjs +9 -2
  16. package/dist/src/composables/Icon/icon.composable.d.ts +10 -0
  17. package/dist/src/composables/Icon/icon.composable.js +6 -2
  18. package/dist/src/composables/index.cjs +12 -0
  19. package/dist/src/composables/index.d.ts +1 -0
  20. package/dist/src/composables/index.js +1 -0
  21. package/dist/src/consts/Commons/mdi-core.const.cjs +61 -0
  22. package/dist/src/consts/Commons/mdi-core.const.d.ts +11 -0
  23. package/dist/src/consts/Commons/mdi-core.const.js +55 -0
  24. package/dist/src/consts/Commons/mdi.const.cjs +9 -54
  25. package/dist/src/consts/Commons/mdi.const.d.ts +2 -2
  26. package/dist/src/consts/Commons/mdi.const.js +3 -53
  27. package/dist/src/interfaces/Card/card.interface.d.ts +3 -11
  28. package/dist/src/interfaces/Commons/content.interface.cjs +1 -0
  29. package/dist/src/interfaces/Commons/content.interface.d.ts +26 -0
  30. package/dist/src/interfaces/Commons/content.interface.js +0 -0
  31. package/dist/src/interfaces/Commons/nuxt-module.interface.d.ts +20 -0
  32. package/dist/src/interfaces/Form/form.interface.d.ts +2 -1
  33. package/dist/src/interfaces/index.cjs +11 -0
  34. package/dist/src/interfaces/index.d.ts +1 -0
  35. package/dist/src/interfaces/index.js +1 -0
  36. package/dist/src/nuxt/create.core.cjs +12 -0
  37. package/dist/src/nuxt/create.core.d.ts +1 -0
  38. package/dist/src/nuxt/create.core.js +1 -0
  39. package/dist/src/nuxt/create.full.cjs +12 -0
  40. package/dist/src/nuxt/create.full.d.ts +7 -0
  41. package/dist/src/nuxt/create.full.js +1 -0
  42. package/dist/src/nuxt/module.cjs +84 -65
  43. package/dist/src/nuxt/module.js +78 -64
  44. package/dist/src/nuxt/plugin.client.cjs +2 -2
  45. package/dist/src/nuxt/plugin.client.js +1 -1
  46. package/dist/src/nuxt/plugin.server.cjs +2 -2
  47. package/dist/src/nuxt/plugin.server.js +1 -1
  48. package/dist/src/origam-core.cjs +153 -0
  49. package/dist/src/origam-core.d.ts +101 -0
  50. package/dist/src/origam-core.js +169 -0
  51. package/dist/src/origam.cjs +11 -133
  52. package/dist/src/origam.d.ts +14 -20
  53. package/dist/src/origam.js +7 -163
  54. package/dist/src/types/tokens.type.d.ts +1 -1
  55. package/dist/src/utils/Code/trim-blank-lines.util.cjs +13 -0
  56. package/dist/src/utils/Code/trim-blank-lines.util.d.ts +9 -0
  57. package/dist/src/utils/Code/trim-blank-lines.util.js +7 -0
  58. package/dist/src/utils/CodeGroup/code-group.util.cjs +2 -1
  59. package/dist/src/utils/CodeGroup/code-group.util.js +2 -1
  60. package/dist/src/utils/index.cjs +11 -0
  61. package/dist/src/utils/index.d.ts +1 -0
  62. package/dist/src/utils/index.js +1 -0
  63. package/package.json +2 -1
@@ -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;
@@ -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
+ }
@@ -3,16 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.activeDefaultsFor = activeDefaultsFor;
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 _contrast = require("./directives/Contrast/contrast.directive.cjs");
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
- const {
25
- aliases = {},
26
- components = origamComponents,
27
- directives = origamDirectives
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
  }
@@ -1,9 +1,17 @@
1
- import type { IDefault, IOrigamOptions, IOrigamTheme } from './interfaces';
2
- import type { TModeResolved } from './types';
1
+ import type { IOrigamOptions } from './interfaces';
3
2
  import '@mdi/font/css/materialdesignicons.css';
4
- import { App } from 'vue';
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;