@eturnity/eturnity_reusable_components 9.34.1 → 9.34.2-panel-placement.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/package.json +1 -1
- package/src/assets/svgIcons/broom.svg +6 -0
- package/src/assets/svgIcons/outline_tool.svg +10 -10
- package/src/assets/tests/__mocks__/fileMock.js +1 -0
- package/src/components/buttons/buttonIcon/buttonIcon.spec.js +40 -0
- package/src/components/buttons/buttonIcon/index.vue +18 -0
- package/src/components/infoText/index.vue +2 -13
- package/src/components/infoText/infoText.spec.js +0 -6
- package/src/components/inputs/inputNumber/index.vue +10 -0
- package/src/components/inputs/switchField/index.vue +23 -14
- package/src/components/inputs/switchField/switchField.spec.js +3 -3
- package/src/components/inputs/toggle/index.vue +22 -1
- package/src/components/inputs/toggle/toggle.spec.js +9 -9
- package/src/components/spinner/index.vue +2 -1
package/package.json
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Uploaded to svgrepo.com" width="800px" height="800px" viewBox="0 0 32 32" xml:space="preserve">
|
|
2
|
+
<style type="text/css">
|
|
3
|
+
.linesandangles_een{fill:#000000;}
|
|
4
|
+
</style>
|
|
5
|
+
<path class="linesandangles_een" d="M26.281,30l-2-8H25v-5h-8V2h-2v15H7v5h0.719l-2,8H26.281z M23.719,28H21v-4h-2v4h-2v-4h-2v4h-2 v-4h-2v4H8.281l1.5-6h12.438L23.719,28z M9,19h14v1H9V19z"/>
|
|
6
|
+
</svg>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<svg width="15" height="16" viewBox="0 0 15 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
<path d="M8.5 3.07846L6.00098 0.935599L6.00098 5.22131L8.5 3.07846Z" fill="white"/>
|
|
5
|
-
<
|
|
6
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M2 4.06409C2.55228 4.06409 3 3.61637 3 3.06409C3 2.5118 2.55228 2.06409 2 2.06409C1.44772 2.06409 1 2.5118 1 3.06409C1 3.61637 1.44772 4.06409 2 4.06409ZM2 5.06409C3.10457 5.06409 4 4.16866 4 3.06409C4 1.95952 3.10457 1.06409 2 1.06409C0.895431 1.06409 0 1.95952 0 3.06409C0 4.16866 0.895431 5.06409 2 5.06409Z" fill="white"/>
|
|
7
|
-
<
|
|
8
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.002 4.06421C12.5542 4.06421 13.002 3.61649 13.002 3.06421C13.002 2.51192 12.5542 2.06421 12.002 2.06421C11.4497 2.06421 11.002 2.51192 11.002 3.06421C11.002 3.61649 11.4497 4.06421 12.002 4.06421ZM12.002 5.06421C13.1065 5.06421 14.002 4.16878 14.002 3.06421C14.002 1.95964 13.1065 1.06421 12.002 1.06421C10.8974 1.06421 10.002 1.95964 10.002 3.06421C10.002 4.16878 10.8974 5.06421 12.002 5.06421Z" fill="white"/>
|
|
9
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.002 14.0643C12.5542 14.0643 13.002 13.6166 13.002 13.0643C13.002 12.512 12.5542 12.0643 12.002 12.0643C11.4497 12.0643 11.002 12.512 11.002 13.0643C11.002 13.6166 11.4497 14.0643 12.002 14.0643ZM12.002 15.0643C13.1065 15.0643 14.002 14.1688 14.002 13.0643C14.002 11.9597 13.1065 11.0643 12.002 11.0643C10.8974 11.0643 10.002 11.9597 10.002 13.0643C10.002 14.1688 10.8974 15.0643 12.002 15.0643Z" fill="white"/>
|
|
10
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M2 14.0644C2.55228 14.0644 3 13.6167 3 13.0644C3 12.5121 2.55228 12.0644 2 12.0644C1.44772 12.0644 1 12.5121 1 13.0644C1 13.6167 1.44772 14.0644 2 14.0644ZM2 15.0644C3.10457 15.0644 4 14.169 4 13.0644C4 11.9598 3.10457 11.0644 2 11.0644C0.895431 11.0644 0 11.9598 0 13.0644C0 14.169 0.895431 15.0644 2 15.0644Z" fill="white"/>
|
|
11
|
-
</svg>
|
|
2
|
+
<path transform="rotate(90 2.80078 4.06415)" fill="white" d="M2.8008 4.0642h8v1.6H2.8008Z" />
|
|
3
|
+
<path transform="rotate(-180 7.00195 3.8642)" fill="white" d="M7.002 3.8642h4v1.6H7.002Z" />
|
|
4
|
+
<path d="M8.5 3.07846L6.00098 0.935599L6.00098 5.22131L8.5 3.07846Z" fill="white" />
|
|
5
|
+
<path transform="rotate(-180 11.002 13.8643)" fill="white" d="M11.002 13.8643h8v1.6H11.002Z" />
|
|
6
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M2 4.06409C2.55228 4.06409 3 3.61637 3 3.06409C3 2.5118 2.55228 2.06409 2 2.06409C1.44772 2.06409 1 2.5118 1 3.06409C1 3.61637 1.44772 4.06409 2 4.06409ZM2 5.06409C3.10457 5.06409 4 4.16866 4 3.06409C4 1.95952 3.10457 1.06409 2 1.06409C0.895431 1.06409 0 1.95952 0 3.06409C0 4.16866 0.895431 5.06409 2 5.06409Z" fill="white" />
|
|
7
|
+
<path transform="rotate(90 12.7988 4.06433)" fill="white" d="M12.7988 4.0643h8v1.6H12.7988Z" />
|
|
8
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.002 4.06421C12.5542 4.06421 13.002 3.61649 13.002 3.06421C13.002 2.51192 12.5542 2.06421 12.002 2.06421C11.4497 2.06421 11.002 2.51192 11.002 3.06421C11.002 3.61649 11.4497 4.06421 12.002 4.06421ZM12.002 5.06421C13.1065 5.06421 14.002 4.16878 14.002 3.06421C14.002 1.95964 13.1065 1.06421 12.002 1.06421C10.8974 1.06421 10.002 1.95964 10.002 3.06421C10.002 4.16878 10.8974 5.06421 12.002 5.06421Z" fill="white" />
|
|
9
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.002 14.0643C12.5542 14.0643 13.002 13.6166 13.002 13.0643C13.002 12.512 12.5542 12.0643 12.002 12.0643C11.4497 12.0643 11.002 12.512 11.002 13.0643C11.002 13.6166 11.4497 14.0643 12.002 14.0643ZM12.002 15.0643C13.1065 15.0643 14.002 14.1688 14.002 13.0643C14.002 11.9597 13.1065 11.0643 12.002 11.0643C10.8974 11.0643 10.002 11.9597 10.002 13.0643C10.002 14.1688 10.8974 15.0643 12.002 15.0643Z" fill="white" />
|
|
10
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M2 14.0644C2.55228 14.0644 3 13.6167 3 13.0644C3 12.5121 2.55228 12.0644 2 12.0644C1.44772 12.0644 1 12.5121 1 13.0644C1 13.6167 1.44772 14.0644 2 14.0644ZM2 15.0644C3.10457 15.0644 4 14.169 4 13.0644C4 11.9598 3.10457 11.0644 2 11.0644C0.895431 11.0644 0 11.9598 0 13.0644C0 14.169 0.895431 15.0644 2 15.0644Z" fill="white" />
|
|
11
|
+
</svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = 'test-file-stub'
|
|
@@ -157,6 +157,46 @@ describe('ButtonIcon.vue', () => {
|
|
|
157
157
|
}
|
|
158
158
|
})
|
|
159
159
|
|
|
160
|
+
it('replaces the icon with a spinner while loading', async () => {
|
|
161
|
+
expect(wrapper.find('[data-test-id="spinner_container"]').exists()).toBe(
|
|
162
|
+
false
|
|
163
|
+
)
|
|
164
|
+
expect(wrapper.findComponent({ name: 'Icon' }).exists()).toBe(true)
|
|
165
|
+
|
|
166
|
+
await wrapper.setProps({ isLoading: true })
|
|
167
|
+
expect(wrapper.find('[data-test-id="spinner_container"]').exists()).toBe(
|
|
168
|
+
true
|
|
169
|
+
)
|
|
170
|
+
expect(wrapper.findComponent({ name: 'Icon' }).exists()).toBe(false)
|
|
171
|
+
|
|
172
|
+
await wrapper.setProps({ isLoading: false })
|
|
173
|
+
expect(wrapper.find('[data-test-id="spinner_container"]').exists()).toBe(
|
|
174
|
+
false
|
|
175
|
+
)
|
|
176
|
+
expect(wrapper.findComponent({ name: 'Icon' }).props('name')).toBe(
|
|
177
|
+
'settings'
|
|
178
|
+
)
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
it('keeps rendering the text while loading', async () => {
|
|
182
|
+
await wrapper.setProps({ isLoading: true })
|
|
183
|
+
expect(wrapper.find('[data-test-id="button-icon-text"]').text()).toBe(
|
|
184
|
+
'Click Me'
|
|
185
|
+
)
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
it('renders a white spinner on types with white button text', async () => {
|
|
189
|
+
await wrapper.setProps({ isLoading: true, type: 'primary' })
|
|
190
|
+
expect(wrapper.findComponent({ name: 'NewSpinner' }).props('isWhite')).toBe(
|
|
191
|
+
true
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
await wrapper.setProps({ type: 'secondary' })
|
|
195
|
+
expect(wrapper.findComponent({ name: 'NewSpinner' }).props('isWhite')).toBe(
|
|
196
|
+
false
|
|
197
|
+
)
|
|
198
|
+
})
|
|
199
|
+
|
|
160
200
|
it('renders caret based on showCaret prop', async () => {
|
|
161
201
|
await wrapper.setProps({ showCaret: true })
|
|
162
202
|
let caret = wrapper.find('[data-test-id="button-icon-caret"]')
|
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
:type="type"
|
|
29
29
|
:variant="variant"
|
|
30
30
|
>
|
|
31
|
+
<RCSpinner v-if="isLoading" :is-white="isSpinnerWhite" size="tiny" />
|
|
31
32
|
<Icon
|
|
33
|
+
v-else
|
|
32
34
|
:color="getIconColor"
|
|
33
35
|
:disable-hover="disableIconHover"
|
|
34
36
|
:fill-type="fillType"
|
|
@@ -83,9 +85,11 @@
|
|
|
83
85
|
// iconName="external_icon"
|
|
84
86
|
// fontColor="white"
|
|
85
87
|
// fontSize="12px"
|
|
88
|
+
// :isLoading="false" // swaps the icon for a spinner
|
|
86
89
|
// />
|
|
87
90
|
|
|
88
91
|
import Icon from '../../icon'
|
|
92
|
+
import RCSpinner from '../../spinner'
|
|
89
93
|
import styled from 'vue3-styled-components'
|
|
90
94
|
import theme from '../../../assets/theme'
|
|
91
95
|
|
|
@@ -419,6 +423,7 @@
|
|
|
419
423
|
ButtonWrapper,
|
|
420
424
|
IconContainer,
|
|
421
425
|
Icon,
|
|
426
|
+
RCSpinner,
|
|
422
427
|
NumberContainer,
|
|
423
428
|
NumberText,
|
|
424
429
|
CountBadge,
|
|
@@ -541,11 +546,24 @@
|
|
|
541
546
|
default: false,
|
|
542
547
|
type: Boolean,
|
|
543
548
|
},
|
|
549
|
+
isLoading: {
|
|
550
|
+
required: false,
|
|
551
|
+
default: false,
|
|
552
|
+
type: Boolean,
|
|
553
|
+
},
|
|
544
554
|
},
|
|
545
555
|
computed: {
|
|
546
556
|
theme() {
|
|
547
557
|
return theme
|
|
548
558
|
},
|
|
559
|
+
// The spinner only offers white/purple, so pick whichever contrasts with
|
|
560
|
+
// the button background the same way the label already does.
|
|
561
|
+
isSpinnerWhite() {
|
|
562
|
+
return (
|
|
563
|
+
this.theme.mainButton[this.appTheme][this.type][this.variant].default
|
|
564
|
+
.textColor === this.theme.colors.white
|
|
565
|
+
)
|
|
566
|
+
},
|
|
549
567
|
getIconColor() {
|
|
550
568
|
if (this.iconColor) return this.iconColor
|
|
551
569
|
if (this.isDisabled) {
|
|
@@ -244,14 +244,10 @@
|
|
|
244
244
|
default: '400px',
|
|
245
245
|
type: String,
|
|
246
246
|
},
|
|
247
|
-
// Floor for the measured popup width; lower it (e.g. '0') for short
|
|
248
|
-
// tooltip-style content.
|
|
249
247
|
minWidth: {
|
|
250
248
|
default: '230px',
|
|
251
249
|
type: String,
|
|
252
250
|
},
|
|
253
|
-
// Padding of the popup box; tighten (e.g. '6px 10px') for
|
|
254
|
-
// tooltip-style content.
|
|
255
251
|
contentPadding: {
|
|
256
252
|
default: '',
|
|
257
253
|
type: String,
|
|
@@ -579,15 +575,11 @@
|
|
|
579
575
|
clone.style.whiteSpace = 'nowrap' // Prevent text wrapping during measurement
|
|
580
576
|
document.body.appendChild(clone)
|
|
581
577
|
|
|
582
|
-
// Get fresh content width from clone
|
|
583
|
-
// integer, which can under-measure by <1px and wrap an exact-fit
|
|
584
|
-
// line — use the subpixel rect width, ceiled.
|
|
578
|
+
// Get fresh content width from clone
|
|
585
579
|
const contentWidth = Math.ceil(clone.getBoundingClientRect().width)
|
|
586
580
|
document.body.removeChild(clone)
|
|
587
581
|
|
|
588
|
-
// Calculate new width
|
|
589
|
-
// TextOverlay wraps it with 10px horizontal padding each side under
|
|
590
|
-
// border-box sizing — compensate or exact-fit content wraps.
|
|
582
|
+
// Calculate new width
|
|
591
583
|
const TEXT_OVERLAY_HORIZONTAL_PADDING_PX = 20
|
|
592
584
|
const calculatedWidth = Math.min(
|
|
593
585
|
Math.max(
|
|
@@ -665,9 +657,6 @@
|
|
|
665
657
|
}
|
|
666
658
|
})
|
|
667
659
|
|
|
668
|
-
// The text can change while the popup is open (e.g. a save button's
|
|
669
|
-
// tooltip flipping to "saving in progress" mid-hover) — re-measure so
|
|
670
|
-
// the box fits the new content instead of wrapping in the old width.
|
|
671
660
|
watch(
|
|
672
661
|
() => props.text,
|
|
673
662
|
async () => {
|
|
@@ -83,9 +83,7 @@ describe('InfoText Component', () => {
|
|
|
83
83
|
const showPopup = async (w) => {
|
|
84
84
|
w.vm.isMobile = false
|
|
85
85
|
await w.vm.$nextTick()
|
|
86
|
-
// the hover listener sits on the component root
|
|
87
86
|
await w.trigger("mouseenter")
|
|
88
|
-
// updatePosition awaits two ticks before measuring
|
|
89
87
|
await new Promise((resolve) => setTimeout(resolve))
|
|
90
88
|
await w.vm.$nextTick()
|
|
91
89
|
}
|
|
@@ -96,7 +94,6 @@ describe('InfoText Component', () => {
|
|
|
96
94
|
global: { stubs: { teleport: true } },
|
|
97
95
|
})
|
|
98
96
|
await showPopup(roomy)
|
|
99
|
-
// jsdom measures content at 0px, so the floor is what remains
|
|
100
97
|
expect(roomy.vm.infoBoxWidth).toBe(230)
|
|
101
98
|
})
|
|
102
99
|
|
|
@@ -117,7 +114,6 @@ describe('InfoText Component', () => {
|
|
|
117
114
|
global: { stubs: { teleport: true } },
|
|
118
115
|
})
|
|
119
116
|
await showPopup(small)
|
|
120
|
-
// jsdom content measures 0px; only the padding compensation remains
|
|
121
117
|
expect(small.vm.infoBoxWidth).toBe(20)
|
|
122
118
|
})
|
|
123
119
|
})
|
|
@@ -126,8 +122,6 @@ describe('InfoText Component', () => {
|
|
|
126
122
|
let rectSpy
|
|
127
123
|
|
|
128
124
|
beforeEach(() => {
|
|
129
|
-
// jsdom measures everything at 0; size rects from text length so the
|
|
130
|
-
// popup width tracks the measured clone's content.
|
|
131
125
|
rectSpy = jest
|
|
132
126
|
.spyOn(Element.prototype, 'getBoundingClientRect')
|
|
133
127
|
.mockImplementation(function () {
|
|
@@ -484,6 +484,7 @@
|
|
|
484
484
|
display: flex;
|
|
485
485
|
gap: 10px;
|
|
486
486
|
align-items: center;
|
|
487
|
+
padding: ${(props) => (props.isInteractive ? '0 4px' : '0')};
|
|
487
488
|
cursor: ${(props) => (props.isInteractive ? 'ew-resize' : 'auto')};
|
|
488
489
|
border: ${(props) =>
|
|
489
490
|
props.alignItems == 'vertical'
|
|
@@ -729,6 +730,11 @@
|
|
|
729
730
|
required: false,
|
|
730
731
|
default: true,
|
|
731
732
|
},
|
|
733
|
+
undefinedState: {
|
|
734
|
+
type: Boolean,
|
|
735
|
+
required: false,
|
|
736
|
+
default: false,
|
|
737
|
+
},
|
|
732
738
|
allowNegative: {
|
|
733
739
|
type: Boolean,
|
|
734
740
|
required: false,
|
|
@@ -844,6 +850,7 @@
|
|
|
844
850
|
},
|
|
845
851
|
computed: {
|
|
846
852
|
displayedPlaceholder() {
|
|
853
|
+
if (this.undefinedState) return '-'
|
|
847
854
|
if (this.placeholder) return this.placeholder
|
|
848
855
|
if (this.defaultNumber)
|
|
849
856
|
return `${this.defaultNumber}${this.hasSpaceBetweenUnit ? ' ' : ''}${
|
|
@@ -1121,6 +1128,9 @@
|
|
|
1121
1128
|
}
|
|
1122
1129
|
},
|
|
1123
1130
|
formatWithCurrency(value) {
|
|
1131
|
+
if (this.undefinedState && !this.isFocused) {
|
|
1132
|
+
return '-'
|
|
1133
|
+
}
|
|
1124
1134
|
let adjustedMinValue =
|
|
1125
1135
|
value || value === 0
|
|
1126
1136
|
? value
|
|
@@ -31,15 +31,16 @@
|
|
|
31
31
|
:border-color="borderColor"
|
|
32
32
|
:color-mode="colorMode"
|
|
33
33
|
:data-id="item.hasOwnProperty('dataId') ? item.dataId : ''"
|
|
34
|
+
:disabled="!!item.disabled"
|
|
34
35
|
:height="height"
|
|
35
36
|
:inactive-border-color="inactiveBorderColor"
|
|
36
37
|
:inactive-color="inactiveColor"
|
|
37
|
-
:is-active="value == item.value"
|
|
38
|
+
:is-active="!undefinedState && value == item.value"
|
|
38
39
|
:primary-color="primaryColor"
|
|
39
40
|
:secondary-color="secondaryColor"
|
|
40
41
|
:size="size"
|
|
41
42
|
:width="item.width || 'auto'"
|
|
42
|
-
@click="selectItem(item
|
|
43
|
+
@click="selectItem(item)"
|
|
43
44
|
>
|
|
44
45
|
<OptionIconContainer v-if="item.icon">
|
|
45
46
|
<RCIcon
|
|
@@ -145,6 +146,7 @@
|
|
|
145
146
|
height: String,
|
|
146
147
|
borderColor: String,
|
|
147
148
|
inactiveBorderColor: String,
|
|
149
|
+
disabled: Boolean,
|
|
148
150
|
}
|
|
149
151
|
const SwitchOption = styled('div', optionAttrs)`
|
|
150
152
|
color: ${(props) =>
|
|
@@ -167,17 +169,19 @@
|
|
|
167
169
|
props.height
|
|
168
170
|
? props.height
|
|
169
171
|
: props.size === 'medium'
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
? '24px'
|
|
173
|
+
: props.size === 'small'
|
|
174
|
+
? '16px'
|
|
175
|
+
: '24px'};
|
|
174
176
|
padding: 0 10px;
|
|
175
177
|
margin-right: -1px;
|
|
176
178
|
transition: all 0.1s ease-in-out;
|
|
177
179
|
overflow: hidden;
|
|
178
180
|
gap: 5px;
|
|
181
|
+
opacity: ${(props) => (props.disabled ? 0.4 : 1)};
|
|
182
|
+
pointer-events: ${(props) => (props.disabled ? 'none' : 'auto')};
|
|
179
183
|
& :hover {
|
|
180
|
-
cursor: pointer;
|
|
184
|
+
cursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};
|
|
181
185
|
}
|
|
182
186
|
&:first-child {
|
|
183
187
|
border-radius: 4px 0 0 4px;
|
|
@@ -264,6 +268,11 @@
|
|
|
264
268
|
default: false,
|
|
265
269
|
type: Boolean,
|
|
266
270
|
},
|
|
271
|
+
undefinedState: {
|
|
272
|
+
required: false,
|
|
273
|
+
default: false,
|
|
274
|
+
type: Boolean,
|
|
275
|
+
},
|
|
267
276
|
},
|
|
268
277
|
data() {
|
|
269
278
|
return {
|
|
@@ -282,19 +291,19 @@
|
|
|
282
291
|
this.borderColor = this.secondaryColor
|
|
283
292
|
this.inactiveBorderColor = theme.semanticColors.teal[600]
|
|
284
293
|
} else {
|
|
285
|
-
this.primaryColor = theme.semanticColors.teal[
|
|
286
|
-
this.secondaryColor = theme.semanticColors.
|
|
287
|
-
this.inactiveColor = theme.semanticColors.
|
|
294
|
+
this.primaryColor = theme.semanticColors.teal[100]
|
|
295
|
+
this.secondaryColor = theme.semanticColors.purple[500]
|
|
296
|
+
this.inactiveColor = theme.semanticColors.purple[500]
|
|
288
297
|
this.borderColor = this.secondaryColor
|
|
289
|
-
this.inactiveBorderColor = theme.semanticColors.teal[
|
|
298
|
+
this.inactiveBorderColor = theme.semanticColors.teal[200]
|
|
290
299
|
}
|
|
291
300
|
},
|
|
292
301
|
methods: {
|
|
293
|
-
selectItem(
|
|
294
|
-
if (this.disabled) {
|
|
302
|
+
selectItem(item) {
|
|
303
|
+
if (this.disabled || item.disabled) {
|
|
295
304
|
return
|
|
296
305
|
}
|
|
297
|
-
this.$emit('on-switch-change', value)
|
|
306
|
+
this.$emit('on-switch-change', item.value)
|
|
298
307
|
},
|
|
299
308
|
},
|
|
300
309
|
}
|
|
@@ -65,9 +65,9 @@ describe('SwitchField', () => {
|
|
|
65
65
|
})
|
|
66
66
|
|
|
67
67
|
it('renders the info text only when a message is provided', () => {
|
|
68
|
-
expect(
|
|
69
|
-
|
|
70
|
-
)
|
|
68
|
+
expect(
|
|
69
|
+
mountSwitch({ label: 'Mode' }).findComponent(InfoText).exists()
|
|
70
|
+
).toBe(false)
|
|
71
71
|
expect(
|
|
72
72
|
mountSwitch({ label: 'Mode', infoTextMessage: 'Helpful hint' })
|
|
73
73
|
.findComponent(InfoText)
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
role="checkbox"
|
|
33
33
|
:size="size"
|
|
34
34
|
tabindex="0"
|
|
35
|
+
:undefined-state="undefinedState"
|
|
35
36
|
@keydown.space.prevent="onToggleChange"
|
|
36
37
|
>
|
|
37
38
|
<ToggleBackground
|
|
@@ -41,6 +42,7 @@
|
|
|
41
42
|
data-test-id="toggle_background"
|
|
42
43
|
:disabled="disabled"
|
|
43
44
|
:is-checked="isChecked"
|
|
45
|
+
:undefined-state="undefinedState"
|
|
44
46
|
/>
|
|
45
47
|
<ToggleDot
|
|
46
48
|
data-test-id="toggle_dot"
|
|
@@ -49,6 +51,7 @@
|
|
|
49
51
|
:size="size"
|
|
50
52
|
:toggle-color="toggleColor"
|
|
51
53
|
:toggle-margin="toggleMargin"
|
|
54
|
+
:undefined-state="undefinedState"
|
|
52
55
|
/>
|
|
53
56
|
</ToggleWrapper>
|
|
54
57
|
<LabelContainer
|
|
@@ -125,6 +128,7 @@
|
|
|
125
128
|
disabled: Boolean,
|
|
126
129
|
backgroundColor: String,
|
|
127
130
|
isChecked: Boolean,
|
|
131
|
+
undefinedState: Boolean,
|
|
128
132
|
}
|
|
129
133
|
const LabelText = styled('div', toggleAttrs)`
|
|
130
134
|
color: ${(props) =>
|
|
@@ -140,6 +144,8 @@
|
|
|
140
144
|
border: ${(props) =>
|
|
141
145
|
props.disabled
|
|
142
146
|
? '1px solid ' + props.theme.colors.disabled
|
|
147
|
+
: props.undefinedState
|
|
148
|
+
? '1px solid ' + props.theme.colors.grey3
|
|
143
149
|
: props.isChecked
|
|
144
150
|
? props.backgroundColor
|
|
145
151
|
? '1px solid ' + props.backgroundColor
|
|
@@ -175,6 +181,7 @@
|
|
|
175
181
|
backgroundColor: String,
|
|
176
182
|
isChecked: Boolean,
|
|
177
183
|
disabled: Boolean,
|
|
184
|
+
undefinedState: Boolean,
|
|
178
185
|
}
|
|
179
186
|
const ToggleBackground = styled('span', backgroundAttrs)`
|
|
180
187
|
display: block;
|
|
@@ -184,6 +191,8 @@
|
|
|
184
191
|
background-color: ${(props) =>
|
|
185
192
|
props.disabled
|
|
186
193
|
? props.theme.colors.grey5
|
|
194
|
+
: props.undefinedState
|
|
195
|
+
? props.theme.colors.grey3
|
|
187
196
|
: props.isChecked
|
|
188
197
|
? props.backgroundColor
|
|
189
198
|
? props.backgroundColor
|
|
@@ -198,6 +207,7 @@
|
|
|
198
207
|
size: String,
|
|
199
208
|
disabled: Boolean,
|
|
200
209
|
toggleMargin: String,
|
|
210
|
+
undefinedState: Boolean,
|
|
201
211
|
}
|
|
202
212
|
const ToggleDot = styled('span', toggleProps)`
|
|
203
213
|
position: absolute;
|
|
@@ -233,7 +243,13 @@
|
|
|
233
243
|
border-radius: 100%;
|
|
234
244
|
transition: transform 0.4s ease;
|
|
235
245
|
transform: ${(props) =>
|
|
236
|
-
props.
|
|
246
|
+
props.undefinedState
|
|
247
|
+
? props.size === 'medium'
|
|
248
|
+
? 'translateX(15px)'
|
|
249
|
+
: props.size === 'small'
|
|
250
|
+
? 'translateX(6px)'
|
|
251
|
+
: 'translateX(15px)'
|
|
252
|
+
: props.isChecked
|
|
237
253
|
? props.size === 'medium'
|
|
238
254
|
? 'translateX(25px)'
|
|
239
255
|
: props.size === 'small'
|
|
@@ -336,6 +352,11 @@
|
|
|
336
352
|
default: null,
|
|
337
353
|
required: false,
|
|
338
354
|
},
|
|
355
|
+
undefinedState: {
|
|
356
|
+
type: Boolean,
|
|
357
|
+
default: false,
|
|
358
|
+
required: false,
|
|
359
|
+
},
|
|
339
360
|
},
|
|
340
361
|
methods: {
|
|
341
362
|
onToggleChange() {
|
|
@@ -77,16 +77,16 @@ describe('RCToggle', () => {
|
|
|
77
77
|
expect(wrapper.find('[data-test-id="label_left_container"]').exists()).toBe(
|
|
78
78
|
false
|
|
79
79
|
)
|
|
80
|
-
expect(
|
|
81
|
-
|
|
82
|
-
)
|
|
80
|
+
expect(
|
|
81
|
+
wrapper.find('[data-test-id="label_right_container"]').exists()
|
|
82
|
+
).toBe(false)
|
|
83
83
|
})
|
|
84
84
|
|
|
85
85
|
it('renders the label on the right by default', () => {
|
|
86
86
|
const wrapper = mountToggle({ label: 'My Label' })
|
|
87
|
-
expect(
|
|
88
|
-
|
|
89
|
-
)
|
|
87
|
+
expect(
|
|
88
|
+
wrapper.find('[data-test-id="label_right_container"]').exists()
|
|
89
|
+
).toBe(true)
|
|
90
90
|
expect(wrapper.find('[data-test-id="label_left_container"]').exists()).toBe(
|
|
91
91
|
false
|
|
92
92
|
)
|
|
@@ -98,9 +98,9 @@ describe('RCToggle', () => {
|
|
|
98
98
|
expect(wrapper.find('[data-test-id="label_left_container"]').exists()).toBe(
|
|
99
99
|
true
|
|
100
100
|
)
|
|
101
|
-
expect(
|
|
102
|
-
|
|
103
|
-
)
|
|
101
|
+
expect(
|
|
102
|
+
wrapper.find('[data-test-id="label_right_container"]').exists()
|
|
103
|
+
).toBe(false)
|
|
104
104
|
})
|
|
105
105
|
|
|
106
106
|
it('renders the info text only when infoTextMessage is provided', () => {
|
|
@@ -113,7 +113,8 @@
|
|
|
113
113
|
size: {
|
|
114
114
|
type: String,
|
|
115
115
|
default: 'medium',
|
|
116
|
-
validator: (value) =>
|
|
116
|
+
validator: (value) =>
|
|
117
|
+
['tiny', 'small', 'medium', 'large'].includes(value),
|
|
117
118
|
},
|
|
118
119
|
isWhite: {
|
|
119
120
|
required: false,
|