@ark-ui/solid 3.6.1 → 3.6.2

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/cjs/index.js CHANGED
@@ -36,6 +36,7 @@ var splitter$1 = require('@zag-js/splitter');
36
36
  var zagSwitch = require('@zag-js/switch');
37
37
  var tabs$1 = require('@zag-js/tabs');
38
38
  var tagsInput$1 = require('@zag-js/tags-input');
39
+ var date = require('@internationalized/date');
39
40
  var timePicker$1 = require('@zag-js/time-picker');
40
41
  var toast$1 = require('@zag-js/toast');
41
42
  var toggleGroup$1 = require('@zag-js/toggle-group');
@@ -5495,191 +5496,6 @@ const TimePickerPositioner = props => {
5495
5496
  });
5496
5497
  };
5497
5498
 
5498
- function $14e0f24ef4ac5c92$export$c19a80a9721b80f6(a, b) {
5499
- return $14e0f24ef4ac5c92$var$timeToMs(a) - $14e0f24ef4ac5c92$var$timeToMs(b);
5500
- }
5501
- function $14e0f24ef4ac5c92$var$timeToMs(a) {
5502
- return a.hour * 3600000 + a.minute * 60000 + a.second * 1000 + a.millisecond;
5503
- }
5504
-
5505
- function $735220c2d4774dd3$export$3e2544e88a25bff8(duration) {
5506
- let inverseDuration = {};
5507
- for(let key in duration)if (typeof duration[key] === 'number') inverseDuration[key] = -duration[key];
5508
- return inverseDuration;
5509
- }
5510
- function $735220c2d4774dd3$export$e5d5e1c1822b6e56(value, fields) {
5511
- let mutableValue = value.copy();
5512
- if (fields.hour != null) mutableValue.hour = fields.hour;
5513
- if (fields.minute != null) mutableValue.minute = fields.minute;
5514
- if (fields.second != null) mutableValue.second = fields.second;
5515
- if (fields.millisecond != null) mutableValue.millisecond = fields.millisecond;
5516
- $735220c2d4774dd3$export$7555de1e070510cb(mutableValue);
5517
- return mutableValue;
5518
- }
5519
- function $735220c2d4774dd3$var$balanceTime(time) {
5520
- time.second += Math.floor(time.millisecond / 1000);
5521
- time.millisecond = $735220c2d4774dd3$var$nonNegativeMod(time.millisecond, 1000);
5522
- time.minute += Math.floor(time.second / 60);
5523
- time.second = $735220c2d4774dd3$var$nonNegativeMod(time.second, 60);
5524
- time.hour += Math.floor(time.minute / 60);
5525
- time.minute = $735220c2d4774dd3$var$nonNegativeMod(time.minute, 60);
5526
- let days = Math.floor(time.hour / 24);
5527
- time.hour = $735220c2d4774dd3$var$nonNegativeMod(time.hour, 24);
5528
- return days;
5529
- }
5530
- function $735220c2d4774dd3$export$7555de1e070510cb(time) {
5531
- time.millisecond = Math.max(0, Math.min(time.millisecond, 1000));
5532
- time.second = Math.max(0, Math.min(time.second, 59));
5533
- time.minute = Math.max(0, Math.min(time.minute, 59));
5534
- time.hour = Math.max(0, Math.min(time.hour, 23));
5535
- }
5536
- function $735220c2d4774dd3$var$nonNegativeMod(a, b) {
5537
- let result = a % b;
5538
- if (result < 0) result += b;
5539
- return result;
5540
- }
5541
- function $735220c2d4774dd3$var$addTimeFields(time, duration) {
5542
- time.hour += duration.hours || 0;
5543
- time.minute += duration.minutes || 0;
5544
- time.second += duration.seconds || 0;
5545
- time.millisecond += duration.milliseconds || 0;
5546
- return $735220c2d4774dd3$var$balanceTime(time);
5547
- }
5548
- function $735220c2d4774dd3$export$7ed87b6bc2506470(time, duration) {
5549
- let res = time.copy();
5550
- $735220c2d4774dd3$var$addTimeFields(res, duration);
5551
- return res;
5552
- }
5553
- function $735220c2d4774dd3$export$fe34d3a381cd7501(time, duration) {
5554
- return $735220c2d4774dd3$export$7ed87b6bc2506470(time, $735220c2d4774dd3$export$3e2544e88a25bff8(duration));
5555
- }
5556
- function $735220c2d4774dd3$export$dd02b3e0007dfe28(value, field, amount, options) {
5557
- let mutable = value.copy();
5558
- switch(field){
5559
- case 'hour':
5560
- {
5561
- let hours = value.hour;
5562
- let min = 0;
5563
- let max = 23;
5564
- if ((options === null || options === void 0 ? void 0 : options.hourCycle) === 12) {
5565
- let isPM = hours >= 12;
5566
- min = isPM ? 12 : 0;
5567
- max = isPM ? 23 : 11;
5568
- }
5569
- mutable.hour = $735220c2d4774dd3$var$cycleValue(hours, amount, min, max, options === null || options === void 0 ? void 0 : options.round);
5570
- break;
5571
- }
5572
- case 'minute':
5573
- mutable.minute = $735220c2d4774dd3$var$cycleValue(value.minute, amount, 0, 59, options === null || options === void 0 ? void 0 : options.round);
5574
- break;
5575
- case 'second':
5576
- mutable.second = $735220c2d4774dd3$var$cycleValue(value.second, amount, 0, 59, options === null || options === void 0 ? void 0 : options.round);
5577
- break;
5578
- case 'millisecond':
5579
- mutable.millisecond = $735220c2d4774dd3$var$cycleValue(value.millisecond, amount, 0, 999, options === null || options === void 0 ? void 0 : options.round);
5580
- break;
5581
- default:
5582
- throw new Error('Unsupported field ' + field);
5583
- }
5584
- return mutable;
5585
- }
5586
- function $735220c2d4774dd3$var$cycleValue(value, amount, min, max, round = false) {
5587
- if (round) {
5588
- value += Math.sign(amount);
5589
- if (value < min) value = max;
5590
- let div = Math.abs(amount);
5591
- if (amount > 0) value = Math.ceil(value / div) * div;
5592
- else value = Math.floor(value / div) * div;
5593
- if (value > max) value = min;
5594
- } else {
5595
- value += amount;
5596
- if (value < min) value = max - (min - value - 1);
5597
- else if (value > max) value = min + (value - max - 1);
5598
- }
5599
- return value;
5600
- }
5601
-
5602
- /*
5603
- * Copyright 2020 Adobe. All rights reserved.
5604
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
5605
- * you may not use this file except in compliance with the License. You may obtain a copy
5606
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
5607
- *
5608
- * Unless required by applicable law or agreed to in writing, software distributed under
5609
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
5610
- * OF ANY KIND, either express or implied. See the License for the specific language
5611
- * governing permissions and limitations under the License.
5612
- */
5613
-
5614
-
5615
-
5616
- const $fae977aafc393c5c$var$TIME_RE = /^(\d{2})(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?$/;
5617
- function $fae977aafc393c5c$export$c9698ec7f05a07e1(value) {
5618
- let m = value.match($fae977aafc393c5c$var$TIME_RE);
5619
- if (!m) throw new Error('Invalid ISO 8601 time string: ' + value);
5620
- return new ($35ea8db9cb2ccb90$export$680ea196effce5f)($fae977aafc393c5c$var$parseNumber(m[1], 0, 23), m[2] ? $fae977aafc393c5c$var$parseNumber(m[2], 0, 59) : 0, m[3] ? $fae977aafc393c5c$var$parseNumber(m[3], 0, 59) : 0, m[4] ? $fae977aafc393c5c$var$parseNumber(m[4], 0, Infinity) * 1000 : 0);
5621
- }
5622
- function $fae977aafc393c5c$var$parseNumber(value, min, max) {
5623
- let val = Number(value);
5624
- if (val < min || val > max) throw new RangeError(`Value out of range: ${min} <= ${val} <= ${max}`);
5625
- return val;
5626
- }
5627
- function $fae977aafc393c5c$export$f59dee82248f5ad4(time) {
5628
- return `${String(time.hour).padStart(2, '0')}:${String(time.minute).padStart(2, '0')}:${String(time.second).padStart(2, '0')}${time.millisecond ? String(time.millisecond / 1000).slice(1) : ''}`;
5629
- }
5630
-
5631
- function _check_private_redeclaration(obj, privateCollection) {
5632
- if (privateCollection.has(obj)) {
5633
- throw new TypeError("Cannot initialize the same private elements twice on an object");
5634
- }
5635
- }
5636
-
5637
- function _class_private_field_init(obj, privateMap, value) {
5638
- _check_private_redeclaration(obj, privateMap);
5639
- privateMap.set(obj, value);
5640
- }
5641
-
5642
- var // This prevents TypeScript from allowing other types with the same fields to match.
5643
- // @ts-ignore
5644
- $35ea8db9cb2ccb90$var$_type1 = /*#__PURE__*/ new WeakMap();
5645
- class $35ea8db9cb2ccb90$export$680ea196effce5f {
5646
- /** Returns a copy of this time. */ copy() {
5647
- return new $35ea8db9cb2ccb90$export$680ea196effce5f(this.hour, this.minute, this.second, this.millisecond);
5648
- }
5649
- /** Returns a new `Time` with the given duration added to it. */ add(duration) {
5650
- return ($735220c2d4774dd3$export$7ed87b6bc2506470)(this, duration);
5651
- }
5652
- /** Returns a new `Time` with the given duration subtracted from it. */ subtract(duration) {
5653
- return ($735220c2d4774dd3$export$fe34d3a381cd7501)(this, duration);
5654
- }
5655
- /** Returns a new `Time` with the given fields set to the provided values. Other fields will be constrained accordingly. */ set(fields) {
5656
- return ($735220c2d4774dd3$export$e5d5e1c1822b6e56)(this, fields);
5657
- }
5658
- /**
5659
- * Returns a new `Time` with the given field adjusted by a specified amount.
5660
- * When the resulting value reaches the limits of the field, it wraps around.
5661
- */ cycle(field, amount, options) {
5662
- return ($735220c2d4774dd3$export$dd02b3e0007dfe28)(this, field, amount, options);
5663
- }
5664
- /** Converts the time to an ISO 8601 formatted string. */ toString() {
5665
- return ($fae977aafc393c5c$export$f59dee82248f5ad4)(this);
5666
- }
5667
- /** Compares this time with another. A negative result indicates that this time is before the given one, and a positive time indicates that it is after. */ compare(b) {
5668
- return ($14e0f24ef4ac5c92$export$c19a80a9721b80f6)(this, b);
5669
- }
5670
- constructor(hour = 0, minute = 0, second = 0, millisecond = 0){
5671
- (_class_private_field_init)(this, $35ea8db9cb2ccb90$var$_type1, {
5672
- writable: true,
5673
- value: void 0
5674
- });
5675
- this.hour = hour;
5676
- this.minute = minute;
5677
- this.second = second;
5678
- this.millisecond = millisecond;
5679
- ($735220c2d4774dd3$export$7555de1e070510cb)(this);
5680
- }
5681
- }
5682
-
5683
5499
  const useTimePicker = (props = {}) => {
5684
5500
  const locale = useLocaleContext();
5685
5501
  const environment = useEnvironmentContext();
@@ -5691,9 +5507,9 @@ const useTimePicker = (props = {}) => {
5691
5507
  open: props.defaultOpen,
5692
5508
  'open.controlled': props.open !== undefined,
5693
5509
  ...props,
5694
- value: props.defaultValue ? $fae977aafc393c5c$export$c9698ec7f05a07e1(props.defaultValue) : undefined,
5695
- min: props.min ? $fae977aafc393c5c$export$c9698ec7f05a07e1(props.min) : undefined,
5696
- max: props.max ? $fae977aafc393c5c$export$c9698ec7f05a07e1(props.max) : undefined
5510
+ value: props.defaultValue ? date.parseTime(props.defaultValue) : undefined,
5511
+ min: props.min ? date.parseTime(props.min) : undefined,
5512
+ max: props.max ? date.parseTime(props.max) : undefined
5697
5513
  }));
5698
5514
  const [state, send] = solid.useMachine(timePicker__namespace.machine(context()), {
5699
5515
  context