@react-aria/color 3.0.0-nightly.4623 → 3.0.0-nightly.4629

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.
@@ -34,8 +34,8 @@ $parcel$export(module.exports, "useColorArea", () => $47925bd68062ac17$export$2f
34
34
 
35
35
 
36
36
  function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
37
- let { isDisabled: isDisabled, inputXRef: inputXRef, inputYRef: inputYRef, containerRef: containerRef, "aria-label": ariaLabel, xName: xName, yName: yName } = props;
38
- let stringFormatter = (0, $fZxfU$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($4a33e168940636d5$exports))), "@react-aria/color");
37
+ let { isDisabled: isDisabled, inputXRef: inputXRef, inputYRef: inputYRef, containerRef: containerRef, 'aria-label': ariaLabel, xName: xName, yName: yName } = props;
38
+ let stringFormatter = (0, $fZxfU$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($4a33e168940636d5$exports))), '@react-aria/color');
39
39
  let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $fZxfU$reactariautils.useGlobalListeners)();
40
40
  let { direction: direction, locale: locale } = (0, $fZxfU$reactariai18n.useLocale)();
41
41
  let [focusedInput, setFocusedInput] = (0, $fZxfU$react.useState)(null);
@@ -71,26 +71,26 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
71
71
  setValueChangedViaKeyboard(true);
72
72
  let dir;
73
73
  switch(e.key){
74
- case "PageUp":
74
+ case 'PageUp':
75
75
  state.incrementY(state.yChannelPageStep);
76
- dir = "y";
76
+ dir = 'y';
77
77
  break;
78
- case "PageDown":
78
+ case 'PageDown':
79
79
  state.decrementY(state.yChannelPageStep);
80
- dir = "y";
80
+ dir = 'y';
81
81
  break;
82
- case "Home":
83
- direction === "rtl" ? state.incrementX(state.xChannelPageStep) : state.decrementX(state.xChannelPageStep);
84
- dir = "x";
82
+ case 'Home':
83
+ direction === 'rtl' ? state.incrementX(state.xChannelPageStep) : state.decrementX(state.xChannelPageStep);
84
+ dir = 'x';
85
85
  break;
86
- case "End":
87
- direction === "rtl" ? state.decrementX(state.xChannelPageStep) : state.incrementX(state.xChannelPageStep);
88
- dir = "x";
86
+ case 'End':
87
+ direction === 'rtl' ? state.decrementX(state.xChannelPageStep) : state.incrementX(state.xChannelPageStep);
88
+ dir = 'x';
89
89
  break;
90
90
  }
91
91
  state.setDragging(false);
92
92
  if (dir) {
93
- let input = dir === "x" ? inputXRef : inputYRef;
93
+ let input = dir === 'x' ? inputXRef : inputYRef;
94
94
  focusInput(input);
95
95
  setFocusedInput(dir);
96
96
  }
@@ -110,19 +110,19 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
110
110
  height: 0
111
111
  };
112
112
  let valueChanged = deltaX !== 0 || deltaY !== 0;
113
- if (pointerType === "keyboard") {
113
+ if (pointerType === 'keyboard') {
114
114
  let deltaXValue = shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;
115
115
  let deltaYValue = shiftKey && yChannelPageStep > yChannelStep ? yChannelPageStep : yChannelStep;
116
- if (deltaX > 0 && direction === "ltr" || deltaX < 0 && direction === "rtl") incrementX(deltaXValue);
117
- else if (deltaX < 0 && direction === "ltr" || deltaX > 0 && direction === "rtl") decrementX(deltaXValue);
116
+ if (deltaX > 0 && direction === 'ltr' || deltaX < 0 && direction === 'rtl') incrementX(deltaXValue);
117
+ else if (deltaX < 0 && direction === 'ltr' || deltaX > 0 && direction === 'rtl') decrementX(deltaXValue);
118
118
  else if (deltaY > 0) decrementY(deltaYValue);
119
119
  else if (deltaY < 0) incrementY(deltaYValue);
120
120
  setValueChangedViaKeyboard(valueChanged);
121
121
  // set the focused input based on which axis has the greater delta
122
- focusedInput = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ? "y" : "x";
122
+ focusedInput = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ? 'y' : 'x';
123
123
  setFocusedInput(focusedInput);
124
124
  } else {
125
- currentPosition.current.x += (direction === "rtl" ? -1 : 1) * deltaX / width;
125
+ currentPosition.current.x += (direction === 'rtl' ? -1 : 1) * deltaX / width;
126
126
  currentPosition.current.y += deltaY / height;
127
127
  setColorFromPoint(currentPosition.current.x, currentPosition.current.y);
128
128
  }
@@ -130,7 +130,7 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
130
130
  onMoveEnd () {
131
131
  isOnColorArea.current = false;
132
132
  state.setDragging(false);
133
- let input = focusedInput === "x" ? inputXRef : inputYRef;
133
+ let input = focusedInput === 'x' ? inputXRef : inputYRef;
134
134
  focusInput(input);
135
135
  }
136
136
  };
@@ -162,10 +162,10 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
162
162
  setValueChangedViaKeyboard(false);
163
163
  focusInput();
164
164
  state.setDragging(true);
165
- if (typeof PointerEvent !== "undefined") addGlobalListener(window, "pointerup", onThumbUp, false);
165
+ if (typeof PointerEvent !== 'undefined') addGlobalListener(window, 'pointerup', onThumbUp, false);
166
166
  else {
167
- addGlobalListener(window, "mouseup", onThumbUp, false);
168
- addGlobalListener(window, "touchend", onThumbUp, false);
167
+ addGlobalListener(window, 'mouseup', onThumbUp, false);
168
+ addGlobalListener(window, 'touchend', onThumbUp, false);
169
169
  }
170
170
  }
171
171
  };
@@ -179,10 +179,10 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
179
179
  state.setDragging(false);
180
180
  currentPointer.current = undefined;
181
181
  isOnColorArea.current = false;
182
- if (typeof PointerEvent !== "undefined") removeGlobalListener(window, "pointerup", onThumbUp, false);
182
+ if (typeof PointerEvent !== 'undefined') removeGlobalListener(window, 'pointerup', onThumbUp, false);
183
183
  else {
184
- removeGlobalListener(window, "mouseup", onThumbUp, false);
185
- removeGlobalListener(window, "touchend", onThumbUp, false);
184
+ removeGlobalListener(window, 'mouseup', onThumbUp, false);
185
+ removeGlobalListener(window, 'touchend', onThumbUp, false);
186
186
  }
187
187
  }
188
188
  };
@@ -191,7 +191,7 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
191
191
  let { width: width, height: height } = rect;
192
192
  let x = (clientX - rect.x) / width;
193
193
  let y = (clientY - rect.y) / height;
194
- if (direction === "rtl") x = 1 - x;
194
+ if (direction === 'rtl') x = 1 - x;
195
195
  if (x >= 0 && x <= 1 && y >= 0 && y <= 1 && !state.isDragging && currentPointer.current === undefined) {
196
196
  isOnColorArea.current = true;
197
197
  setValueChangedViaKeyboard(false);
@@ -199,10 +199,10 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
199
199
  state.setColorFromPoint(x, y);
200
200
  focusInput();
201
201
  state.setDragging(true);
202
- if (typeof PointerEvent !== "undefined") addGlobalListener(window, "pointerup", onColorAreaUp, false);
202
+ if (typeof PointerEvent !== 'undefined') addGlobalListener(window, 'pointerup', onColorAreaUp, false);
203
203
  else {
204
- addGlobalListener(window, "mouseup", onColorAreaUp, false);
205
- addGlobalListener(window, "touchend", onColorAreaUp, false);
204
+ addGlobalListener(window, 'mouseup', onColorAreaUp, false);
205
+ addGlobalListener(window, 'touchend', onColorAreaUp, false);
206
206
  }
207
207
  }
208
208
  };
@@ -216,17 +216,17 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
216
216
  currentPointer.current = undefined;
217
217
  state.setDragging(false);
218
218
  focusInput();
219
- if (typeof PointerEvent !== "undefined") removeGlobalListener(window, "pointerup", onColorAreaUp, false);
219
+ if (typeof PointerEvent !== 'undefined') removeGlobalListener(window, 'pointerup', onColorAreaUp, false);
220
220
  else {
221
- removeGlobalListener(window, "mouseup", onColorAreaUp, false);
222
- removeGlobalListener(window, "touchend", onColorAreaUp, false);
221
+ removeGlobalListener(window, 'mouseup', onColorAreaUp, false);
222
+ removeGlobalListener(window, 'touchend', onColorAreaUp, false);
223
223
  }
224
224
  }
225
225
  };
226
226
  let colorAreaInteractions = isDisabled ? {} : (0, $fZxfU$reactariautils.mergeProps)({
227
- ...typeof PointerEvent !== "undefined" ? {
227
+ ...typeof PointerEvent !== 'undefined' ? {
228
228
  onPointerDown: (e)=>{
229
- if (e.pointerType === "mouse" && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
229
+ if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
230
230
  onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);
231
231
  }
232
232
  } : {
@@ -240,9 +240,9 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
240
240
  }
241
241
  }, movePropsContainer);
242
242
  let thumbInteractions = isDisabled ? {} : (0, $fZxfU$reactariautils.mergeProps)({
243
- ...typeof PointerEvent !== "undefined" ? {
243
+ ...typeof PointerEvent !== 'undefined' ? {
244
244
  onPointerDown: (e)=>{
245
- if (e.pointerType === "mouse" && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
245
+ if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
246
246
  onThumbDown(e.pointerId);
247
247
  }
248
248
  } : {
@@ -257,12 +257,12 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
257
257
  }, focusWithinProps, keyboardProps, movePropsThumb);
258
258
  let { focusProps: xInputFocusProps } = (0, $fZxfU$reactariainteractions.useFocus)({
259
259
  onFocus: ()=>{
260
- setFocusedInput("x");
260
+ setFocusedInput('x');
261
261
  }
262
262
  });
263
263
  let { focusProps: yInputFocusProps } = (0, $fZxfU$reactariainteractions.useFocus)({
264
264
  onFocus: ()=>{
265
- setFocusedInput("y");
265
+ setFocusedInput('y');
266
266
  }
267
267
  });
268
268
  const onChange = (e)=>{
@@ -275,23 +275,23 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
275
275
  let value = state.getDisplayColor();
276
276
  const getAriaValueTextForChannel = (0, $fZxfU$react.useCallback)((channel)=>{
277
277
  const isAfterInput = valueChangedViaInputChangeEvent || valueChangedViaKeyboard;
278
- return `${isAfterInput ? stringFormatter.format("colorNameAndValue", {
278
+ return `${isAfterInput ? stringFormatter.format('colorNameAndValue', {
279
279
  name: value.getChannelName(channel, locale),
280
280
  value: value.formatChannelValue(channel, locale)
281
281
  }) : [
282
- stringFormatter.format("colorNameAndValue", {
282
+ stringFormatter.format('colorNameAndValue', {
283
283
  name: value.getChannelName(channel, locale),
284
284
  value: value.formatChannelValue(channel, locale)
285
285
  }),
286
- stringFormatter.format("colorNameAndValue", {
286
+ stringFormatter.format('colorNameAndValue', {
287
287
  name: value.getChannelName(channel === yChannel ? xChannel : yChannel, locale),
288
288
  value: value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)
289
289
  }),
290
- stringFormatter.format("colorNameAndValue", {
290
+ stringFormatter.format('colorNameAndValue', {
291
291
  name: value.getChannelName(zChannel, locale),
292
292
  value: value.formatChannelValue(zChannel, locale)
293
293
  })
294
- ].join(", ")}, ${value.getColorName(locale)}`;
294
+ ].join(', ')}, ${value.getColorName(locale)}`;
295
295
  }, [
296
296
  locale,
297
297
  value,
@@ -302,32 +302,32 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
302
302
  yChannel,
303
303
  zChannel
304
304
  ]);
305
- let colorPickerLabel = stringFormatter.format("colorPicker");
305
+ let colorPickerLabel = stringFormatter.format('colorPicker');
306
306
  let xInputLabellingProps = (0, $fZxfU$reactariautils.useLabels)({
307
307
  ...props,
308
- "aria-label": ariaLabel ? stringFormatter.format("colorInputLabel", {
308
+ 'aria-label': ariaLabel ? stringFormatter.format('colorInputLabel', {
309
309
  label: ariaLabel,
310
310
  channelLabel: colorPickerLabel
311
311
  }) : colorPickerLabel
312
312
  });
313
313
  let yInputLabellingProps = (0, $fZxfU$reactariautils.useLabels)({
314
314
  ...props,
315
- "aria-label": ariaLabel ? stringFormatter.format("colorInputLabel", {
315
+ 'aria-label': ariaLabel ? stringFormatter.format('colorInputLabel', {
316
316
  label: ariaLabel,
317
317
  channelLabel: colorPickerLabel
318
318
  }) : colorPickerLabel
319
319
  });
320
320
  let colorAreaLabellingProps = (0, $fZxfU$reactariautils.useLabels)({
321
321
  ...props,
322
- "aria-label": ariaLabel ? `${ariaLabel}, ${colorPickerLabel}` : undefined
322
+ 'aria-label': ariaLabel ? `${ariaLabel}, ${colorPickerLabel}` : undefined
323
323
  }, isMobile ? colorPickerLabel : undefined);
324
- let ariaRoleDescription = stringFormatter.format("twoDimensionalSlider");
324
+ let ariaRoleDescription = stringFormatter.format('twoDimensionalSlider');
325
325
  let { visuallyHiddenProps: visuallyHiddenProps } = (0, $fZxfU$reactariavisuallyhidden.useVisuallyHidden)({
326
326
  style: {
327
- opacity: "0.0001",
328
- width: "100%",
329
- height: "100%",
330
- pointerEvents: "none"
327
+ opacity: '0.0001',
328
+ width: '100%',
329
+ height: '100%',
330
+ pointerEvents: 'none'
331
331
  }
332
332
  });
333
333
  let { colorAreaStyleProps: colorAreaStyleProps, thumbStyleProps: thumbStyleProps } = (0, $99936ad0bf67c8c4$exports.useColorAreaGradient)({
@@ -342,59 +342,59 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
342
342
  ...colorAreaLabellingProps,
343
343
  ...colorAreaInteractions,
344
344
  ...colorAreaStyleProps,
345
- role: "group"
345
+ role: 'group'
346
346
  },
347
347
  thumbProps: {
348
348
  ...thumbInteractions,
349
349
  ...thumbStyleProps,
350
- role: "presentation"
350
+ role: 'presentation'
351
351
  },
352
352
  xInputProps: {
353
353
  ...xInputLabellingProps,
354
354
  ...visuallyHiddenProps,
355
355
  ...xInputFocusProps,
356
- type: "range",
356
+ type: 'range',
357
357
  min: state.value.getChannelRange(xChannel).minValue,
358
358
  max: state.value.getChannelRange(xChannel).maxValue,
359
359
  step: xChannelStep,
360
- "aria-roledescription": ariaRoleDescription,
361
- "aria-valuetext": getAriaValueTextForChannel(xChannel),
362
- "aria-orientation": "horizontal",
363
- "aria-describedby": props["aria-describedby"],
364
- "aria-details": props["aria-details"],
360
+ 'aria-roledescription': ariaRoleDescription,
361
+ 'aria-valuetext': getAriaValueTextForChannel(xChannel),
362
+ 'aria-orientation': 'horizontal',
363
+ 'aria-describedby': props['aria-describedby'],
364
+ 'aria-details': props['aria-details'],
365
365
  disabled: isDisabled,
366
366
  value: state.value.getChannelValue(xChannel),
367
367
  name: xName,
368
- tabIndex: isMobile || !focusedInput || focusedInput === "x" ? undefined : -1,
368
+ tabIndex: isMobile || !focusedInput || focusedInput === 'x' ? undefined : -1,
369
369
  /*
370
370
  So that only a single "2d slider" control shows up when listing form elements for screen readers,
371
371
  add aria-hidden="true" to the unfocused control when the value has not changed via the keyboard,
372
372
  but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
373
- */ "aria-hidden": isMobile || !focusedInput || focusedInput === "x" || valueChangedViaKeyboard ? undefined : "true",
373
+ */ 'aria-hidden': isMobile || !focusedInput || focusedInput === 'x' || valueChangedViaKeyboard ? undefined : 'true',
374
374
  onChange: onChange
375
375
  },
376
376
  yInputProps: {
377
377
  ...yInputLabellingProps,
378
378
  ...visuallyHiddenProps,
379
379
  ...yInputFocusProps,
380
- type: "range",
380
+ type: 'range',
381
381
  min: state.value.getChannelRange(yChannel).minValue,
382
382
  max: state.value.getChannelRange(yChannel).maxValue,
383
383
  step: yChannelStep,
384
- "aria-roledescription": ariaRoleDescription,
385
- "aria-valuetext": getAriaValueTextForChannel(yChannel),
386
- "aria-orientation": "vertical",
387
- "aria-describedby": props["aria-describedby"],
388
- "aria-details": props["aria-details"],
384
+ 'aria-roledescription': ariaRoleDescription,
385
+ 'aria-valuetext': getAriaValueTextForChannel(yChannel),
386
+ 'aria-orientation': 'vertical',
387
+ 'aria-describedby': props['aria-describedby'],
388
+ 'aria-details': props['aria-details'],
389
389
  disabled: isDisabled,
390
390
  value: state.value.getChannelValue(yChannel),
391
391
  name: yName,
392
- tabIndex: isMobile || focusedInput === "y" ? undefined : -1,
392
+ tabIndex: isMobile || focusedInput === 'y' ? undefined : -1,
393
393
  /*
394
394
  So that only a single "2d slider" control shows up when listing form elements for screen readers,
395
395
  add aria-hidden="true" to the unfocused input when the value has not changed via the keyboard,
396
396
  but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
397
- */ "aria-hidden": isMobile || focusedInput === "y" || valueChangedViaKeyboard ? undefined : "true",
397
+ */ 'aria-hidden': isMobile || focusedInput === 'y' || valueChangedViaKeyboard ? undefined : 'true',
398
398
  onChange: onChange
399
399
  }
400
400
  };