@noya-app/noya-designsystem 0.1.29 → 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];
@@ -15048,7 +15048,7 @@ var TreeView;
15048
15048
 
15049
15049
  // src/components/WorkspaceLayout.tsx
15050
15050
  import { useKeyboardShortcuts as useKeyboardShortcuts3 } from "@noya-app/noya-keymap";
15051
- import React71, { forwardRef as forwardRef20, memo as memo32, useImperativeHandle as useImperativeHandle4, useRef as useRef22 } from "react";
15051
+ import React71, { forwardRef as forwardRef20, useImperativeHandle as useImperativeHandle4, useRef as useRef22 } from "react";
15052
15052
  import {
15053
15053
  Panel,
15054
15054
  PanelGroup,
@@ -15370,8 +15370,8 @@ var WorkspaceLayoutWithTheme = forwardRef20(function WorkspaceLayoutWithTheme2({
15370
15370
  )
15371
15371
  );
15372
15372
  });
15373
- var WorkspaceLayout = memo32(function WorkspaceLayout2(props) {
15374
- return /* @__PURE__ */ React71.createElement(DesignSystemThemeProvider, null, /* @__PURE__ */ React71.createElement(WorkspaceLayoutWithTheme, { ...props }));
15373
+ var WorkspaceLayout = forwardRef20(function WorkspaceLayout2(props, forwardedRef) {
15374
+ return /* @__PURE__ */ React71.createElement(DesignSystemThemeProvider, null, /* @__PURE__ */ React71.createElement(WorkspaceLayoutWithTheme, { ...props, ref: forwardedRef }));
15375
15375
  });
15376
15376
 
15377
15377
  // src/hooks/usePlatform.ts
@@ -15414,10 +15414,41 @@ var SUPPORTED_CANVAS_UPLOAD_TYPES = [
15414
15414
  ""
15415
15415
  ];
15416
15416
 
15417
- // src/components/ArrayController.tsx
15418
- import { range as range2 } from "@noya-app/noya-utils";
15419
- import React73, { memo as memo34, useCallback as useCallback27, useMemo as useMemo24 } from "react";
15420
- 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
+ });
15421
15452
 
15422
15453
  // src/components/InspectorPrimitives.tsx
15423
15454
  var InspectorPrimitives_exports = {};
@@ -15435,7 +15466,7 @@ __export(InspectorPrimitives_exports, {
15435
15466
  Title: () => Title3,
15436
15467
  VerticalSeparator: () => VerticalSeparator
15437
15468
  });
15438
- import React72, { memo as memo33 } from "react";
15469
+ import React73, { memo as memo33 } from "react";
15439
15470
  import styled35, { useTheme as useTheme4 } from "styled-components";
15440
15471
  var Section2 = styled35.div(({ theme, $padding = "10px", $gap }) => ({
15441
15472
  flex: "0 0 auto",
@@ -15482,8 +15513,8 @@ var Checkbox = styled35.input(({ theme }) => ({
15482
15513
  var Text3 = styled35.span(({ theme }) => ({
15483
15514
  ...theme.textStyles.small
15484
15515
  }));
15485
- var VerticalSeparator = () => /* @__PURE__ */ React72.createElement(Spacer.Vertical, { size: useTheme4().sizes.inspector.verticalSeparator });
15486
- 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 });
15487
15518
  var SliderRowLabel = styled35.span(({ theme }) => ({
15488
15519
  ...theme.textStyles.small,
15489
15520
  color: theme.colors.textMuted,
@@ -15511,155 +15542,16 @@ var LabeledRow = memo33(function LabeledRow2({
15511
15542
  gap,
15512
15543
  right
15513
15544
  }) {
15514
- 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)));
15515
15546
  });
15516
15547
  var LabeledSliderRow = memo33(function LabeledRow3({
15517
15548
  children: children2,
15518
15549
  label
15519
15550
  }) {
15520
- return /* @__PURE__ */ React72.createElement(Row2, null, /* @__PURE__ */ React72.createElement(Column2, null, /* @__PURE__ */ React72.createElement(SliderRowLabel, null, label), /* @__PURE__ */ React72.createElement(Row2, null, children2)));
15521
- });
15522
-
15523
- // src/components/ArrayController.tsx
15524
- var ElementRow = styled36.div({
15525
- flex: "0 0 auto",
15526
- display: "flex",
15527
- flexDirection: "row",
15528
- alignItems: "center"
15529
- });
15530
- var ItemContainer2 = styled36.div({
15531
- position: "relative"
15532
- });
15533
- var ArrayController = memo34(function ArrayController2({
15534
- id,
15535
- items,
15536
- title,
15537
- sortable = false,
15538
- reversed = true,
15539
- expanded = false,
15540
- getKey,
15541
- onMoveItem,
15542
- onClickPlus,
15543
- onClickTrash,
15544
- onClickExpand,
15545
- renderItem,
15546
- renderExpandedContent,
15547
- padding = 10
15548
- }) {
15549
- const iconColor = useTheme5().colors.icon;
15550
- const primaryLightColor = useTheme5().colors.primaryLight;
15551
- const keys = useMemo24(
15552
- () => items.map((item, index) => getKey?.(item) ?? index.toString()),
15553
- [getKey, items]
15554
- );
15555
- const indexes = reversed ? range2(0, items.length).reverse() : range2(0, items.length);
15556
- const handleMoveItem = useCallback27(
15557
- (sourceIndex, destinationIndex, position) => {
15558
- if (reversed) {
15559
- if (position === "above") {
15560
- position = "below";
15561
- } else if (position === "below") {
15562
- position = "above";
15563
- }
15564
- }
15565
- onMoveItem?.(
15566
- sourceIndex,
15567
- position === "below" ? destinationIndex + 1 : destinationIndex
15568
- );
15569
- },
15570
- [onMoveItem, reversed]
15571
- );
15572
- const renderRow = (index) => {
15573
- return /* @__PURE__ */ React73.createElement(ElementRow, { key: keys[index] }, renderItem({ item: items[index], index }));
15574
- };
15575
- 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(
15576
- [
15577
- onClickTrash && /* @__PURE__ */ React73.createElement(
15578
- IconButton,
15579
- {
15580
- id: `${id}-trash`,
15581
- iconName: "TrashIcon",
15582
- color: iconColor,
15583
- onClick: onClickTrash
15584
- }
15585
- ),
15586
- onClickExpand && /* @__PURE__ */ React73.createElement(
15587
- IconButton,
15588
- {
15589
- id: `${id}-gear`,
15590
- iconName: "GearIcon",
15591
- color: expanded ? primaryLightColor : iconColor,
15592
- onClick: onClickExpand
15593
- }
15594
- ),
15595
- onClickPlus && /* @__PURE__ */ React73.createElement(
15596
- IconButton,
15597
- {
15598
- id: `${id}-add`,
15599
- iconName: "PlusIcon",
15600
- color: iconColor,
15601
- onClick: onClickPlus
15602
- }
15603
- )
15604
- ],
15605
- /* @__PURE__ */ React73.createElement(Spacer.Horizontal, { size: 8 })
15606
- )), /* @__PURE__ */ React73.createElement(Stack.V, { gap: "4px" }, sortable ? /* @__PURE__ */ React73.createElement(
15607
- Sortable.Root,
15608
- {
15609
- keys,
15610
- renderOverlay: renderRow,
15611
- onMoveItem: handleMoveItem
15612
- },
15613
- 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(
15614
- ListView.DragIndicator,
15615
- {
15616
- $gap: 0,
15617
- $colorScheme: "primary",
15618
- $relativeDropPosition: relativeDropPosition,
15619
- $offsetLeft: 0
15620
- }
15621
- ))))
15622
- ) : indexes.map(renderRow)), expanded && renderExpandedContent?.());
15623
- });
15624
-
15625
- // src/components/DimensionInput.tsx
15626
- import { round } from "@noya-app/noya-utils";
15627
- import React74, { memo as memo35, useCallback as useCallback28 } from "react";
15628
- function getNewValue(value, mode, delta) {
15629
- return delta === void 0 ? value : mode === "replace" ? delta : value + delta;
15630
- }
15631
- var DimensionInput = memo35(function DimensionInput2({
15632
- id,
15633
- value,
15634
- onSetValue,
15635
- label,
15636
- size: size3,
15637
- placeholder = "multi",
15638
- disabled,
15639
- trigger = "submit"
15640
- }) {
15641
- const handleNudgeValue = useCallback28(
15642
- (value2) => onSetValue(value2, "adjust"),
15643
- [onSetValue]
15644
- );
15645
- const handleSetValue = useCallback28(
15646
- (value2) => onSetValue(value2, "replace"),
15647
- [onSetValue]
15648
- );
15649
- return /* @__PURE__ */ React74.createElement(InputField.Root, { id, width: size3 }, /* @__PURE__ */ React74.createElement(
15650
- InputField.NumberInput,
15651
- {
15652
- value: value === void 0 ? value : round(value, 2),
15653
- placeholder: value === void 0 ? placeholder : void 0,
15654
- onNudge: handleNudgeValue,
15655
- disabled,
15656
- ...trigger === "change" ? { onChange: handleSetValue } : { onSubmit: handleSetValue }
15657
- }
15658
- ), 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)));
15659
15552
  });
15660
15553
  export {
15661
15554
  ActivityIndicator,
15662
- ArrayController,
15663
15555
  AutoResizingTextArea,
15664
15556
  Avatar,
15665
15557
  AvatarStack,