@noya-app/noya-designsystem 0.1.28 → 0.1.30

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/index.mjs CHANGED
@@ -5446,44 +5446,44 @@ var sizes2 = {
5446
5446
  gap: 32
5447
5447
  }
5448
5448
  };
5449
- var Grid2 = styled22.div(({ theme, size: size3, padding }) => {
5449
+ var Grid2 = styled22.div(({ theme, $size, $padding }) => {
5450
5450
  return {
5451
5451
  color: theme.colors.text,
5452
5452
  display: "grid",
5453
- gridTemplateColumns: `repeat(auto-fill, minmax(${sizes2[size3].itemWidth}px, 1fr))`,
5453
+ gridTemplateColumns: `repeat(auto-fill, minmax(${sizes2[$size].itemWidth}px, 1fr))`,
5454
5454
  // gridAutoRows: `${sizes[size].itemHeight}px`,
5455
- gap: `${sizes2[size3].gap}px`,
5455
+ gap: `${sizes2[$size].gap}px`,
5456
5456
  // gridTemplateColumns: `repeat(auto-fill, minmax(
5457
5457
  // ${size === 'large' ? '280px' : size === 'small' ? '160px' : '116px'}
5458
5458
  // , 1fr))`,
5459
5459
  // gridAutoRows:
5460
5460
  // size === 'large' ? '280px' : size === 'small' ? '170px' : '116px',
5461
5461
  // gap: size === 'large' || size === 'small' ? `20px` : `12px`,
5462
- padding
5462
+ padding: $padding
5463
5463
  };
5464
5464
  });
5465
5465
  var Container3 = styled22.div(
5466
- ({ theme, scrollable }) => ({
5467
- flex: scrollable ? "1" : "0 0 auto",
5466
+ ({ theme, $scrollable }) => ({
5467
+ flex: $scrollable ? "1" : "0 0 auto",
5468
5468
  display: "flex",
5469
5469
  flexDirection: "column"
5470
5470
  })
5471
5471
  );
5472
- var ContentContainer = styled22.div(({ theme, selected, hovered, bordered, disabled }) => ({
5472
+ var ContentContainer = styled22.div(({ theme, $selected, $hovered, $bordered, $disabled }) => ({
5473
5473
  display: "flex",
5474
5474
  flex: "1",
5475
5475
  backgroundColor: theme.colors.sidebar.background,
5476
5476
  alignItems: "center",
5477
5477
  justifyContent: "center",
5478
5478
  borderRadius: "2px",
5479
- border: `1px solid ${selected ? theme.colors.primary : (
5479
+ border: `1px solid ${$selected ? theme.colors.primary : (
5480
5480
  // : hovered
5481
5481
  // ? `rgb(132, 63, 255, 0.5)`
5482
- bordered ? theme.colors.divider : "transparent"
5482
+ $bordered ? theme.colors.divider : "transparent"
5483
5483
  )}`,
5484
5484
  overflow: "hidden",
5485
5485
  cursor: "pointer",
5486
- ...disabled ? { opacity: 0.5 } : {
5486
+ ...$disabled ? { opacity: 0.5 } : {
5487
5487
  "&:hover": { opacity: 0.85 },
5488
5488
  "&:active": { opacity: 0.7 }
5489
5489
  }
@@ -5498,7 +5498,7 @@ var ItemContainer = styled22.div(({ theme }) => ({
5498
5498
  }
5499
5499
  }));
5500
5500
  var ItemTitle = styled22.span(
5501
- ({ theme, showBackground }) => ({
5501
+ ({ theme, $showBackground }) => ({
5502
5502
  ...theme.textStyles.small,
5503
5503
  lineHeight: "1",
5504
5504
  color: theme.colors.text,
@@ -5507,7 +5507,7 @@ var ItemTitle = styled22.span(
5507
5507
  whiteSpace: "pre",
5508
5508
  overflow: "hidden",
5509
5509
  textOverflow: "ellipsis",
5510
- ...showBackground && {
5510
+ ...$showBackground && {
5511
5511
  background: theme.colors.sidebar.background,
5512
5512
  // border: `1px solid ${theme.colors.dividerSubtle}`,
5513
5513
  padding: "2px 4px",
@@ -5517,7 +5517,7 @@ var ItemTitle = styled22.span(
5517
5517
  })
5518
5518
  );
5519
5519
  var ItemDescription = styled22.span(
5520
- ({ theme, showBackground }) => ({
5520
+ ({ theme, $showBackground }) => ({
5521
5521
  ...theme.textStyles.small,
5522
5522
  fontSize: "0.7rem",
5523
5523
  lineHeight: "1",
@@ -5526,7 +5526,7 @@ var ItemDescription = styled22.span(
5526
5526
  whiteSpace: "pre",
5527
5527
  overflow: "hidden",
5528
5528
  textOverflow: "ellipsis",
5529
- ...showBackground && {
5529
+ ...$showBackground && {
5530
5530
  background: theme.colors.sidebar.background,
5531
5531
  // border: `1px solid ${theme.colors.dividerSubtle}`,
5532
5532
  padding: "2px 4px",
@@ -5647,10 +5647,10 @@ var GridViewItem = forwardRef12(function GridViewItem2({
5647
5647
  /* @__PURE__ */ React33.createElement(
5648
5648
  ContentContainer,
5649
5649
  {
5650
- disabled,
5651
- bordered,
5652
- selected,
5653
- hovered: !disabled && hovered,
5650
+ $disabled: disabled,
5651
+ $bordered: bordered,
5652
+ $selected: selected,
5653
+ $hovered: !disabled && hovered,
5654
5654
  onClick: handleClick,
5655
5655
  onDoubleClick,
5656
5656
  onContextMenu,
@@ -5658,8 +5658,8 @@ var GridViewItem = forwardRef12(function GridViewItem2({
5658
5658
  },
5659
5659
  children2
5660
5660
  ),
5661
- textPosition === "below" && /* @__PURE__ */ React33.createElement(React33.Fragment, null, /* @__PURE__ */ React33.createElement(Spacer.Vertical, { size: 8 }), /* @__PURE__ */ React33.createElement(ItemTitle, { showBackground: false }, title || " "), /* @__PURE__ */ React33.createElement(ItemDescription, { showBackground: false }, subtitle || " ")),
5662
- textPosition === "overlay" && hovered && (title || subtitle) && /* @__PURE__ */ React33.createElement(TextOverlay, null, title && /* @__PURE__ */ React33.createElement(ItemTitle, { showBackground: true }, title), subtitle && /* @__PURE__ */ React33.createElement(ItemDescription, { showBackground: true }, subtitle)),
5661
+ textPosition === "below" && /* @__PURE__ */ React33.createElement(React33.Fragment, null, /* @__PURE__ */ React33.createElement(Spacer.Vertical, { size: 8 }), /* @__PURE__ */ React33.createElement(ItemTitle, { $showBackground: false }, title || " "), /* @__PURE__ */ React33.createElement(ItemDescription, { $showBackground: false }, subtitle || " ")),
5662
+ textPosition === "overlay" && hovered && (title || subtitle) && /* @__PURE__ */ React33.createElement(TextOverlay, null, title && /* @__PURE__ */ React33.createElement(ItemTitle, { $showBackground: true }, title), subtitle && /* @__PURE__ */ React33.createElement(ItemDescription, { $showBackground: true }, subtitle)),
5663
5663
  loading && /* @__PURE__ */ React33.createElement(Shimmer, null, /* @__PURE__ */ React33.createElement(ActivityIndicator, { opacity: 0.5, size: 13 }))
5664
5664
  );
5665
5665
  if (menuItems && onSelectMenuItem) {
@@ -5669,7 +5669,7 @@ var GridViewItem = forwardRef12(function GridViewItem2({
5669
5669
  element = /* @__PURE__ */ React33.createElement(
5670
5670
  Tooltip,
5671
5671
  {
5672
- content: /* @__PURE__ */ React33.createElement(Stack.V, { gap: 2 }, /* @__PURE__ */ React33.createElement(ItemTitle, { showBackground: false }, title), /* @__PURE__ */ React33.createElement(ItemDescription, { showBackground: false }, subtitle))
5672
+ content: /* @__PURE__ */ React33.createElement(Stack.V, { gap: 2 }, /* @__PURE__ */ React33.createElement(ItemTitle, { $showBackground: false }, title), /* @__PURE__ */ React33.createElement(ItemDescription, { $showBackground: false }, subtitle))
5673
5673
  },
5674
5674
  element
5675
5675
  );
@@ -5708,14 +5708,14 @@ function GridViewRoot({
5708
5708
  }),
5709
5709
  [bordered, disabled, size3, textPosition]
5710
5710
  );
5711
- return /* @__PURE__ */ React33.createElement(GridViewContext.Provider, { value: contextValue }, /* @__PURE__ */ React33.createElement(Container3, { onClick: handleClick, scrollable }, scrollable ? /* @__PURE__ */ React33.createElement(ScrollArea, null, children2) : children2));
5711
+ return /* @__PURE__ */ React33.createElement(GridViewContext.Provider, { value: contextValue }, /* @__PURE__ */ React33.createElement(Container3, { onClick: handleClick, $scrollable: scrollable }, scrollable ? /* @__PURE__ */ React33.createElement(ScrollArea, null, children2) : children2));
5712
5712
  }
5713
5713
  function GridViewSection({
5714
5714
  children: children2,
5715
5715
  padding = "20px"
5716
5716
  }) {
5717
5717
  const { size: size3 } = useContext7(GridViewContext);
5718
- return /* @__PURE__ */ React33.createElement(Grid2, { size: size3, padding }, children2);
5718
+ return /* @__PURE__ */ React33.createElement(Grid2, { $size: size3, $padding: padding }, children2);
5719
5719
  }
5720
5720
  function GridViewSectionHeader({ title }) {
5721
5721
  const grouped = title.split("/");
@@ -5802,14 +5802,14 @@ function mergeRanges(ranges) {
5802
5802
  const merged = [];
5803
5803
  const sorted = [...ranges].sort((a, b) => a.start - b.start);
5804
5804
  let current;
5805
- for (const range3 of sorted) {
5805
+ for (const range2 of sorted) {
5806
5806
  if (!current) {
5807
- current = range3;
5808
- } else if (range3.start <= current.end) {
5809
- current.end = Math.max(current.end, range3.end);
5807
+ current = range2;
5808
+ } else if (range2.start <= current.end) {
5809
+ current.end = Math.max(current.end, range2.end);
5810
5810
  } else {
5811
5811
  merged.push(current);
5812
- current = range3;
5812
+ current = range2;
5813
5813
  }
5814
5814
  }
5815
5815
  if (current) {
@@ -10462,7 +10462,7 @@ var PositionCache = /* @__PURE__ */ function() {
10462
10462
  // Render all cells visible within the viewport range defined.
10463
10463
  }, {
10464
10464
  key: "range",
10465
- value: function range3(scrollTop, clientHeight, renderCallback) {
10465
+ value: function range2(scrollTop, clientHeight, renderCallback) {
10466
10466
  var _this = this;
10467
10467
  this._intervalTree.queryInterval(scrollTop, scrollTop + clientHeight, function(_ref) {
10468
10468
  var _ref2 = (0, import_slicedToArray.default)(_ref, 3), top = _ref2[0], _ = _ref2[1], index = _ref2[2];
@@ -15189,7 +15189,7 @@ function usePreservePanelSize(panelGroupRef, setPanelLayoutState) {
15189
15189
  }
15190
15190
 
15191
15191
  // src/components/WorkspaceLayout.tsx
15192
- var WorkspaceLayout = forwardRef20(function WorkspaceLayout2({
15192
+ var WorkspaceLayoutWithTheme = forwardRef20(function WorkspaceLayoutWithTheme2({
15193
15193
  autoSavePrefix,
15194
15194
  leftSidebarContent: leftPanelContent,
15195
15195
  children: centerPanelContent,
@@ -15370,6 +15370,9 @@ var WorkspaceLayout = forwardRef20(function WorkspaceLayout2({
15370
15370
  )
15371
15371
  );
15372
15372
  });
15373
+ var WorkspaceLayout = forwardRef20(function WorkspaceLayout2(props, forwardedRef) {
15374
+ return /* @__PURE__ */ React71.createElement(DesignSystemThemeProvider, null, /* @__PURE__ */ React71.createElement(WorkspaceLayoutWithTheme, { ...props, ref: forwardedRef }));
15375
+ });
15373
15376
 
15374
15377
  // src/hooks/usePlatform.ts
15375
15378
  function usePlatform() {
@@ -15411,10 +15414,41 @@ var SUPPORTED_CANVAS_UPLOAD_TYPES = [
15411
15414
  ""
15412
15415
  ];
15413
15416
 
15414
- // src/components/ArrayController.tsx
15415
- import { range as range2 } from "@noya-app/noya-utils";
15416
- import React73, { memo as memo33, useCallback as useCallback27, useMemo as useMemo24 } from "react";
15417
- import styled36, { useTheme as useTheme5 } from "styled-components";
15417
+ // src/components/DimensionInput.tsx
15418
+ import { round } from "@noya-app/noya-utils";
15419
+ import React72, { memo as memo32, useCallback as useCallback27 } from "react";
15420
+ function getNewValue(value, mode, delta) {
15421
+ return delta === void 0 ? value : mode === "replace" ? delta : value + delta;
15422
+ }
15423
+ var DimensionInput = memo32(function DimensionInput2({
15424
+ id,
15425
+ value,
15426
+ onSetValue,
15427
+ label,
15428
+ size: size3,
15429
+ placeholder = "multi",
15430
+ disabled,
15431
+ trigger = "submit"
15432
+ }) {
15433
+ const handleNudgeValue = useCallback27(
15434
+ (value2) => onSetValue(value2, "adjust"),
15435
+ [onSetValue]
15436
+ );
15437
+ const handleSetValue = useCallback27(
15438
+ (value2) => onSetValue(value2, "replace"),
15439
+ [onSetValue]
15440
+ );
15441
+ return /* @__PURE__ */ React72.createElement(InputField.Root, { id, width: size3 }, /* @__PURE__ */ React72.createElement(
15442
+ InputField.NumberInput,
15443
+ {
15444
+ value: value === void 0 ? value : round(value, 2),
15445
+ placeholder: value === void 0 ? placeholder : void 0,
15446
+ onNudge: handleNudgeValue,
15447
+ disabled,
15448
+ ...trigger === "change" ? { onChange: handleSetValue } : { onSubmit: handleSetValue }
15449
+ }
15450
+ ), label && /* @__PURE__ */ React72.createElement(InputField.Label, null, label));
15451
+ });
15418
15452
 
15419
15453
  // src/components/InspectorPrimitives.tsx
15420
15454
  var InspectorPrimitives_exports = {};
@@ -15432,7 +15466,7 @@ __export(InspectorPrimitives_exports, {
15432
15466
  Title: () => Title3,
15433
15467
  VerticalSeparator: () => VerticalSeparator
15434
15468
  });
15435
- import React72, { memo as memo32 } from "react";
15469
+ import React73, { memo as memo33 } from "react";
15436
15470
  import styled35, { useTheme as useTheme4 } from "styled-components";
15437
15471
  var Section2 = styled35.div(({ theme, $padding = "10px", $gap }) => ({
15438
15472
  flex: "0 0 auto",
@@ -15479,8 +15513,8 @@ var Checkbox = styled35.input(({ theme }) => ({
15479
15513
  var Text3 = styled35.span(({ theme }) => ({
15480
15514
  ...theme.textStyles.small
15481
15515
  }));
15482
- var VerticalSeparator = () => /* @__PURE__ */ React72.createElement(Spacer.Vertical, { size: useTheme4().sizes.inspector.verticalSeparator });
15483
- var HorizontalSeparator = () => /* @__PURE__ */ React72.createElement(Spacer.Horizontal, { size: useTheme4().sizes.inspector.horizontalSeparator });
15516
+ var VerticalSeparator = () => /* @__PURE__ */ React73.createElement(Spacer.Vertical, { size: useTheme4().sizes.inspector.verticalSeparator });
15517
+ var HorizontalSeparator = () => /* @__PURE__ */ React73.createElement(Spacer.Horizontal, { size: useTheme4().sizes.inspector.horizontalSeparator });
15484
15518
  var SliderRowLabel = styled35.span(({ theme }) => ({
15485
15519
  ...theme.textStyles.small,
15486
15520
  color: theme.colors.textMuted,
@@ -15500,7 +15534,7 @@ var RowLabel = styled35.span(({ theme, $textStyle }) => ({
15500
15534
  // Button height
15501
15535
  alignItems: "center"
15502
15536
  }));
15503
- var LabeledRow = memo32(function LabeledRow2({
15537
+ var LabeledRow = memo33(function LabeledRow2({
15504
15538
  id,
15505
15539
  children: children2,
15506
15540
  label,
@@ -15508,155 +15542,16 @@ var LabeledRow = memo32(function LabeledRow2({
15508
15542
  gap,
15509
15543
  right
15510
15544
  }) {
15511
- return /* @__PURE__ */ React72.createElement(Row2, { id }, /* @__PURE__ */ React72.createElement(Column2, null, /* @__PURE__ */ React72.createElement(RowLabel, { $textStyle: labelTextStyle }, label, right && /* @__PURE__ */ React72.createElement(Spacer.Horizontal, null), right), /* @__PURE__ */ React72.createElement(Row2, { $gap: gap }, children2)));
15545
+ return /* @__PURE__ */ React73.createElement(Row2, { id }, /* @__PURE__ */ React73.createElement(Column2, null, /* @__PURE__ */ React73.createElement(RowLabel, { $textStyle: labelTextStyle }, label, right && /* @__PURE__ */ React73.createElement(Spacer.Horizontal, null), right), /* @__PURE__ */ React73.createElement(Row2, { $gap: gap }, children2)));
15512
15546
  });
15513
- var LabeledSliderRow = memo32(function LabeledRow3({
15547
+ var LabeledSliderRow = memo33(function LabeledRow3({
15514
15548
  children: children2,
15515
15549
  label
15516
15550
  }) {
15517
- return /* @__PURE__ */ React72.createElement(Row2, null, /* @__PURE__ */ React72.createElement(Column2, null, /* @__PURE__ */ React72.createElement(SliderRowLabel, null, label), /* @__PURE__ */ React72.createElement(Row2, null, children2)));
15518
- });
15519
-
15520
- // src/components/ArrayController.tsx
15521
- var ElementRow = styled36.div({
15522
- flex: "0 0 auto",
15523
- display: "flex",
15524
- flexDirection: "row",
15525
- alignItems: "center"
15526
- });
15527
- var ItemContainer2 = styled36.div({
15528
- position: "relative"
15529
- });
15530
- var ArrayController = memo33(function ArrayController2({
15531
- id,
15532
- items,
15533
- title,
15534
- sortable = false,
15535
- reversed = true,
15536
- expanded = false,
15537
- getKey,
15538
- onMoveItem,
15539
- onClickPlus,
15540
- onClickTrash,
15541
- onClickExpand,
15542
- renderItem,
15543
- renderExpandedContent,
15544
- padding = 10
15545
- }) {
15546
- const iconColor = useTheme5().colors.icon;
15547
- const primaryLightColor = useTheme5().colors.primaryLight;
15548
- const keys = useMemo24(
15549
- () => items.map((item, index) => getKey?.(item) ?? index.toString()),
15550
- [getKey, items]
15551
- );
15552
- const indexes = reversed ? range2(0, items.length).reverse() : range2(0, items.length);
15553
- const handleMoveItem = useCallback27(
15554
- (sourceIndex, destinationIndex, position) => {
15555
- if (reversed) {
15556
- if (position === "above") {
15557
- position = "below";
15558
- } else if (position === "below") {
15559
- position = "above";
15560
- }
15561
- }
15562
- onMoveItem?.(
15563
- sourceIndex,
15564
- position === "below" ? destinationIndex + 1 : destinationIndex
15565
- );
15566
- },
15567
- [onMoveItem, reversed]
15568
- );
15569
- const renderRow = (index) => {
15570
- return /* @__PURE__ */ React73.createElement(ElementRow, { key: keys[index] }, renderItem({ item: items[index], index }));
15571
- };
15572
- return /* @__PURE__ */ React73.createElement(Section2, { id, $padding: padding, $gap: "2px" }, /* @__PURE__ */ React73.createElement(SectionHeader, null, /* @__PURE__ */ React73.createElement(Button, { variant: "none", onClick: onClickPlus }, /* @__PURE__ */ React73.createElement(Title3, null, title)), /* @__PURE__ */ React73.createElement(Spacer.Horizontal, null), withSeparatorElements(
15573
- [
15574
- onClickTrash && /* @__PURE__ */ React73.createElement(
15575
- IconButton,
15576
- {
15577
- id: `${id}-trash`,
15578
- iconName: "TrashIcon",
15579
- color: iconColor,
15580
- onClick: onClickTrash
15581
- }
15582
- ),
15583
- onClickExpand && /* @__PURE__ */ React73.createElement(
15584
- IconButton,
15585
- {
15586
- id: `${id}-gear`,
15587
- iconName: "GearIcon",
15588
- color: expanded ? primaryLightColor : iconColor,
15589
- onClick: onClickExpand
15590
- }
15591
- ),
15592
- onClickPlus && /* @__PURE__ */ React73.createElement(
15593
- IconButton,
15594
- {
15595
- id: `${id}-add`,
15596
- iconName: "PlusIcon",
15597
- color: iconColor,
15598
- onClick: onClickPlus
15599
- }
15600
- )
15601
- ],
15602
- /* @__PURE__ */ React73.createElement(Spacer.Horizontal, { size: 8 })
15603
- )), /* @__PURE__ */ React73.createElement(Stack.V, { gap: "4px" }, sortable ? /* @__PURE__ */ React73.createElement(
15604
- Sortable.Root,
15605
- {
15606
- keys,
15607
- renderOverlay: renderRow,
15608
- onMoveItem: handleMoveItem
15609
- },
15610
- indexes.map((index) => /* @__PURE__ */ React73.createElement(Sortable.Item, { id: keys[index], key: keys[index] }, ({ relativeDropPosition, ...sortableProps }) => /* @__PURE__ */ React73.createElement(ItemContainer2, { ...sortableProps }, renderRow(index), relativeDropPosition && /* @__PURE__ */ React73.createElement(
15611
- ListView.DragIndicator,
15612
- {
15613
- $gap: 0,
15614
- $colorScheme: "primary",
15615
- $relativeDropPosition: relativeDropPosition,
15616
- $offsetLeft: 0
15617
- }
15618
- ))))
15619
- ) : indexes.map(renderRow)), expanded && renderExpandedContent?.());
15620
- });
15621
-
15622
- // src/components/DimensionInput.tsx
15623
- import { round } from "@noya-app/noya-utils";
15624
- import React74, { memo as memo34, useCallback as useCallback28 } from "react";
15625
- function getNewValue(value, mode, delta) {
15626
- return delta === void 0 ? value : mode === "replace" ? delta : value + delta;
15627
- }
15628
- var DimensionInput = memo34(function DimensionInput2({
15629
- id,
15630
- value,
15631
- onSetValue,
15632
- label,
15633
- size: size3,
15634
- placeholder = "multi",
15635
- disabled,
15636
- trigger = "submit"
15637
- }) {
15638
- const handleNudgeValue = useCallback28(
15639
- (value2) => onSetValue(value2, "adjust"),
15640
- [onSetValue]
15641
- );
15642
- const handleSetValue = useCallback28(
15643
- (value2) => onSetValue(value2, "replace"),
15644
- [onSetValue]
15645
- );
15646
- return /* @__PURE__ */ React74.createElement(InputField.Root, { id, width: size3 }, /* @__PURE__ */ React74.createElement(
15647
- InputField.NumberInput,
15648
- {
15649
- value: value === void 0 ? value : round(value, 2),
15650
- placeholder: value === void 0 ? placeholder : void 0,
15651
- onNudge: handleNudgeValue,
15652
- disabled,
15653
- ...trigger === "change" ? { onChange: handleSetValue } : { onSubmit: handleSetValue }
15654
- }
15655
- ), label && /* @__PURE__ */ React74.createElement(InputField.Label, null, label));
15551
+ return /* @__PURE__ */ React73.createElement(Row2, null, /* @__PURE__ */ React73.createElement(Column2, null, /* @__PURE__ */ React73.createElement(SliderRowLabel, null, label), /* @__PURE__ */ React73.createElement(Row2, null, children2)));
15656
15552
  });
15657
15553
  export {
15658
15554
  ActivityIndicator,
15659
- ArrayController,
15660
15555
  AutoResizingTextArea,
15661
15556
  Avatar,
15662
15557
  AvatarStack,