ripple 0.3.2 → 0.3.4
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/CHANGELOG.md +85 -0
- package/package.json +2 -2
- package/src/compiler/identifier-utils.js +0 -2
- package/src/compiler/phases/1-parse/index.js +101 -195
- package/src/compiler/phases/2-analyze/index.js +82 -174
- package/src/compiler/phases/2-analyze/prune.js +2 -2
- package/src/compiler/phases/3-transform/client/index.js +174 -264
- package/src/compiler/phases/3-transform/segments.js +0 -22
- package/src/compiler/phases/3-transform/server/index.js +185 -42
- package/src/compiler/types/index.d.ts +14 -33
- package/src/compiler/utils.js +32 -20
- package/src/runtime/index-client.js +0 -17
- package/src/runtime/internal/client/bindings.js +118 -7
- package/src/runtime/internal/client/render.js +5 -1
- package/src/runtime/internal/client/runtime.js +1 -1
- package/src/runtime/internal/client/types.d.ts +4 -0
- package/tests/client/array/array.copy-within.test.ripple +7 -7
- package/tests/client/array/array.derived.test.ripple +24 -24
- package/tests/client/array/array.iteration.test.ripple +7 -7
- package/tests/client/array/array.mutations.test.ripple +17 -17
- package/tests/client/array/array.to-methods.test.ripple +4 -4
- package/tests/client/async-suspend.test.ripple +3 -3
- package/tests/client/basic/basic.attributes.test.ripple +31 -31
- package/tests/client/basic/basic.collections.test.ripple +6 -6
- package/tests/client/basic/basic.components.test.ripple +8 -8
- package/tests/client/basic/basic.errors.test.ripple +31 -34
- package/tests/client/basic/basic.events.test.ripple +11 -11
- package/tests/client/basic/basic.get-set.test.ripple +18 -18
- package/tests/client/basic/basic.reactivity.test.ripple +36 -36
- package/tests/client/basic/basic.rendering.test.ripple +7 -7
- package/tests/client/basic/basic.utilities.test.ripple +4 -4
- package/tests/client/boundaries.test.ripple +7 -7
- package/tests/client/compiler/__snapshots__/compiler.typescript.test.ripple.snap +24 -0
- package/tests/client/compiler/compiler.assignments.test.ripple +12 -10
- package/tests/client/compiler/compiler.basic.test.ripple +58 -60
- package/tests/client/compiler/compiler.tracked-access.test.ripple +14 -8
- package/tests/client/compiler/compiler.typescript.test.ripple +31 -0
- package/tests/client/composite/composite.dynamic-components.test.ripple +6 -6
- package/tests/client/composite/composite.props.test.ripple +9 -9
- package/tests/client/composite/composite.reactivity.test.ripple +23 -23
- package/tests/client/composite/composite.render.test.ripple +52 -4
- package/tests/client/computed-properties.test.ripple +3 -3
- package/tests/client/context.test.ripple +3 -3
- package/tests/client/css/global-additional-cases.test.ripple +5 -2
- package/tests/client/css/style-identifier.test.ripple +40 -49
- package/tests/client/date.test.ripple +39 -39
- package/tests/client/dynamic-elements.test.ripple +37 -37
- package/tests/client/events.test.ripple +25 -25
- package/tests/client/for.test.ripple +8 -8
- package/tests/client/head.test.ripple +7 -7
- package/tests/client/html.test.ripple +2 -2
- package/tests/client/input-value.test.ripple +376 -177
- package/tests/client/lazy-destructuring.test.ripple +185 -0
- package/tests/client/map.test.ripple +20 -20
- package/tests/client/media-query.test.ripple +4 -4
- package/tests/client/object.test.ripple +5 -5
- package/tests/client/portal.test.ripple +4 -4
- package/tests/client/ref.test.ripple +3 -3
- package/tests/client/return.test.ripple +17 -17
- package/tests/client/set.test.ripple +10 -10
- package/tests/client/svg.test.ripple +6 -5
- package/tests/client/switch.test.ripple +10 -10
- package/tests/client/tracked-expression.test.ripple +3 -1
- package/tests/client/try.test.ripple +4 -4
- package/tests/client/url/url.derived.test.ripple +6 -7
- package/tests/client/url/url.parsing.test.ripple +9 -9
- package/tests/client/url/url.partial-removal.test.ripple +9 -9
- package/tests/client/url/url.reactivity.test.ripple +16 -16
- package/tests/client/url/url.serialization.test.ripple +3 -3
- package/tests/client/url-search-params/url-search-params.derived.test.ripple +7 -8
- package/tests/client/url-search-params/url-search-params.initialization.test.ripple +6 -4
- package/tests/client/url-search-params/url-search-params.iteration.test.ripple +12 -12
- package/tests/client/url-search-params/url-search-params.mutation.test.ripple +18 -18
- package/tests/client/url-search-params/url-search-params.retrieval.test.ripple +16 -16
- package/tests/client/url-search-params/url-search-params.serialization.test.ripple +4 -4
- package/tests/client/url-search-params/url-search-params.tracked-url.test.ripple +3 -3
- package/tests/hydration/build-components.js +4 -10
- package/tests/hydration/compiled/client/basic.js +4 -4
- package/tests/hydration/compiled/client/events.js +2 -0
- package/tests/hydration/compiled/client/for.js +2 -0
- package/tests/hydration/compiled/client/head.js +13 -11
- package/tests/hydration/compiled/client/hmr.js +4 -2
- package/tests/hydration/compiled/client/html.js +82 -95
- package/tests/hydration/compiled/client/if-children.js +8 -9
- package/tests/hydration/compiled/client/if.js +2 -0
- package/tests/hydration/compiled/client/mixed-control-flow.js +4 -2
- package/tests/hydration/compiled/client/portal.js +1 -1
- package/tests/hydration/compiled/client/reactivity.js +2 -0
- package/tests/hydration/compiled/client/return.js +2 -0
- package/tests/hydration/compiled/client/switch.js +2 -0
- package/tests/hydration/compiled/server/composite.js +2 -2
- package/tests/hydration/compiled/server/events.js +2 -0
- package/tests/hydration/compiled/server/for.js +2 -0
- package/tests/hydration/compiled/server/head.js +13 -11
- package/tests/hydration/compiled/server/hmr.js +2 -0
- package/tests/hydration/compiled/server/html.js +2 -0
- package/tests/hydration/compiled/server/if-children.js +2 -0
- package/tests/hydration/compiled/server/if.js +2 -0
- package/tests/hydration/compiled/server/mixed-control-flow.js +2 -0
- package/tests/hydration/compiled/server/portal.js +1 -1
- package/tests/hydration/compiled/server/reactivity.js +2 -0
- package/tests/hydration/compiled/server/return.js +2 -0
- package/tests/hydration/compiled/server/switch.js +2 -0
- package/tests/hydration/components/composite.ripple +1 -1
- package/tests/hydration/components/events.ripple +10 -8
- package/tests/hydration/components/for.ripple +22 -20
- package/tests/hydration/components/head.ripple +8 -6
- package/tests/hydration/components/hmr.ripple +3 -1
- package/tests/hydration/components/html.ripple +3 -1
- package/tests/hydration/components/if-children.ripple +9 -7
- package/tests/hydration/components/if.ripple +7 -5
- package/tests/hydration/components/mixed-control-flow.ripple +5 -3
- package/tests/hydration/components/portal.ripple +2 -2
- package/tests/hydration/components/reactivity.ripple +11 -9
- package/tests/hydration/components/return.ripple +13 -11
- package/tests/hydration/components/switch.ripple +6 -4
- package/tests/server/__snapshots__/compiler.test.ripple.snap +22 -0
- package/tests/server/await.test.ripple +2 -2
- package/tests/server/basic.attributes.test.ripple +21 -19
- package/tests/server/basic.components.test.ripple +5 -4
- package/tests/server/basic.test.ripple +21 -20
- package/tests/server/compiler.test.ripple +36 -5
- package/tests/server/composite.props.test.ripple +7 -6
- package/tests/server/context.test.ripple +3 -1
- package/tests/server/dynamic-elements.test.ripple +24 -24
- package/tests/server/head.test.ripple +7 -5
- package/tests/server/style-identifier.test.ripple +95 -16
- package/types/index.d.ts +4 -1
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import { track } from 'ripple';
|
|
1
2
|
import { compile } from 'ripple/compiler';
|
|
2
3
|
|
|
3
|
-
describe('#
|
|
4
|
+
describe('#style identifier', () => {
|
|
4
5
|
describe('basic usage with components', () => {
|
|
5
|
-
it('passes scoped class to a child component via #
|
|
6
|
+
it('passes scoped class to a child component via #style', () => {
|
|
6
7
|
component Child({ className }: { className: string }) {
|
|
7
8
|
<div class={className}>{'styled child'}</div>
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
component Parent() {
|
|
11
|
-
<Child className={#
|
|
12
|
+
<Child className={#style.highlight} />
|
|
12
13
|
|
|
13
14
|
<style>
|
|
14
15
|
.highlight {
|
|
@@ -27,14 +28,14 @@ describe('#ripple.style identifier', () => {
|
|
|
27
28
|
expect(classes.some((cls: string) => cls === 'highlight')).toBe(true);
|
|
28
29
|
});
|
|
29
30
|
|
|
30
|
-
it('passes multiple #
|
|
31
|
+
it('passes multiple #style classes to a child component', () => {
|
|
31
32
|
component Child({ primary, secondary }: { primary: string; secondary: string }) {
|
|
32
33
|
<div class={primary}>{'primary'}</div>
|
|
33
34
|
<span class={secondary}>{'secondary'}</span>
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
component Parent() {
|
|
37
|
-
<Child primary={#
|
|
38
|
+
<Child primary={#style.primary} secondary={#style.secondary} />
|
|
38
39
|
|
|
39
40
|
<style>
|
|
40
41
|
.primary {
|
|
@@ -63,15 +64,15 @@ describe('#ripple.style identifier', () => {
|
|
|
63
64
|
expect(spanClasses.some((cls: string) => cls === 'secondary')).toBe(true);
|
|
64
65
|
});
|
|
65
66
|
|
|
66
|
-
it('passes scoped class to a dynamic child component via #
|
|
67
|
+
it('passes scoped class to a dynamic child component via #style', () => {
|
|
67
68
|
component Child({ cls }: { cls: string }) {
|
|
68
69
|
<span class={cls}>{'text'}</span>
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
component Parent() {
|
|
72
|
-
let dynamic =
|
|
73
|
+
let dynamic = track(() => Child);
|
|
73
74
|
<div class="wrapper">
|
|
74
|
-
<@dynamic cls={#
|
|
75
|
+
<@dynamic cls={#style.text} />
|
|
75
76
|
</div>
|
|
76
77
|
|
|
77
78
|
<style>
|
|
@@ -90,7 +91,7 @@ describe('#ripple.style identifier', () => {
|
|
|
90
91
|
expect(classes.some((cls: string) => cls === 'text')).toBe(true);
|
|
91
92
|
});
|
|
92
93
|
|
|
93
|
-
it('child can combine its own classes with parent #
|
|
94
|
+
it('child can combine its own classes with parent #style class', () => {
|
|
94
95
|
component Card({ className }: { className?: string }) {
|
|
95
96
|
<div class={['card-base', className ?? '']}>{'card content'}</div>
|
|
96
97
|
|
|
@@ -102,7 +103,7 @@ describe('#ripple.style identifier', () => {
|
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
component App() {
|
|
105
|
-
<Card className={#
|
|
106
|
+
<Card className={#style.themed} />
|
|
106
107
|
|
|
107
108
|
<style>
|
|
108
109
|
.themed {
|
|
@@ -127,7 +128,7 @@ describe('#ripple.style identifier', () => {
|
|
|
127
128
|
|
|
128
129
|
component App() {
|
|
129
130
|
<div class="parent">
|
|
130
|
-
<Child cls={#
|
|
131
|
+
<Child cls={#style.dual} />
|
|
131
132
|
</div>
|
|
132
133
|
|
|
133
134
|
<style>
|
|
@@ -151,10 +152,10 @@ describe('#ripple.style identifier', () => {
|
|
|
151
152
|
});
|
|
152
153
|
|
|
153
154
|
describe('compile errors', () => {
|
|
154
|
-
it('errors when #
|
|
155
|
+
it('errors when #style is used directly on a DOM element', () => {
|
|
155
156
|
const source = `
|
|
156
157
|
component App() {
|
|
157
|
-
<div class={#
|
|
158
|
+
<div class={#style.box}>{'content'}</div>
|
|
158
159
|
|
|
159
160
|
<style>
|
|
160
161
|
.box {
|
|
@@ -167,10 +168,10 @@ component App() {
|
|
|
167
168
|
);
|
|
168
169
|
});
|
|
169
170
|
|
|
170
|
-
it('errors when #
|
|
171
|
+
it('errors when #style bracket notation is used directly on a DOM element', () => {
|
|
171
172
|
const source = `
|
|
172
173
|
component App() {
|
|
173
|
-
<div class={#
|
|
174
|
+
<div class={#style['container']}>{'content'}</div>
|
|
174
175
|
|
|
175
176
|
<style>
|
|
176
177
|
.container {
|
|
@@ -183,15 +184,13 @@ component App() {
|
|
|
183
184
|
);
|
|
184
185
|
});
|
|
185
186
|
|
|
186
|
-
it(
|
|
187
|
-
|
|
188
|
-
() => {
|
|
189
|
-
const source = `
|
|
187
|
+
it('errors when #style references a class in a compound selector passed to component', () => {
|
|
188
|
+
const source = `
|
|
190
189
|
component Child({ cls }) {
|
|
191
190
|
<span class={cls}>{'text'}</span>
|
|
192
191
|
}
|
|
193
192
|
component App() {
|
|
194
|
-
<Child cls={#
|
|
193
|
+
<Child cls={#style.special} />
|
|
195
194
|
|
|
196
195
|
<style>
|
|
197
196
|
span.special {
|
|
@@ -199,11 +198,8 @@ component App() {
|
|
|
199
198
|
}
|
|
200
199
|
</style>
|
|
201
200
|
}`;
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
);
|
|
205
|
-
},
|
|
206
|
-
);
|
|
201
|
+
expect(() => compile(source, 'test.ripple')).toThrow(/does not exist as a stand-alone class/);
|
|
202
|
+
});
|
|
207
203
|
|
|
208
204
|
it('errors if descendant class is attempted to be passed in to child component', () => {
|
|
209
205
|
const source = `
|
|
@@ -214,7 +210,7 @@ component App() {
|
|
|
214
210
|
component App() {
|
|
215
211
|
<div class="wrapper">
|
|
216
212
|
<Child
|
|
217
|
-
cls={#
|
|
213
|
+
cls={#style.nested}
|
|
218
214
|
/>
|
|
219
215
|
</div>
|
|
220
216
|
|
|
@@ -242,7 +238,7 @@ component App() {
|
|
|
242
238
|
<Child
|
|
243
239
|
// @ts-expect-error - cannot use child combinator class as standalone
|
|
244
240
|
// @ripple-expect-error - cannot use child combinator class as standalone
|
|
245
|
-
cls={#
|
|
241
|
+
cls={#style.child}
|
|
246
242
|
/>
|
|
247
243
|
</div>
|
|
248
244
|
|
|
@@ -269,7 +265,7 @@ component App() {
|
|
|
269
265
|
<Child
|
|
270
266
|
// @ts-expect-error - cannot use compound class as standalone
|
|
271
267
|
// @ripple-expect-error - cannot use compound class as standalone
|
|
272
|
-
cls={#
|
|
268
|
+
cls={#style.child}
|
|
273
269
|
/>
|
|
274
270
|
</div>
|
|
275
271
|
|
|
@@ -285,7 +281,7 @@ component App() {
|
|
|
285
281
|
expect(() => compile(source, 'test.ripple')).toThrow(/does not exist as a stand-alone class/);
|
|
286
282
|
});
|
|
287
283
|
|
|
288
|
-
it('errors if descendant #
|
|
284
|
+
it('errors if descendant #style class is used on a dynamic component', () => {
|
|
289
285
|
const source = `
|
|
290
286
|
|
|
291
287
|
component Child({ cls }) {
|
|
@@ -293,9 +289,9 @@ component App() {
|
|
|
293
289
|
}
|
|
294
290
|
|
|
295
291
|
component App() {
|
|
296
|
-
let dynamic =
|
|
292
|
+
let dynamic = track(() => Child);
|
|
297
293
|
<div class="wrapper">
|
|
298
|
-
<@dynamic cls={#
|
|
294
|
+
<@dynamic cls={#style.nested} />
|
|
299
295
|
</div>
|
|
300
296
|
|
|
301
297
|
<style>
|
|
@@ -310,15 +306,13 @@ component App() {
|
|
|
310
306
|
expect(() => compile(source, 'test.ripple')).toThrow(/does not exist as a stand-alone class/);
|
|
311
307
|
});
|
|
312
308
|
|
|
313
|
-
it(
|
|
314
|
-
|
|
315
|
-
() => {
|
|
316
|
-
const source = `
|
|
309
|
+
it('errors when #style references a class that does not exist in the style block', () => {
|
|
310
|
+
const source = `
|
|
317
311
|
component Child({ cls }) {
|
|
318
312
|
<div class={cls}>{'text'}</div>
|
|
319
313
|
}
|
|
320
314
|
component App() {
|
|
321
|
-
<Child cls={#
|
|
315
|
+
<Child cls={#style.missing} />
|
|
322
316
|
|
|
323
317
|
<style>
|
|
324
318
|
.other {
|
|
@@ -326,20 +320,17 @@ component App() {
|
|
|
326
320
|
}
|
|
327
321
|
</style>
|
|
328
322
|
}`;
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
);
|
|
332
|
-
},
|
|
333
|
-
);
|
|
323
|
+
expect(() => compile(source, 'test.ripple')).toThrow(/does not exist as a stand-alone class/);
|
|
324
|
+
});
|
|
334
325
|
|
|
335
|
-
it('errors when #
|
|
326
|
+
it('errors when #style is used with a dynamic expression', () => {
|
|
336
327
|
const source = `
|
|
337
328
|
component Child({ cls }) {
|
|
338
329
|
<div class={cls}>{'text'}</div>
|
|
339
330
|
}
|
|
340
331
|
component App() {
|
|
341
332
|
const key = 'highlight';
|
|
342
|
-
<Child cls={#
|
|
333
|
+
<Child cls={#style[key]} />
|
|
343
334
|
|
|
344
335
|
<style>
|
|
345
336
|
.highlight {
|
|
@@ -352,22 +343,22 @@ component App() {
|
|
|
352
343
|
);
|
|
353
344
|
});
|
|
354
345
|
|
|
355
|
-
it('errors when #
|
|
346
|
+
it('errors when #style is used outside of a component', () => {
|
|
356
347
|
const source = `function notAComponent() {
|
|
357
|
-
const cls = #
|
|
348
|
+
const cls = #style.foo;
|
|
358
349
|
}`;
|
|
359
350
|
expect(() => compile(source, 'test.ripple')).toThrow(/can only be used within a component/);
|
|
360
351
|
});
|
|
361
352
|
});
|
|
362
353
|
|
|
363
354
|
describe('compiler output', () => {
|
|
364
|
-
it('generates #
|
|
355
|
+
it('generates #style object with standalone classes for client mode', () => {
|
|
365
356
|
const source = `
|
|
366
357
|
component Child({ cls }) {
|
|
367
358
|
<div class={cls}>{'text'}</div>
|
|
368
359
|
}
|
|
369
360
|
export component App() {
|
|
370
|
-
<Child cls={#
|
|
361
|
+
<Child cls={#style.highlight} />
|
|
371
362
|
|
|
372
363
|
<style>
|
|
373
364
|
.highlight {
|
|
@@ -381,13 +372,13 @@ export component App() {
|
|
|
381
372
|
expect(js.code).toMatch(/ripple-[a-z0-9]+/);
|
|
382
373
|
});
|
|
383
374
|
|
|
384
|
-
it('generates #
|
|
375
|
+
it('generates #style object with standalone classes for server mode', () => {
|
|
385
376
|
const source = `
|
|
386
377
|
component Child({ cls }) {
|
|
387
378
|
<div class={cls}>{'text'}</div>
|
|
388
379
|
}
|
|
389
380
|
export component App() {
|
|
390
|
-
<Child cls={#
|
|
381
|
+
<Child cls={#style.highlight} />
|
|
391
382
|
|
|
392
383
|
<style>
|
|
393
384
|
.highlight {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { flushSync } from 'ripple';
|
|
1
|
+
import { RippleDate, flushSync, track } from 'ripple';
|
|
2
2
|
|
|
3
3
|
describe('RippleDate', () => {
|
|
4
4
|
it('handles getTime() with reactive updates', () => {
|
|
5
5
|
component DateTest() {
|
|
6
|
-
let date =
|
|
7
|
-
let time =
|
|
6
|
+
let date = RippleDate(2025, 0, 1);
|
|
7
|
+
let time = track(() => date.getTime());
|
|
8
8
|
|
|
9
9
|
<button onClick={() => date.setFullYear(2026)}>{'Change Year'}</button>
|
|
10
10
|
<pre>{@time}</pre>
|
|
@@ -25,8 +25,8 @@ describe('RippleDate', () => {
|
|
|
25
25
|
|
|
26
26
|
it('handles getFullYear() with reactive updates', () => {
|
|
27
27
|
component DateTest() {
|
|
28
|
-
let date =
|
|
29
|
-
let year =
|
|
28
|
+
let date = RippleDate(2025, 5, 15);
|
|
29
|
+
let year = track(() => date.getFullYear());
|
|
30
30
|
|
|
31
31
|
<button onClick={() => date.setFullYear(2030)}>{'Change Year'}</button>
|
|
32
32
|
<pre>{@year}</pre>
|
|
@@ -46,8 +46,8 @@ describe('RippleDate', () => {
|
|
|
46
46
|
|
|
47
47
|
it('handles getMonth() with reactive updates', () => {
|
|
48
48
|
component DateTest() {
|
|
49
|
-
let date =
|
|
50
|
-
let month =
|
|
49
|
+
let date = RippleDate(2025, 0, 15);
|
|
50
|
+
let month = track(() => date.getMonth());
|
|
51
51
|
|
|
52
52
|
<button onClick={() => date.setMonth(11)}>{'Change to December'}</button>
|
|
53
53
|
<pre>{@month}</pre>
|
|
@@ -67,8 +67,8 @@ describe('RippleDate', () => {
|
|
|
67
67
|
|
|
68
68
|
it('handles getDate() with reactive updates', () => {
|
|
69
69
|
component DateTest() {
|
|
70
|
-
let date =
|
|
71
|
-
let day =
|
|
70
|
+
let date = RippleDate(2025, 0, 1);
|
|
71
|
+
let day = track(() => date.getDate());
|
|
72
72
|
|
|
73
73
|
<button onClick={() => date.setDate(15)}>{'Change Day'}</button>
|
|
74
74
|
<pre>{@day}</pre>
|
|
@@ -88,8 +88,8 @@ describe('RippleDate', () => {
|
|
|
88
88
|
|
|
89
89
|
it('handles getDay() with reactive updates', () => {
|
|
90
90
|
component DateTest() {
|
|
91
|
-
let date =
|
|
92
|
-
let dayOfWeek =
|
|
91
|
+
let date = RippleDate(2025, 0, 1);
|
|
92
|
+
let dayOfWeek = track(() => date.getDay());
|
|
93
93
|
|
|
94
94
|
<button onClick={() => date.setDate(2)}>{'Next Day'}</button>
|
|
95
95
|
<pre>{@dayOfWeek}</pre>
|
|
@@ -109,8 +109,8 @@ describe('RippleDate', () => {
|
|
|
109
109
|
|
|
110
110
|
it('handles getHours() with reactive updates', () => {
|
|
111
111
|
component DateTest() {
|
|
112
|
-
let date =
|
|
113
|
-
let hours =
|
|
112
|
+
let date = RippleDate(2025, 0, 1, 10, 30, 0);
|
|
113
|
+
let hours = track(() => date.getHours());
|
|
114
114
|
|
|
115
115
|
<button onClick={() => date.setHours(15)}>{'Change to 3 PM'}</button>
|
|
116
116
|
<pre>{@hours}</pre>
|
|
@@ -130,8 +130,8 @@ describe('RippleDate', () => {
|
|
|
130
130
|
|
|
131
131
|
it('handles getMinutes() with reactive updates', () => {
|
|
132
132
|
component DateTest() {
|
|
133
|
-
let date =
|
|
134
|
-
let minutes =
|
|
133
|
+
let date = RippleDate(2025, 0, 1, 10, 15, 0);
|
|
134
|
+
let minutes = track(() => date.getMinutes());
|
|
135
135
|
|
|
136
136
|
<button onClick={() => date.setMinutes(45)}>{'Change Minutes'}</button>
|
|
137
137
|
<pre>{@minutes}</pre>
|
|
@@ -151,8 +151,8 @@ describe('RippleDate', () => {
|
|
|
151
151
|
|
|
152
152
|
it('handles getSeconds() with reactive updates', () => {
|
|
153
153
|
component DateTest() {
|
|
154
|
-
let date =
|
|
155
|
-
let seconds =
|
|
154
|
+
let date = RippleDate(2025, 0, 1, 10, 15, 30);
|
|
155
|
+
let seconds = track(() => date.getSeconds());
|
|
156
156
|
|
|
157
157
|
<button onClick={() => date.setSeconds(45)}>{'Change Seconds'}</button>
|
|
158
158
|
<pre>{@seconds}</pre>
|
|
@@ -172,8 +172,8 @@ describe('RippleDate', () => {
|
|
|
172
172
|
|
|
173
173
|
it('handles toISOString() with reactive updates', () => {
|
|
174
174
|
component DateTest() {
|
|
175
|
-
let date =
|
|
176
|
-
let isoString =
|
|
175
|
+
let date = RippleDate(2025, 0, 1, 12, 0, 0);
|
|
176
|
+
let isoString = track(() => date.toISOString());
|
|
177
177
|
|
|
178
178
|
<button onClick={() => date.setFullYear(2026)}>{'Change Year'}</button>
|
|
179
179
|
<pre>{@isoString}</pre>
|
|
@@ -198,8 +198,8 @@ describe('RippleDate', () => {
|
|
|
198
198
|
|
|
199
199
|
it('handles toDateString() with reactive updates', () => {
|
|
200
200
|
component DateTest() {
|
|
201
|
-
let date =
|
|
202
|
-
let dateString =
|
|
201
|
+
let date = RippleDate(2025, 0, 1);
|
|
202
|
+
let dateString = track(() => date.toDateString());
|
|
203
203
|
|
|
204
204
|
<button onClick={() => date.setMonth(11)}>{'Change to December'}</button>
|
|
205
205
|
<pre>{@dateString}</pre>
|
|
@@ -222,8 +222,8 @@ describe('RippleDate', () => {
|
|
|
222
222
|
|
|
223
223
|
it('handles valueOf() with reactive updates', () => {
|
|
224
224
|
component DateTest() {
|
|
225
|
-
let date =
|
|
226
|
-
let valueOf =
|
|
225
|
+
let date = RippleDate(2025, 0, 1);
|
|
226
|
+
let valueOf = track(() => date.valueOf());
|
|
227
227
|
|
|
228
228
|
<button onClick={() => date.setDate(2)}>{'Next Day'}</button>
|
|
229
229
|
<pre>{@valueOf}</pre>
|
|
@@ -244,11 +244,11 @@ describe('RippleDate', () => {
|
|
|
244
244
|
|
|
245
245
|
it('handles multiple get methods reacting to same setTime change', () => {
|
|
246
246
|
component DateTest() {
|
|
247
|
-
let date =
|
|
248
|
-
let year =
|
|
249
|
-
let month =
|
|
250
|
-
let day =
|
|
251
|
-
let hours =
|
|
247
|
+
let date = RippleDate(2025, 0, 1, 10, 30, 15);
|
|
248
|
+
let year = track(() => date.getFullYear());
|
|
249
|
+
let month = track(() => date.getMonth());
|
|
250
|
+
let day = track(() => date.getDate());
|
|
251
|
+
let hours = track(() => date.getHours());
|
|
252
252
|
|
|
253
253
|
<button onClick={() => date.setTime(new Date(2026, 5, 15, 14, 45, 30).getTime())}>
|
|
254
254
|
{'Change All'}
|
|
@@ -292,15 +292,15 @@ describe('RippleDate', () => {
|
|
|
292
292
|
|
|
293
293
|
it('handles constructor with different parameter combinations', () => {
|
|
294
294
|
component DateTest() {
|
|
295
|
-
let dateNow =
|
|
296
|
-
let dateFromString =
|
|
297
|
-
let dateFromNumbers =
|
|
298
|
-
let dateFromTimestamp =
|
|
295
|
+
let dateNow = RippleDate();
|
|
296
|
+
let dateFromString = RippleDate('2025-01-01');
|
|
297
|
+
let dateFromNumbers = RippleDate(2025, 0, 1);
|
|
298
|
+
let dateFromTimestamp = RippleDate(1735689600000);
|
|
299
299
|
|
|
300
|
-
let nowYear =
|
|
301
|
-
let stringYear =
|
|
302
|
-
let numbersYear =
|
|
303
|
-
let timestampYear =
|
|
300
|
+
let nowYear = track(() => dateNow.getFullYear());
|
|
301
|
+
let stringYear = track(() => dateFromString.getFullYear());
|
|
302
|
+
let numbersYear = track(() => dateFromNumbers.getFullYear());
|
|
303
|
+
let timestampYear = track(() => dateFromTimestamp.getFullYear());
|
|
304
304
|
|
|
305
305
|
<div>
|
|
306
306
|
{'Now: '}
|
|
@@ -341,9 +341,9 @@ describe('RippleDate', () => {
|
|
|
341
341
|
|
|
342
342
|
it('handles get methods with arguments non-memoized', () => {
|
|
343
343
|
component DateTest() {
|
|
344
|
-
let date =
|
|
345
|
-
let localeDateString =
|
|
346
|
-
let localeTimeString =
|
|
344
|
+
let date = RippleDate();
|
|
345
|
+
let localeDateString = track(() => date.toLocaleDateString('en-US'));
|
|
346
|
+
let localeTimeString = track(() => date.toLocaleTimeString('en-US'));
|
|
347
347
|
|
|
348
348
|
<button onClick={() => date.setFullYear(date.getFullYear() + 1)}>{'Next Year'}</button>
|
|
349
349
|
<div>
|