@onereach/ui-components 8.12.0 → 8.12.1-beta.3771.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.
Files changed (41) hide show
  1. package/dist/bundled/v2/components/OrRatingV3/OrRating.js +2 -0
  2. package/dist/bundled/v2/components/OrRatingV3/OrRating.vue.d.ts +56 -0
  3. package/dist/bundled/v2/components/OrRatingV3/index.d.ts +1 -0
  4. package/dist/bundled/v2/components/OrRatingV3/index.js +1 -0
  5. package/dist/bundled/v2/components/OrRatingV3/styles.d.ts +2 -0
  6. package/dist/bundled/v2/components/OrRatingV3/styles.js +1 -0
  7. package/dist/bundled/v2/components/OrRatingV3-0860f5b3.js +154 -0
  8. package/dist/bundled/v2/components/index.d.ts +1 -0
  9. package/dist/bundled/v2/components/index.js +1 -0
  10. package/dist/bundled/v2/index.js +2 -1
  11. package/dist/bundled/v3/components/OrRatingV3/OrRating.js +1 -0
  12. package/dist/bundled/v3/components/OrRatingV3/OrRating.vue.d.ts +37 -0
  13. package/dist/bundled/v3/components/OrRatingV3/index.d.ts +1 -0
  14. package/dist/bundled/v3/components/OrRatingV3/index.js +1 -0
  15. package/dist/bundled/v3/components/OrRatingV3/styles.d.ts +2 -0
  16. package/dist/bundled/v3/components/OrRatingV3/styles.js +1 -0
  17. package/dist/bundled/v3/components/OrRatingV3-d1230c2b.js +117 -0
  18. package/dist/bundled/v3/components/index.d.ts +1 -0
  19. package/dist/bundled/v3/components/index.js +1 -0
  20. package/dist/bundled/v3/index.js +2 -1
  21. package/dist/esm/v2/OrRating-1cda1619.js +158 -0
  22. package/dist/esm/v2/components/index.d.ts +1 -0
  23. package/dist/esm/v2/components/index.js +1 -0
  24. package/dist/esm/v2/components/or-rating-v3/OrRating.vue.d.ts +56 -0
  25. package/dist/esm/v2/components/or-rating-v3/index.d.ts +1 -0
  26. package/dist/esm/v2/components/or-rating-v3/index.js +11 -0
  27. package/dist/esm/v2/components/or-rating-v3/styles.d.ts +2 -0
  28. package/dist/esm/v2/index.js +1 -0
  29. package/dist/esm/v3/OrRating-51a033dc.js +121 -0
  30. package/dist/esm/v3/components/index.d.ts +1 -0
  31. package/dist/esm/v3/components/index.js +1 -0
  32. package/dist/esm/v3/components/or-rating-v3/OrRating.vue.d.ts +37 -0
  33. package/dist/esm/v3/components/or-rating-v3/index.d.ts +1 -0
  34. package/dist/esm/v3/components/or-rating-v3/index.js +11 -0
  35. package/dist/esm/v3/components/or-rating-v3/styles.d.ts +2 -0
  36. package/dist/esm/v3/index.js +1 -0
  37. package/package.json +3 -4
  38. package/src/components/index.ts +1 -0
  39. package/src/components/or-rating-v3/OrRating.vue +129 -0
  40. package/src/components/or-rating-v3/index.ts +1 -0
  41. package/src/components/or-rating-v3/styles.ts +24 -0
@@ -0,0 +1,158 @@
1
+ import { defineComponent, inject, ref, computed, toRef, watch, reactive } from 'vue-demi';
2
+ import '@vueuse/core';
3
+ import './dom-aecadd9a.js';
4
+ import { u as useProxyModelValue } from './useProxyModelValue-940010d2.js';
5
+ import '@onereach/styles/tailwind/plugins/core';
6
+ import '@onereach/styles/tailwind.config.json';
7
+ import { _ as __vue_component__$1 } from './OrIcon-0343b3d8.js';
8
+ import { n as normalizeComponent } from './normalize-component-6e8e3d80.js';
9
+
10
+ const Rating = [
11
+ // Layout
12
+ 'layout-row',
13
+ // Theme
14
+ 'theme-foreground-disabled', 'dark:theme-foreground-disabled-dark'];
15
+ const RatingStar = [
16
+ // Layout
17
+ 'layout-row justify-center',
18
+ // Interactivity
19
+ 'interactivity-click',
20
+ // Box
21
+ 'w-[28px] md:w-[24px]', 'h-[28px] md:h-[24px]',
22
+ // Theme (activated)
23
+ 'activated:theme-foreground-warning-hover', 'dark:activated:theme-foreground-warning-hover-dark'];
24
+
25
+ const RATING_LENGTH = Symbol();
26
+ var script = defineComponent({
27
+ components: {
28
+ OrIcon: __vue_component__$1
29
+ },
30
+ model: {
31
+ prop: 'modelValue',
32
+ event: 'update:modelValue'
33
+ },
34
+ props: {
35
+ modelValue: {
36
+ type: Number,
37
+ default: 0
38
+ },
39
+ disabled: {
40
+ type: Boolean,
41
+ default: false
42
+ }
43
+ },
44
+ emits: ['update:modelValue'],
45
+ expose: ['root'],
46
+ setup(props, context) {
47
+ // Options
48
+ const length = inject(RATING_LENGTH, 5);
49
+ // Refs
50
+ const root = ref();
51
+ // Styles
52
+ const rootStyles = computed(() => ['or-rating-v3', ...Rating]);
53
+ const starStyles = computed(() => [...RatingStar]);
54
+ // State
55
+ const proxyModelValue = useProxyModelValue(toRef(props, 'modelValue'), context.emit);
56
+ const draftModelValue = ref(proxyModelValue.value);
57
+ watch(proxyModelValue, value => {
58
+ draftModelValue.value = value;
59
+ });
60
+ const hoverIndex = reactive(Array(length).fill(false));
61
+ // Handlers
62
+ function onMouseEnter(event, index) {
63
+ hoverIndex[index] = true;
64
+ }
65
+ function onMouseMove(event, index) {
66
+ const {
67
+ width
68
+ } = event.currentTarget.getBoundingClientRect();
69
+ draftModelValue.value = Math.ceil((index - (width - event.offsetX) / width + 1) * 2) / 2;
70
+ }
71
+ function onMouseLeave(event, index) {
72
+ hoverIndex[index] = false;
73
+ draftModelValue.value = proxyModelValue.value;
74
+ }
75
+ return {
76
+ length,
77
+ root,
78
+ rootStyles,
79
+ starStyles,
80
+ proxyModelValue,
81
+ draftModelValue,
82
+ hoverIndex,
83
+ onMouseEnter,
84
+ onMouseMove,
85
+ onMouseLeave
86
+ };
87
+ }
88
+ });
89
+
90
+ /* script */
91
+ const __vue_script__ = script;
92
+
93
+ /* template */
94
+ var __vue_render__ = function () {
95
+ var _vm = this;
96
+ var _h = _vm.$createElement;
97
+ var _c = _vm._self._c || _h;
98
+ return _c('div', {
99
+ ref: "root",
100
+ class: _vm.rootStyles,
101
+ attrs: {
102
+ "disabled": _vm.disabled
103
+ }
104
+ }, _vm._l(_vm.length, function (value) {
105
+ return _c('div', {
106
+ key: value,
107
+ ref: "stars",
108
+ refInFor: true,
109
+ class: _vm.starStyles,
110
+ attrs: {
111
+ "activated": value <= Math.ceil(_vm.proxyModelValue),
112
+ "disabled": _vm.disabled
113
+ },
114
+ on: {
115
+ "mouseenter": function ($event) {
116
+ return _vm.onMouseEnter($event, value - 1);
117
+ },
118
+ "mousemove": function ($event) {
119
+ return _vm.onMouseMove($event, value - 1);
120
+ },
121
+ "mouseleave": function ($event) {
122
+ return _vm.onMouseLeave($event, value - 1);
123
+ },
124
+ "click": function ($event) {
125
+ _vm.proxyModelValue = _vm.draftModelValue;
126
+ }
127
+ }
128
+ }, [_c('OrIcon', {
129
+ attrs: {
130
+ "icon": _vm.draftModelValue - value + 1 === 0.5 ? 'star_half' : 'star',
131
+ "variant": value <= _vm.draftModelValue ? 'filled' : 'outlined',
132
+ "size": _vm.hoverIndex[value - 1] ? 'xl' : 'l'
133
+ }
134
+ })], 1);
135
+ }), 0);
136
+ };
137
+ var __vue_staticRenderFns__ = [];
138
+
139
+ /* style */
140
+ const __vue_inject_styles__ = undefined;
141
+ /* scoped */
142
+ const __vue_scope_id__ = undefined;
143
+ /* module identifier */
144
+ const __vue_module_identifier__ = undefined;
145
+ /* functional template */
146
+ const __vue_is_functional_template__ = false;
147
+ /* style inject */
148
+
149
+ /* style inject SSR */
150
+
151
+ /* style inject shadow dom */
152
+
153
+ const __vue_component__ = /*#__PURE__*/normalizeComponent({
154
+ render: __vue_render__,
155
+ staticRenderFns: __vue_staticRenderFns__
156
+ }, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined);
157
+
158
+ export { __vue_component__ as _ };
@@ -77,6 +77,7 @@ export * from './or-radio-group';
77
77
  export * from './or-radio-group-v3';
78
78
  export * from './or-radio-v3';
79
79
  export * from './or-range-slider-v3';
80
+ export * from './or-rating-v3';
80
81
  export * from './or-resizeable-panel-v3';
81
82
  export * from './or-rich-text-editor-v3';
82
83
  export * from './or-search';
@@ -95,6 +95,7 @@ export { _ as OrRadioV3 } from '../OrRadio-81a1263e.js';
95
95
  export { _ as OrRangeSliderV3 } from '../OrRangeSlider-32622ccc.js';
96
96
  export { _ as OrSliderV3 } from '../OrSlider-4720f2e2.js';
97
97
  export { S as RangeSliderColor, a as RangeSliderOrientation, S as SliderColor, a as SliderOrientation } from '../OrSlider.vue_rollup-plugin-vue_script-071cae38.js';
98
+ export { _ as OrRatingV3 } from '../OrRating-1cda1619.js';
98
99
  export { _ as OrResizeablePanelV3, R as ResizeablePanelPadding, a as ResizeablePanelPlacement, R as SidebarPadding } from '../OrResizeablePanel-51314593.js';
99
100
  export { F as Formats, _ as OrRichTextEditorV3 } from '../OrRichTextEditor-e92007c4.js';
100
101
  export { _ as OrSearch } from '../OrSearch-ac542dd6.js';
@@ -0,0 +1,56 @@
1
+ export declare const RATING_LENGTH: unique symbol;
2
+ declare const _default: import("vue").ComponentOptions<import("vue").default, import("@vue/composition-api").ShallowUnwrapRef<{
3
+ length: number;
4
+ root: import("@vue/composition-api").Ref<HTMLElement | undefined>;
5
+ rootStyles: import("@vue/composition-api").ComputedRef<string[]>;
6
+ starStyles: import("@vue/composition-api").ComputedRef<string[]>;
7
+ proxyModelValue: import("../../hooks").UseProxyModelValueReturn<number>;
8
+ draftModelValue: import("@vue/composition-api").Ref<number>;
9
+ hoverIndex: boolean[];
10
+ onMouseEnter: (event: MouseEvent, index: number) => void;
11
+ onMouseMove: (event: MouseEvent, index: number) => void;
12
+ onMouseLeave: (event: MouseEvent, index: number) => void;
13
+ }> & import("@vue/composition-api").Data, {}, {}, {
14
+ modelValue: {
15
+ type: NumberConstructor;
16
+ default: number;
17
+ };
18
+ disabled: {
19
+ type: BooleanConstructor;
20
+ default: boolean;
21
+ };
22
+ }, import("@vue/composition-api").ExtractPropTypes<{
23
+ modelValue: {
24
+ type: NumberConstructor;
25
+ default: number;
26
+ };
27
+ disabled: {
28
+ type: BooleanConstructor;
29
+ default: boolean;
30
+ };
31
+ }>> & Omit<import("vue").VueConstructor<import("vue").default>, never> & (new (...args: any[]) => import("@vue/composition-api").ComponentRenderProxy<{
32
+ modelValue: number;
33
+ disabled: boolean;
34
+ } & {} & {
35
+ [x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
36
+ }, import("@vue/composition-api").ShallowUnwrapRef<{
37
+ length: number;
38
+ root: import("@vue/composition-api").Ref<HTMLElement | undefined>;
39
+ rootStyles: import("@vue/composition-api").ComputedRef<string[]>;
40
+ starStyles: import("@vue/composition-api").ComputedRef<string[]>;
41
+ proxyModelValue: import("../../hooks").UseProxyModelValueReturn<number>;
42
+ draftModelValue: import("@vue/composition-api").Ref<number>;
43
+ hoverIndex: boolean[];
44
+ onMouseEnter: (event: MouseEvent, index: number) => void;
45
+ onMouseMove: (event: MouseEvent, index: number) => void;
46
+ onMouseLeave: (event: MouseEvent, index: number) => void;
47
+ }>, import("@vue/composition-api").Data, {}, {}, {}, {}, string[], {
48
+ modelValue: number;
49
+ disabled: boolean;
50
+ } & {} & {
51
+ [x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
52
+ }, {
53
+ modelValue: number;
54
+ disabled: boolean;
55
+ }, true>);
56
+ export default _default;
@@ -0,0 +1 @@
1
+ export { default as OrRatingV3 } from './OrRating.vue';
@@ -0,0 +1,11 @@
1
+ export { _ as OrRatingV3 } from '../../OrRating-1cda1619.js';
2
+ import 'vue-demi';
3
+ import '@vueuse/core';
4
+ import '../../dom-aecadd9a.js';
5
+ import 'lodash/isElement';
6
+ import 'lodash/get';
7
+ import '../../useProxyModelValue-940010d2.js';
8
+ import '@onereach/styles/tailwind/plugins/core';
9
+ import '@onereach/styles/tailwind.config.json';
10
+ import '../../OrIcon-0343b3d8.js';
11
+ import '../../normalize-component-6e8e3d80.js';
@@ -0,0 +1,2 @@
1
+ export declare const Rating: string[];
2
+ export declare const RatingStar: string[];
@@ -95,6 +95,7 @@ export { _ as OrRadioV3 } from './OrRadio-81a1263e.js';
95
95
  export { _ as OrRangeSliderV3 } from './OrRangeSlider-32622ccc.js';
96
96
  export { _ as OrSliderV3 } from './OrSlider-4720f2e2.js';
97
97
  export { S as RangeSliderColor, a as RangeSliderOrientation, S as SliderColor, a as SliderOrientation } from './OrSlider.vue_rollup-plugin-vue_script-071cae38.js';
98
+ export { _ as OrRatingV3 } from './OrRating-1cda1619.js';
98
99
  export { _ as OrResizeablePanelV3, R as ResizeablePanelPadding, a as ResizeablePanelPlacement, R as SidebarPadding } from './OrResizeablePanel-51314593.js';
99
100
  export { F as Formats, _ as OrRichTextEditorV3 } from './OrRichTextEditor-e92007c4.js';
100
101
  export { _ as OrSearch } from './OrSearch-ac542dd6.js';
@@ -0,0 +1,121 @@
1
+ import { defineComponent, inject, ref, computed, toRef, watch, reactive } from 'vue-demi';
2
+ import '@vueuse/core';
3
+ import './dom-aecadd9a.js';
4
+ import { u as useProxyModelValue } from './useProxyModelValue-940010d2.js';
5
+ import '@onereach/styles/tailwind/plugins/core';
6
+ import '@onereach/styles/tailwind.config.json';
7
+ import { s as script$1 } from './OrIcon-8f6c9c29.js';
8
+ import { resolveComponent, openBlock, createElementBlock, normalizeClass, Fragment, renderList, createVNode } from 'vue';
9
+
10
+ const Rating = [
11
+ // Layout
12
+ 'layout-row',
13
+ // Theme
14
+ 'theme-foreground-disabled', 'dark:theme-foreground-disabled-dark'];
15
+ const RatingStar = [
16
+ // Layout
17
+ 'layout-row justify-center',
18
+ // Interactivity
19
+ 'interactivity-click',
20
+ // Box
21
+ 'w-[28px] md:w-[24px]', 'h-[28px] md:h-[24px]',
22
+ // Theme (activated)
23
+ 'activated:theme-foreground-warning-hover', 'dark:activated:theme-foreground-warning-hover-dark'];
24
+
25
+ const RATING_LENGTH = Symbol();
26
+ var script = defineComponent({
27
+ components: {
28
+ OrIcon: script$1
29
+ },
30
+ model: {
31
+ prop: 'modelValue',
32
+ event: 'update:modelValue'
33
+ },
34
+ props: {
35
+ modelValue: {
36
+ type: Number,
37
+ default: 0
38
+ },
39
+ disabled: {
40
+ type: Boolean,
41
+ default: false
42
+ }
43
+ },
44
+ emits: ['update:modelValue'],
45
+ expose: ['root'],
46
+ setup(props, context) {
47
+ // Options
48
+ const length = inject(RATING_LENGTH, 5);
49
+ // Refs
50
+ const root = ref();
51
+ // Styles
52
+ const rootStyles = computed(() => ['or-rating-v3', ...Rating]);
53
+ const starStyles = computed(() => [...RatingStar]);
54
+ // State
55
+ const proxyModelValue = useProxyModelValue(toRef(props, 'modelValue'), context.emit);
56
+ const draftModelValue = ref(proxyModelValue.value);
57
+ watch(proxyModelValue, value => {
58
+ draftModelValue.value = value;
59
+ });
60
+ const hoverIndex = reactive(Array(length).fill(false));
61
+ // Handlers
62
+ function onMouseEnter(event, index) {
63
+ hoverIndex[index] = true;
64
+ }
65
+ function onMouseMove(event, index) {
66
+ const {
67
+ width
68
+ } = event.currentTarget.getBoundingClientRect();
69
+ draftModelValue.value = Math.ceil((index - (width - event.offsetX) / width + 1) * 2) / 2;
70
+ }
71
+ function onMouseLeave(event, index) {
72
+ hoverIndex[index] = false;
73
+ draftModelValue.value = proxyModelValue.value;
74
+ }
75
+ return {
76
+ length,
77
+ root,
78
+ rootStyles,
79
+ starStyles,
80
+ proxyModelValue,
81
+ draftModelValue,
82
+ hoverIndex,
83
+ onMouseEnter,
84
+ onMouseMove,
85
+ onMouseLeave
86
+ };
87
+ }
88
+ });
89
+
90
+ const _hoisted_1 = ["disabled"];
91
+ const _hoisted_2 = ["activated", "disabled", "onMouseenter", "onMousemove", "onMouseleave"];
92
+ function render(_ctx, _cache, $props, $setup, $data, $options) {
93
+ const _component_OrIcon = resolveComponent("OrIcon");
94
+ return openBlock(), createElementBlock("div", {
95
+ ref: "root",
96
+ class: normalizeClass(_ctx.rootStyles),
97
+ disabled: _ctx.disabled
98
+ }, [(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.length, value => {
99
+ return openBlock(), createElementBlock("div", {
100
+ ref_for: true,
101
+ ref: "stars",
102
+ key: value,
103
+ class: normalizeClass(_ctx.starStyles),
104
+ activated: value <= Math.ceil(_ctx.proxyModelValue),
105
+ disabled: _ctx.disabled,
106
+ onMouseenter: $event => _ctx.onMouseEnter($event, value - 1),
107
+ onMousemove: $event => _ctx.onMouseMove($event, value - 1),
108
+ onMouseleave: $event => _ctx.onMouseLeave($event, value - 1),
109
+ onClick: _cache[0] || (_cache[0] = $event => _ctx.proxyModelValue = _ctx.draftModelValue)
110
+ }, [createVNode(_component_OrIcon, {
111
+ icon: _ctx.draftModelValue - value + 1 === 0.5 ? 'star_half' : 'star',
112
+ variant: value <= _ctx.draftModelValue ? 'filled' : 'outlined',
113
+ size: _ctx.hoverIndex[value - 1] ? 'xl' : 'l'
114
+ }, null, 8 /* PROPS */, ["icon", "variant", "size"])], 42 /* CLASS, PROPS, HYDRATE_EVENTS */, _hoisted_2);
115
+ }), 128 /* KEYED_FRAGMENT */))], 10 /* CLASS, PROPS */, _hoisted_1);
116
+ }
117
+
118
+ script.render = render;
119
+ script.__file = "src/components/or-rating-v3/OrRating.vue";
120
+
121
+ export { script as s };
@@ -77,6 +77,7 @@ export * from './or-radio-group';
77
77
  export * from './or-radio-group-v3';
78
78
  export * from './or-radio-v3';
79
79
  export * from './or-range-slider-v3';
80
+ export * from './or-rating-v3';
80
81
  export * from './or-resizeable-panel-v3';
81
82
  export * from './or-rich-text-editor-v3';
82
83
  export * from './or-search';
@@ -91,6 +91,7 @@ export { s as OrRadioGroupV3 } from '../OrRadioGroup-b4b6d364.js';
91
91
  export { s as OrRadioV3 } from '../OrRadio-50b0ead5.js';
92
92
  export { s as OrRangeSliderV3 } from '../OrRangeSlider-8edcdad1.js';
93
93
  export { s as OrSliderV3, S as RangeSliderColor, a as RangeSliderOrientation, S as SliderColor, a as SliderOrientation } from '../OrSlider-a0ec670e.js';
94
+ export { s as OrRatingV3 } from '../OrRating-51a033dc.js';
94
95
  export { s as OrResizeablePanelV3, R as ResizeablePanelPadding, a as ResizeablePanelPlacement, R as SidebarPadding } from '../OrResizeablePanel-60f83f9a.js';
95
96
  export { F as Formats, s as OrRichTextEditorV3 } from '../OrRichTextEditor-a1f04ce6.js';
96
97
  export { s as OrSearch } from '../OrSearch-2800e9bf.js';
@@ -0,0 +1,37 @@
1
+ export declare const RATING_LENGTH: unique symbol;
2
+ declare const _default: import("vue-demi").DefineComponent<{
3
+ modelValue: {
4
+ type: NumberConstructor;
5
+ default: number;
6
+ };
7
+ disabled: {
8
+ type: BooleanConstructor;
9
+ default: boolean;
10
+ };
11
+ }, {
12
+ length: number;
13
+ root: import("vue-demi").Ref<HTMLElement | undefined>;
14
+ rootStyles: import("vue-demi").ComputedRef<string[]>;
15
+ starStyles: import("vue-demi").ComputedRef<string[]>;
16
+ proxyModelValue: import("../../hooks").UseProxyModelValueReturn<number>;
17
+ draftModelValue: import("vue-demi").Ref<number>;
18
+ hoverIndex: boolean[];
19
+ onMouseEnter: (event: MouseEvent, index: number) => void;
20
+ onMouseMove: (event: MouseEvent, index: number) => void;
21
+ onMouseLeave: (event: MouseEvent, index: number) => void;
22
+ }, unknown, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<{
23
+ modelValue: {
24
+ type: NumberConstructor;
25
+ default: number;
26
+ };
27
+ disabled: {
28
+ type: BooleanConstructor;
29
+ default: boolean;
30
+ };
31
+ }>> & {
32
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
33
+ }, {
34
+ modelValue: number;
35
+ disabled: boolean;
36
+ }>;
37
+ export default _default;
@@ -0,0 +1 @@
1
+ export { default as OrRatingV3 } from './OrRating.vue';
@@ -0,0 +1,11 @@
1
+ export { s as OrRatingV3 } from '../../OrRating-51a033dc.js';
2
+ import 'vue-demi';
3
+ import '@vueuse/core';
4
+ import '../../dom-aecadd9a.js';
5
+ import 'lodash/isElement';
6
+ import 'lodash/get';
7
+ import '../../useProxyModelValue-940010d2.js';
8
+ import '@onereach/styles/tailwind/plugins/core';
9
+ import '@onereach/styles/tailwind.config.json';
10
+ import '../../OrIcon-8f6c9c29.js';
11
+ import 'vue';
@@ -0,0 +1,2 @@
1
+ export declare const Rating: string[];
2
+ export declare const RatingStar: string[];
@@ -91,6 +91,7 @@ export { s as OrRadioGroupV3 } from './OrRadioGroup-b4b6d364.js';
91
91
  export { s as OrRadioV3 } from './OrRadio-50b0ead5.js';
92
92
  export { s as OrRangeSliderV3 } from './OrRangeSlider-8edcdad1.js';
93
93
  export { s as OrSliderV3, S as RangeSliderColor, a as RangeSliderOrientation, S as SliderColor, a as SliderOrientation } from './OrSlider-a0ec670e.js';
94
+ export { s as OrRatingV3 } from './OrRating-51a033dc.js';
94
95
  export { s as OrResizeablePanelV3, R as ResizeablePanelPadding, a as ResizeablePanelPlacement, R as SidebarPadding } from './OrResizeablePanel-60f83f9a.js';
95
96
  export { F as Formats, s as OrRichTextEditorV3 } from './OrRichTextEditor-a1f04ce6.js';
96
97
  export { s as OrSearch } from './OrSearch-2800e9bf.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/ui-components",
3
- "version": "8.12.0",
3
+ "version": "8.12.1-beta.3771.0",
4
4
  "npmUnpacked": "4.15.2",
5
5
  "description": "Vue components library for v2/3",
6
6
  "sideEffects": false,
@@ -40,7 +40,7 @@
40
40
  "@codemirror/lang-json": "6.0.1",
41
41
  "@codemirror/lang-markdown": "6.1.1",
42
42
  "@floating-ui/dom": "1.4.2",
43
- "@onereach/styles": "^6.5.0",
43
+ "@onereach/styles": "^6.5.1-beta.3771.0",
44
44
  "@splidejs/splide": "4.0.6",
45
45
  "@tiptap/core": "2.0.3",
46
46
  "@tiptap/extension-blockquote": "2.0.3",
@@ -176,6 +176,5 @@
176
176
  "default": "./dist/bundled/v3/components/*/index.js"
177
177
  },
178
178
  "./package.json": "./package.json"
179
- },
180
- "gitHead": "6fa9a02db827c5e2a229cdf40f42164fe15898c5"
179
+ }
181
180
  }
@@ -77,6 +77,7 @@ export * from './or-radio-group';
77
77
  export * from './or-radio-group-v3';
78
78
  export * from './or-radio-v3';
79
79
  export * from './or-range-slider-v3';
80
+ export * from './or-rating-v3';
80
81
  export * from './or-resizeable-panel-v3';
81
82
  export * from './or-rich-text-editor-v3';
82
83
  export * from './or-search';
@@ -0,0 +1,129 @@
1
+ <template>
2
+ <div
3
+ ref="root"
4
+ :class="rootStyles"
5
+ :disabled="disabled"
6
+ >
7
+ <div
8
+ v-for="value of length"
9
+ ref="stars"
10
+ :key="value"
11
+ :class="starStyles"
12
+ :activated="value <= Math.ceil(proxyModelValue)"
13
+ :disabled="disabled"
14
+ @mouseenter="onMouseEnter($event, value - 1)"
15
+ @mousemove="onMouseMove($event, value - 1)"
16
+ @mouseleave="onMouseLeave($event, value - 1)"
17
+ @click="proxyModelValue = draftModelValue"
18
+ >
19
+ <OrIcon
20
+ :icon="draftModelValue - value + 1 === 0.5 ? 'star_half' : 'star'"
21
+ :variant="value <= draftModelValue ? 'filled' : 'outlined'"
22
+ :size="hoverIndex[value - 1] ? 'xl' : 'l'"
23
+ />
24
+ </div>
25
+ </div>
26
+ </template>
27
+
28
+ <script lang="ts">
29
+ import { computed, defineComponent, inject, reactive, ref, toRef, watch } from 'vue-demi';
30
+ import { useProxyModelValue } from '../../hooks';
31
+ import { OrIconV3 as OrIcon } from '../or-icon-v3';
32
+ import { Rating, RatingStar } from './styles';
33
+
34
+ export const RATING_LENGTH = Symbol();
35
+
36
+ export default defineComponent({
37
+ components: {
38
+ OrIcon,
39
+ },
40
+
41
+ model: {
42
+ prop: 'modelValue',
43
+ event: 'update:modelValue',
44
+ },
45
+
46
+ props: {
47
+ modelValue: {
48
+ type: Number,
49
+ default: 0,
50
+ },
51
+
52
+ disabled: {
53
+ type: Boolean,
54
+ default: false,
55
+ },
56
+ },
57
+
58
+ emits: [
59
+ 'update:modelValue',
60
+ ],
61
+
62
+ expose: [
63
+ 'root',
64
+ ],
65
+
66
+ setup(props, context) {
67
+ // Options
68
+ const length = inject(RATING_LENGTH, 5);
69
+
70
+ // Refs
71
+ const root = ref<HTMLElement>();
72
+
73
+ // Styles
74
+ const rootStyles = computed(() => [
75
+ 'or-rating-v3',
76
+ ...Rating,
77
+ ]);
78
+
79
+ const starStyles = computed(() => [
80
+ ...RatingStar,
81
+ ]);
82
+
83
+ // State
84
+ const proxyModelValue = useProxyModelValue(toRef(props, 'modelValue'), context.emit);
85
+ const draftModelValue = ref(proxyModelValue.value);
86
+
87
+ watch(proxyModelValue, (value) => {
88
+ draftModelValue.value = value;
89
+ });
90
+
91
+ const hoverIndex = reactive(Array<boolean>(length).fill(false));
92
+
93
+ // Handlers
94
+ function onMouseEnter(event: MouseEvent, index: number): void {
95
+ hoverIndex[index] = true;
96
+ }
97
+
98
+ function onMouseMove(event: MouseEvent, index: number): void {
99
+ const { width } = (event.currentTarget as Element).getBoundingClientRect();
100
+
101
+ draftModelValue.value = Math.ceil((index - (width - event.offsetX) / width + 1) * 2) / 2;
102
+ }
103
+
104
+ function onMouseLeave(event: MouseEvent, index: number): void {
105
+ hoverIndex[index] = false;
106
+
107
+ draftModelValue.value = proxyModelValue.value;
108
+ }
109
+
110
+ return {
111
+ length,
112
+
113
+ root,
114
+
115
+ rootStyles,
116
+ starStyles,
117
+
118
+ proxyModelValue,
119
+ draftModelValue,
120
+
121
+ hoverIndex,
122
+
123
+ onMouseEnter,
124
+ onMouseMove,
125
+ onMouseLeave,
126
+ };
127
+ },
128
+ });
129
+ </script>
@@ -0,0 +1 @@
1
+ export { default as OrRatingV3 } from './OrRating.vue';
@@ -0,0 +1,24 @@
1
+ export const Rating: string[] = [
2
+ // Layout
3
+ 'layout-row',
4
+
5
+ // Theme
6
+ 'theme-foreground-disabled',
7
+ 'dark:theme-foreground-disabled-dark',
8
+ ];
9
+
10
+ export const RatingStar: string[] = [
11
+ // Layout
12
+ 'layout-row justify-center',
13
+
14
+ // Interactivity
15
+ 'interactivity-click',
16
+
17
+ // Box
18
+ 'w-[28px] md:w-[24px]',
19
+ 'h-[28px] md:h-[24px]',
20
+
21
+ // Theme (activated)
22
+ 'activated:theme-foreground-warning-hover',
23
+ 'dark:activated:theme-foreground-warning-hover-dark',
24
+ ];