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
@@ -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 { setContrastConfig } from "./directives/Contrast/contrast.directive.js";
30
- import { applyThemes, installedThemesFromList, mergeDeep, registerSsrStyleCollector } from "./utils/index.js";
3
+ import { createOrigamCore } from "./origam-core.js";
4
+ import { mergeDeep } from "./utils/index.js";
31
5
  import "@mdi/font/css/materialdesignicons.css";
32
- import { defineComponent, effectScope, nextTick, reactive } from "vue";
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
- const {
37
- aliases = {},
38
- components = origamComponents,
39
- directives = origamDirectives
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
- }