@pequity/squirrel 5.4.7 → 5.4.9
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 +1 -1
- package/dist/cjs/chunks/p-date-picker.js +143 -85
- package/dist/cjs/chunks/p-dropdown-select.js +4 -4
- package/dist/cjs/chunks/p-inline-date-picker.js +117 -67
- package/dist/cjs/chunks/p-link.js +1 -1
- package/dist/cjs/chunks/p-select.js +1 -1
- package/dist/cjs/index.js +37 -37
- package/dist/cjs/p-btn.js +2 -2
- package/dist/cjs/p-checkbox.js +1 -1
- package/dist/cjs/p-chips.js +2 -2
- package/dist/cjs/p-input-number.js +3 -3
- package/dist/cjs/p-input-search.js +1 -1
- package/dist/cjs/p-loading.js +2 -2
- package/dist/cjs/p-modal.js +2 -2
- package/dist/cjs/p-skeleton-loader.js +1 -1
- package/dist/cjs/p-table-td.js +1 -1
- package/dist/cjs/p-toggle.js +1 -1
- package/dist/cjs/tailwind.js +2 -2
- package/dist/cjs/usePTableRowVirtualizer.js +1 -1
- package/dist/cjs/useSelectList.js +3 -3
- package/dist/es/chunks/p-date-picker.js +144 -86
- package/dist/es/chunks/p-dropdown-select.js +4 -4
- package/dist/es/chunks/p-inline-date-picker.js +118 -68
- package/dist/es/chunks/p-link.js +1 -1
- package/dist/es/chunks/p-select.js +1 -1
- package/dist/es/index.js +35 -35
- package/dist/es/p-btn.js +2 -2
- package/dist/es/p-checkbox.js +1 -1
- package/dist/es/p-chips.js +2 -2
- package/dist/es/p-input-number.js +3 -3
- package/dist/es/p-input-search.js +1 -1
- package/dist/es/p-loading.js +2 -2
- package/dist/es/p-modal.js +2 -2
- package/dist/es/p-skeleton-loader.js +1 -1
- package/dist/es/p-table-td.js +1 -1
- package/dist/es/p-toggle.js +1 -1
- package/dist/es/tailwind.js +2 -2
- package/dist/es/usePTableRowVirtualizer.js +1 -1
- package/dist/es/useSelectList.js +3 -3
- package/dist/squirrel/components/index.d.ts +13 -13
- package/dist/squirrel/components/p-btn/p-btn.vue.d.ts +2 -2
- package/dist/squirrel/components/p-card/p-card.vue.d.ts +3 -2
- package/dist/squirrel/components/p-checkbox/p-checkbox.vue.d.ts +2 -1
- package/dist/squirrel/components/p-close-btn/p-close-btn.vue.d.ts +1 -1
- package/dist/squirrel/components/p-date-picker/p-date-picker.vue.d.ts +27 -30
- package/dist/squirrel/components/p-drawer/p-drawer.vue.d.ts +3 -3
- package/dist/squirrel/components/p-dropdown-select/p-dropdown-select.vue.d.ts +8 -7
- package/dist/squirrel/components/p-file-upload/p-file-upload.vue.d.ts +1 -1
- package/dist/squirrel/components/p-icon/p-icon.vue.d.ts +2 -2
- package/dist/squirrel/components/p-info-icon/p-info-icon.vue.d.ts +2 -1
- package/dist/squirrel/components/p-inline-date-picker/p-inline-date-picker.vue.d.ts +46 -0
- package/dist/squirrel/components/p-input/p-input.vue.d.ts +1 -1
- package/dist/squirrel/components/p-input-number/p-input-number.vue.d.ts +1 -1
- package/dist/squirrel/components/p-input-percent/p-input-percent.vue.d.ts +1 -1
- package/dist/squirrel/components/p-input-search/p-input-search.vue.d.ts +2 -2
- package/dist/squirrel/components/p-link/p-link.vue.d.ts +2 -1
- package/dist/squirrel/components/p-modal/p-modal.vue.d.ts +5 -4
- package/dist/squirrel/components/p-pagination-info/p-pagination-info.vue.d.ts +2 -1
- package/dist/squirrel/components/p-ring-loader/p-ring-loader.vue.d.ts +1 -1
- package/dist/squirrel/components/p-select/p-select.vue.d.ts +3 -2
- package/dist/squirrel/components/p-select-btn/p-select-btn.vue.d.ts +3 -2
- package/dist/squirrel/components/p-select-list/p-select-list.vue.d.ts +6 -5
- package/dist/squirrel/components/p-select-pill/p-select-pill.vue.d.ts +1 -1
- package/dist/squirrel/components/p-table/p-table.vue.d.ts +3 -2
- package/dist/squirrel/components/p-table-loader/p-table-loader.vue.d.ts +1 -1
- package/dist/squirrel/components/p-table-sort/p-table-sort.vue.d.ts +1 -1
- package/dist/squirrel/components/p-table-td/p-table-td.vue.d.ts +2 -1
- package/dist/squirrel/components/p-tabs/p-tabs.vue.d.ts +2 -2
- package/dist/squirrel/components/p-textarea/p-textarea.vue.d.ts +1 -1
- package/dist/squirrel/components/p-toggle/p-toggle.vue.d.ts +1 -1
- package/dist/squirrel/index.d.ts +1 -1
- package/dist/squirrel/utils/index.d.ts +8 -8
- package/dist/squirrel/utils/inputClassesMixin.d.ts +1 -1
- package/dist/style.css +98 -989
- package/package.json +30 -32
- package/squirrel/assets/squirrel.css +45 -6
- package/squirrel/components/index.ts +37 -37
- package/squirrel/components/p-action-bar/p-action-bar.spec.ts +1 -1
- package/squirrel/components/p-action-bar/p-action-bar.stories.js +2 -2
- package/squirrel/components/p-action-bar/p-action-bar.vue +1 -1
- package/squirrel/components/p-alert/p-alert.vue +1 -1
- package/squirrel/components/p-btn/p-btn.spec.js +2 -2
- package/squirrel/components/p-btn/p-btn.vue +4 -4
- package/squirrel/components/p-checkbox/p-checkbox.vue +1 -1
- package/squirrel/components/p-chips/p-chips.vue +1 -1
- package/squirrel/components/p-date-picker/p-date-picker.spec.js +292 -0
- package/squirrel/components/p-date-picker/p-date-picker.stories.js +3 -3
- package/squirrel/components/p-date-picker/p-date-picker.vue +45 -90
- package/squirrel/components/p-dropdown/p-dropdown.spec.js +1 -1
- package/squirrel/components/p-dropdown/p-dropdown.vue +1 -1
- package/squirrel/components/p-dropdown-select/p-dropdown-select.spec.js +4 -4
- package/squirrel/components/p-dropdown-select/p-dropdown-select.stories.js +2 -2
- package/squirrel/components/p-dropdown-select/p-dropdown-select.vue +8 -8
- package/squirrel/components/p-file-upload/p-file-upload.vue +2 -2
- package/squirrel/components/p-icon/p-icon.spec.js +1 -1
- package/squirrel/components/p-icon/p-icon.stories.js +1 -1
- package/squirrel/components/p-icon/p-icon.vue +2 -2
- package/squirrel/components/p-inline-date-picker/p-inline-date-picker.spec.js +21 -45
- package/squirrel/components/p-inline-date-picker/p-inline-date-picker.stories.js +3 -3
- package/squirrel/components/p-inline-date-picker/p-inline-date-picker.vue +16 -85
- package/squirrel/components/p-input/p-input.stories.js +1 -1
- package/squirrel/components/p-input/p-input.vue +1 -1
- package/squirrel/components/p-input-number/p-input-number.stories.js +1 -1
- package/squirrel/components/p-input-number/p-input-number.vue +3 -3
- package/squirrel/components/p-input-percent/p-input-percent.stories.js +1 -1
- package/squirrel/components/p-input-percent/p-input-percent.vue +1 -1
- package/squirrel/components/p-input-search/p-input-search.stories.js +1 -1
- package/squirrel/components/p-input-search/p-input-search.vue +1 -1
- package/squirrel/components/p-link/p-link.spec.js +1 -1
- package/squirrel/components/p-link/p-link.vue +1 -1
- package/squirrel/components/p-loading/p-loading.spec.js +2 -2
- package/squirrel/components/p-loading/p-loading.stories.js +2 -2
- package/squirrel/components/p-loading/p-loading.vue +1 -1
- package/squirrel/components/p-loading/usePLoading.ts +1 -1
- package/squirrel/components/p-modal/p-modal-basic.spec.js +1 -1
- package/squirrel/components/p-modal/p-modal-events.spec.js +1 -1
- package/squirrel/components/p-modal/p-modal-features.spec.js +1 -1
- package/squirrel/components/p-modal/p-modal.vue +3 -3
- package/squirrel/components/p-pagination/p-pagination.vue +1 -1
- package/squirrel/components/p-progress-bar/p-progess-bar.spec.js +1 -1
- package/squirrel/components/p-progress-bar/p-progress-bar.vue +1 -1
- package/squirrel/components/p-select/p-select.spec.js +1 -1
- package/squirrel/components/p-select/p-select.stories.js +1 -1
- package/squirrel/components/p-select/p-select.vue +1 -1
- package/squirrel/components/p-select-btn/p-select-btn.spec.js +1 -1
- package/squirrel/components/p-select-btn/p-select-btn.stories.js +1 -1
- package/squirrel/components/p-select-btn/p-select-btn.vue +1 -1
- package/squirrel/components/p-select-list/p-select-list.spec.js +4 -4
- package/squirrel/components/p-select-list/p-select-list.vue +5 -5
- package/squirrel/components/p-select-list/useSelectList.ts +3 -3
- package/squirrel/components/p-select-pill/p-select-pill.spec.js +1 -1
- package/squirrel/components/p-select-pill/p-select-pill.stories.js +2 -2
- package/squirrel/components/p-select-pill/p-select-pill.vue +1 -1
- package/squirrel/components/p-skeleton-loader/p-skeleton-loader.vue +1 -1
- package/squirrel/components/p-table/p-table.spec.js +2 -2
- package/squirrel/components/p-table/p-table.vue +4 -4
- package/squirrel/components/p-table/usePTableColResize.spec.js +1 -1
- package/squirrel/components/p-table/usePTableColResize.ts +1 -1
- package/squirrel/components/p-table/usePTableRowVirtualizer.ts +1 -1
- package/squirrel/components/p-table-sort/p-table-sort.spec.js +1 -1
- package/squirrel/components/p-table-sort/p-table-sort.stories.js +1 -1
- package/squirrel/components/p-table-sort/p-table-sort.vue +1 -1
- package/squirrel/components/p-table-td/p-table-td.spec.js +3 -3
- package/squirrel/components/p-table-td/p-table-td.stories.js +1 -1
- package/squirrel/components/p-table-td/p-table-td.vue +2 -2
- package/squirrel/components/p-tabs/p-tabs.vue +1 -1
- package/squirrel/components/p-textarea/p-textarea.stories.js +1 -1
- package/squirrel/components/p-textarea/p-textarea.vue +1 -1
- package/squirrel/components/p-toggle/p-toggle.stories.js +1 -1
- package/squirrel/components/p-toggle/p-toggle.vue +1 -1
- package/squirrel/composables/useInputClasses.spec.js +1 -1
- package/squirrel/index.ts +1 -1
- package/squirrel/utils/component.ts +1 -1
- package/squirrel/utils/index.ts +18 -18
- package/squirrel/utils/inputClassesMixin.ts +1 -1
- package/squirrel/utils/pagination.spec.js +2 -2
- package/squirrel/utils/sanitization.spec.js +1 -1
- package/squirrel/utils/tailwind.ts +3 -2
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import PInlineDatePicker from '@squirrel/components/p-inline-date-picker/p-inline-date-picker.vue';
|
|
2
|
-
import { DatePicker } from 'v-calendar';
|
|
3
2
|
import { createWrapperFor } from '@tests/vitest.helpers';
|
|
4
3
|
|
|
5
4
|
const createWrapper = (props) => {
|
|
@@ -7,11 +6,7 @@ const createWrapper = (props) => {
|
|
|
7
6
|
props,
|
|
8
7
|
global: {
|
|
9
8
|
stubs: {
|
|
10
|
-
|
|
11
|
-
name: 'DatePicker',
|
|
12
|
-
template: '<div class="date-picker-stub"></div>',
|
|
13
|
-
props: ['modelValue', 'selectAttribute', 'minDate', 'maxDate', 'masks', 'timezone', 'style'],
|
|
14
|
-
},
|
|
9
|
+
VueDatePicker: true,
|
|
15
10
|
},
|
|
16
11
|
},
|
|
17
12
|
});
|
|
@@ -21,15 +16,13 @@ describe('PInlineDatePicker.vue', () => {
|
|
|
21
16
|
it('renders a datepicker', () => {
|
|
22
17
|
const wrapper = createWrapper();
|
|
23
18
|
|
|
24
|
-
const datePicker = wrapper.findComponent(
|
|
19
|
+
const datePicker = wrapper.findComponent({ name: 'VueDatePicker' });
|
|
25
20
|
|
|
26
21
|
expect(datePicker.props()).toMatchObject({
|
|
27
|
-
modelValue:
|
|
28
|
-
selectAttribute: { highlight: { class: 'bg-primary', contentClass: 'text-white' } },
|
|
22
|
+
modelValue: '',
|
|
29
23
|
minDate: null,
|
|
30
24
|
maxDate: null,
|
|
31
|
-
|
|
32
|
-
timezone: '',
|
|
25
|
+
timezone: null,
|
|
33
26
|
});
|
|
34
27
|
|
|
35
28
|
expect(wrapper.find('label').exists()).toBe(false);
|
|
@@ -44,9 +37,9 @@ describe('PInlineDatePicker.vue', () => {
|
|
|
44
37
|
timezone: 'UTC',
|
|
45
38
|
});
|
|
46
39
|
|
|
47
|
-
const datePicker = wrapper.findComponent(
|
|
40
|
+
const datePicker = wrapper.findComponent({ name: 'VueDatePicker' });
|
|
48
41
|
|
|
49
|
-
expect(datePicker.props().modelValue).
|
|
42
|
+
expect(datePicker.props().modelValue).toBe('2024-05-19');
|
|
50
43
|
expect(datePicker.props().minDate).toEqual(new Date('2024-05-01'));
|
|
51
44
|
expect(datePicker.props().maxDate).toEqual(new Date('2024-05-31'));
|
|
52
45
|
expect(datePicker.props().timezone).toBe('UTC');
|
|
@@ -78,8 +71,9 @@ describe('PInlineDatePicker.vue', () => {
|
|
|
78
71
|
|
|
79
72
|
expect(wrapper.props().required).toBe(true);
|
|
80
73
|
});
|
|
74
|
+
|
|
81
75
|
it('passes listeners to the datepicker', () => {
|
|
82
|
-
// Since
|
|
76
|
+
// Since VueDatePicker emits are not defined on PInlineDatePicker we need to Spy on console.warn and mock the implementation to suppress the warning:
|
|
83
77
|
// [Vue warn]: Component emitted event "update:view" but it is neither declared in the emits option nor as an "onUpdate:view" prop.
|
|
84
78
|
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
85
79
|
|
|
@@ -100,7 +94,7 @@ describe('PInlineDatePicker.vue', () => {
|
|
|
100
94
|
},
|
|
101
95
|
});
|
|
102
96
|
|
|
103
|
-
const datePicker = wrapper.findComponent(
|
|
97
|
+
const datePicker = wrapper.findComponent({ name: 'VueDatePicker' });
|
|
104
98
|
|
|
105
99
|
datePicker.vm.$emit('update:view');
|
|
106
100
|
|
|
@@ -112,12 +106,16 @@ describe('PInlineDatePicker.vue', () => {
|
|
|
112
106
|
it('sets the disabled state correctly', () => {
|
|
113
107
|
const wrapper = createWrapper({ label: 'test datepicker', disabled: true });
|
|
114
108
|
|
|
115
|
-
const
|
|
109
|
+
const datePicker = wrapper.findComponent({ name: 'VueDatePicker' });
|
|
116
110
|
|
|
117
|
-
expect(
|
|
111
|
+
expect(datePicker.props().disabled).toBe(true);
|
|
118
112
|
});
|
|
119
113
|
|
|
120
|
-
it(
|
|
114
|
+
it('updates the value bound with v-model', async () => {
|
|
115
|
+
// Since VueDatePicker emits are not defined on PInlineDatePicker we need to Spy on console.warn and mock the implementation to suppress the warning:
|
|
116
|
+
// [Vue warn]: Component emitted event "update:modelValue" but it is neither declared in the emits option nor as an "onUpdate:view" prop.
|
|
117
|
+
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
118
|
+
|
|
121
119
|
const wrapper = createWrapperFor({
|
|
122
120
|
template: `<PInlineDatePicker v-model="dateStrVal" />`,
|
|
123
121
|
components: { PInlineDatePicker },
|
|
@@ -128,25 +126,13 @@ describe('PInlineDatePicker.vue', () => {
|
|
|
128
126
|
},
|
|
129
127
|
});
|
|
130
128
|
|
|
131
|
-
const datePicker = wrapper.findComponent(
|
|
129
|
+
const datePicker = wrapper.findComponent({ name: 'VueDatePicker' });
|
|
132
130
|
|
|
133
|
-
datePicker.vm.$emit('
|
|
131
|
+
datePicker.vm.$emit('update:modelValue', '2024-09-02');
|
|
134
132
|
|
|
135
133
|
expect(wrapper.vm.dateStrVal).toBe('2024-09-02');
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it(`updates the datepicker value when modelValue is changed`, async () => {
|
|
139
|
-
const wrapper = createWrapper({ modelValue: '2024-09-01' });
|
|
140
|
-
|
|
141
|
-
const datePicker = wrapper.findComponent(DatePicker);
|
|
142
|
-
datePicker.vm.move = vi.fn();
|
|
143
|
-
|
|
144
|
-
expect(datePicker.props().modelValue).toEqual(new Date('2024-09-01'));
|
|
145
|
-
|
|
146
|
-
await wrapper.setProps({ modelValue: '2024-09-02' });
|
|
147
134
|
|
|
148
|
-
|
|
149
|
-
expect(datePicker.props().modelValue).toEqual(new Date('2024-09-02'));
|
|
135
|
+
warnSpy.mockRestore();
|
|
150
136
|
});
|
|
151
137
|
|
|
152
138
|
it('sets the error state correctly', () => {
|
|
@@ -155,20 +141,10 @@ describe('PInlineDatePicker.vue', () => {
|
|
|
155
141
|
errorMsg: 'datepicker has error',
|
|
156
142
|
});
|
|
157
143
|
|
|
158
|
-
expect(wrapper.attributes()['data-has-error']).toBeDefined();
|
|
159
|
-
const datePickerDiv = wrapper.find('.vc-container');
|
|
160
|
-
|
|
161
|
-
expect(datePickerDiv.element.style.border).toBe('1px solid #f0453c');
|
|
162
144
|
const errorDiv = wrapper.find('div.text-xs.text-on-error.mt-1');
|
|
145
|
+
|
|
146
|
+
expect(wrapper.attributes()['data-has-error']).toBeDefined();
|
|
163
147
|
expect(errorDiv.isVisible()).toBe(true);
|
|
164
148
|
expect(errorDiv.text()).toBe('datepicker has error');
|
|
165
149
|
});
|
|
166
|
-
|
|
167
|
-
it('emits null when date is invalid', async () => {
|
|
168
|
-
const wrapper = createWrapper({ label: 'test datepicker', modelValue: 'not a date' });
|
|
169
|
-
|
|
170
|
-
await wrapper.vm.$nextTick();
|
|
171
|
-
|
|
172
|
-
expect(wrapper.emitted()['update:modelValue'][0][0]).toBe(null);
|
|
173
|
-
});
|
|
174
150
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// import PBtn from '@squirrel/components/p-btn/p-btn.vue';
|
|
2
2
|
// import PDropdown from '@squirrel/components/p-dropdown/p-dropdown.vue';
|
|
3
|
-
import PInlineDatePicker from '@squirrel/components/p-inline-date-picker/p-inline-date-picker.vue';
|
|
4
3
|
import { fieldArgTypes } from '@root/stories/common/field';
|
|
4
|
+
import PInlineDatePicker from '@squirrel/components/p-inline-date-picker/p-inline-date-picker.vue';
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
7
|
title: 'Components/PInlineDatePicker',
|
|
@@ -22,8 +22,8 @@ export default {
|
|
|
22
22
|
docs: {
|
|
23
23
|
description: {
|
|
24
24
|
component: `Allows users to select a date by choosing a date from the calendar.
|
|
25
|
-
This component uses
|
|
26
|
-
So please take a look also there at their extensive [documentation](https://
|
|
25
|
+
This component uses \`VueDatePicker\` from [@vuepic/vue-datepicker](https://vue3datepicker.com) internally.
|
|
26
|
+
So please take a look also there at their extensive [documentation](https://vue3datepicker.com/).`,
|
|
27
27
|
},
|
|
28
28
|
},
|
|
29
29
|
},
|
|
@@ -5,123 +5,54 @@
|
|
|
5
5
|
{{ label }}
|
|
6
6
|
</label>
|
|
7
7
|
</slot>
|
|
8
|
-
<
|
|
9
|
-
ref="datepickerRef"
|
|
10
|
-
:class="{ 'pointer-events-none opacity-70': $attrs.disabled }"
|
|
11
|
-
:model-value="innerValue"
|
|
12
|
-
:select-attribute="selectAttribute"
|
|
13
|
-
:min-date="minDate || null"
|
|
14
|
-
:max-date="maxDate || null"
|
|
15
|
-
:masks="masks"
|
|
16
|
-
:style="styleDatepicker"
|
|
17
|
-
:timezone="timezone"
|
|
18
|
-
v-bind="listeners"
|
|
19
|
-
@dayclick="dayclick"
|
|
20
|
-
/>
|
|
8
|
+
<VueDatePicker v-model="model" v-bind="datePickerProps" />
|
|
21
9
|
<div v-show="errorMsg" :class="errorMsgClasses">{{ errorMsg }}</div>
|
|
22
10
|
</div>
|
|
23
11
|
</template>
|
|
24
12
|
|
|
25
13
|
<script setup lang="ts">
|
|
26
|
-
import dayjs from 'dayjs';
|
|
27
|
-
import { type AttributeConfig } from 'v-calendar/dist/types/src/utils/attribute.d';
|
|
28
|
-
import { DatePicker } from 'v-calendar';
|
|
29
|
-
import { type StyleValue, computed, ref, useAttrs, watch } from 'vue';
|
|
30
14
|
import { useInputClasses } from '@squirrel/composables/useInputClasses';
|
|
15
|
+
import VueDatePicker, { type VueDatePickerProps } from '@vuepic/vue-datepicker';
|
|
16
|
+
import { computed, type StyleValue, useAttrs } from 'vue';
|
|
31
17
|
|
|
32
18
|
defineOptions({
|
|
33
19
|
name: 'PInlineDatePicker',
|
|
34
20
|
inheritAttrs: false,
|
|
35
21
|
});
|
|
36
22
|
|
|
37
|
-
const selectAttribute: AttributeConfig = {
|
|
38
|
-
highlight: { class: 'bg-primary', contentClass: 'text-white' },
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const DEFAULT_MASKS = {
|
|
42
|
-
// The mask for the input
|
|
43
|
-
input: 'DD-MMM-YYYY',
|
|
44
|
-
// The mask for the model value
|
|
45
|
-
data: 'YYYY-MM-DD',
|
|
46
|
-
};
|
|
47
|
-
|
|
48
23
|
type Props = {
|
|
49
|
-
modelValue?: string | null;
|
|
50
24
|
label?: string;
|
|
51
25
|
errorMsg?: string;
|
|
52
26
|
required?: boolean;
|
|
53
|
-
|
|
54
|
-
maxDate?: Date | null;
|
|
55
|
-
timezone?: string;
|
|
56
|
-
};
|
|
27
|
+
} & VueDatePickerProps;
|
|
57
28
|
|
|
58
29
|
const props = withDefaults(defineProps<Props>(), {
|
|
59
|
-
modelValue: '',
|
|
60
30
|
label: '',
|
|
61
31
|
errorMsg: '',
|
|
62
32
|
required: false,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
33
|
+
inline: true,
|
|
34
|
+
autoApply: true,
|
|
35
|
+
enableTimePicker: false,
|
|
36
|
+
modelType: 'yyyy-MM-dd',
|
|
37
|
+
hideOffsetDates: true,
|
|
38
|
+
weekStart: 0,
|
|
66
39
|
});
|
|
67
40
|
|
|
68
|
-
const
|
|
69
|
-
'update:modelValue': [value: string | null];
|
|
70
|
-
}>();
|
|
41
|
+
const model = defineModel<Date | string | null>({ default: '' });
|
|
71
42
|
|
|
72
43
|
// Data
|
|
73
|
-
const { labelClasses, errorMsgClasses } = useInputClasses(props);
|
|
74
44
|
const attrs = useAttrs();
|
|
75
|
-
|
|
76
|
-
const innerValue = ref<Date | null>(null);
|
|
77
|
-
const datepickerRef = ref<InstanceType<typeof DatePicker> | null>(null);
|
|
45
|
+
const { labelClasses, errorMsgClasses } = useInputClasses(props);
|
|
78
46
|
|
|
79
47
|
// Computed
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
}
|
|
48
|
+
const datePickerProps = computed(() => {
|
|
49
|
+
const { modelValue: _, ...propsWithoutModelValue } = props;
|
|
50
|
+
const { class: classes, style, ...attrsWithoutClassAndStyle } = attrs;
|
|
83
51
|
|
|
84
|
-
|
|
85
|
-
return Object.keys(attrs).reduce((acc, curr) => {
|
|
86
|
-
if (curr.startsWith('on')) {
|
|
87
|
-
return { ...acc, [curr]: attrs[curr] };
|
|
88
|
-
} else {
|
|
89
|
-
return acc;
|
|
90
|
-
}
|
|
91
|
-
}, {});
|
|
52
|
+
return { ...propsWithoutModelValue, ...attrsWithoutClassAndStyle };
|
|
92
53
|
});
|
|
93
54
|
|
|
94
55
|
const style = computed(() => {
|
|
95
56
|
return attrs.style as StyleValue;
|
|
96
57
|
});
|
|
97
|
-
|
|
98
|
-
const styleDatepicker = computed(() => {
|
|
99
|
-
return props.errorMsg ? { border: '1px solid #f0453c' } : {};
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
// Methods
|
|
103
|
-
const dayclick = (e: { id: string }) => {
|
|
104
|
-
emit('update:modelValue', e.id);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
// Watch
|
|
108
|
-
watch(
|
|
109
|
-
() => props.modelValue,
|
|
110
|
-
async (nV) => {
|
|
111
|
-
const date = dayjs(nV, masks.value.data).toDate();
|
|
112
|
-
|
|
113
|
-
if (nV && date.toString() === 'Invalid Date') {
|
|
114
|
-
emit('update:modelValue', null);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
innerValue.value = nV ? dayjs(nV, masks.value.data).toDate() : null;
|
|
119
|
-
const datepicker = datepickerRef.value as { move: (val: unknown) => void };
|
|
120
|
-
|
|
121
|
-
if (datepicker && typeof datepicker.move === 'function' && innerValue.value) {
|
|
122
|
-
await datepicker.move(innerValue.value);
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
{ immediate: true }
|
|
126
|
-
);
|
|
127
58
|
</script>
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
|
|
27
27
|
<script lang="ts">
|
|
28
28
|
import inputClassesMixin from '@squirrel/utils/inputClassesMixin';
|
|
29
|
-
import { type PropType, type StyleValue
|
|
29
|
+
import { defineComponent, type PropType, type StyleValue } from 'vue';
|
|
30
30
|
|
|
31
31
|
const INPUT_TYPES = { TEXT: 'text', PASSWORD: 'password' };
|
|
32
32
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import PInputNumber from '@squirrel/components/p-input-number/p-input-number.vue';
|
|
2
1
|
import { fieldArgTypes } from '@root/stories/common/field';
|
|
2
|
+
import PInputNumber from '@squirrel/components/p-input-number/p-input-number.vue';
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
title: 'Components/PInputNumber',
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
<script lang="ts">
|
|
22
22
|
import PInfoIcon from '@squirrel/components/p-info-icon/p-info-icon.vue';
|
|
23
23
|
import inputClassesMixin from '@squirrel/utils/inputClassesMixin';
|
|
24
|
-
import { type CurrencyDisplay, type CurrencyInputOptions, useCurrencyInput } from 'vue-currency-input';
|
|
25
|
-
import { type PropType, type StyleValue, computed, defineComponent, watch } from 'vue';
|
|
26
|
-
import { kebabCase } from 'lodash-es';
|
|
27
24
|
import { toNumberOrNull } from '@squirrel/utils/number';
|
|
25
|
+
import { kebabCase } from 'lodash-es';
|
|
26
|
+
import { computed, defineComponent, type PropType, type StyleValue, watch } from 'vue';
|
|
27
|
+
import { type CurrencyDisplay, type CurrencyInputOptions, useCurrencyInput } from 'vue-currency-input';
|
|
28
28
|
|
|
29
29
|
const ALL_OPTIONS = [
|
|
30
30
|
'locale',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import PInputPercent from '@squirrel/components/p-input-percent/p-input-percent.vue';
|
|
2
1
|
import { fieldArgTypes } from '@root/stories/common/field';
|
|
2
|
+
import PInputPercent from '@squirrel/components/p-input-percent/p-input-percent.vue';
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
title: 'Components/PInputPercent',
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
<script setup lang="ts">
|
|
12
12
|
import PInputNumber from '@squirrel/components/p-input-number/p-input-number.vue';
|
|
13
13
|
import { type InputSize } from '@squirrel/utils/inputClassesShared';
|
|
14
|
-
import { type PropType, computed } from 'vue';
|
|
15
14
|
import { isNumber } from 'lodash-es';
|
|
15
|
+
import { computed, type PropType } from 'vue';
|
|
16
16
|
|
|
17
17
|
const prefixClasses: Record<InputSize, string> = {
|
|
18
18
|
sm: 'text-sm h-8 left-2',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import PInputSearch from '@squirrel/components/p-input-search/p-input-search.vue';
|
|
2
1
|
import { fieldArgTypes } from '@root/stories/common/field';
|
|
2
|
+
import PInputSearch from '@squirrel/components/p-input-search/p-input-search.vue';
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
title: 'Components/PInputSearch',
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
<script lang="ts">
|
|
36
36
|
import PInput from '@squirrel/components/p-input/p-input.vue';
|
|
37
37
|
import { INPUT_SIZES, type InputSize } from '@squirrel/utils/inputClassesShared';
|
|
38
|
-
import { type PropType
|
|
38
|
+
import { defineComponent, type PropType } from 'vue';
|
|
39
39
|
|
|
40
40
|
type PInputInstance = InstanceType<typeof PInput>;
|
|
41
41
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import PLink from '@squirrel/components/p-link/p-link.vue';
|
|
2
|
-
import { createWrapperFor } from '@tests/vitest.helpers';
|
|
3
2
|
import { isExternalLink } from '@squirrel/utils/link';
|
|
4
3
|
import { sanitizeUrl } from '@squirrel/utils/sanitization';
|
|
4
|
+
import { createWrapperFor } from '@tests/vitest.helpers';
|
|
5
5
|
|
|
6
6
|
vi.mock('@squirrel/utils/sanitization');
|
|
7
7
|
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
</template>
|
|
9
9
|
|
|
10
10
|
<script setup lang="ts">
|
|
11
|
-
import { RouterLink, type RouterLinkProps } from 'vue-router';
|
|
12
11
|
import { isExternalLink } from '@squirrel/utils/link';
|
|
13
12
|
import { sanitizeUrl } from '@squirrel/utils/sanitization';
|
|
13
|
+
import { RouterLink, type RouterLinkProps } from 'vue-router';
|
|
14
14
|
|
|
15
15
|
defineOptions({
|
|
16
16
|
name: 'PLink',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import PLoading from '@squirrel/components/p-loading/p-loading.vue';
|
|
2
|
+
import { usePLoading } from '@squirrel/components/p-loading/usePLoading';
|
|
2
3
|
import PSkeletonLoader from '@squirrel/components/p-skeleton-loader/p-skeleton-loader.vue';
|
|
3
4
|
import { createWrapperFor, waitNT } from '@tests/vitest.helpers';
|
|
4
5
|
import { defineComponent, ref } from 'vue';
|
|
5
|
-
import { usePLoading } from '@squirrel/components/p-loading/usePLoading';
|
|
6
6
|
|
|
7
7
|
const createAppWrapper = () =>
|
|
8
8
|
createWrapperFor({
|
|
@@ -131,7 +131,7 @@ describe('PLoading.vue', () => {
|
|
|
131
131
|
expect(appWrapper.find('[aria-busy]').exists()).toBe(false);
|
|
132
132
|
});
|
|
133
133
|
|
|
134
|
-
it(`
|
|
134
|
+
it(`waits for the queue to clear in order to hide the loading indicator`, async () => {
|
|
135
135
|
const wrapper = createWrapper({ delay: 200 });
|
|
136
136
|
|
|
137
137
|
await wrapper.find('.request-1-sec').trigger('click');
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import ComputationStatus1 from '@/playground/components/ComputationStatus1.vue';
|
|
2
1
|
import PBtn from '@squirrel/components/p-btn/p-btn.vue';
|
|
3
2
|
import PLoading from '@squirrel/components/p-loading/p-loading.vue';
|
|
4
|
-
import { defineComponent, ref } from 'vue';
|
|
5
3
|
import { usePLoading } from '@squirrel/components/p-loading/usePLoading';
|
|
4
|
+
import { defineComponent, ref } from 'vue';
|
|
5
|
+
import ComputationStatus1 from '@/playground/components/ComputationStatus1.vue';
|
|
6
6
|
|
|
7
7
|
const TestComponent = defineComponent({
|
|
8
8
|
name: 'TestComponent',
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
</template>
|
|
29
29
|
|
|
30
30
|
<script setup lang="ts">
|
|
31
|
+
import { usePLoading } from '@squirrel/components/p-loading/usePLoading';
|
|
31
32
|
import { isComponent } from '@squirrel/utils/component';
|
|
32
33
|
import { onBeforeUnmount, ref, toValue, watch } from 'vue';
|
|
33
|
-
import { usePLoading } from '@squirrel/components/p-loading/usePLoading';
|
|
34
34
|
|
|
35
35
|
const textDivClass = `overflow-hidden whitespace-nowrap px-4 pt-1 h-8 text-center text-sm font-semibold text-p-purple-60`;
|
|
36
36
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import PModal from '@squirrel/components/p-modal/p-modal.vue';
|
|
2
|
-
import { mount } from '@vue/test-utils';
|
|
3
2
|
import { waitRAF } from '@tests/vitest.helpers';
|
|
3
|
+
import { mount } from '@vue/test-utils';
|
|
4
4
|
|
|
5
5
|
const createWrapperContainer = (componentArgs) => {
|
|
6
6
|
const args = componentArgs || {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import PModal from '@squirrel/components/p-modal/p-modal.vue';
|
|
2
|
-
import { mount } from '@vue/test-utils';
|
|
3
2
|
import { sleep, waitNT } from '@tests/vitest.helpers';
|
|
3
|
+
import { mount } from '@vue/test-utils';
|
|
4
4
|
|
|
5
5
|
const originalOffsetHeight = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'offsetHeight');
|
|
6
6
|
const originalOffsetWidth = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'offsetWidth');
|
|
@@ -73,18 +73,18 @@
|
|
|
73
73
|
<script setup lang="ts">
|
|
74
74
|
import PAlert from '@squirrel/components/p-alert/p-alert.vue';
|
|
75
75
|
import PCloseBtn from '@squirrel/components/p-close-btn/p-close-btn.vue';
|
|
76
|
+
import { usePModal } from '@squirrel/components/p-modal/usePModal';
|
|
76
77
|
import {
|
|
77
|
-
type PropType,
|
|
78
|
-
type StyleValue,
|
|
79
78
|
getCurrentInstance,
|
|
80
79
|
nextTick,
|
|
81
80
|
onBeforeMount,
|
|
82
81
|
onBeforeUnmount,
|
|
83
82
|
onMounted,
|
|
83
|
+
type PropType,
|
|
84
84
|
ref,
|
|
85
|
+
type StyleValue,
|
|
85
86
|
watch,
|
|
86
87
|
} from 'vue';
|
|
87
|
-
import { usePModal } from '@squirrel/components/p-modal/usePModal';
|
|
88
88
|
|
|
89
89
|
const FOCUSABLE_ELEMENTS =
|
|
90
90
|
'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
|
|
33
33
|
<script setup lang="ts">
|
|
34
34
|
import PSkeletonLoader from '@squirrel/components/p-skeleton-loader/p-skeleton-loader.vue';
|
|
35
|
-
import { type PropType, computed } from 'vue';
|
|
36
35
|
import { createPagingRange } from '@squirrel/utils/pagination';
|
|
36
|
+
import { computed, type PropType } from 'vue';
|
|
37
37
|
|
|
38
38
|
defineOptions({ name: 'PPagination' });
|
|
39
39
|
|
|
@@ -21,7 +21,7 @@ describe('PProgressBar.vue', () => {
|
|
|
21
21
|
expect(div.classes()).toEqual(['flex', 'justify-start', 'overflow-hidden', 'rounded', 'bg-p-blue-20']);
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
it('attrs fall through
|
|
24
|
+
it('attrs fall through', async () => {
|
|
25
25
|
const ParentComponent = {
|
|
26
26
|
template: `
|
|
27
27
|
<PProgressBar :total="2" :items="items" class="test-class" data-testattr="test attribute" />
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import PSelect from '@squirrel/components/p-select/p-select.vue';
|
|
2
|
-
import { cloneDeep } from 'lodash-es';
|
|
3
2
|
import { createWrapperFor, sleep, waitNT } from '@tests/vitest.helpers';
|
|
3
|
+
import { cloneDeep } from 'lodash-es';
|
|
4
4
|
|
|
5
5
|
const baseClasses = () => [
|
|
6
6
|
'text-night',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import PSelect from '@squirrel/components/p-select/p-select.vue';
|
|
2
1
|
import { fieldArgTypes } from '@root/stories/common/field';
|
|
2
|
+
import PSelect from '@squirrel/components/p-select/p-select.vue';
|
|
3
3
|
|
|
4
4
|
const selectItems = Object.freeze([
|
|
5
5
|
{ value: 1, text: 'Aleksandr Chappel' },
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
</template>
|
|
16
16
|
|
|
17
17
|
<script setup lang="ts">
|
|
18
|
+
import { useInputClasses } from '@squirrel/composables/useInputClasses';
|
|
18
19
|
import { INPUT_SIZES, type InputSize } from '@squirrel/utils/inputClassesShared';
|
|
19
20
|
import { type PropType, type StyleValue } from 'vue';
|
|
20
21
|
import { computed, useAttrs } from 'vue';
|
|
21
|
-
import { useInputClasses } from '@squirrel/composables/useInputClasses';
|
|
22
22
|
|
|
23
23
|
defineOptions({
|
|
24
24
|
name: 'PSelect',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import PSelectBtn from '@squirrel/components/p-select-btn/p-select-btn.vue';
|
|
2
|
-
import { cloneDeep } from 'lodash-es';
|
|
3
2
|
import { createWrapperFor } from '@tests/vitest.helpers';
|
|
3
|
+
import { cloneDeep } from 'lodash-es';
|
|
4
4
|
|
|
5
5
|
const items = [
|
|
6
6
|
{ textCustom: 'Option 1', valueCustom: 1 },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { fieldArgTypes } from '@root/stories/common/field';
|
|
1
2
|
import PSelectBtn from '@squirrel/components/p-select-btn/p-select-btn.vue';
|
|
2
3
|
import { expect, userEvent, within } from '@storybook/test';
|
|
3
|
-
import { fieldArgTypes } from '@root/stories/common/field';
|
|
4
4
|
|
|
5
5
|
const selectItems = Object.freeze([
|
|
6
6
|
{ value: 1, text: 'Aleksandr Chappel', tooltip: 'lorem ipsum text 1' },
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
</template>
|
|
28
28
|
|
|
29
29
|
<script setup lang="ts">
|
|
30
|
-
import PBtn from '@squirrel/components/p-btn/p-btn.vue';
|
|
31
30
|
import { type Size } from '@squirrel/components/p-btn/p-btn.types';
|
|
31
|
+
import PBtn from '@squirrel/components/p-btn/p-btn.vue';
|
|
32
32
|
|
|
33
33
|
type BtnGroupItem = Record<string, string | number | boolean>;
|
|
34
34
|
type Key = string | number;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import PSelectList from '@squirrel/components/p-select-list/p-select-list.vue';
|
|
2
1
|
import filterListItems from '@squirrel/components/p-dropdown-select/p-dropdown-select.mock.json';
|
|
3
|
-
import
|
|
2
|
+
import PSelectList from '@squirrel/components/p-select-list/p-select-list.vue';
|
|
3
|
+
import { useVirtualizer } from '@tanstack/vue-virtual';
|
|
4
4
|
import { createWrapperFor, sleep } from '@tests/vitest.helpers';
|
|
5
|
+
import { cloneDeep } from 'lodash-es';
|
|
5
6
|
import { ref } from 'vue';
|
|
6
|
-
import { useVirtualizer } from '@tanstack/vue-virtual';
|
|
7
7
|
|
|
8
8
|
vi.mock('@tanstack/vue-virtual', () => ({
|
|
9
9
|
useVirtualizer: vi.fn(),
|
|
@@ -355,7 +355,7 @@ describe('PSelectList.vue', () => {
|
|
|
355
355
|
cleanup(wrapper);
|
|
356
356
|
});
|
|
357
357
|
|
|
358
|
-
it.each([true, false])('renders correctly when "multiple" is set to %s
|
|
358
|
+
it.each([true, false])('renders correctly when "multiple" is set to %s', async (val) => {
|
|
359
359
|
const items = cloneDeep(filterListItems).slice(0, 20);
|
|
360
360
|
const wrapper = createWrapper({ items }, { multiple: val });
|
|
361
361
|
|
|
@@ -123,14 +123,14 @@ import {
|
|
|
123
123
|
type AnyObject,
|
|
124
124
|
type AnyValue,
|
|
125
125
|
type ModelValue,
|
|
126
|
-
SIZES,
|
|
127
126
|
type Size,
|
|
127
|
+
SIZES,
|
|
128
128
|
} from '@squirrel/components/p-select-list/p-select-list.types';
|
|
129
|
-
import { type ComponentPublicInstance, type PropType, type StyleValue, computed, onMounted, ref, useAttrs } from 'vue';
|
|
130
|
-
import { splitStringForHighlight } from '@squirrel/utils/text';
|
|
131
|
-
import { toString } from '@squirrel/utils/string';
|
|
132
|
-
import { useInputClasses } from '@squirrel/composables/useInputClasses';
|
|
133
129
|
import { useSelectList } from '@squirrel/components/p-select-list/useSelectList';
|
|
130
|
+
import { useInputClasses } from '@squirrel/composables/useInputClasses';
|
|
131
|
+
import { toString } from '@squirrel/utils/string';
|
|
132
|
+
import { splitStringForHighlight } from '@squirrel/utils/text';
|
|
133
|
+
import { type ComponentPublicInstance, computed, onMounted, type PropType, ref, type StyleValue, useAttrs } from 'vue';
|
|
134
134
|
|
|
135
135
|
defineOptions({
|
|
136
136
|
name: 'PSelectList',
|