@overmap-ai/blocks 1.0.40-overlay.1 → 1.0.40

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.
@@ -0,0 +1,6 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ import * as RadixRadioGroup from "@radix-ui/react-radio-group";
3
+ export interface RatingItemProps extends Omit<ComponentPropsWithRef<typeof RadixRadioGroup.Item>, "value"> {
4
+ value: number;
5
+ }
6
+ export declare const RatingItem: import('react').NamedExoticComponent<RatingItemProps>;
@@ -0,0 +1,5 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ import * as RadixRadioGroup from "@radix-ui/react-radio-group";
3
+ export interface RatingItemIndicatorProps extends ComponentPropsWithRef<typeof RadixRadioGroup.Indicator> {
4
+ }
5
+ export declare const RatingItemIndicator: import('react').NamedExoticComponent<RatingItemIndicatorProps>;
@@ -0,0 +1,8 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ import * as RadixRadioGroup from "@radix-ui/react-radio-group";
3
+ export interface RatingRootProps extends Omit<ComponentPropsWithRef<typeof RadixRadioGroup.Root>, "defaultValue" | "value" | "onValueChange"> {
4
+ defaultValue?: number;
5
+ value?: number | null;
6
+ onValueChange?: (value: number) => void;
7
+ }
8
+ export declare const RatingRoot: import('react').NamedExoticComponent<RatingRootProps>;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ export interface IRatingRootContext {
3
+ value: number | null;
4
+ }
5
+ export declare const RatingRootContext: import('react').Context<IRatingRootContext>;
6
+ export interface IRatingItemContext {
7
+ value: number;
8
+ }
9
+ export declare const RatingItemContext: import('react').Context<IRatingItemContext>;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ export * from './Item';
3
+ export * from './ItemIndicator';
4
+ export * from './Root';
5
+ export declare const Rating: {
6
+ Item: import('react').NamedExoticComponent<import('./Item').RatingItemProps>;
7
+ ItemIndicator: import('react').NamedExoticComponent<import('./ItemIndicator').RatingItemIndicatorProps>;
8
+ Root: import('react').NamedExoticComponent<import('./Root').RatingRootProps>;
9
+ };
package/dist/blocks.js CHANGED
@@ -4373,6 +4373,65 @@ const RadioGroup = {
4373
4373
  Item: RadioGroupItem,
4374
4374
  Root: RadioGroupRoot
4375
4375
  };
4376
+ const RatingRootContext = createContext({});
4377
+ const RatingItemContext = createContext({});
4378
+ const RatingItem = memo((props) => {
4379
+ const { ref, children, value, ...rest } = props;
4380
+ const { value: activeValue } = use(RatingRootContext);
4381
+ const active = !!activeValue && value <= activeValue;
4382
+ const contextValue = useMemo(() => ({ value }), [value]);
4383
+ return /* @__PURE__ */ jsx(RadixRadioGroup.Item, { ref, value: value.toString(), "data-active": active, ...rest, children: /* @__PURE__ */ jsx(RatingItemContext, { value: contextValue, children }) });
4384
+ });
4385
+ RatingItem.displayName = "RatingItem";
4386
+ const RatingItemIndicator = memo((props) => {
4387
+ const { ref, children, forceMount, ...rest } = props;
4388
+ const { value: activeValue } = use(RatingRootContext);
4389
+ const { value } = use(RatingItemContext);
4390
+ const active = !!activeValue && value <= activeValue;
4391
+ return /* @__PURE__ */ jsx(
4392
+ RadixRadioGroup.Indicator,
4393
+ {
4394
+ ref,
4395
+ forceMount: forceMount ?? (active || void 0),
4396
+ "data-active": active,
4397
+ ...rest,
4398
+ children
4399
+ }
4400
+ );
4401
+ });
4402
+ RatingItemIndicator.displayName = "RatingItemIndicator";
4403
+ const RatingRoot = memo((props) => {
4404
+ const { ref, children, defaultValue, value: controlledValue, onValueChange, ...rest } = props;
4405
+ const [value, setValue] = useControlledState(defaultValue ?? null, controlledValue, onValueChange);
4406
+ const handleValueChange = useCallback(
4407
+ (value2) => {
4408
+ setValue(parseInt(value2));
4409
+ },
4410
+ [setValue]
4411
+ );
4412
+ const contextValue = useMemo(
4413
+ () => ({
4414
+ value
4415
+ }),
4416
+ [value]
4417
+ );
4418
+ return /* @__PURE__ */ jsx(
4419
+ RadixRadioGroup.Root,
4420
+ {
4421
+ ref,
4422
+ value: value ? value.toString() : null,
4423
+ onValueChange: handleValueChange,
4424
+ ...rest,
4425
+ children: /* @__PURE__ */ jsx(RatingRootContext, { value: contextValue, children })
4426
+ }
4427
+ );
4428
+ });
4429
+ RatingRoot.displayName = "RatingRoot";
4430
+ const Rating = {
4431
+ Item: RatingItem,
4432
+ ItemIndicator: RatingItemIndicator,
4433
+ Root: RatingRoot
4434
+ };
4376
4435
  const segmentedControlRootCva = cva(
4377
4436
  ["shrink-0", "transition-colors", "inline-flex", "box-border", "min-w-max", "text-center"],
4378
4437
  {
@@ -6250,6 +6309,10 @@ export {
6250
6309
  RadioGroupIndicator,
6251
6310
  RadioGroupItem,
6252
6311
  RadioGroupRoot,
6312
+ Rating,
6313
+ RatingItem,
6314
+ RatingItemIndicator,
6315
+ RatingRoot,
6253
6316
  SegmentedControl,
6254
6317
  SegmentedControlItem,
6255
6318
  SegmentedControlRoot,