ropav 0.1.4 → 0.1.6

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 (138) hide show
  1. package/README.md +20 -0
  2. package/dist/accordion.js +11 -8
  3. package/dist/alert.css +18 -18
  4. package/dist/alert.js +27 -21
  5. package/dist/avatar.css +19 -19
  6. package/dist/avatar.js +16 -11
  7. package/dist/badge.css +16 -16
  8. package/dist/badge.js +14 -9
  9. package/dist/base.css +214 -69
  10. package/dist/button-group.js +1 -1
  11. package/dist/button-link.js +16 -14
  12. package/dist/button.css +37 -28
  13. package/dist/button.js +16 -14
  14. package/dist/{useButtonColor.js → button.scss_vue_type_style_index_0_src_true_lang.js} +8 -4
  15. package/dist/card.js +1 -1
  16. package/dist/checkbox.css +32 -32
  17. package/dist/checkbox.js +19 -11
  18. package/dist/chevron-right.js +12 -0
  19. package/dist/collapse.css +6 -6
  20. package/dist/collapse.js +4 -4
  21. package/dist/collectionNavigation.js +120 -0
  22. package/dist/color-input.css +19 -19
  23. package/dist/color-input.js +6 -5
  24. package/dist/color-picker.css +7 -7
  25. package/dist/color-picker.js +4 -5
  26. package/dist/color-swatch.js +1 -1
  27. package/dist/componentColors.js +135 -23
  28. package/dist/components/alert/types.d.ts +1 -0
  29. package/dist/components/alert/useAlertColor.d.ts +1 -1
  30. package/dist/components/avatar/types.d.ts +1 -0
  31. package/dist/components/avatar/useAvatarColor.d.ts +1 -1
  32. package/dist/components/badge/types.d.ts +1 -0
  33. package/dist/components/badge/useBadgeColor.d.ts +1 -1
  34. package/dist/components/button/types.d.ts +1 -0
  35. package/dist/components/button/useButtonColor.d.ts +1 -1
  36. package/dist/components/button-link/types.d.ts +1 -0
  37. package/dist/components/checkbox/types.d.ts +1 -0
  38. package/dist/components/checkbox/useCheckbox.d.ts +1 -1
  39. package/dist/components/color-input/color-input.d.ts +2 -2
  40. package/dist/components/color-input/useColorInput.d.ts +1 -1
  41. package/dist/components/dialog/dialog-core.d.ts +1 -1
  42. package/dist/components/dropdown-menu/dropdown-menu-content.d.ts +2 -2
  43. package/dist/components/dropdown-menu/dropdown-menu-primitive-core.d.ts +2 -1
  44. package/dist/components/dropdown-menu/dropdown-menu-sub-content.d.ts +2 -2
  45. package/dist/components/dropdown-menu/dropdown-menu-utils.d.ts +0 -2
  46. package/dist/components/dropdown-menu/dropdown-menu.d.ts +3 -3
  47. package/dist/components/dropdown-menu/index.d.ts +1 -0
  48. package/dist/components/dropdown-menu/types.d.ts +4 -0
  49. package/dist/components/dropdown-menu/useDropdownMenuDisclosure.d.ts +3 -4
  50. package/dist/components/dropdown-menu/useDropdownMenuInteractions.d.ts +2 -1
  51. package/dist/components/dropdown-menu/useDropdownMenuNavigation.d.ts +1 -0
  52. package/dist/components/icon-button/types.d.ts +1 -0
  53. package/dist/components/input/useInput.d.ts +1 -1
  54. package/dist/components/number-input/useNumberInput.d.ts +1 -1
  55. package/dist/components/pagination/index.d.ts +4 -0
  56. package/dist/components/pagination/index.js +2 -0
  57. package/dist/components/pagination/pagination.d.ts +49 -0
  58. package/dist/components/pagination/types.d.ts +54 -0
  59. package/dist/components/pagination/usePagination.d.ts +19 -0
  60. package/dist/components/progress/useProgress.d.ts +1 -1
  61. package/dist/components/radio/types.d.ts +3 -0
  62. package/dist/components/radio/useRadio.d.ts +2 -2
  63. package/dist/components/scroll-area/scrollAreaCore.d.ts +5 -0
  64. package/dist/components/scroll-area/types.d.ts +4 -0
  65. package/dist/components/scroll-area/useScrollArea.d.ts +1 -0
  66. package/dist/components/scroll-area/useScrollAreaMetrics.d.ts +3 -0
  67. package/dist/components/scroll-area/useScrollAreaPresentation.d.ts +3 -0
  68. package/dist/components/select/useSelect.d.ts +3 -2
  69. package/dist/components/select/useSelectNativeValue.d.ts +1 -7
  70. package/dist/components/slider/range-slider-tooltip.d.ts +2 -0
  71. package/dist/components/slider/sliderCore.d.ts +2 -1
  72. package/dist/components/slider/types.d.ts +1 -1
  73. package/dist/components/slider/useRangeSlider.d.ts +3 -1
  74. package/dist/components/slider/useSlider.d.ts +3 -1
  75. package/dist/components/switch/useSwitch.d.ts +1 -1
  76. package/dist/components/textarea/useTextarea.d.ts +1 -1
  77. package/dist/components/toast/types.d.ts +2 -0
  78. package/dist/components/toast/useToastColor.d.ts +1 -1
  79. package/dist/components/tooltip/types.d.ts +1 -0
  80. package/dist/components/tooltip/useTooltip.d.ts +1 -1
  81. package/dist/composables/index.d.ts +2 -0
  82. package/dist/composables/index.js +2 -0
  83. package/dist/composables/useControllableValue.d.ts +14 -0
  84. package/dist/dialog.js +8 -5
  85. package/dist/dropdown-menu.js +98 -59
  86. package/dist/field.js +1 -1
  87. package/dist/floating.js +19 -7
  88. package/dist/icon-button.css +12 -169
  89. package/dist/icon-button.js +11 -7
  90. package/dist/index.d.ts +6 -4
  91. package/dist/index.js +8 -5
  92. package/dist/input.css +24 -24
  93. package/dist/input.js +6 -5
  94. package/dist/modal.js +11 -7
  95. package/dist/number-input.css +18 -18
  96. package/dist/number-input.js +8 -7
  97. package/dist/overlay.js +1 -1
  98. package/dist/pagination.css +140 -0
  99. package/dist/pagination.js +442 -0
  100. package/dist/popover.js +9 -6
  101. package/dist/progress.css +29 -21
  102. package/dist/progress.js +17 -10
  103. package/dist/radio.js +17 -7
  104. package/dist/scroll-area.css +10 -1
  105. package/dist/scroll-area.js +82 -25
  106. package/dist/select.css +45 -45
  107. package/dist/select.js +111 -70
  108. package/dist/slider.css +191 -191
  109. package/dist/slider.js +58 -46
  110. package/dist/switch.css +17 -17
  111. package/dist/switch.js +7 -6
  112. package/dist/tabs.css +3 -3
  113. package/dist/tabs.js +25 -15
  114. package/dist/textarea.css +26 -26
  115. package/dist/textarea.js +5 -4
  116. package/dist/toast.css +26 -26
  117. package/dist/toast.js +35 -23
  118. package/dist/tooltip.css +12 -12
  119. package/dist/tooltip.js +24 -16
  120. package/dist/unplugin-icons.js +38 -25
  121. package/dist/useCollapse.js +12 -7
  122. package/dist/useControlState.js +1 -1
  123. package/dist/useControllableValue.js +33 -0
  124. package/dist/useFloatingPosition.js +4 -1140
  125. package/dist/useFormControl.js +5 -29
  126. package/dist/useOverlayZIndex.js +1 -1
  127. package/dist/useRequiredInject.js +1 -1
  128. package/dist/utils/componentColors.d.ts +14 -1
  129. package/docs/public-composables-api.md +52 -0
  130. package/docs/public-styles-api.md +1 -1
  131. package/docs/public-tokens.md +648 -508
  132. package/package.json +49 -36
  133. package/src/styles/_mixins.scss +4 -0
  134. package/src/styles/_tokens.scss +460 -320
  135. package/src/styles/_variables.scss +1 -1
  136. package/src/styles/styles-manifest.json +1122 -2
  137. package/dist/button-link.css +0 -163
  138. /package/dist/{composables → internal/composables}/useOverlayLayer.d.ts +0 -0
@@ -1,30 +1,5 @@
1
- import { computed, inject, provide, shallowRef, watch, watchEffect } from "vue";
2
- //#region src/composables/useControllableValue.ts
3
- function useControllableValue(options) {
4
- const initialValue = options.defaultValue();
5
- const uncontrolledValue = shallowRef(initialValue);
6
- const isControlled = computed(() => options.modelValue() !== void 0);
7
- watch(options.modelValue, (value) => {
8
- if (value !== void 0) uncontrolledValue.value = value;
9
- }, { immediate: true });
10
- const value = computed(() => options.modelValue() ?? uncontrolledValue.value);
11
- function setValue(nextValue) {
12
- if (!isControlled.value) uncontrolledValue.value = nextValue;
13
- options.onChange(nextValue);
14
- }
15
- function resetValue(nextValue = initialValue) {
16
- if (!isControlled.value) uncontrolledValue.value = nextValue;
17
- }
18
- return {
19
- initialValue,
20
- isControlled,
21
- value,
22
- setValue,
23
- resetValue
24
- };
25
- }
26
- //#endregion
27
- //#region src/composables/useFormControl.ts
1
+ import { inject, provide, watchEffect } from "vue";
2
+ //#region src/internal/composables/useFormControl.ts
28
3
  var nestedFormControlOwnerKey = Symbol("nestedFormControlOwner");
29
4
  function provideNestedFormControlOwner() {
30
5
  let claimed = false;
@@ -57,7 +32,8 @@ function useFormControl(options) {
57
32
  if (documents.size === 0) return;
58
33
  function onReset(event) {
59
34
  const form = event.target;
60
- if (!(form instanceof HTMLFormElement)) return;
35
+ const FormConstructor = event.currentTarget?.defaultView?.HTMLFormElement;
36
+ if (!FormConstructor || !(form instanceof FormConstructor)) return;
61
37
  const elements = getElements(options).filter((element) => element.form === form);
62
38
  if (elements.length === 0) return;
63
39
  queueMicrotask(() => {
@@ -104,4 +80,4 @@ function useCheckedFormControl(element, controllable, validationMessage) {
104
80
  });
105
81
  }
106
82
  //#endregion
107
- export { useTextFormControl as a, useFormControl as i, provideNestedFormControlOwner as n, useControllableValue as o, useCheckedFormControl as r, claimNestedFormControlOwner as t };
83
+ export { useTextFormControl as a, useFormControl as i, provideNestedFormControlOwner as n, useCheckedFormControl as r, claimNestedFormControlOwner as t };
@@ -1,5 +1,5 @@
1
1
  import { computed, inject, onBeforeUnmount, provide, readonly, ref, shallowRef, toValue, watch } from "vue";
2
- //#region src/composables/useOverlayLayer.ts
2
+ //#region src/internal/composables/useOverlayLayer.ts
3
3
  var overlayLayerKey = Symbol("overlay-layer");
4
4
  var documentStates = /* @__PURE__ */ new WeakMap();
5
5
  var layerMetadata = /* @__PURE__ */ new WeakMap();
@@ -1,5 +1,5 @@
1
1
  import { inject } from "vue";
2
- //#region src/composables/useRequiredInject.ts
2
+ //#region src/internal/composables/useRequiredInject.ts
3
3
  function useRequiredInject(key, componentName) {
4
4
  const value = inject(key);
5
5
  if (value == null) throw new Error(`[Ropav] <${componentName}> must be used inside its parent provider component.`);
@@ -10,6 +10,8 @@ export interface ComponentColorRoles {
10
10
  hover: string;
11
11
  active: string;
12
12
  contrast: string;
13
+ contrastHover: string;
14
+ contrastActive: string;
13
15
  light: string;
14
16
  lightHover: string;
15
17
  lightActive: string;
@@ -22,12 +24,22 @@ export interface ComponentVariantColorRoles {
22
24
  hover: string;
23
25
  active: string;
24
26
  color: string;
27
+ colorHover: string;
28
+ colorActive: string;
25
29
  border: string;
26
30
  borderHover: string;
27
31
  borderActive: string;
28
32
  }
29
33
  export interface ComponentContrastColorOptions {
34
+ /** Automatically selects a readable foreground for preset and opaque custom colors. */
30
35
  autoContrast?: boolean;
36
+ /** Required when an automatically contrasted custom color is translucent. */
37
+ contrastColor?: string;
38
+ }
39
+ export interface ComponentContrastColorRoles {
40
+ color: string;
41
+ hover: string;
42
+ active: string;
31
43
  }
32
44
  export interface ComponentVariantColorOptions extends ComponentContrastColorOptions {
33
45
  color: ComponentColorValue | undefined;
@@ -56,5 +68,6 @@ export declare function isComponentPresetColor(color: ComponentColorValue | unde
56
68
  export declare function parseComponentColor(color: ComponentColorValue | undefined): ParsedComponentColor;
57
69
  export declare function getComponentColorValue(color: ComponentColorValue | undefined): string | undefined;
58
70
  export declare function getComponentContrastColor(color: ComponentColorValue | undefined, options?: ComponentContrastColorOptions): string;
71
+ export declare function getComponentContrastColorRoles(color: ComponentColorValue | undefined, options?: ComponentContrastColorOptions): ComponentContrastColorRoles;
59
72
  export declare function getComponentColorRoles(color: ComponentColorValue | undefined): ComponentColorRoles | undefined;
60
- export declare function getComponentVariantColorRoles({ color, variant, defaultColor, autoContrast, }: ComponentVariantColorOptions): ComponentVariantColorRoles | undefined;
73
+ export declare function getComponentVariantColorRoles({ color, variant, defaultColor, autoContrast, contrastColor, }: ComponentVariantColorOptions): ComponentVariantColorRoles | undefined;
@@ -0,0 +1,52 @@
1
+ # Public composables API
2
+
3
+ Ropav exposes framework-level composables from both the root package and the dedicated
4
+ `ropav/composables` entrypoint. Prefer the dedicated entrypoint when an application only needs
5
+ headless state behavior.
6
+
7
+ ## `useControllableValue`
8
+
9
+ `useControllableValue` implements the controlled/uncontrolled value pattern used across Ropav
10
+ components and composables. A defined `modelValue` makes the value controlled; only `undefined`
11
+ selects internal state, so values such as `null` and `false` remain controlled values.
12
+
13
+ ```vue
14
+ <script setup lang="ts">
15
+ import { useControllableValue } from 'ropav/composables';
16
+
17
+ const props = withDefaults(
18
+ defineProps<{
19
+ modelValue?: string;
20
+ defaultValue?: string;
21
+ }>(),
22
+ {
23
+ modelValue: undefined,
24
+ defaultValue: '',
25
+ },
26
+ );
27
+
28
+ const emit = defineEmits<{
29
+ 'update:modelValue': [value: string];
30
+ }>();
31
+
32
+ const { value, isControlled, setValue, resetValue } = useControllableValue({
33
+ modelValue: () => props.modelValue,
34
+ defaultValue: () => props.defaultValue,
35
+ onChange: (value) => emit('update:modelValue', value),
36
+ });
37
+ </script>
38
+ ```
39
+
40
+ `defaultValue()` is read once when the composable is created. `setValue()` updates internal state
41
+ only in uncontrolled mode and always calls `onChange`, including repeated requests for the same
42
+ value. In controlled mode, the parent remains responsible for updating `modelValue`, and a rejected
43
+ change request does not replace the internal fallback.
44
+
45
+ `resetValue(value)` updates uncontrolled state without calling `onChange`. Calling `resetValue()`
46
+ without an argument restores the initial default. A reset is a no-op while controlled. If a value
47
+ changes from controlled to uncontrolled, the latest defined controlled value becomes the internal
48
+ fallback synchronously. Releasing control does not call `onChange`.
49
+
50
+ The return value contains readonly `value` and `isControlled` computed refs, the captured
51
+ `initialValue`, and the `setValue()` and `resetValue()` commands. `undefined` is reserved as the
52
+ uncontrolled sentinel and should not be used as a controlled value.
@@ -111,7 +111,7 @@ The exact entries in [`styles-manifest.json`](../src/styles/styles-manifest.json
111
111
 
112
112
  The manifest contains design tokens plus a deliberately small component-geometry allowlist. Slider and RangeSlider share the `--rp-slider-*` namespace. Size presets provide fallbacks, while a consumer value wins for the individual dimension. See the generated [token table](./public-tokens.md).
113
113
 
114
- Palette shades and their `*-contrast` companions are required override groups because `autoContrast` consumes the companion selected at build time. The [color override contract](./public-tokens.md#color-override-contract) documents the paired override and preset-role requirements.
114
+ Palette shades and their normal and active `*-contrast` companions are required override groups because `autoContrast` consumes state-specific companions selected at build time. The [color override contract](./public-tokens.md#color-override-contract) documents the state pairings and preset-role requirements.
115
115
 
116
116
  ## Cascade layers and migration
117
117