@marwes-ui/vue 1.0.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -393,6 +393,12 @@ Marwes is compatible with Tailwind and shadcn-style dark variants through `targe
393
393
 
394
394
  Read the [Tailwind and shadcn integration guide](https://github.com/niklas-westman/marwes/blob/main/docs/guides/tailwind-shadcn-integration.md) for Tailwind v3/v4 examples, token mapping, provider-scoped variable limits, and the SSR no-flash boundary.
395
395
 
396
+ ### Nuxt SSR
397
+
398
+ Use `createMarwesThemeStyle()`, `createMarwesThemeScript()`, and `variable-strategy="style-tag"` when a server-rendered app needs the correct light or dark variables before hydration. This is opt-in; normal Vue apps keep inline provider variables by default.
399
+
400
+ Read the [theme SSR no-flash guide](https://github.com/niklas-westman/marwes/blob/main/docs/guides/theme-ssr-no-flash.md) for Nuxt setup, CSP nonces, hydration warning guidance, custom light/dark themes, and stored/system preference behavior.
401
+
396
402
  For a simple brand pass, override shared values once and let Marwes fill the rest. If your product needs different brand colors in light and dark mode, control `mode` and switch between two small `ThemeInput` override objects:
397
403
 
398
404
  ```vue
@@ -0,0 +1,3 @@
1
+ export { createMarwesThemeScript, createMarwesThemeStyle } from '@marwes-ui/core';
2
+ //# sourceMappingURL=chunk-DVJD5CQS.js.map
3
+ //# sourceMappingURL=chunk-DVJD5CQS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-DVJD5CQS.js","sourcesContent":[]}
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as vue from 'vue';
2
2
  import { ComputedRef, VNodeChild } from 'vue';
3
3
  import * as _marwes_ui_core from '@marwes-ui/core';
4
- import { ThemeInput, ThemePreference, ThemeMode, FontLoadingConfig, ResolvedTheme, ButtonOptions, InputOptions, SelectOptions, SelectAppearance as SelectAppearance$1, SelectOption as SelectOption$1, TextareaOptions, RichTextOptions, InputOtpOptions, CurrencyCode, iconRegistry, IconSize, IconStrokeWidth, AvatarOptions, CheckboxProps as CheckboxProps$1, DividerOptions, DividerSize, DividerOrientation, SpinnerOptions, SpacingOptions, SpacingSize, HeadingOptions, HeadingSize, ParagraphOptions, ParagraphSize, ToastOptions, ToastVariant, ToastIntent, ToastPlacement, TooltipOptions, IconNameType, RadioOptions, BadgeOptions, SwitchOptions, SliderOptions, TabOptions, DialogOptions } from '@marwes-ui/core';
5
- export { AvatarSize, AvatarType, BadgeVariant, ButtonAction, ButtonSize, ButtonVariant, Density, FontLoadingConfig, FontLoadingMode, FontLoadingOptions, IconName, MwAvailableFont, MwFontFallback, MwGoogleFontFamily, MwStyledTheme, MwThemeVarName, MwThemeVarNames, MwThemeVarReference, MwThemeVars, ResolvedTheme, SpacingSize, Spacings, SwitchSize, Theme, ThemeInput, ThemeMode, ThemePreference, ToneName, createFontStack, mwAvailableFonts, mwFontFallbacks, mwGoogleFontFamilies, mwStyledTheme, mwThemeVarNames, mwThemeVars, mwVar } from '@marwes-ui/core';
4
+ import { ThemeInput, ThemePreference, ThemeMode, FontLoadingConfig, ThemeVariableStrategy, ResolvedTheme, ButtonOptions, InputOptions, SelectOptions, SelectAppearance as SelectAppearance$1, SelectOption as SelectOption$1, TextareaOptions, RichTextOptions, InputOtpOptions, CurrencyCode, iconRegistry, IconSize, IconStrokeWidth, AvatarOptions, CheckboxProps as CheckboxProps$1, DividerOptions, DividerSize, DividerOrientation, SpinnerOptions, SpacingOptions, SpacingSize, HeadingOptions, HeadingSize, ParagraphOptions, ParagraphSize, ToastOptions, ToastVariant, ToastIntent, ToastPlacement, TooltipOptions, IconNameType, RadioOptions, BadgeOptions, SwitchOptions, SliderOptions, TabOptions, DialogOptions } from '@marwes-ui/core';
5
+ export { AvatarSize, AvatarType, BadgeVariant, ButtonAction, ButtonSize, ButtonVariant, Density, FontLoadingConfig, FontLoadingMode, FontLoadingOptions, IconName, MarwesThemeScriptOptions, MarwesThemeStyleOptions, MwAvailableFont, MwFontFallback, MwGoogleFontFamily, MwStyledTheme, MwThemeVarName, MwThemeVarNames, MwThemeVarReference, MwThemeVars, ResolvedTheme, SpacingSize, Spacings, SwitchSize, Theme, ThemeInput, ThemeMode, ThemeModeAttribute, ThemeModeRootTarget, ThemePreference, ThemeVariableStrategy, ToneName, createFontStack, createMarwesThemeScript, createMarwesThemeStyle, mwAvailableFonts, mwFontFallbacks, mwGoogleFontFamilies, mwStyledTheme, mwThemeVarNames, mwThemeVars, mwVar } from '@marwes-ui/core';
6
6
 
7
7
  type ThemeTarget = "provider" | "html" | "body";
8
8
  type ThemeAttribute = "class" | "data-theme" | "data-mode";
@@ -21,37 +21,40 @@ type MarwesProviderProps = {
21
21
  target?: ThemeTarget;
22
22
  attribute?: ThemeAttribute;
23
23
  disableTransitionOnChange?: boolean;
24
+ variableStrategy?: ThemeVariableStrategy;
24
25
  };
25
26
  declare const MarwesProvider: vue.DefineComponent<{
26
27
  mode?: any;
28
+ storageKey?: any;
29
+ defaultPreference?: any;
30
+ enableSystem?: any;
27
31
  target?: any;
28
32
  attribute?: any;
29
- theme?: any;
30
- defaultPreference?: any;
31
33
  preference?: any;
34
+ theme?: any;
32
35
  defaultMode?: any;
33
36
  fontLoading?: any;
34
37
  onPreferenceChange?: any;
35
38
  onModeChange?: any;
36
- storageKey?: any;
37
- enableSystem?: any;
38
39
  disableTransitionOnChange?: any;
40
+ variableStrategy?: any;
39
41
  }, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
40
42
  [key: string]: any;
41
43
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{
42
44
  mode?: any;
45
+ storageKey?: any;
46
+ defaultPreference?: any;
47
+ enableSystem?: any;
43
48
  target?: any;
44
49
  attribute?: any;
45
- theme?: any;
46
- defaultPreference?: any;
47
50
  preference?: any;
51
+ theme?: any;
48
52
  defaultMode?: any;
49
53
  fontLoading?: any;
50
54
  onPreferenceChange?: any;
51
55
  onModeChange?: any;
52
- storageKey?: any;
53
- enableSystem?: any;
54
56
  disableTransitionOnChange?: any;
57
+ variableStrategy?: any;
55
58
  }> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
56
59
 
57
60
  declare function useTheme(): ResolvedTheme;
@@ -2162,11 +2165,11 @@ type YesNoRadioGroupProps = Omit<RadioGroupFieldProps, "options"> & {
2162
2165
  declare const YesNoRadioGroup: vue.DefineComponent<{
2163
2166
  disabled?: any;
2164
2167
  label?: any;
2168
+ value?: any;
2165
2169
  error?: any;
2166
2170
  id?: any;
2167
2171
  required?: any;
2168
2172
  name?: any;
2169
- value?: any;
2170
2173
  ariaDescribedBy?: any;
2171
2174
  defaultValue?: any;
2172
2175
  options?: any;
@@ -2181,11 +2184,11 @@ declare const YesNoRadioGroup: vue.DefineComponent<{
2181
2184
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{
2182
2185
  disabled?: any;
2183
2186
  label?: any;
2187
+ value?: any;
2184
2188
  error?: any;
2185
2189
  id?: any;
2186
2190
  required?: any;
2187
2191
  name?: any;
2188
- value?: any;
2189
2192
  ariaDescribedBy?: any;
2190
2193
  defaultValue?: any;
2191
2194
  options?: any;
@@ -2204,11 +2207,11 @@ type RatingRadioGroupProps = Omit<RadioGroupFieldProps, "options"> & {
2204
2207
  declare const RatingRadioGroup: vue.DefineComponent<{
2205
2208
  disabled?: any;
2206
2209
  label?: any;
2210
+ value?: any;
2207
2211
  error?: any;
2208
2212
  id?: any;
2209
2213
  required?: any;
2210
2214
  name?: any;
2211
- value?: any;
2212
2215
  ariaDescribedBy?: any;
2213
2216
  defaultValue?: any;
2214
2217
  options?: any;
@@ -2224,11 +2227,11 @@ declare const RatingRadioGroup: vue.DefineComponent<{
2224
2227
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{
2225
2228
  disabled?: any;
2226
2229
  label?: any;
2230
+ value?: any;
2227
2231
  error?: any;
2228
2232
  id?: any;
2229
2233
  required?: any;
2230
2234
  name?: any;
2231
- value?: any;
2232
2235
  ariaDescribedBy?: any;
2233
2236
  defaultValue?: any;
2234
2237
  options?: any;
@@ -2244,11 +2247,11 @@ type OptionRadioGroupProps = RadioGroupFieldProps;
2244
2247
  declare const OptionRadioGroup: vue.DefineComponent<{
2245
2248
  disabled?: any;
2246
2249
  label?: any;
2250
+ value?: any;
2247
2251
  error?: any;
2248
2252
  id?: any;
2249
2253
  required?: any;
2250
2254
  name?: any;
2251
- value?: any;
2252
2255
  ariaDescribedBy?: any;
2253
2256
  defaultValue?: any;
2254
2257
  options?: any;
@@ -2261,11 +2264,11 @@ declare const OptionRadioGroup: vue.DefineComponent<{
2261
2264
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{
2262
2265
  disabled?: any;
2263
2266
  label?: any;
2267
+ value?: any;
2264
2268
  error?: any;
2265
2269
  id?: any;
2266
2270
  required?: any;
2267
2271
  name?: any;
2268
- value?: any;
2269
2272
  ariaDescribedBy?: any;
2270
2273
  defaultValue?: any;
2271
2274
  options?: any;
package/dist/index.js CHANGED
@@ -1,10 +1,9 @@
1
+ export { createMarwesThemeScript, createMarwesThemeStyle } from './chunk-DVJD5CQS.js';
1
2
  import '@marwes-ui/presets/firstEdition/styles.css';
2
3
  import { ThemeMode, resolveThemePreference, resolveThemeInput, resolveIconSize, resolveIconStrokeWidth, iconRegistry, resolveIconA11y, createSpinnerRecipe, createButtonRecipe, ButtonAction, ButtonVariant, IconName, createInputRecipe, createSelectRecipe, resolveSelectMode, createTextareaRecipe, createRichTextRecipe, resolveRichTextAllowedFormats, normalizeRichTextHtml, isRichTextHtmlEmpty, paragraphRecipe, buildInputFieldA11yIds, sanitizeInputOtpValue, createInputOtpRecipe, buildRichTextFieldA11yIds, buildCurrencyHelperText, getCurrencySymbol, sanitizeCurrencyValue, createAvatarRecipe, createPurposeSemanticAttributes, checkboxRecipe, buildCheckboxFieldA11yIds, buildCheckboxGroupFieldA11yIds, createDividerRecipe, createSpacingRecipe, createCardRecipe, createToastRecipe, createTooltipRecipe, createAccordionRecipe, buildAccordionFieldA11yIds, radioRecipe, buildRadioGroupFieldA11yIds, createBadgeRecipe, createSwitchRecipe, buildSwitchFieldA11yIds, createSliderRecipe, buildSliderFieldA11yIds, createTabRecipe, resolveTabValue, buildTabGroupA11yIds, createDialogRecipe, isThemePreference, nextThemeMode, themeToCSSVars, richTextCommandByFormat, headingRecipe, moveTabSelection, extractUsedWeights, extractFontFamilyName, shouldLoadGoogleFont, buildGoogleFontsUrl } from '@marwes-ui/core';
3
4
  export { AvatarSize, AvatarType, BadgeVariant, ButtonAction, ButtonSize, ButtonVariant, IconName, Spacings, SwitchSize, ThemeMode, createFontStack, mwAvailableFonts, mwFontFallbacks, mwGoogleFontFamilies, mwStyledTheme, mwThemeVarNames, mwThemeVars, mwVar } from '@marwes-ui/core';
4
5
  import { defineComponent, ref, computed, onMounted, onUnmounted, watch, provide, h, useAttrs, onBeforeUnmount, shallowRef, Fragment, nextTick, Teleport, inject } from 'vue';
5
6
 
6
- // src/index.ts
7
-
8
7
  // src/provider/marwes-context.ts
9
8
  var marwesContextKey = /* @__PURE__ */ Symbol("MarwesContext");
10
9
  var loadedFonts = /* @__PURE__ */ new Set();
@@ -18,6 +17,7 @@ function themeToRootStyle(theme) {
18
17
  }
19
18
  function applyThemeToElement(element, theme) {
20
19
  element.setAttribute("data-marwes-theme", "true");
20
+ element.setAttribute("data-marwes-mode", theme.mode);
21
21
  for (const [property, value] of Object.entries(themeToRootStyle(theme))) {
22
22
  if (property === "backgroundColor") {
23
23
  element.style.backgroundColor = value;
@@ -155,7 +155,8 @@ var MarwesProvider = defineComponent({
155
155
  "enableSystem",
156
156
  "target",
157
157
  "attribute",
158
- "disableTransitionOnChange"
158
+ "disableTransitionOnChange",
159
+ "variableStrategy"
159
160
  ],
160
161
  setup(rawProps, { slots }) {
161
162
  const props = rawProps;
@@ -170,6 +171,9 @@ var MarwesProvider = defineComponent({
170
171
  const target = computed(() => props.target ?? "provider");
171
172
  const attribute = computed(() => props.attribute ?? "class");
172
173
  const disableTransitionOnChange = computed(() => props.disableTransitionOnChange === true);
174
+ const variableStrategy = computed(
175
+ () => props.variableStrategy ?? "inline"
176
+ );
173
177
  const isPreferenceControlled = computed(
174
178
  () => props.preference !== void 0 || props.mode !== void 0 || props.theme?.mode !== void 0
175
179
  );
@@ -198,7 +202,7 @@ var MarwesProvider = defineComponent({
198
202
  setMode(nextThemeMode(activeMode.value));
199
203
  }
200
204
  function syncThemeToRuntime() {
201
- if (rootRef.value) {
205
+ if (rootRef.value && variableStrategy.value === "inline") {
202
206
  applyThemeToElement(rootRef.value, resolved.value);
203
207
  }
204
208
  loadThemeFonts(resolved.value, props.fontLoading ?? "auto");
@@ -246,7 +250,7 @@ var MarwesProvider = defineComponent({
246
250
  onUnmounted(() => {
247
251
  unsubscribeSystemThemeMode?.();
248
252
  });
249
- watch(resolved, syncThemeToRuntime);
253
+ watch([resolved, variableStrategy], syncThemeToRuntime);
250
254
  watch([activeMode, target, attribute, disableTransitionOnChange], syncTargetModeAttribute);
251
255
  watch([activePreference, enableSystem], syncSystemThemeSubscription);
252
256
  provide(marwesContextKey, {
@@ -264,7 +268,8 @@ var MarwesProvider = defineComponent({
264
268
  ref: rootRef,
265
269
  class: `mw-theme--${resolved.value.mode}`,
266
270
  "data-marwes-theme": "true",
267
- style: themeToRootStyle(resolved.value)
271
+ "data-marwes-mode": resolved.value.mode,
272
+ style: variableStrategy.value === "inline" ? themeToRootStyle(resolved.value) : void 0
268
273
  },
269
274
  slots.default?.()
270
275
  );