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.
- package/CHANGELOG.md +29 -0
- package/dist/src/assets/css/main.css +1 -1
- package/dist/src/assets/css/tokens/dark.css +10 -0
- package/dist/src/assets/css/tokens/light.css +5 -0
- package/dist/src/assets/scss/tokens/_dark.scss +10 -0
- package/dist/src/assets/scss/tokens/_light.scss +5 -0
- package/dist/src/components/Card/OrigamCard.vue +12 -5
- package/dist/src/components/Code/OrigamCode.vue +2 -1
- package/dist/src/components/Dialog/OrigamDialog.vue +8 -4
- package/dist/src/components/Dialog/OrigamDialogConfirmation.vue +8 -4
- package/dist/src/components/Form/OrigamForm.vue +20 -1
- package/dist/src/composables/Commons/content.composable.cjs +20 -0
- package/dist/src/composables/Commons/content.composable.d.ts +14 -0
- package/dist/src/composables/Commons/content.composable.js +9 -0
- 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/composables/index.cjs +12 -0
- package/dist/src/composables/index.d.ts +1 -0
- package/dist/src/composables/index.js +1 -0
- 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/Card/card.interface.d.ts +3 -11
- package/dist/src/interfaces/Commons/content.interface.cjs +1 -0
- package/dist/src/interfaces/Commons/content.interface.d.ts +26 -0
- package/dist/src/interfaces/Commons/content.interface.js +0 -0
- package/dist/src/interfaces/Commons/nuxt-module.interface.d.ts +20 -0
- package/dist/src/interfaces/Form/form.interface.d.ts +2 -1
- package/dist/src/interfaces/index.cjs +11 -0
- package/dist/src/interfaces/index.d.ts +1 -0
- package/dist/src/interfaces/index.js +1 -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 +2 -2
- package/dist/src/nuxt/plugin.server.js +1 -1
- 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/types/tokens.type.d.ts +1 -1
- 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/index.cjs +11 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.js +1 -0
- package/package.json +2 -1
|
@@ -1,57 +1,7 @@
|
|
|
1
|
-
import { h } from "vue";
|
|
2
|
-
import { OrigamClassIcon } from "../../components/Icon/index.js";
|
|
3
1
|
import { MDI_ICONS } from "../../enums/index.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// Consumers may pass either the bare name (`magnify`) — as is the case when
|
|
7
|
-
// an `mdi:` prefix has been stripped by the icon resolver — or the already-
|
|
8
|
-
// prefixed form (`mdi-magnify`, as found in MDI_ALIASES below). We
|
|
9
|
-
// normalise to always emit the `mdi-` class so the font renders.
|
|
10
|
-
component: (props) => h(OrigamClassIcon, {
|
|
11
|
-
...props,
|
|
12
|
-
icon: typeof props.icon === "string" && !props.icon.startsWith("mdi-") ? `mdi-${props.icon}` : props.icon,
|
|
13
|
-
class: "mdi"
|
|
14
|
-
})
|
|
15
|
-
};
|
|
2
|
+
import { MDI_CORE_ALIASES } from "./mdi-core.const.js";
|
|
3
|
+
export { MDI } from "./mdi-core.const.js";
|
|
16
4
|
export const MDI_ALIASES = {
|
|
17
5
|
...MDI_ICONS,
|
|
18
|
-
|
|
19
|
-
complete: "mdi-check",
|
|
20
|
-
cancel: "mdi-close-circle",
|
|
21
|
-
close: "mdi-close",
|
|
22
|
-
delete: "mdi-close-circle",
|
|
23
|
-
clear: "mdi-close-circle",
|
|
24
|
-
success: "mdi-check-circle",
|
|
25
|
-
info: "mdi-information",
|
|
26
|
-
warning: "mdi-alert-circle",
|
|
27
|
-
error: "mdi-close-circle",
|
|
28
|
-
prev: "mdi-chevron-left",
|
|
29
|
-
next: "mdi-chevron-right",
|
|
30
|
-
checkboxOn: "mdi-checkbox-marked",
|
|
31
|
-
checkboxOff: "mdi-checkbox-blank-outline",
|
|
32
|
-
checkboxIndeterminate: "mdi-minus-box",
|
|
33
|
-
delimiter: "mdi-circle",
|
|
34
|
-
sortAsc: "mdi-arrow-up",
|
|
35
|
-
sortDesc: "mdi-arrow-down",
|
|
36
|
-
expand: "mdi-chevron-down",
|
|
37
|
-
menu: "mdi-menu",
|
|
38
|
-
subgroup: "mdi-menu-down",
|
|
39
|
-
dropdown: "mdi-menu-down",
|
|
40
|
-
radioOn: "mdi-radiobox-marked",
|
|
41
|
-
radioOff: "mdi-radiobox-blank",
|
|
42
|
-
edit: "mdi-pencil",
|
|
43
|
-
ratingEmpty: "mdi-star-outline",
|
|
44
|
-
ratingFull: "mdi-star",
|
|
45
|
-
ratingHalf: "mdi-star-half-full",
|
|
46
|
-
loading: "mdi-cached",
|
|
47
|
-
first: "mdi-page-first",
|
|
48
|
-
last: "mdi-page-last",
|
|
49
|
-
unfold: "mdi-unfold-more-horizontal",
|
|
50
|
-
file: "mdi-paperclip",
|
|
51
|
-
plus: "mdi-plus",
|
|
52
|
-
minus: "mdi-minus",
|
|
53
|
-
calendar: "mdi-calendar",
|
|
54
|
-
eyeDropper: "mdi-eyedropper",
|
|
55
|
-
eyeOff: "mdi-eye-off-outline",
|
|
56
|
-
eyeOn: "mdi-eye-outline"
|
|
6
|
+
...MDI_CORE_ALIASES
|
|
57
7
|
};
|
|
@@ -15,17 +15,9 @@ import type { IPaddingProps } from '../Commons/padding.interface';
|
|
|
15
15
|
import type { IPositionProps } from '../Commons/position.interface';
|
|
16
16
|
import type { IRippleProps } from '../Commons/ripple.interface';
|
|
17
17
|
import type { IRoundedProps } from '../Commons/rounded.interface';
|
|
18
|
-
import type {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* contentDisplay
|
|
22
|
-
*
|
|
23
|
-
* @description
|
|
24
|
-
* `display` of the `.origam-card__content` wrapper around the default and `text` slots (#1100).
|
|
25
|
-
* `contents` flattens it so the slotted children become direct items of the card's own grid / flex layout.
|
|
26
|
-
* Defaults to the `--origam-card__content---display` token (`block`).
|
|
27
|
-
********************************************************/
|
|
28
|
-
contentDisplay?: TCardContentDisplay;
|
|
18
|
+
import type { IContentProps } from '../Commons/content.interface';
|
|
19
|
+
import type { TCardType } from '../../types/Card/card.type';
|
|
20
|
+
export interface ICardProps extends ICommonsComponentProps, ITagProps, IBorderProps, IColorProps, IBgColorProps, IDensityProps, IDimensionProps, IElevationProps, ILoaderProps, ILocationProps, IPositionProps, IRoundedProps, IMarginProps, IPaddingProps, ILinkProps, IRippleProps, IAdjacentProps, IActiveProps, IHoverProps, IContentProps {
|
|
29
21
|
disabled?: boolean;
|
|
30
22
|
flat?: boolean;
|
|
31
23
|
image?: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { TCardContentDisplay } from '../../types/Card/card.type';
|
|
2
|
+
/*********************************************************
|
|
3
|
+
* IContentProps
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* Layout of the `.origam-*__content` wrapper around a component's default slot
|
|
7
|
+
* (Card, Form). Both ride INLINE on that wrapper, never as a custom property on
|
|
8
|
+
* the root: a custom property would inherit into any Card/Form nested in the
|
|
9
|
+
* slot. Unset, the `--origam-{cmp}__content---display|gap` tokens apply.
|
|
10
|
+
********************************************************/
|
|
11
|
+
export interface IContentProps {
|
|
12
|
+
/*********************************************************
|
|
13
|
+
* contentDisplay
|
|
14
|
+
*
|
|
15
|
+
* @description
|
|
16
|
+
* `display` of the content wrapper. `contents` flattens it into the host's own layout.
|
|
17
|
+
********************************************************/
|
|
18
|
+
contentDisplay?: TCardContentDisplay;
|
|
19
|
+
/*********************************************************
|
|
20
|
+
* contentGap
|
|
21
|
+
*
|
|
22
|
+
* @description
|
|
23
|
+
* `gap` between the blocks of the content wrapper — a CSS length, or a number read as px. Needs `flex` / `grid`.
|
|
24
|
+
********************************************************/
|
|
25
|
+
contentGap?: string | number;
|
|
26
|
+
}
|
|
File without changes
|
|
@@ -109,6 +109,26 @@ export interface IOrigamNuxtModuleOptions {
|
|
|
109
109
|
* @default true
|
|
110
110
|
*/
|
|
111
111
|
includeUtilities?: boolean;
|
|
112
|
+
/*********************************************************
|
|
113
|
+
* lite (#1384)
|
|
114
|
+
*
|
|
115
|
+
* @description
|
|
116
|
+
* Build the app with `createOrigamCore` instead of `createOrigam`: no `import *` of the components and directives, no MDI stylesheet. Themes, PROPS-FIRST, locale, display and SSR styles are unchanged; components come from Nuxt's on-demand auto-import, so only the ones a template uses are bundled.
|
|
117
|
+
* @description
|
|
118
|
+
* Icons become opt-in: add `@mdi/font/css/materialdesignicons.css` to `css` yourself, or pass SVG icons.
|
|
119
|
+
*
|
|
120
|
+
* @default false
|
|
121
|
+
********************************************************/
|
|
122
|
+
lite?: boolean;
|
|
123
|
+
/*********************************************************
|
|
124
|
+
* include (#1384)
|
|
125
|
+
*
|
|
126
|
+
* @description
|
|
127
|
+
* Only meaningful with `lite` and `autoImport`: names of the components Nuxt may auto-import (`['OrigamBtn', 'OrigamTitle']`). When omitted, every component stays available on demand. An unknown name fails the build.
|
|
128
|
+
*
|
|
129
|
+
* @default undefined
|
|
130
|
+
********************************************************/
|
|
131
|
+
include?: string[];
|
|
112
132
|
/**
|
|
113
133
|
* Prefix applied to auto-imported components. Origam ships components
|
|
114
134
|
* already prefixed `Origam*` so the default is an empty prefix — set
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ComponentInternalInstance, ComputedRef, Raw, Ref } from 'vue';
|
|
2
2
|
import type { ICommonsComponentEmits, ICommonsComponentProps, ICommonsComponentSlots } from '../Commons/commons.interface';
|
|
3
|
+
import type { IContentProps } from '../Commons/content.interface';
|
|
3
4
|
import type { ITypographyProps } from '../Commons/typography.interface';
|
|
4
5
|
import type { TValidateOn } from '../../types/Commons/validation.type';
|
|
5
6
|
export interface IFormProvide {
|
|
@@ -19,7 +20,7 @@ export interface IFormProvide {
|
|
|
19
20
|
isValid: Ref<boolean | null | undefined>;
|
|
20
21
|
validateOn: Ref<TValidateOn | undefined>;
|
|
21
22
|
}
|
|
22
|
-
export interface IFormProps extends ICommonsComponentProps, Pick<ITypographyProps, 'fontSize' | 'fontWeight' | 'lineHeight' | 'letterSpacing'> {
|
|
23
|
+
export interface IFormProps extends ICommonsComponentProps, IContentProps, Pick<ITypographyProps, 'fontSize' | 'fontWeight' | 'lineHeight' | 'letterSpacing'> {
|
|
23
24
|
disabled?: boolean;
|
|
24
25
|
fastFail?: boolean;
|
|
25
26
|
readonly?: boolean;
|
|
@@ -938,6 +938,17 @@ Object.keys(_margin).forEach(function (key) {
|
|
|
938
938
|
}
|
|
939
939
|
});
|
|
940
940
|
});
|
|
941
|
+
var _content = require("./Commons/content.interface.cjs");
|
|
942
|
+
Object.keys(_content).forEach(function (key) {
|
|
943
|
+
if (key === "default" || key === "__esModule") return;
|
|
944
|
+
if (key in exports && exports[key] === _content[key]) return;
|
|
945
|
+
Object.defineProperty(exports, key, {
|
|
946
|
+
enumerable: true,
|
|
947
|
+
get: function () {
|
|
948
|
+
return _content[key];
|
|
949
|
+
}
|
|
950
|
+
});
|
|
951
|
+
});
|
|
941
952
|
var _message = require("./Commons/message.interface.cjs");
|
|
942
953
|
Object.keys(_message).forEach(function (key) {
|
|
943
954
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -83,6 +83,7 @@ export * from './Commons/loader.interface';
|
|
|
83
83
|
export * from './Commons/location.interface';
|
|
84
84
|
export * from './Commons/locale.interface';
|
|
85
85
|
export * from './Commons/margin.interface';
|
|
86
|
+
export * from './Commons/content.interface';
|
|
86
87
|
export * from './Commons/message.interface';
|
|
87
88
|
export * from './Commons/nested.interface';
|
|
88
89
|
export * from './Commons/opacity.interface';
|
|
@@ -83,6 +83,7 @@ export * from "./Commons/loader.interface.js";
|
|
|
83
83
|
export * from "./Commons/location.interface.js";
|
|
84
84
|
export * from "./Commons/locale.interface.js";
|
|
85
85
|
export * from "./Commons/margin.interface.js";
|
|
86
|
+
export * from "./Commons/content.interface.js";
|
|
86
87
|
export * from "./Commons/message.interface.js";
|
|
87
88
|
export * from "./Commons/nested.interface.js";
|
|
88
89
|
export * from "./Commons/opacity.interface.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "createOrigamForNuxt", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _origamCore.createOrigamCore;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _origamCore = require("../origam-core.cjs");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createOrigamCore as createOrigamForNuxt } from '../origam-core';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createOrigamCore as createOrigamForNuxt } from "../origam-core.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "createOrigamForNuxt", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _origam.createOrigam;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _origam = require("../origam.cjs");
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*********************************************************
|
|
2
|
+
* createOrigamForNuxt
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* The Nuxt plugins create the app through the `#origam-create` alias, which the module points at this file (default) or at `create.core.ts` (`lite: true`, #1384).
|
|
6
|
+
********************************************************/
|
|
7
|
+
export { createOrigam as createOrigamForNuxt } from '../origam';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createOrigam as createOrigamForNuxt } from "../origam.js";
|
package/dist/src/nuxt/module.cjs
CHANGED
|
@@ -25,7 +25,9 @@ const DEFAULTS = {
|
|
|
25
25
|
includeUtilities: true,
|
|
26
26
|
prefix: "Origam",
|
|
27
27
|
locale: {},
|
|
28
|
-
icons: {}
|
|
28
|
+
icons: {},
|
|
29
|
+
lite: false,
|
|
30
|
+
include: []
|
|
29
31
|
};
|
|
30
32
|
const SCALAR_DEFAULTS = {
|
|
31
33
|
defaultTheme: DEFAULTS.defaultTheme,
|
|
@@ -37,6 +39,81 @@ const SCALAR_DEFAULTS = {
|
|
|
37
39
|
includeUtilities: DEFAULTS.includeUtilities,
|
|
38
40
|
prefix: DEFAULTS.prefix
|
|
39
41
|
};
|
|
42
|
+
function registerStyleSheets(nuxt, includeUtilities) {
|
|
43
|
+
nuxt.options.css = nuxt.options.css || [];
|
|
44
|
+
const sheets = ["origam/tokens/css/light", "origam/tokens/css/dark", ...(includeUtilities ? ["origam/tokens/css/utilities"] : [])];
|
|
45
|
+
if (!nuxt.options.css.includes("origam/tokens/css/primitive")) {
|
|
46
|
+
nuxt.options.css.unshift("origam/tokens/css/primitive");
|
|
47
|
+
}
|
|
48
|
+
for (const sheet of sheets) {
|
|
49
|
+
if (!nuxt.options.css.includes(sheet)) {
|
|
50
|
+
nuxt.options.css.push(sheet);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const EXPORT_NAME_REGEX = /export\s+(?:async\s+)?(?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/g;
|
|
55
|
+
function safely(fn, fallback) {
|
|
56
|
+
try {
|
|
57
|
+
return fn();
|
|
58
|
+
} catch {
|
|
59
|
+
return fallback;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function exportedNames(file) {
|
|
63
|
+
const src = safely(() => (0, _nodeFs.readFileSync)(file, "utf-8"), "");
|
|
64
|
+
return [...src.matchAll(EXPORT_NAME_REGEX)].map(m => m[1]).filter(name => !NUXT_COMPOSABLES_BLOCKLIST.has(name));
|
|
65
|
+
}
|
|
66
|
+
function collectComposableImports(dir, acc) {
|
|
67
|
+
for (const entry of safely(() => (0, _nodeFs.readdirSync)(dir), [])) {
|
|
68
|
+
const full = (0, _nodePath.join)(dir, entry);
|
|
69
|
+
const stat = safely(() => (0, _nodeFs.statSync)(full), null);
|
|
70
|
+
if (!stat) continue;
|
|
71
|
+
if (stat.isDirectory()) {
|
|
72
|
+
collectComposableImports(full, acc);
|
|
73
|
+
} else if (/\.(?:m?js|ts)$/.test(entry) && !entry.endsWith(".d.ts")) {
|
|
74
|
+
acc.push(...exportedNames(full).map(name => ({
|
|
75
|
+
name,
|
|
76
|
+
from: full
|
|
77
|
+
})));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function registerComposableImports(composablesRoot) {
|
|
82
|
+
const imports = [];
|
|
83
|
+
collectComposableImports(composablesRoot, imports);
|
|
84
|
+
if (imports.length) {
|
|
85
|
+
(0, _kit.addImports)(imports);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function collectVueFiles(dir, files) {
|
|
89
|
+
for (const entry of (0, _nodeFs.readdirSync)(dir, {
|
|
90
|
+
withFileTypes: true
|
|
91
|
+
})) {
|
|
92
|
+
const full = (0, _nodePath.join)(dir, entry.name);
|
|
93
|
+
if (entry.isDirectory()) collectVueFiles(full, files);else if (entry.name.endsWith(".vue") && !entry.name.endsWith(".story.vue")) files.set((0, _nodePath.basename)(entry.name, ".vue"), full);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function registerComponents(componentsRoot, lite, include) {
|
|
97
|
+
if (!(lite && include.length)) {
|
|
98
|
+
(0, _kit.addComponentsDir)({
|
|
99
|
+
path: componentsRoot,
|
|
100
|
+
prefix: "",
|
|
101
|
+
pathPrefix: false,
|
|
102
|
+
global: false
|
|
103
|
+
});
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const files = /* @__PURE__ */new Map();
|
|
107
|
+
collectVueFiles(componentsRoot, files);
|
|
108
|
+
for (const name of include) {
|
|
109
|
+
const filePath = files.get(name);
|
|
110
|
+
if (!filePath) throw new Error(`[origam] \`include\`: unknown component "${name}"`);
|
|
111
|
+
(0, _kit.addComponent)({
|
|
112
|
+
name,
|
|
113
|
+
filePath
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
40
117
|
const origamNuxtModule = (0, _kit.defineNuxtModule)({
|
|
41
118
|
meta: {
|
|
42
119
|
name: MODULE_NAME,
|
|
@@ -57,18 +134,10 @@ const origamNuxtModule = (0, _kit.defineNuxtModule)({
|
|
|
57
134
|
const cookieMaxAge = options.cookieMaxAge ?? DEFAULTS.cookieMaxAge;
|
|
58
135
|
const autoImport = options.autoImport ?? DEFAULTS.autoImport;
|
|
59
136
|
const includeUtilities = options.includeUtilities ?? DEFAULTS.includeUtilities;
|
|
60
|
-
nuxt
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
for (const sheet of ["origam/tokens/css/light", "origam/tokens/css/dark"]) {
|
|
65
|
-
if (!nuxt.options.css.includes(sheet)) {
|
|
66
|
-
nuxt.options.css.push(sheet);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if (includeUtilities && !nuxt.options.css.includes("origam/tokens/css/utilities")) {
|
|
70
|
-
nuxt.options.css.push("origam/tokens/css/utilities");
|
|
71
|
-
}
|
|
137
|
+
registerStyleSheets(nuxt, includeUtilities);
|
|
138
|
+
const lite = options.lite ?? DEFAULTS.lite;
|
|
139
|
+
nuxt.options.alias = nuxt.options.alias || {};
|
|
140
|
+
nuxt.options.alias["#origam-create"] = resolver.resolve(lite ? "./create.core" : "./create.full");
|
|
72
141
|
(0, _kit.addPlugin)({
|
|
73
142
|
src: resolver.resolve("./plugin.server"),
|
|
74
143
|
mode: "server"
|
|
@@ -78,58 +147,8 @@ const origamNuxtModule = (0, _kit.defineNuxtModule)({
|
|
|
78
147
|
mode: "client"
|
|
79
148
|
});
|
|
80
149
|
if (autoImport) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const collect = (dir, acc) => {
|
|
84
|
-
let entries;
|
|
85
|
-
try {
|
|
86
|
-
entries = (0, _nodeFs.readdirSync)(dir);
|
|
87
|
-
} catch {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
for (const entry of entries) {
|
|
91
|
-
const full = (0, _nodePath.join)(dir, entry);
|
|
92
|
-
let s;
|
|
93
|
-
try {
|
|
94
|
-
s = (0, _nodeFs.statSync)(full);
|
|
95
|
-
} catch {
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
if (s.isDirectory()) {
|
|
99
|
-
collect(full, acc);
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
if (!/\.(?:m?js|ts)$/.test(entry)) continue;
|
|
103
|
-
if (entry.endsWith(".d.ts")) continue;
|
|
104
|
-
let src = "";
|
|
105
|
-
try {
|
|
106
|
-
src = (0, _nodeFs.readFileSync)(full, "utf-8");
|
|
107
|
-
} catch {
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
let m;
|
|
111
|
-
exportNameRegex.lastIndex = 0;
|
|
112
|
-
while (m = exportNameRegex.exec(src)) {
|
|
113
|
-
const name = m[1];
|
|
114
|
-
if (NUXT_COMPOSABLES_BLOCKLIST.has(name)) continue;
|
|
115
|
-
acc.push({
|
|
116
|
-
name,
|
|
117
|
-
from: full
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
const imports = [];
|
|
123
|
-
collect(composablesRoot, imports);
|
|
124
|
-
if (imports.length) {
|
|
125
|
-
(0, _kit.addImports)(imports);
|
|
126
|
-
}
|
|
127
|
-
(0, _kit.addComponentsDir)({
|
|
128
|
-
path: resolver.resolve("../components"),
|
|
129
|
-
prefix: "",
|
|
130
|
-
pathPrefix: false,
|
|
131
|
-
global: false
|
|
132
|
-
});
|
|
150
|
+
registerComposableImports(resolver.resolve("../composables"));
|
|
151
|
+
registerComponents(resolver.resolve("../components"), lite, options.include ?? DEFAULTS.include);
|
|
133
152
|
}
|
|
134
153
|
nuxt.options.runtimeConfig.public = nuxt.options.runtimeConfig.public || {};
|
|
135
154
|
nuxt.options.runtimeConfig.public.origam = {
|
package/dist/src/nuxt/module.js
CHANGED
|
@@ -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
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
81
|
-
|
|
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
|
|
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,
|
|
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 "
|
|
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,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
var
|
|
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");
|
|
@@ -68,7 +68,7 @@ module.exports = (0, _app.defineNuxtPlugin)({
|
|
|
68
68
|
innerHTML: ssrThemeCss
|
|
69
69
|
}] : []
|
|
70
70
|
});
|
|
71
|
-
const origam = (0,
|
|
71
|
+
const origam = (0, _origamCreate.createOrigamForNuxt)({
|
|
72
72
|
themes,
|
|
73
73
|
ssr: true,
|
|
74
74
|
...(0, _nuxtLocale.nuxtLocaleOptions)(config),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createOrigam } from "
|
|
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
4
|
import { isModePinned, knownBrand, themeToCss, themeToUnpinnedCss } from "../utils/Commons/apply-theme.util.js";
|