@parrot-co/parrot-ui 0.1.10 → 0.1.11

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/main.js CHANGED
@@ -72,6 +72,8 @@ $parcel$export(module.exports, "ColorPicker", () => $b4c448f742efa2a7$export$9fe
72
72
  $parcel$export(module.exports, "ColorSlider", () => $7796dcb4fe09bf12$export$44fd664bcca5b6fb);
73
73
  $parcel$export(module.exports, "ColorSwatchPicker", () => $799f02b9b0e744b9$export$b46792416e3d8515);
74
74
  $parcel$export(module.exports, "parseColor", () => $e93fd810053d36a8$export$6e865ea70d7724f);
75
+ $parcel$export(module.exports, "Toggle", () => $fcb2cacda3f71fdc$export$bea8ebba691c5813);
76
+ $parcel$export(module.exports, "ToggleGroup", () => $fcb2cacda3f71fdc$export$af3ec21f6cfb5e30);
75
77
 
76
78
 
77
79
  function $d99c85a751d7ffbd$export$7e4aa119212bc614(value) {
@@ -4321,4 +4323,175 @@ function $e93fd810053d36a8$export$6e865ea70d7724f(color) {
4321
4323
 
4322
4324
 
4323
4325
 
4326
+
4327
+
4328
+
4329
+
4330
+
4331
+
4332
+ const $fcb2cacda3f71fdc$var$ToggleGroupContext = /*#__PURE__*/ $8zHUo$react.createContext(null);
4333
+ function $fcb2cacda3f71fdc$export$af3ec21f6cfb5e30({ children: children, mode: mode = "single", value: value, defaultValue: defaultValue, onChange: onChange, validate: validate, styles: styles, classNames: classNames, className: className, style: style, ...props }) {
4334
+ const Wrapper = $8zHUo$react.useMemo(()=>{
4335
+ if (mode === "single") return $fcb2cacda3f71fdc$var$SingleSelectGroup;
4336
+ return $fcb2cacda3f71fdc$var$MultiSelectGroup;
4337
+ }, [
4338
+ mode
4339
+ ]);
4340
+ props = {
4341
+ ...props
4342
+ };
4343
+ return /*#__PURE__*/ (0, $8zHUo$reactjsxruntime.jsx)((0, $ec2376a5dd0d13e6$export$a455218a85c89869), {
4344
+ label: props.label,
4345
+ replaceDefaultControlWrapper: true,
4346
+ children: /*#__PURE__*/ (0, $8zHUo$reactjsxruntime.jsx)(Wrapper, {
4347
+ value: value,
4348
+ defaultValue: defaultValue,
4349
+ onChange: onChange,
4350
+ validate: validate,
4351
+ ...props,
4352
+ children: /*#__PURE__*/ (0, $8zHUo$reactjsxruntime.jsx)((0, $eae337549f49a5a2$export$eef1e68107c58ef2), {
4353
+ className: className,
4354
+ styles: styles,
4355
+ classNames: classNames,
4356
+ style: style,
4357
+ ...props,
4358
+ children: children
4359
+ })
4360
+ })
4361
+ });
4362
+ }
4363
+ function $fcb2cacda3f71fdc$var$SingleSelectGroup({ children: children, orientation: orientation = "horizontal", ...props }) {
4364
+ const state = (0, $8zHUo$reactstately.useRadioGroupState)(props);
4365
+ const { radioGroupProps: radioGroupProps } = (0, $8zHUo$reactaria.useRadioGroup)({
4366
+ ...props,
4367
+ orientation: orientation,
4368
+ "aria-label": "single toggle group"
4369
+ }, state);
4370
+ return /*#__PURE__*/ (0, $8zHUo$reactjsxruntime.jsx)("div", {
4371
+ ...radioGroupProps,
4372
+ children: /*#__PURE__*/ (0, $8zHUo$reactjsxruntime.jsx)($fcb2cacda3f71fdc$var$ToggleGroupContext.Provider, {
4373
+ value: {
4374
+ state: state,
4375
+ mode: "single",
4376
+ props: props
4377
+ },
4378
+ children: children
4379
+ })
4380
+ });
4381
+ }
4382
+ function $fcb2cacda3f71fdc$var$MultiSelectGroup({ children: children, ...props }) {
4383
+ const state = (0, $8zHUo$reactstately.useCheckboxGroupState)(props);
4384
+ const { groupProps: groupProps } = (0, $8zHUo$reactaria.useCheckboxGroup)({
4385
+ ...props,
4386
+ "aria-label": "multiple toggle group"
4387
+ }, state);
4388
+ return /*#__PURE__*/ (0, $8zHUo$reactjsxruntime.jsx)("div", {
4389
+ ...groupProps,
4390
+ children: /*#__PURE__*/ (0, $8zHUo$reactjsxruntime.jsx)($fcb2cacda3f71fdc$var$ToggleGroupContext.Provider, {
4391
+ value: {
4392
+ state: state,
4393
+ mode: "multiple",
4394
+ props: props
4395
+ },
4396
+ children: children
4397
+ })
4398
+ });
4399
+ }
4400
+ function $fcb2cacda3f71fdc$var$SingleToggle({ ...props }) {
4401
+ const ctx = $8zHUo$react.useContext($fcb2cacda3f71fdc$var$ToggleGroupContext);
4402
+ const state = ctx?.state;
4403
+ const ref = $8zHUo$react.useRef(null);
4404
+ if (!ctx) throw new Error("Toggle must be used within a ToggleGroup");
4405
+ const { focusProps: focusProps, isFocusVisible: isFocusVisible } = (0, $8zHUo$reactaria.useFocusRing)();
4406
+ const isSelected = state.selectedValue === props.value;
4407
+ const { inputProps: inputProps } = (0, $8zHUo$reactaria.useRadio)(props, ctx.state, ref);
4408
+ return /*#__PURE__*/ (0, $8zHUo$reactjsxruntime.jsxs)($fcb2cacda3f71fdc$var$ToggleButton, {
4409
+ isSelected: isSelected,
4410
+ isFocusVisible: isFocusVisible,
4411
+ children: [
4412
+ /*#__PURE__*/ (0, $8zHUo$reactjsxruntime.jsx)((0, $8zHUo$reactaria.VisuallyHidden), {
4413
+ children: /*#__PURE__*/ (0, $8zHUo$reactjsxruntime.jsx)("input", {
4414
+ ref: ref,
4415
+ ...(0, $8zHUo$reactaria.mergeProps)(inputProps, focusProps)
4416
+ })
4417
+ }),
4418
+ props.children
4419
+ ]
4420
+ });
4421
+ }
4422
+ function $fcb2cacda3f71fdc$var$MultiToggle({ ...props }) {
4423
+ const ctx = $8zHUo$react.useContext($fcb2cacda3f71fdc$var$ToggleGroupContext);
4424
+ const state = ctx?.state;
4425
+ const ref = $8zHUo$react.useRef(null);
4426
+ if (!ctx) throw new Error("Toggle must be used within a ToggleGroup");
4427
+ const { focusProps: focusProps, isFocusVisible: isFocusVisible } = (0, $8zHUo$reactaria.useFocusRing)();
4428
+ const isSelected = state.isSelected(props.value);
4429
+ const { inputProps: inputProps } = (0, $8zHUo$reactaria.useCheckboxGroupItem)(props, ctx.state, ref);
4430
+ return /*#__PURE__*/ (0, $8zHUo$reactjsxruntime.jsxs)($fcb2cacda3f71fdc$var$ToggleButton, {
4431
+ isSelected: isSelected,
4432
+ isFocusVisible: isFocusVisible,
4433
+ children: [
4434
+ /*#__PURE__*/ (0, $8zHUo$reactjsxruntime.jsx)((0, $8zHUo$reactaria.VisuallyHidden), {
4435
+ children: /*#__PURE__*/ (0, $8zHUo$reactjsxruntime.jsx)("input", {
4436
+ ref: ref,
4437
+ ...(0, $8zHUo$reactaria.mergeProps)(inputProps, focusProps)
4438
+ })
4439
+ }),
4440
+ props.children
4441
+ ]
4442
+ });
4443
+ }
4444
+ const $fcb2cacda3f71fdc$var$ToggleContext = /*#__PURE__*/ $8zHUo$react.createContext(null);
4445
+ function $fcb2cacda3f71fdc$export$bea8ebba691c5813({ ...props }) {
4446
+ const ctx = $8zHUo$react.useContext($fcb2cacda3f71fdc$var$ToggleGroupContext);
4447
+ if (!ctx) throw new Error("Toggle must be used within a ToggleGroup");
4448
+ const Wrapper = $8zHUo$react.useMemo(()=>{
4449
+ if (ctx?.mode === "single") return $fcb2cacda3f71fdc$var$SingleToggle;
4450
+ return $fcb2cacda3f71fdc$var$MultiToggle;
4451
+ }, [
4452
+ ctx?.mode
4453
+ ]);
4454
+ return /*#__PURE__*/ (0, $8zHUo$reactjsxruntime.jsx)($fcb2cacda3f71fdc$var$ToggleContext.Provider, {
4455
+ value: {
4456
+ props: props
4457
+ },
4458
+ children: /*#__PURE__*/ (0, $8zHUo$reactjsxruntime.jsx)(Wrapper, {
4459
+ value: props.value,
4460
+ children: props.children
4461
+ })
4462
+ });
4463
+ }
4464
+ function $fcb2cacda3f71fdc$var$ToggleButton({ children: children, isFocusVisible: isFocusVisible, isSelected: isSelected, ...props }) {
4465
+ const ctx = $8zHUo$react.useContext($fcb2cacda3f71fdc$var$ToggleContext)?.props;
4466
+ const groupCtx = $8zHUo$react.useContext($fcb2cacda3f71fdc$var$ToggleGroupContext);
4467
+ if (!ctx || !groupCtx) throw new Error("Toggle must be used within a ToggleGroup");
4468
+ const theme = (0, $f2fd0cbe11b7f0dd$export$93d4e7f90805808f)();
4469
+ const space = (0, $eae337549f49a5a2$export$450c36e0b0e62ccd)();
4470
+ const idleColor = ctx.idleColor ?? groupCtx.props.idleColor ?? "gray";
4471
+ const activeColor = ctx.activeColor ?? groupCtx.props.activeColor ?? theme?.color ?? "gray";
4472
+ const idleVariant = ctx.idleVariant ?? groupCtx.props.idleVariant ?? "light";
4473
+ const activeVariant = ctx.activeVariant ?? groupCtx.props.activeVariant ?? "solid";
4474
+ const color = isSelected ? activeColor : idleColor;
4475
+ const variant = isSelected ? activeVariant : idleVariant;
4476
+ const radius = ctx.radius ?? groupCtx.props.radius ?? "full";
4477
+ const size = ctx.size ?? groupCtx.props.size ?? "md";
4478
+ return /*#__PURE__*/ (0, $8zHUo$reactjsxruntime.jsx)("label", {
4479
+ "data-icon-button": ctx.isIconButton,
4480
+ "data-is-toggle": true,
4481
+ "data-radius": radius,
4482
+ "data-color": color,
4483
+ "data-variant": variant,
4484
+ className: (0, $62f1c614c0962470$export$a274e22fb40f762e)("p-button", ctx.className, ctx.classNames?.wrapper, `size-${size}`, space.classNames),
4485
+ "data-selected": isSelected,
4486
+ "data-focus-visible": isFocusVisible,
4487
+ ...props,
4488
+ children: children
4489
+ });
4490
+ }
4491
+
4492
+
4493
+
4494
+
4495
+
4496
+
4324
4497
  //# sourceMappingURL=main.js.map