xmlui 0.10.15 → 0.10.18
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/dist/lib/{index-axjeT2uJ.mjs → index-Cy6Emsex.mjs} +3452 -1954
- package/dist/lib/index.css +1 -1
- package/dist/lib/{initMock-BoTWMs19.mjs → initMock-B-rmnC-t.mjs} +1 -1
- package/dist/lib/xmlui-parser.d.ts +1 -1
- package/dist/lib/xmlui.d.ts +4 -6
- package/dist/lib/xmlui.mjs +1 -1
- package/dist/metadata/{collectedComponentMetadata-CQywuPDB.mjs → collectedComponentMetadata-CB63ngkU.mjs} +3845 -2357
- package/dist/metadata/{initMock-Bi5kF5Af.mjs → initMock-D0wDKF_I.mjs} +1 -1
- package/dist/metadata/style.css +1 -1
- package/dist/metadata/xmlui-metadata.mjs +1 -1
- package/dist/metadata/xmlui-metadata.umd.js +3 -3
- package/dist/scripts/package.json +1 -1
- package/dist/scripts/src/components/Accordion/Accordion.spec.js +1 -1
- package/dist/scripts/src/components/Accordion/AccordionItemNative.js +1 -1
- package/dist/scripts/src/components/Animation/AnimationNative.js +5 -1
- package/dist/scripts/src/components/AutoComplete/AutoComplete.js +1 -5
- package/dist/scripts/src/components/AutoComplete/AutoComplete.spec.js +29 -0
- package/dist/scripts/src/components/AutoComplete/AutoCompleteContext.js +2 -0
- package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +262 -62
- package/dist/scripts/src/components/Checkbox/Checkbox.js +1 -5
- package/dist/scripts/src/components/ColorPicker/ColorPicker.js +2 -6
- package/dist/scripts/src/components/ColorPicker/ColorPicker.spec.js +29 -0
- package/dist/scripts/src/components/ColorPicker/ColorPickerNative.js +12 -9
- package/dist/scripts/src/components/ComponentProvider.js +2 -0
- package/dist/scripts/src/components/DateInput/DateInput.js +1 -5
- package/dist/scripts/src/components/DateInput/DateInput.spec.js +29 -0
- package/dist/scripts/src/components/DateInput/DateInputNative.js +12 -16
- package/dist/scripts/src/components/DatePicker/DatePicker.js +1 -5
- package/dist/scripts/src/components/DatePicker/DatePicker.spec.js +29 -0
- package/dist/scripts/src/components/DatePicker/DatePickerNative.js +12 -13
- package/dist/scripts/src/components/FileInput/FileInput.js +1 -5
- package/dist/scripts/src/components/FileInput/FileInput.spec.js +29 -0
- package/dist/scripts/src/components/FileInput/FileInputNative.js +14 -15
- package/dist/scripts/src/components/Form/Form.spec.js +11 -9
- package/dist/scripts/src/components/Form/FormNative.js +41 -27
- package/dist/scripts/src/components/FormItem/FormItem.spec.js +179 -30
- package/dist/scripts/src/components/FormItem/FormItemNative.js +20 -22
- package/dist/scripts/src/components/FormItem/ItemWithLabel.js +8 -17
- package/dist/scripts/src/components/FormItem/Validations.js +25 -6
- package/dist/scripts/src/components/Icon/IconNative.js +18 -15
- package/dist/scripts/src/components/Input/PartialInput.js +2 -2
- package/dist/scripts/src/components/NestedApp/AppWithCodeViewNative.js +1 -1
- package/dist/scripts/src/components/NumberBox/NumberBox.js +5 -9
- package/dist/scripts/src/components/NumberBox/NumberBox.spec.js +142 -430
- package/dist/scripts/src/components/NumberBox/NumberBoxNative.js +33 -21
- package/dist/scripts/src/components/Option/Option.js +3 -1
- package/dist/scripts/src/components/RadioGroup/RadioGroup.js +1 -5
- package/dist/scripts/src/components/RadioGroup/RadioGroupNative.js +4 -5
- package/dist/scripts/src/components/RadioGroup/RadioItem.js +28 -0
- package/dist/scripts/src/components/Select/HiddenOption.js +1 -1
- package/dist/scripts/src/components/Select/Select.js +1 -5
- package/dist/scripts/src/components/Select/Select.spec.js +31 -3
- package/dist/scripts/src/components/Select/SelectNative.js +26 -32
- package/dist/scripts/src/components/Slider/Slider.js +1 -5
- package/dist/scripts/src/components/Slider/Slider.spec.js +75 -13
- package/dist/scripts/src/components/Slider/SliderNative.js +33 -24
- package/dist/scripts/src/components/Switch/Switch.js +1 -5
- package/dist/scripts/src/components/TextArea/TextArea.js +1 -5
- package/dist/scripts/src/components/TextArea/TextArea.spec.js +29 -0
- package/dist/scripts/src/components/TextArea/TextAreaNative.js +8 -29
- package/dist/scripts/src/components/TextBox/TextBox.spec.js +38 -7
- package/dist/scripts/src/components/TextBox/TextBoxNative.js +2 -2
- package/dist/scripts/src/components/TimeInput/TimeInput.spec.js +31 -0
- package/dist/scripts/src/components/Timer/Timer.spec.js +66 -96
- package/dist/scripts/src/components/Toggle/Toggle.js +28 -25
- package/dist/scripts/src/components/Tree/Tree-dynamic.spec.js +2894 -0
- package/dist/scripts/src/components/Tree/Tree-icons.spec.js +206 -0
- package/dist/scripts/src/components/Tree/Tree.spec.js +2839 -0
- package/dist/scripts/src/components/Tree/TreeComponent.js +303 -10
- package/dist/scripts/src/components/Tree/TreeNative.js +1090 -23
- package/dist/scripts/src/components/Tree/testData.js +296 -0
- package/dist/scripts/src/components-core/behaviors/Behavior.js +2 -0
- package/dist/scripts/src/components-core/behaviors/CoreBehaviors.js +8 -4
- package/dist/scripts/src/components-core/rendering/AppRoot.js +1 -2
- package/dist/scripts/src/components-core/rendering/ComponentAdapter.js +13 -15
- package/dist/scripts/src/components-core/utils/treeUtils.js +190 -12
- package/dist/scripts/src/testing/ComponentDrivers.js +79 -7
- package/dist/scripts/src/testing/drivers/NumberBoxDriver.js +2 -2
- package/dist/scripts/src/testing/drivers/TreeDriver.js +13 -0
- package/dist/scripts/src/testing/fixtures.js +7 -2
- package/dist/standalone/xmlui-standalone.es.d.ts +4 -6
- package/dist/standalone/xmlui-standalone.umd.js +36 -36
- package/package.json +1 -1
- package/dist/scripts/src/components/Animation/Animation.js +0 -50
- package/dist/scripts/src/components-core/behaviors/BehaviorContext.js +0 -54
- package/dist/scripts/src/testing/drivers/SliderDriver.js +0 -20
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const component_test_helpers_1 = require("../../testing/component-test-helpers");
|
|
12
13
|
const fixtures_1 = require("../../testing/fixtures");
|
|
13
14
|
fixtures_1.test.describe("Basic Functionality", () => {
|
|
14
15
|
(0, fixtures_1.test)("component renders with default props", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
@@ -44,11 +45,11 @@ fixtures_1.test.describe("Basic Functionality", () => {
|
|
|
44
45
|
yield (0, fixtures_1.expect)(timer).not.toBeVisible();
|
|
45
46
|
}));
|
|
46
47
|
});
|
|
47
|
-
fixtures_1.test.describe("Event Handling", () => {
|
|
48
|
+
fixtures_1.test.describe.fixme("Event Handling", () => {
|
|
48
49
|
(0, fixtures_1.test)("timer tick event is called", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
49
50
|
yield initTestBed(`
|
|
50
51
|
<Fragment var.tickCount="{0}">
|
|
51
|
-
<Timer interval="
|
|
52
|
+
<Timer interval="800" enabled="true" onTick="tickCount++" />
|
|
52
53
|
<Text testId="counter">{tickCount}</Text>
|
|
53
54
|
</Fragment>
|
|
54
55
|
`);
|
|
@@ -65,7 +66,7 @@ fixtures_1.test.describe("Event Handling", () => {
|
|
|
65
66
|
(0, fixtures_1.test)("timer stops when enabled is false", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
66
67
|
yield initTestBed(`
|
|
67
68
|
<Fragment var.tickCount="{0}" var.timerEnabled="{true}">
|
|
68
|
-
<Timer interval="
|
|
69
|
+
<Timer interval="800" enabled="{timerEnabled}" onTick="tickCount++" />
|
|
69
70
|
<Button testId="stopButton" onClick="timerEnabled = false">Stop Timer</Button>
|
|
70
71
|
<Text testId="counter">{tickCount}</Text>
|
|
71
72
|
</Fragment>
|
|
@@ -81,169 +82,139 @@ fixtures_1.test.describe("Event Handling", () => {
|
|
|
81
82
|
yield page.waitForTimeout(1500);
|
|
82
83
|
yield (0, fixtures_1.expect)(counter).toHaveText("1");
|
|
83
84
|
}));
|
|
84
|
-
|
|
85
|
+
fixtures_1.test.fixme("timer prevents overlapping events", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
85
86
|
// This test verifies that a new tick event doesn't fire if the previous one hasn't completed
|
|
86
87
|
yield initTestBed(`
|
|
87
|
-
<Fragment var.
|
|
88
|
+
<Fragment var.tickStr="" var.processingTime="{2000}">
|
|
88
89
|
<Timer
|
|
89
|
-
interval="
|
|
90
|
+
interval="800"
|
|
90
91
|
enabled="true"
|
|
91
92
|
onTick="
|
|
92
|
-
|
|
93
|
+
tickStr += '+';
|
|
93
94
|
delay(processingTime);
|
|
94
95
|
"
|
|
95
96
|
/>
|
|
96
|
-
<Text testId="counter">{
|
|
97
|
+
<Text testId="counter">{tickStr}</Text>
|
|
97
98
|
</Fragment>
|
|
98
99
|
`);
|
|
99
100
|
const counter = page.getByTestId("counter");
|
|
100
101
|
// First tick should start and take 2000ms to complete
|
|
101
102
|
// but interval is 1000ms, so second tick should not start until first completes
|
|
102
|
-
yield page.waitForTimeout(
|
|
103
|
-
yield (0, fixtures_1.expect)(counter).toHaveText("
|
|
103
|
+
yield page.waitForTimeout(1500); // Wait for first tick to complete
|
|
104
|
+
yield (0, fixtures_1.expect)(counter).toHaveText("+");
|
|
104
105
|
// Wait a bit more to see if overlapping was prevented
|
|
105
106
|
yield page.waitForTimeout(1500); // Should be enough for second tick to start
|
|
106
|
-
yield (0, fixtures_1.expect)(counter).
|
|
107
|
+
yield (0, fixtures_1.expect)(counter).toContainText("++");
|
|
107
108
|
}));
|
|
108
109
|
});
|
|
109
|
-
fixtures_1.test.describe("Initial Delay Functionality", () => {
|
|
110
|
+
fixtures_1.test.describe.fixme("Initial Delay Functionality", () => {
|
|
110
111
|
(0, fixtures_1.test)("timer waits for initial delay before first tick", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
111
112
|
yield initTestBed(`
|
|
112
|
-
<Fragment var.
|
|
113
|
-
<Timer interval="
|
|
114
|
-
<Text testId="counter">{
|
|
113
|
+
<Fragment var.tickStr="">
|
|
114
|
+
<Timer interval="800" initialDelay="1600" onTick="tickStr += '+'"/>
|
|
115
|
+
<Text testId="counter">{tickStr}</Text>
|
|
115
116
|
</Fragment>
|
|
116
117
|
`);
|
|
117
118
|
const counter = page.getByTestId("counter");
|
|
118
119
|
// Should not tick immediately
|
|
119
|
-
yield (0, fixtures_1.expect)(counter).toHaveText("
|
|
120
|
+
yield (0, fixtures_1.expect)(counter).toHaveText("");
|
|
120
121
|
// Should not tick before initial delay
|
|
121
|
-
yield page.waitForTimeout(
|
|
122
|
-
yield (0, fixtures_1.expect)(counter).toHaveText("
|
|
122
|
+
yield page.waitForTimeout(1200);
|
|
123
|
+
yield (0, fixtures_1.expect)(counter).toHaveText("");
|
|
123
124
|
// Should tick after initial delay
|
|
124
|
-
yield page.waitForTimeout(
|
|
125
|
-
yield (0, fixtures_1.expect)(counter).toHaveText("
|
|
125
|
+
yield page.waitForTimeout(800); // Total 2500ms, past the 2000ms initial delay + 1000ms interval
|
|
126
|
+
yield (0, fixtures_1.expect)(counter).toHaveText("+");
|
|
126
127
|
// Should continue ticking at interval
|
|
127
|
-
yield page.waitForTimeout(
|
|
128
|
-
yield (0, fixtures_1.expect)(counter).toHaveText("
|
|
128
|
+
yield page.waitForTimeout(800);
|
|
129
|
+
yield (0, fixtures_1.expect)(counter).toHaveText("++");
|
|
129
130
|
}));
|
|
130
131
|
(0, fixtures_1.test)("initial delay only applies to first execution, not restarts", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
131
132
|
yield initTestBed(`
|
|
132
|
-
<Fragment var.
|
|
133
|
+
<Fragment var.tickStr="" var.timerEnabled="{true}">
|
|
133
134
|
<Timer
|
|
134
|
-
interval="
|
|
135
|
-
initialDelay="
|
|
135
|
+
interval="400"
|
|
136
|
+
initialDelay="800"
|
|
136
137
|
enabled="{timerEnabled}"
|
|
137
|
-
onTick="
|
|
138
|
+
onTick="tickStr += '+'"
|
|
138
139
|
/>
|
|
139
140
|
<Button testId="restartButton" onClick="timerEnabled = false; timerEnabled = true">Restart</Button>
|
|
140
|
-
<Text testId="counter">{
|
|
141
|
+
<Text testId="counter">{tickStr}</Text>
|
|
141
142
|
</Fragment>
|
|
142
143
|
`);
|
|
143
144
|
const counter = page.getByTestId("counter");
|
|
144
145
|
const restartButton = page.getByTestId("restartButton");
|
|
145
146
|
// Wait for initial delay + first tick
|
|
146
|
-
yield page.waitForTimeout(
|
|
147
|
-
yield (0, fixtures_1.expect)(counter).toHaveText("
|
|
147
|
+
yield page.waitForTimeout(1300);
|
|
148
|
+
yield (0, fixtures_1.expect)(counter).toHaveText("+");
|
|
148
149
|
// Restart the timer
|
|
149
150
|
yield restartButton.click();
|
|
150
151
|
// After restart, should tick immediately without initial delay
|
|
151
|
-
yield page.waitForTimeout(
|
|
152
|
-
yield (0, fixtures_1.expect)(counter).
|
|
152
|
+
yield page.waitForTimeout(500);
|
|
153
|
+
yield (0, fixtures_1.expect)(counter).toContainText("++");
|
|
153
154
|
}));
|
|
154
155
|
(0, fixtures_1.test)("initial delay works with once timer", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
155
156
|
yield initTestBed(`
|
|
156
|
-
<Fragment var.
|
|
157
|
-
<Timer interval="
|
|
158
|
-
<Text testId="counter">{
|
|
157
|
+
<Fragment var.tickStr="">
|
|
158
|
+
<Timer interval="800" initialDelay="1600" once="true" onTick="tickStr += '+'"/>
|
|
159
|
+
<Text testId="counter">{tickStr}</Text>
|
|
159
160
|
</Fragment>
|
|
160
161
|
`);
|
|
161
162
|
const counter = page.getByTestId("counter");
|
|
162
163
|
// Should not tick before initial delay
|
|
163
|
-
yield page.waitForTimeout(
|
|
164
|
-
yield (0, fixtures_1.expect)(counter).toHaveText("
|
|
164
|
+
yield page.waitForTimeout(1200);
|
|
165
|
+
yield (0, fixtures_1.expect)(counter).toHaveText("");
|
|
165
166
|
// Should tick once after initial delay
|
|
166
167
|
yield page.waitForTimeout(1000);
|
|
167
|
-
yield (0, fixtures_1.expect)(counter).toHaveText("
|
|
168
|
+
yield (0, fixtures_1.expect)(counter).toHaveText("+");
|
|
168
169
|
// Should not tick again
|
|
169
|
-
yield page.waitForTimeout(
|
|
170
|
-
yield (0, fixtures_1.expect)(counter).toHaveText("
|
|
170
|
+
yield page.waitForTimeout(1000);
|
|
171
|
+
yield (0, fixtures_1.expect)(counter).toHaveText("+");
|
|
171
172
|
}));
|
|
172
173
|
});
|
|
173
|
-
fixtures_1.test.describe("Pause and Resume API", () => {
|
|
174
|
+
fixtures_1.test.describe.fixme("Pause and Resume API", () => {
|
|
174
175
|
(0, fixtures_1.test)("timer can be paused and resumed via API", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
175
176
|
yield initTestBed(`
|
|
176
|
-
<Fragment var.
|
|
177
|
+
<Fragment var.tickStr="">
|
|
177
178
|
<Timer
|
|
178
179
|
id="myTimer"
|
|
179
|
-
interval="
|
|
180
|
-
onTick="
|
|
180
|
+
interval="800"
|
|
181
|
+
onTick="tickStr += '+'"
|
|
181
182
|
/>
|
|
182
183
|
<Button testId="pauseButton" onClick="myTimer.pause()">Pause</Button>
|
|
183
184
|
<Button testId="resumeButton" onClick="myTimer.resume()">Resume</Button>
|
|
184
|
-
<Text testId="counter">{
|
|
185
|
+
<Text testId="counter">{tickStr}</Text>
|
|
185
186
|
</Fragment>
|
|
186
187
|
`);
|
|
187
188
|
const counter = page.getByTestId("counter");
|
|
188
189
|
const pauseButton = page.getByTestId("pauseButton");
|
|
189
190
|
const resumeButton = page.getByTestId("resumeButton");
|
|
190
191
|
// Wait for first tick
|
|
191
|
-
yield page.waitForTimeout(
|
|
192
|
-
yield (0, fixtures_1.expect)(counter).toHaveText("
|
|
192
|
+
yield page.waitForTimeout(1000);
|
|
193
|
+
yield (0, fixtures_1.expect)(counter).toHaveText("+");
|
|
193
194
|
// Pause the timer
|
|
194
195
|
yield pauseButton.click();
|
|
195
196
|
// Should not tick while paused
|
|
196
|
-
|
|
197
|
-
yield
|
|
198
|
-
yield (0, fixtures_1.expect)(counter).toHaveText(currentCount || "1");
|
|
197
|
+
yield page.waitForTimeout(1000);
|
|
198
|
+
yield (0, fixtures_1.expect)(counter).toHaveText("+");
|
|
199
199
|
// Resume the timer
|
|
200
200
|
yield resumeButton.click();
|
|
201
201
|
// Should continue ticking after resume
|
|
202
|
-
yield page.waitForTimeout(1200);
|
|
203
|
-
const finalCount = parseInt((yield counter.textContent()) || "0");
|
|
204
|
-
(0, fixtures_1.expect)(finalCount).toBeGreaterThan(parseInt(currentCount || "1"));
|
|
205
|
-
}));
|
|
206
|
-
(0, fixtures_1.test)("pause during initial delay stops the delay", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
207
|
-
yield initTestBed(`
|
|
208
|
-
<Fragment var.tickCount="{0}">
|
|
209
|
-
<Timer
|
|
210
|
-
id="myTimer"
|
|
211
|
-
interval="1000"
|
|
212
|
-
initialDelay="3000"
|
|
213
|
-
onTick="tickCount++"
|
|
214
|
-
/>
|
|
215
|
-
<Button testId="pauseButton" onClick="myTimer.pause()">Pause</Button>
|
|
216
|
-
<Button testId="resumeButton" onClick="myTimer.resume()">Resume</Button>
|
|
217
|
-
<Text testId="counter">{tickCount}</Text>
|
|
218
|
-
</Fragment>
|
|
219
|
-
`);
|
|
220
|
-
const counter = page.getByTestId("counter");
|
|
221
|
-
const pauseButton = page.getByTestId("pauseButton");
|
|
222
|
-
const resumeButton = page.getByTestId("resumeButton");
|
|
223
|
-
// Pause during initial delay
|
|
224
202
|
yield page.waitForTimeout(1000);
|
|
225
|
-
yield
|
|
226
|
-
// Should not tick even after original delay would have passed
|
|
227
|
-
yield page.waitForTimeout(3000);
|
|
228
|
-
yield (0, fixtures_1.expect)(counter).toHaveText("0");
|
|
229
|
-
// Resume should start ticking
|
|
230
|
-
yield resumeButton.click();
|
|
231
|
-
yield page.waitForTimeout(1200);
|
|
232
|
-
yield (0, fixtures_1.expect)(counter).toHaveText("1");
|
|
203
|
+
yield (0, fixtures_1.expect)(counter).toContainText("++");
|
|
233
204
|
}));
|
|
234
205
|
(0, fixtures_1.test)("pause state is reset when timer is disabled", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
235
206
|
yield initTestBed(`
|
|
236
|
-
<Fragment var.
|
|
207
|
+
<Fragment var.tickStr="" var.timerEnabled="{true}">
|
|
237
208
|
<Timer
|
|
238
209
|
id="myTimer"
|
|
239
210
|
interval="1000"
|
|
240
211
|
enabled="{timerEnabled}"
|
|
241
|
-
onTick="
|
|
212
|
+
onTick="tickStr += '+'"
|
|
242
213
|
/>
|
|
243
214
|
<Button testId="pauseButton" onClick="myTimer.pause()">Pause</Button>
|
|
244
215
|
<Button testId="disableButton" onClick="timerEnabled = false">Disable</Button>
|
|
245
216
|
<Button testId="enableButton" onClick="timerEnabled = true">Enable</Button>
|
|
246
|
-
<Text testId="counter">{
|
|
217
|
+
<Text testId="counter">{tickStr}</Text>
|
|
247
218
|
<Text testId="paused">{myTimer.isPaused() ? 'Paused' : 'Running'}</Text>
|
|
248
219
|
</Fragment>
|
|
249
220
|
`);
|
|
@@ -262,7 +233,7 @@ fixtures_1.test.describe("Pause and Resume API", () => {
|
|
|
262
233
|
}));
|
|
263
234
|
});
|
|
264
235
|
fixtures_1.test.describe("Once Functionality", () => {
|
|
265
|
-
|
|
236
|
+
fixtures_1.test.fixme("timer with once=true fires only once", component_test_helpers_1.SKIP_REASON.TEST_NOT_WORKING("Waiting for timeouts are bad practice because they are flaky."), (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
266
237
|
yield initTestBed(`
|
|
267
238
|
<Fragment var.tickCount="{0}">
|
|
268
239
|
<Timer interval="1000" once="true" onTick="tickCount++" />
|
|
@@ -277,7 +248,7 @@ fixtures_1.test.describe("Once Functionality", () => {
|
|
|
277
248
|
yield page.waitForTimeout(2000);
|
|
278
249
|
yield (0, fixtures_1.expect)(counter).toHaveText("1");
|
|
279
250
|
}));
|
|
280
|
-
|
|
251
|
+
fixtures_1.test.fixme("timer with once=true can be restarted by re-enabling", component_test_helpers_1.SKIP_REASON.TEST_NOT_WORKING("Waiting for timeouts are bad practice because they are flaky."), (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
281
252
|
yield initTestBed(`
|
|
282
253
|
<Fragment var.tickCount="{0}" var.timerEnabled="{true}">
|
|
283
254
|
<Timer interval="1000" once="true" enabled="{timerEnabled}" onTick="tickCount++" />
|
|
@@ -296,25 +267,24 @@ fixtures_1.test.describe("Once Functionality", () => {
|
|
|
296
267
|
yield page.waitForTimeout(1200);
|
|
297
268
|
yield (0, fixtures_1.expect)(counter).toHaveText("2");
|
|
298
269
|
}));
|
|
299
|
-
|
|
270
|
+
fixtures_1.test.fixme("once timer doesn't interfere with regular timer functionality", component_test_helpers_1.SKIP_REASON.TEST_NOT_WORKING("Waiting for timeouts are bad practice because they are flaky."), (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
300
271
|
yield initTestBed(`
|
|
301
|
-
<Fragment var.
|
|
302
|
-
<Timer interval="1000" once="false" onTick="
|
|
303
|
-
<Text testId="counter">{
|
|
272
|
+
<Fragment var.tickStr="">
|
|
273
|
+
<Timer interval="1000" once="false" onTick="tickStr += '+'" />
|
|
274
|
+
<Text testId="counter">{tickStr}</Text>
|
|
304
275
|
</Fragment>
|
|
305
276
|
`);
|
|
306
277
|
const counter = page.getByTestId("counter");
|
|
307
278
|
// Wait for multiple ticks
|
|
308
|
-
yield page.waitForTimeout(
|
|
309
|
-
|
|
310
|
-
(0, fixtures_1.expect)(finalCount).toBeGreaterThan(2);
|
|
279
|
+
yield page.waitForTimeout(2000);
|
|
280
|
+
yield (0, fixtures_1.expect)(counter).toContainText("+");
|
|
311
281
|
}));
|
|
312
282
|
});
|
|
313
|
-
fixtures_1.test.describe("State Management", () => {
|
|
283
|
+
fixtures_1.test.describe.fixme("State Management", () => {
|
|
314
284
|
(0, fixtures_1.test)("timer can be dynamically enabled and disabled", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
315
285
|
yield initTestBed(`
|
|
316
286
|
<Fragment var.tickCount="{0}" var.timerEnabled="{false}">
|
|
317
|
-
<Timer interval="
|
|
287
|
+
<Timer interval="800" enabled="{timerEnabled}" onTick="tickCount++" />
|
|
318
288
|
<Button testId="startButton" onClick="timerEnabled = true">Start Timer</Button>
|
|
319
289
|
<Button testId="stopButton" onClick="timerEnabled = false">Stop Timer</Button>
|
|
320
290
|
<Text testId="counter">{tickCount}</Text>
|
|
@@ -324,16 +294,16 @@ fixtures_1.test.describe("State Management", () => {
|
|
|
324
294
|
const startButton = page.getByTestId("startButton");
|
|
325
295
|
const stopButton = page.getByTestId("stopButton");
|
|
326
296
|
// Initially disabled - should not increment
|
|
327
|
-
yield page.waitForTimeout(
|
|
297
|
+
yield page.waitForTimeout(1000);
|
|
328
298
|
yield (0, fixtures_1.expect)(counter).toHaveText("0");
|
|
329
299
|
// Start the timer
|
|
330
300
|
yield startButton.click();
|
|
331
|
-
yield page.waitForTimeout(
|
|
301
|
+
yield page.waitForTimeout(1000);
|
|
332
302
|
yield (0, fixtures_1.expect)(counter).toHaveText("1");
|
|
333
303
|
// Stop the timer again
|
|
334
304
|
yield stopButton.click();
|
|
335
305
|
const currentCount = yield counter.textContent();
|
|
336
|
-
yield page.waitForTimeout(
|
|
306
|
+
yield page.waitForTimeout(1000);
|
|
337
307
|
yield (0, fixtures_1.expect)(counter).toHaveText(currentCount || "1");
|
|
338
308
|
}));
|
|
339
309
|
(0, fixtures_1.test)("timer interval can be changed dynamically", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
@@ -50,14 +50,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
50
50
|
exports.Toggle = exports.defaultProps = void 0;
|
|
51
51
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
52
52
|
const react_1 = require("react");
|
|
53
|
-
const react_2 = require("react");
|
|
54
|
-
const react_3 = __importStar(require("react"));
|
|
53
|
+
const react_2 = __importStar(require("react"));
|
|
55
54
|
const classnames_1 = __importDefault(require("classnames"));
|
|
56
55
|
const Toggle_module_scss_1 = __importDefault(require("./Toggle.module.scss"));
|
|
57
56
|
const constants_1 = require("../../components-core/constants");
|
|
58
57
|
const misc_1 = require("../../components-core/utils/misc");
|
|
59
|
-
const ItemWithLabel_1 = require("../FormItem/ItemWithLabel");
|
|
60
58
|
const parts_1 = require("../../components-core/parts");
|
|
59
|
+
const react_compose_refs_1 = require("@radix-ui/react-compose-refs");
|
|
61
60
|
exports.defaultProps = {
|
|
62
61
|
initialValue: false,
|
|
63
62
|
value: false,
|
|
@@ -65,11 +64,10 @@ exports.defaultProps = {
|
|
|
65
64
|
validationStatus: "none",
|
|
66
65
|
indeterminate: false,
|
|
67
66
|
};
|
|
68
|
-
exports.Toggle = (0,
|
|
69
|
-
var { id, initialValue = exports.defaultProps.initialValue, value = exports.defaultProps.value, enabled = exports.defaultProps.enabled, style, readOnly, validationStatus = exports.defaultProps.validationStatus, updateState = constants_1.noop, onClick = constants_1.noop, onDidChange = constants_1.noop, onFocus = constants_1.noop, onBlur = constants_1.noop, variant = "checkbox", indeterminate = exports.defaultProps.indeterminate, className,
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
const innerRef = react_3.default.useRef(null);
|
|
67
|
+
exports.Toggle = (0, react_2.forwardRef)(function Toggle(_a, forwardedRef) {
|
|
68
|
+
var { id, initialValue = exports.defaultProps.initialValue, value = exports.defaultProps.value, enabled = exports.defaultProps.enabled, style, readOnly, validationStatus = exports.defaultProps.validationStatus, updateState = constants_1.noop, onClick = constants_1.noop, onDidChange = constants_1.noop, onFocus = constants_1.noop, onBlur = constants_1.noop, variant = "checkbox", indeterminate = exports.defaultProps.indeterminate, className, required, autoFocus, registerComponentApi, inputRenderer } = _a, rest = __rest(_a, ["id", "initialValue", "value", "enabled", "style", "readOnly", "validationStatus", "updateState", "onClick", "onDidChange", "onFocus", "onBlur", "variant", "indeterminate", "className", "required", "autoFocus", "registerComponentApi", "inputRenderer"]);
|
|
69
|
+
const innerRef = react_2.default.useRef(null);
|
|
70
|
+
const ref = innerRef ? (0, react_compose_refs_1.composeRefs)(forwardedRef, innerRef) : forwardedRef;
|
|
73
71
|
const transformToLegitValue = (inp) => {
|
|
74
72
|
if (typeof inp === "undefined" || inp === null) {
|
|
75
73
|
return false;
|
|
@@ -91,39 +89,39 @@ exports.Toggle = (0, react_3.forwardRef)(function Toggle(_a, forwardedRef) {
|
|
|
91
89
|
}
|
|
92
90
|
return false;
|
|
93
91
|
};
|
|
94
|
-
(0,
|
|
92
|
+
(0, react_2.useEffect)(() => {
|
|
95
93
|
updateState({ value: transformToLegitValue(initialValue) }, { initial: true });
|
|
96
94
|
}, [initialValue, updateState]);
|
|
97
|
-
const updateValue = (0,
|
|
95
|
+
const updateValue = (0, react_2.useCallback)((value) => {
|
|
98
96
|
var _a;
|
|
99
97
|
if (((_a = innerRef.current) === null || _a === void 0 ? void 0 : _a.checked) === value)
|
|
100
98
|
return;
|
|
101
99
|
updateState({ value });
|
|
102
100
|
onDidChange(value);
|
|
103
101
|
}, [onDidChange, updateState]);
|
|
104
|
-
const onInputChange = (0,
|
|
102
|
+
const onInputChange = (0, react_2.useCallback)((event) => {
|
|
105
103
|
if (readOnly) {
|
|
106
104
|
return;
|
|
107
105
|
}
|
|
108
106
|
updateState({ value: event.target.checked });
|
|
109
107
|
onDidChange(event.target.checked);
|
|
110
108
|
}, [onDidChange, readOnly, updateState]);
|
|
111
|
-
const handleOnFocus = (0,
|
|
109
|
+
const handleOnFocus = (0, react_2.useCallback)(() => {
|
|
112
110
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus();
|
|
113
111
|
}, [onFocus]);
|
|
114
|
-
const handleOnBlur = (0,
|
|
112
|
+
const handleOnBlur = (0, react_2.useCallback)(() => {
|
|
115
113
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur();
|
|
116
114
|
}, [onBlur]);
|
|
117
|
-
(0,
|
|
115
|
+
(0, react_2.useEffect)(() => {
|
|
118
116
|
if (typeof indeterminate === "boolean" && innerRef.current) {
|
|
119
117
|
innerRef.current.indeterminate = indeterminate;
|
|
120
118
|
}
|
|
121
119
|
}, [indeterminate]);
|
|
122
|
-
const focus = (0,
|
|
120
|
+
const focus = (0, react_2.useCallback)(() => {
|
|
123
121
|
var _a;
|
|
124
122
|
(_a = innerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
125
123
|
}, []);
|
|
126
|
-
(0,
|
|
124
|
+
(0, react_2.useEffect)(() => {
|
|
127
125
|
if (innerRef.current && autoFocus) {
|
|
128
126
|
setTimeout(() => focus(), 0);
|
|
129
127
|
}
|
|
@@ -131,27 +129,32 @@ exports.Toggle = (0, react_3.forwardRef)(function Toggle(_a, forwardedRef) {
|
|
|
131
129
|
const setValue = (0, misc_1.useEvent)((newValue) => {
|
|
132
130
|
updateValue(transformToLegitValue(newValue));
|
|
133
131
|
});
|
|
134
|
-
(0,
|
|
132
|
+
(0, react_2.useEffect)(() => {
|
|
135
133
|
registerComponentApi === null || registerComponentApi === void 0 ? void 0 : registerComponentApi({
|
|
136
134
|
focus,
|
|
137
135
|
setValue,
|
|
138
136
|
});
|
|
139
137
|
}, [focus, registerComponentApi, setValue]);
|
|
140
|
-
const input = (0,
|
|
138
|
+
const input = (0, react_1.useMemo)(() => {
|
|
141
139
|
const legitValue = transformToLegitValue(value);
|
|
142
|
-
return ((0, jsx_runtime_1.jsx)("input", { id:
|
|
140
|
+
return ((0, jsx_runtime_1.jsx)("input", Object.assign({}, rest, { id: id, "data-part-id": parts_1.PART_INPUT, ref: ref, type: "checkbox", role: variant, checked: legitValue, disabled: !enabled, required: required, readOnly: readOnly, "aria-readonly": readOnly, "aria-checked": indeterminate ? "mixed" : legitValue, "aria-required": required, "aria-disabled": !enabled, onClick: onClick, onChange: onInputChange, onFocus: handleOnFocus, onBlur: handleOnBlur, autoFocus: autoFocus, style: style, className: (0, classnames_1.default)(className, Toggle_module_scss_1.default.resetAppearance, {
|
|
143
141
|
[Toggle_module_scss_1.default.checkbox]: variant === "checkbox",
|
|
144
142
|
[Toggle_module_scss_1.default.switch]: variant === "switch",
|
|
145
143
|
[Toggle_module_scss_1.default.error]: validationStatus === "error",
|
|
146
144
|
[Toggle_module_scss_1.default.warning]: validationStatus === "warning",
|
|
147
145
|
[Toggle_module_scss_1.default.valid]: validationStatus === "valid",
|
|
148
|
-
}) }));
|
|
146
|
+
}) })));
|
|
149
147
|
}, [
|
|
150
|
-
|
|
148
|
+
rest,
|
|
149
|
+
className,
|
|
150
|
+
ref,
|
|
151
|
+
style,
|
|
152
|
+
id,
|
|
151
153
|
enabled,
|
|
152
154
|
handleOnBlur,
|
|
153
155
|
handleOnFocus,
|
|
154
156
|
onInputChange,
|
|
157
|
+
onClick,
|
|
155
158
|
readOnly,
|
|
156
159
|
required,
|
|
157
160
|
validationStatus,
|
|
@@ -160,8 +163,8 @@ exports.Toggle = (0, react_3.forwardRef)(function Toggle(_a, forwardedRef) {
|
|
|
160
163
|
indeterminate,
|
|
161
164
|
autoFocus,
|
|
162
165
|
]);
|
|
163
|
-
return (
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
166
|
+
return (inputRenderer ? ((0, jsx_runtime_1.jsxs)("label", { className: Toggle_module_scss_1.default.label, children: [(0, jsx_runtime_1.jsx)("div", { className: Toggle_module_scss_1.default.inputContainer, children: input }), inputRenderer({
|
|
167
|
+
$checked: transformToLegitValue(value),
|
|
168
|
+
$setChecked: setValue,
|
|
169
|
+
})] })) : (input));
|
|
167
170
|
});
|