@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/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');
@@ -837,14 +838,14 @@ const useFieldset = props => {
837
838
  const getRootProps = () => ({
838
839
  ...parts$2.root.attrs,
839
840
  disabled,
840
- 'data-disabled': dataAttr$1(disabled),
841
- 'data-invalid': dataAttr$1(invalid),
841
+ 'data-disabled': dataAttr(disabled),
842
+ 'data-invalid': dataAttr(invalid),
842
843
  'aria-describedby': labelIds.join(' ') || undefined
843
844
  });
844
845
  const getLegendProps = () => ({
845
846
  ...parts$2.legend.attrs,
846
- 'data-disabled': dataAttr$1(disabled),
847
- 'data-invalid': dataAttr$1(invalid)
847
+ 'data-disabled': dataAttr(disabled),
848
+ 'data-invalid': dataAttr(invalid)
848
849
  });
849
850
  const getHelperTextProps = () => ({
850
851
  id: helperTextId,
@@ -867,7 +868,7 @@ const useFieldset = props => {
867
868
  getErrorTextProps
868
869
  }));
869
870
  };
870
- const dataAttr$1 = condition => condition ? '' : undefined;
871
+ const dataAttr = condition => condition ? '' : undefined;
871
872
 
872
873
  const FieldsetRoot = props => {
873
874
  const [useFieldsetProps, localProps] = createSplitProps()(props, ['id', 'disabled', 'invalid']);
@@ -917,6 +918,7 @@ const parts$1 = fieldAnatomy.build();
917
918
  const useField = props => {
918
919
  const fieldset = useFieldsetContext();
919
920
  const {
921
+ ids,
920
922
  disabled = Boolean(fieldset?.().disabled),
921
923
  invalid = false,
922
924
  readOnly = false,
@@ -926,25 +928,27 @@ const useField = props => {
926
928
  const [hasHelperText, setHasHelperText] = solidJs.createSignal(false);
927
929
  const id = props.id ?? solidJs.createUniqueId();
928
930
  let rootRef;
929
- const errorTextId = `field::${id}::error-text`;
930
- const helperTextId = `field::${id}::helper-text`;
931
- const labelId = `field::${id}::label`;
931
+ const rootId = ids?.control ?? `field::${id}`;
932
+ const errorTextId = ids?.errorText ?? `field::${id}::error-text`;
933
+ const helperTextId = ids?.helperText ?? `field::${id}::helper-text`;
934
+ const labelId = ids?.label ?? `field::${id}::label`;
932
935
  solidJs.createEffect(() => {
933
936
  return;
934
937
  });
935
938
  const getRootProps = () => ({
936
939
  ...parts$1.root.attrs,
940
+ id: rootId,
937
941
  role: 'group',
938
- 'data-disabled': dataAttr(disabled),
939
- 'data-invalid': dataAttr(invalid),
940
- 'data-readonly': dataAttr(readOnly)
942
+ 'data-disabled': domQuery.dataAttr(disabled),
943
+ 'data-invalid': domQuery.dataAttr(invalid),
944
+ 'data-readonly': domQuery.dataAttr(readOnly)
941
945
  });
942
946
  const getLabelProps = () => ({
943
947
  ...parts$1.label.attrs,
944
948
  id: labelId,
945
- 'data-disabled': dataAttr(disabled),
946
- 'data-invalid': dataAttr(invalid),
947
- 'data-readonly': dataAttr(readOnly),
949
+ 'data-disabled': domQuery.dataAttr(disabled),
950
+ 'data-invalid': domQuery.dataAttr(invalid),
951
+ 'data-readonly': domQuery.dataAttr(readOnly),
948
952
  htmlFor: id
949
953
  });
950
954
  const labelIds = [];
@@ -952,9 +956,10 @@ const useField = props => {
952
956
  if (hasHelperText()) labelIds.push(helperTextId);
953
957
  const getControlProps = () => ({
954
958
  'aria-describedby': labelIds.join(' ') || undefined,
955
- 'aria-invalid': ariaAttr(invalid),
956
- 'aria-required': ariaAttr(required),
957
- 'aria-readonly': ariaAttr(readOnly),
959
+ 'aria-invalid': domQuery.ariaAttr(invalid),
960
+ 'data-invalid': domQuery.dataAttr(invalid),
961
+ 'data-required': domQuery.dataAttr(required),
962
+ 'data-readonly': domQuery.dataAttr(readOnly),
958
963
  id,
959
964
  required,
960
965
  disabled,
@@ -1005,11 +1010,9 @@ const useField = props => {
1005
1010
  getErrorTextProps
1006
1011
  }));
1007
1012
  };
1008
- const dataAttr = condition => condition ? '' : undefined;
1009
- const ariaAttr = condition => condition ? true : undefined;
1010
1013
 
1011
1014
  const FieldRoot = props => {
1012
- const [useFieldProps, localProps] = createSplitProps()(props, ['id', 'disabled', 'invalid', 'readOnly', 'required']);
1015
+ const [useFieldProps, localProps] = createSplitProps()(props, ['id', 'ids', 'disabled', 'invalid', 'readOnly', 'required']);
1013
1016
  const field = useField(useFieldProps);
1014
1017
  const mergedProps = solid.mergeProps(() => field().getRootProps(), localProps);
1015
1018
  return web.createComponent(FieldProvider, {
@@ -3917,7 +3920,7 @@ const ProgressValueText = props => {
3917
3920
  const mergedProps = solid.mergeProps(() => api().getValueTextProps(), props);
3918
3921
  return web.createComponent(ark.span, web.mergeProps(mergedProps, {
3919
3922
  get children() {
3920
- return props.children || api().valueAsString;
3923
+ return props.children || api().percentAsString;
3921
3924
  }
3922
3925
  }));
3923
3926
  };
@@ -4563,14 +4566,14 @@ const SelectPositioner = props => {
4563
4566
 
4564
4567
  const useSelect = props => {
4565
4568
  const [collectionOptions, selectProps] = createSplitProps()(props, ['isItemDisabled', 'itemToValue', 'itemToString', 'items']);
4566
- const collection = () => select__namespace.collection({
4569
+ const collection = solidJs.createMemo(() => select__namespace.collection({
4567
4570
  ...collectionOptions
4568
- });
4571
+ }));
4569
4572
  const locale = useLocaleContext();
4570
4573
  const environment = useEnvironmentContext();
4571
4574
  const id = solidJs.createUniqueId();
4572
4575
  const field = useFieldContext();
4573
- const context = solidJs.createMemo(() => ({
4576
+ const initialContext = solidJs.createMemo(() => ({
4574
4577
  id,
4575
4578
  ids: {
4576
4579
  label: field?.().ids.label,
@@ -4588,10 +4591,18 @@ const useSelect = props => {
4588
4591
  'open.controlled': props.open !== undefined,
4589
4592
  ...selectProps
4590
4593
  }));
4591
- const [state, send] = solid.useMachine(select__namespace.machine(context()), {
4594
+ const context = solidJs.createMemo(() => {
4595
+ const [, restProps] = solidJs.splitProps(initialContext(), ['collection']);
4596
+ return restProps;
4597
+ });
4598
+ const [state, send] = solid.useMachine(select__namespace.machine(initialContext()), {
4592
4599
  context
4593
4600
  });
4594
- return solidJs.createMemo(() => select__namespace.connect(state, send, solid.normalizeProps));
4601
+ const api = solidJs.createMemo(() => select__namespace.connect(state, send, solid.normalizeProps));
4602
+ solidJs.createEffect(() => {
4603
+ api().setCollection(collection());
4604
+ });
4605
+ return api;
4595
4606
  };
4596
4607
 
4597
4608
  const SelectRoot = props => {
@@ -5495,191 +5506,6 @@ const TimePickerPositioner = props => {
5495
5506
  });
5496
5507
  };
5497
5508
 
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
5509
  const useTimePicker = (props = {}) => {
5684
5510
  const locale = useLocaleContext();
5685
5511
  const environment = useEnvironmentContext();
@@ -5691,9 +5517,9 @@ const useTimePicker = (props = {}) => {
5691
5517
  open: props.defaultOpen,
5692
5518
  'open.controlled': props.open !== undefined,
5693
5519
  ...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
5520
+ value: props.defaultValue ? date.parseTime(props.defaultValue) : undefined,
5521
+ min: props.min ? date.parseTime(props.min) : undefined,
5522
+ max: props.max ? date.parseTime(props.max) : undefined
5697
5523
  }));
5698
5524
  const [state, send] = solid.useMachine(timePicker__namespace.machine(context()), {
5699
5525
  context