@ark-ui/solid 3.6.1 → 3.7.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/dist/esm/index.js CHANGED
@@ -24,7 +24,7 @@ import * as dialog$1 from '@zag-js/dialog';
24
24
  export { anatomy as dialogAnatomy } from '@zag-js/dialog';
25
25
  import * as editable$1 from '@zag-js/editable';
26
26
  export { anatomy as editableAnatomy } from '@zag-js/editable';
27
- import { getDocument, getWindow } from '@zag-js/dom-query';
27
+ import { getDocument, getWindow, dataAttr as dataAttr$1, ariaAttr } from '@zag-js/dom-query';
28
28
  import { createAnatomy } from '@zag-js/anatomy';
29
29
  import * as fileUpload$1 from '@zag-js/file-upload';
30
30
  export { anatomy as fileUploadAnatomy } from '@zag-js/file-upload';
@@ -64,6 +64,7 @@ import * as tabs$1 from '@zag-js/tabs';
64
64
  export { anatomy as tabsAnatomy } from '@zag-js/tabs';
65
65
  import * as tagsInput$1 from '@zag-js/tags-input';
66
66
  export { anatomy as tagsInputAnatomy } from '@zag-js/tags-input';
67
+ import { parseTime } from '@internationalized/date';
67
68
  import * as timePicker$1 from '@zag-js/time-picker';
68
69
  import * as toast$1 from '@zag-js/toast';
69
70
  export { anatomy as toastAnatomy } from '@zag-js/toast';
@@ -816,14 +817,14 @@ const useFieldset = props => {
816
817
  const getRootProps = () => ({
817
818
  ...parts$2.root.attrs,
818
819
  disabled,
819
- 'data-disabled': dataAttr$1(disabled),
820
- 'data-invalid': dataAttr$1(invalid),
820
+ 'data-disabled': dataAttr(disabled),
821
+ 'data-invalid': dataAttr(invalid),
821
822
  'aria-describedby': labelIds.join(' ') || undefined
822
823
  });
823
824
  const getLegendProps = () => ({
824
825
  ...parts$2.legend.attrs,
825
- 'data-disabled': dataAttr$1(disabled),
826
- 'data-invalid': dataAttr$1(invalid)
826
+ 'data-disabled': dataAttr(disabled),
827
+ 'data-invalid': dataAttr(invalid)
827
828
  });
828
829
  const getHelperTextProps = () => ({
829
830
  id: helperTextId,
@@ -846,7 +847,7 @@ const useFieldset = props => {
846
847
  getErrorTextProps
847
848
  }));
848
849
  };
849
- const dataAttr$1 = condition => condition ? '' : undefined;
850
+ const dataAttr = condition => condition ? '' : undefined;
850
851
 
851
852
  const FieldsetRoot = props => {
852
853
  const [useFieldsetProps, localProps] = createSplitProps()(props, ['id', 'disabled', 'invalid']);
@@ -896,6 +897,7 @@ const parts$1 = fieldAnatomy.build();
896
897
  const useField = props => {
897
898
  const fieldset = useFieldsetContext();
898
899
  const {
900
+ ids,
899
901
  disabled = Boolean(fieldset?.().disabled),
900
902
  invalid = false,
901
903
  readOnly = false,
@@ -905,25 +907,27 @@ const useField = props => {
905
907
  const [hasHelperText, setHasHelperText] = createSignal(false);
906
908
  const id = props.id ?? createUniqueId();
907
909
  let rootRef;
908
- const errorTextId = `field::${id}::error-text`;
909
- const helperTextId = `field::${id}::helper-text`;
910
- const labelId = `field::${id}::label`;
910
+ const rootId = ids?.control ?? `field::${id}`;
911
+ const errorTextId = ids?.errorText ?? `field::${id}::error-text`;
912
+ const helperTextId = ids?.helperText ?? `field::${id}::helper-text`;
913
+ const labelId = ids?.label ?? `field::${id}::label`;
911
914
  createEffect(() => {
912
915
  return;
913
916
  });
914
917
  const getRootProps = () => ({
915
918
  ...parts$1.root.attrs,
919
+ id: rootId,
916
920
  role: 'group',
917
- 'data-disabled': dataAttr(disabled),
918
- 'data-invalid': dataAttr(invalid),
919
- 'data-readonly': dataAttr(readOnly)
921
+ 'data-disabled': dataAttr$1(disabled),
922
+ 'data-invalid': dataAttr$1(invalid),
923
+ 'data-readonly': dataAttr$1(readOnly)
920
924
  });
921
925
  const getLabelProps = () => ({
922
926
  ...parts$1.label.attrs,
923
927
  id: labelId,
924
- 'data-disabled': dataAttr(disabled),
925
- 'data-invalid': dataAttr(invalid),
926
- 'data-readonly': dataAttr(readOnly),
928
+ 'data-disabled': dataAttr$1(disabled),
929
+ 'data-invalid': dataAttr$1(invalid),
930
+ 'data-readonly': dataAttr$1(readOnly),
927
931
  htmlFor: id
928
932
  });
929
933
  const labelIds = [];
@@ -932,8 +936,9 @@ const useField = props => {
932
936
  const getControlProps = () => ({
933
937
  'aria-describedby': labelIds.join(' ') || undefined,
934
938
  'aria-invalid': ariaAttr(invalid),
935
- 'aria-required': ariaAttr(required),
936
- 'aria-readonly': ariaAttr(readOnly),
939
+ 'data-invalid': dataAttr$1(invalid),
940
+ 'data-required': dataAttr$1(required),
941
+ 'data-readonly': dataAttr$1(readOnly),
937
942
  id,
938
943
  required,
939
944
  disabled,
@@ -984,11 +989,9 @@ const useField = props => {
984
989
  getErrorTextProps
985
990
  }));
986
991
  };
987
- const dataAttr = condition => condition ? '' : undefined;
988
- const ariaAttr = condition => condition ? true : undefined;
989
992
 
990
993
  const FieldRoot = props => {
991
- const [useFieldProps, localProps] = createSplitProps()(props, ['id', 'disabled', 'invalid', 'readOnly', 'required']);
994
+ const [useFieldProps, localProps] = createSplitProps()(props, ['id', 'ids', 'disabled', 'invalid', 'readOnly', 'required']);
992
995
  const field = useField(useFieldProps);
993
996
  const mergedProps = mergeProps$1(() => field().getRootProps(), localProps);
994
997
  return createComponent(FieldProvider, {
@@ -3896,7 +3899,7 @@ const ProgressValueText = props => {
3896
3899
  const mergedProps = mergeProps$1(() => api().getValueTextProps(), props);
3897
3900
  return createComponent(ark.span, mergeProps(mergedProps, {
3898
3901
  get children() {
3899
- return props.children || api().valueAsString;
3902
+ return props.children || api().percentAsString;
3900
3903
  }
3901
3904
  }));
3902
3905
  };
@@ -4542,14 +4545,14 @@ const SelectPositioner = props => {
4542
4545
 
4543
4546
  const useSelect = props => {
4544
4547
  const [collectionOptions, selectProps] = createSplitProps()(props, ['isItemDisabled', 'itemToValue', 'itemToString', 'items']);
4545
- const collection = () => select$1.collection({
4548
+ const collection = createMemo(() => select$1.collection({
4546
4549
  ...collectionOptions
4547
- });
4550
+ }));
4548
4551
  const locale = useLocaleContext();
4549
4552
  const environment = useEnvironmentContext();
4550
4553
  const id = createUniqueId();
4551
4554
  const field = useFieldContext();
4552
- const context = createMemo(() => ({
4555
+ const initialContext = createMemo(() => ({
4553
4556
  id,
4554
4557
  ids: {
4555
4558
  label: field?.().ids.label,
@@ -4567,10 +4570,18 @@ const useSelect = props => {
4567
4570
  'open.controlled': props.open !== undefined,
4568
4571
  ...selectProps
4569
4572
  }));
4570
- const [state, send] = useMachine(select$1.machine(context()), {
4573
+ const context = createMemo(() => {
4574
+ const [, restProps] = splitProps(initialContext(), ['collection']);
4575
+ return restProps;
4576
+ });
4577
+ const [state, send] = useMachine(select$1.machine(initialContext()), {
4571
4578
  context
4572
4579
  });
4573
- return createMemo(() => select$1.connect(state, send, normalizeProps));
4580
+ const api = createMemo(() => select$1.connect(state, send, normalizeProps));
4581
+ createEffect(() => {
4582
+ api().setCollection(collection());
4583
+ });
4584
+ return api;
4574
4585
  };
4575
4586
 
4576
4587
  const SelectRoot = props => {
@@ -5474,191 +5485,6 @@ const TimePickerPositioner = props => {
5474
5485
  });
5475
5486
  };
5476
5487
 
5477
- function $14e0f24ef4ac5c92$export$c19a80a9721b80f6(a, b) {
5478
- return $14e0f24ef4ac5c92$var$timeToMs(a) - $14e0f24ef4ac5c92$var$timeToMs(b);
5479
- }
5480
- function $14e0f24ef4ac5c92$var$timeToMs(a) {
5481
- return a.hour * 3600000 + a.minute * 60000 + a.second * 1000 + a.millisecond;
5482
- }
5483
-
5484
- function $735220c2d4774dd3$export$3e2544e88a25bff8(duration) {
5485
- let inverseDuration = {};
5486
- for(let key in duration)if (typeof duration[key] === 'number') inverseDuration[key] = -duration[key];
5487
- return inverseDuration;
5488
- }
5489
- function $735220c2d4774dd3$export$e5d5e1c1822b6e56(value, fields) {
5490
- let mutableValue = value.copy();
5491
- if (fields.hour != null) mutableValue.hour = fields.hour;
5492
- if (fields.minute != null) mutableValue.minute = fields.minute;
5493
- if (fields.second != null) mutableValue.second = fields.second;
5494
- if (fields.millisecond != null) mutableValue.millisecond = fields.millisecond;
5495
- $735220c2d4774dd3$export$7555de1e070510cb(mutableValue);
5496
- return mutableValue;
5497
- }
5498
- function $735220c2d4774dd3$var$balanceTime(time) {
5499
- time.second += Math.floor(time.millisecond / 1000);
5500
- time.millisecond = $735220c2d4774dd3$var$nonNegativeMod(time.millisecond, 1000);
5501
- time.minute += Math.floor(time.second / 60);
5502
- time.second = $735220c2d4774dd3$var$nonNegativeMod(time.second, 60);
5503
- time.hour += Math.floor(time.minute / 60);
5504
- time.minute = $735220c2d4774dd3$var$nonNegativeMod(time.minute, 60);
5505
- let days = Math.floor(time.hour / 24);
5506
- time.hour = $735220c2d4774dd3$var$nonNegativeMod(time.hour, 24);
5507
- return days;
5508
- }
5509
- function $735220c2d4774dd3$export$7555de1e070510cb(time) {
5510
- time.millisecond = Math.max(0, Math.min(time.millisecond, 1000));
5511
- time.second = Math.max(0, Math.min(time.second, 59));
5512
- time.minute = Math.max(0, Math.min(time.minute, 59));
5513
- time.hour = Math.max(0, Math.min(time.hour, 23));
5514
- }
5515
- function $735220c2d4774dd3$var$nonNegativeMod(a, b) {
5516
- let result = a % b;
5517
- if (result < 0) result += b;
5518
- return result;
5519
- }
5520
- function $735220c2d4774dd3$var$addTimeFields(time, duration) {
5521
- time.hour += duration.hours || 0;
5522
- time.minute += duration.minutes || 0;
5523
- time.second += duration.seconds || 0;
5524
- time.millisecond += duration.milliseconds || 0;
5525
- return $735220c2d4774dd3$var$balanceTime(time);
5526
- }
5527
- function $735220c2d4774dd3$export$7ed87b6bc2506470(time, duration) {
5528
- let res = time.copy();
5529
- $735220c2d4774dd3$var$addTimeFields(res, duration);
5530
- return res;
5531
- }
5532
- function $735220c2d4774dd3$export$fe34d3a381cd7501(time, duration) {
5533
- return $735220c2d4774dd3$export$7ed87b6bc2506470(time, $735220c2d4774dd3$export$3e2544e88a25bff8(duration));
5534
- }
5535
- function $735220c2d4774dd3$export$dd02b3e0007dfe28(value, field, amount, options) {
5536
- let mutable = value.copy();
5537
- switch(field){
5538
- case 'hour':
5539
- {
5540
- let hours = value.hour;
5541
- let min = 0;
5542
- let max = 23;
5543
- if ((options === null || options === void 0 ? void 0 : options.hourCycle) === 12) {
5544
- let isPM = hours >= 12;
5545
- min = isPM ? 12 : 0;
5546
- max = isPM ? 23 : 11;
5547
- }
5548
- mutable.hour = $735220c2d4774dd3$var$cycleValue(hours, amount, min, max, options === null || options === void 0 ? void 0 : options.round);
5549
- break;
5550
- }
5551
- case 'minute':
5552
- mutable.minute = $735220c2d4774dd3$var$cycleValue(value.minute, amount, 0, 59, options === null || options === void 0 ? void 0 : options.round);
5553
- break;
5554
- case 'second':
5555
- mutable.second = $735220c2d4774dd3$var$cycleValue(value.second, amount, 0, 59, options === null || options === void 0 ? void 0 : options.round);
5556
- break;
5557
- case 'millisecond':
5558
- mutable.millisecond = $735220c2d4774dd3$var$cycleValue(value.millisecond, amount, 0, 999, options === null || options === void 0 ? void 0 : options.round);
5559
- break;
5560
- default:
5561
- throw new Error('Unsupported field ' + field);
5562
- }
5563
- return mutable;
5564
- }
5565
- function $735220c2d4774dd3$var$cycleValue(value, amount, min, max, round = false) {
5566
- if (round) {
5567
- value += Math.sign(amount);
5568
- if (value < min) value = max;
5569
- let div = Math.abs(amount);
5570
- if (amount > 0) value = Math.ceil(value / div) * div;
5571
- else value = Math.floor(value / div) * div;
5572
- if (value > max) value = min;
5573
- } else {
5574
- value += amount;
5575
- if (value < min) value = max - (min - value - 1);
5576
- else if (value > max) value = min + (value - max - 1);
5577
- }
5578
- return value;
5579
- }
5580
-
5581
- /*
5582
- * Copyright 2020 Adobe. All rights reserved.
5583
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
5584
- * you may not use this file except in compliance with the License. You may obtain a copy
5585
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
5586
- *
5587
- * Unless required by applicable law or agreed to in writing, software distributed under
5588
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
5589
- * OF ANY KIND, either express or implied. See the License for the specific language
5590
- * governing permissions and limitations under the License.
5591
- */
5592
-
5593
-
5594
-
5595
- const $fae977aafc393c5c$var$TIME_RE = /^(\d{2})(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?$/;
5596
- function $fae977aafc393c5c$export$c9698ec7f05a07e1(value) {
5597
- let m = value.match($fae977aafc393c5c$var$TIME_RE);
5598
- if (!m) throw new Error('Invalid ISO 8601 time string: ' + value);
5599
- 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);
5600
- }
5601
- function $fae977aafc393c5c$var$parseNumber(value, min, max) {
5602
- let val = Number(value);
5603
- if (val < min || val > max) throw new RangeError(`Value out of range: ${min} <= ${val} <= ${max}`);
5604
- return val;
5605
- }
5606
- function $fae977aafc393c5c$export$f59dee82248f5ad4(time) {
5607
- 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) : ''}`;
5608
- }
5609
-
5610
- function _check_private_redeclaration(obj, privateCollection) {
5611
- if (privateCollection.has(obj)) {
5612
- throw new TypeError("Cannot initialize the same private elements twice on an object");
5613
- }
5614
- }
5615
-
5616
- function _class_private_field_init(obj, privateMap, value) {
5617
- _check_private_redeclaration(obj, privateMap);
5618
- privateMap.set(obj, value);
5619
- }
5620
-
5621
- var // This prevents TypeScript from allowing other types with the same fields to match.
5622
- // @ts-ignore
5623
- $35ea8db9cb2ccb90$var$_type1 = /*#__PURE__*/ new WeakMap();
5624
- class $35ea8db9cb2ccb90$export$680ea196effce5f {
5625
- /** Returns a copy of this time. */ copy() {
5626
- return new $35ea8db9cb2ccb90$export$680ea196effce5f(this.hour, this.minute, this.second, this.millisecond);
5627
- }
5628
- /** Returns a new `Time` with the given duration added to it. */ add(duration) {
5629
- return ($735220c2d4774dd3$export$7ed87b6bc2506470)(this, duration);
5630
- }
5631
- /** Returns a new `Time` with the given duration subtracted from it. */ subtract(duration) {
5632
- return ($735220c2d4774dd3$export$fe34d3a381cd7501)(this, duration);
5633
- }
5634
- /** Returns a new `Time` with the given fields set to the provided values. Other fields will be constrained accordingly. */ set(fields) {
5635
- return ($735220c2d4774dd3$export$e5d5e1c1822b6e56)(this, fields);
5636
- }
5637
- /**
5638
- * Returns a new `Time` with the given field adjusted by a specified amount.
5639
- * When the resulting value reaches the limits of the field, it wraps around.
5640
- */ cycle(field, amount, options) {
5641
- return ($735220c2d4774dd3$export$dd02b3e0007dfe28)(this, field, amount, options);
5642
- }
5643
- /** Converts the time to an ISO 8601 formatted string. */ toString() {
5644
- return ($fae977aafc393c5c$export$f59dee82248f5ad4)(this);
5645
- }
5646
- /** 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) {
5647
- return ($14e0f24ef4ac5c92$export$c19a80a9721b80f6)(this, b);
5648
- }
5649
- constructor(hour = 0, minute = 0, second = 0, millisecond = 0){
5650
- (_class_private_field_init)(this, $35ea8db9cb2ccb90$var$_type1, {
5651
- writable: true,
5652
- value: void 0
5653
- });
5654
- this.hour = hour;
5655
- this.minute = minute;
5656
- this.second = second;
5657
- this.millisecond = millisecond;
5658
- ($735220c2d4774dd3$export$7555de1e070510cb)(this);
5659
- }
5660
- }
5661
-
5662
5488
  const useTimePicker = (props = {}) => {
5663
5489
  const locale = useLocaleContext();
5664
5490
  const environment = useEnvironmentContext();
@@ -5670,9 +5496,9 @@ const useTimePicker = (props = {}) => {
5670
5496
  open: props.defaultOpen,
5671
5497
  'open.controlled': props.open !== undefined,
5672
5498
  ...props,
5673
- value: props.defaultValue ? $fae977aafc393c5c$export$c9698ec7f05a07e1(props.defaultValue) : undefined,
5674
- min: props.min ? $fae977aafc393c5c$export$c9698ec7f05a07e1(props.min) : undefined,
5675
- max: props.max ? $fae977aafc393c5c$export$c9698ec7f05a07e1(props.max) : undefined
5499
+ value: props.defaultValue ? parseTime(props.defaultValue) : undefined,
5500
+ min: props.min ? parseTime(props.min) : undefined,
5501
+ max: props.max ? parseTime(props.max) : undefined
5676
5502
  }));
5677
5503
  const [state, send] = useMachine(timePicker$1.machine(context()), {
5678
5504
  context