@plasmicpkgs/react-aria 0.0.29 → 0.0.31

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.
Files changed (173) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/contexts.d.ts +3 -0
  3. package/dist/react-aria.esm.js +1759 -924
  4. package/dist/react-aria.esm.js.map +1 -1
  5. package/dist/react-aria.js +1758 -923
  6. package/dist/react-aria.js.map +1 -1
  7. package/dist/registerButton.d.ts +1 -0
  8. package/dist/registerCheckbox.d.ts +8 -2
  9. package/dist/registerCheckboxGroup.d.ts +2 -2
  10. package/dist/registerDescription.d.ts +2 -1
  11. package/dist/registerDialogTrigger.d.ts +1 -2
  12. package/dist/registerHeader.d.ts +1 -1
  13. package/dist/registerInput.d.ts +1 -0
  14. package/dist/registerListBox.d.ts +3 -6
  15. package/dist/registerListBoxItem.d.ts +3 -1
  16. package/dist/registerModal.d.ts +3 -1
  17. package/dist/registerPopover.d.ts +3 -0
  18. package/dist/registerRadio.d.ts +5 -2
  19. package/dist/registerRadioGroup.d.ts +3 -3
  20. package/dist/registerSection.d.ts +1 -1
  21. package/dist/registerSelect.d.ts +5 -2
  22. package/dist/registerText.d.ts +2 -1
  23. package/dist/registerTextField.d.ts +1 -0
  24. package/dist/registerTooltip.d.ts +2 -1
  25. package/dist/utils.d.ts +9 -2
  26. package/package.json +2 -2
  27. package/skinny/contexts-9475faad.esm.js +16 -0
  28. package/skinny/contexts-9475faad.esm.js.map +1 -0
  29. package/skinny/{contexts-dd0ce341.cjs.js → contexts-b21f6b12.cjs.js} +7 -1
  30. package/skinny/contexts-b21f6b12.cjs.js.map +1 -0
  31. package/skinny/contexts.d.ts +3 -0
  32. package/skinny/registerButton.cjs.js +19 -4
  33. package/skinny/registerButton.cjs.js.map +1 -1
  34. package/skinny/registerButton.d.ts +1 -0
  35. package/skinny/registerButton.esm.js +19 -5
  36. package/skinny/registerButton.esm.js.map +1 -1
  37. package/skinny/registerCheckbox.cjs.js +75 -6
  38. package/skinny/registerCheckbox.cjs.js.map +1 -1
  39. package/skinny/registerCheckbox.d.ts +8 -2
  40. package/skinny/registerCheckbox.esm.js +75 -7
  41. package/skinny/registerCheckbox.esm.js.map +1 -1
  42. package/skinny/registerCheckboxGroup.cjs.js +89 -13
  43. package/skinny/registerCheckboxGroup.cjs.js.map +1 -1
  44. package/skinny/registerCheckboxGroup.d.ts +2 -2
  45. package/skinny/registerCheckboxGroup.esm.js +88 -16
  46. package/skinny/registerCheckboxGroup.esm.js.map +1 -1
  47. package/skinny/registerComboBox.cjs.js +113 -8
  48. package/skinny/registerComboBox.cjs.js.map +1 -1
  49. package/skinny/registerComboBox.esm.js +109 -4
  50. package/skinny/registerComboBox.esm.js.map +1 -1
  51. package/skinny/registerDescription.cjs.js +10 -3
  52. package/skinny/registerDescription.cjs.js.map +1 -1
  53. package/skinny/registerDescription.d.ts +2 -1
  54. package/skinny/registerDescription.esm.js +10 -4
  55. package/skinny/registerDescription.esm.js.map +1 -1
  56. package/skinny/registerDialogTrigger.cjs.js +25 -4
  57. package/skinny/registerDialogTrigger.cjs.js.map +1 -1
  58. package/skinny/registerDialogTrigger.d.ts +1 -2
  59. package/skinny/registerDialogTrigger.esm.js +25 -4
  60. package/skinny/registerDialogTrigger.esm.js.map +1 -1
  61. package/skinny/registerFieldError.cjs.js +21 -11
  62. package/skinny/registerFieldError.cjs.js.map +1 -1
  63. package/skinny/registerFieldError.esm.js +21 -11
  64. package/skinny/registerFieldError.esm.js.map +1 -1
  65. package/skinny/registerForm.cjs.js +1 -1
  66. package/skinny/registerForm.esm.js +1 -1
  67. package/skinny/registerHeader.cjs.js +7 -3
  68. package/skinny/registerHeader.cjs.js.map +1 -1
  69. package/skinny/registerHeader.d.ts +1 -1
  70. package/skinny/registerHeader.esm.js +7 -3
  71. package/skinny/registerHeader.esm.js.map +1 -1
  72. package/skinny/registerInput.cjs.js +11 -2
  73. package/skinny/registerInput.cjs.js.map +1 -1
  74. package/skinny/registerInput.d.ts +1 -0
  75. package/skinny/registerInput.esm.js +11 -3
  76. package/skinny/registerInput.esm.js.map +1 -1
  77. package/skinny/registerLabel.cjs.js +1 -1
  78. package/skinny/registerLabel.esm.js +1 -1
  79. package/skinny/registerListBox-1effa43d.esm.js +299 -0
  80. package/skinny/registerListBox-1effa43d.esm.js.map +1 -0
  81. package/skinny/registerListBox-837b90d8.cjs.js +311 -0
  82. package/skinny/registerListBox-837b90d8.cjs.js.map +1 -0
  83. package/skinny/registerListBox.cjs.js +14 -108
  84. package/skinny/registerListBox.cjs.js.map +1 -1
  85. package/skinny/registerListBox.d.ts +3 -6
  86. package/skinny/registerListBox.esm.js +11 -106
  87. package/skinny/registerListBox.esm.js.map +1 -1
  88. package/skinny/registerListBoxItem.cjs.js +49 -5
  89. package/skinny/registerListBoxItem.cjs.js.map +1 -1
  90. package/skinny/registerListBoxItem.d.ts +3 -1
  91. package/skinny/registerListBoxItem.esm.js +49 -6
  92. package/skinny/registerListBoxItem.esm.js.map +1 -1
  93. package/skinny/registerModal.cjs.js +78 -9
  94. package/skinny/registerModal.cjs.js.map +1 -1
  95. package/skinny/registerModal.d.ts +3 -1
  96. package/skinny/registerModal.esm.js +78 -10
  97. package/skinny/registerModal.esm.js.map +1 -1
  98. package/skinny/registerPopover.cjs.js +56 -4
  99. package/skinny/registerPopover.cjs.js.map +1 -1
  100. package/skinny/registerPopover.d.ts +3 -0
  101. package/skinny/registerPopover.esm.js +55 -5
  102. package/skinny/registerPopover.esm.js.map +1 -1
  103. package/skinny/registerRadio.cjs.js +51 -6
  104. package/skinny/registerRadio.cjs.js.map +1 -1
  105. package/skinny/registerRadio.d.ts +5 -2
  106. package/skinny/registerRadio.esm.js +51 -7
  107. package/skinny/registerRadio.esm.js.map +1 -1
  108. package/skinny/registerRadioGroup.cjs.js +80 -16
  109. package/skinny/registerRadioGroup.cjs.js.map +1 -1
  110. package/skinny/registerRadioGroup.d.ts +3 -3
  111. package/skinny/registerRadioGroup.esm.js +79 -19
  112. package/skinny/registerRadioGroup.esm.js.map +1 -1
  113. package/skinny/registerSection.cjs.js +36 -12
  114. package/skinny/registerSection.cjs.js.map +1 -1
  115. package/skinny/registerSection.d.ts +1 -1
  116. package/skinny/registerSection.esm.js +36 -12
  117. package/skinny/registerSection.esm.js.map +1 -1
  118. package/skinny/registerSelect.cjs.js +133 -30
  119. package/skinny/registerSelect.cjs.js.map +1 -1
  120. package/skinny/registerSelect.d.ts +5 -2
  121. package/skinny/registerSelect.esm.js +130 -25
  122. package/skinny/registerSelect.esm.js.map +1 -1
  123. package/skinny/{registerSlider-73e80194.cjs.js → registerSlider-61c84cf7.cjs.js} +6 -11
  124. package/skinny/registerSlider-61c84cf7.cjs.js.map +1 -0
  125. package/skinny/{registerSlider-efdba013.esm.js → registerSlider-de8e9387.esm.js} +6 -11
  126. package/skinny/registerSlider-de8e9387.esm.js.map +1 -0
  127. package/skinny/registerSlider.cjs.js +3 -3
  128. package/skinny/registerSlider.esm.js +3 -3
  129. package/skinny/registerSliderOutput.cjs.js +1 -1
  130. package/skinny/registerSliderOutput.esm.js +1 -1
  131. package/skinny/registerSliderThumb.cjs.js +7 -3
  132. package/skinny/registerSliderThumb.cjs.js.map +1 -1
  133. package/skinny/registerSliderThumb.esm.js +7 -3
  134. package/skinny/registerSliderThumb.esm.js.map +1 -1
  135. package/skinny/registerSliderTrack.cjs.js +3 -3
  136. package/skinny/registerSliderTrack.esm.js +3 -3
  137. package/skinny/registerSwitch.cjs.js +83 -3
  138. package/skinny/registerSwitch.cjs.js.map +1 -1
  139. package/skinny/registerSwitch.esm.js +83 -3
  140. package/skinny/registerSwitch.esm.js.map +1 -1
  141. package/skinny/registerText.cjs.js +11 -4
  142. package/skinny/registerText.cjs.js.map +1 -1
  143. package/skinny/registerText.d.ts +2 -1
  144. package/skinny/registerText.esm.js +11 -5
  145. package/skinny/registerText.esm.js.map +1 -1
  146. package/skinny/registerTextArea.cjs.js +1 -1
  147. package/skinny/registerTextArea.esm.js +1 -1
  148. package/skinny/registerTextField.cjs.js +47 -6
  149. package/skinny/registerTextField.cjs.js.map +1 -1
  150. package/skinny/registerTextField.d.ts +1 -0
  151. package/skinny/registerTextField.esm.js +50 -10
  152. package/skinny/registerTextField.esm.js.map +1 -1
  153. package/skinny/registerTooltip.cjs.js +8 -6
  154. package/skinny/registerTooltip.cjs.js.map +1 -1
  155. package/skinny/registerTooltip.d.ts +2 -1
  156. package/skinny/registerTooltip.esm.js +8 -6
  157. package/skinny/registerTooltip.esm.js.map +1 -1
  158. package/skinny/{utils-cf2632c9.esm.js → utils-5051df41.esm.js} +3 -2
  159. package/skinny/utils-5051df41.esm.js.map +1 -0
  160. package/skinny/{utils-18b2465b.cjs.js → utils-745db876.cjs.js} +2 -1
  161. package/skinny/utils-745db876.cjs.js.map +1 -0
  162. package/skinny/utils.d.ts +9 -2
  163. package/skinny/contexts-8a2a183b.esm.js +0 -13
  164. package/skinny/contexts-8a2a183b.esm.js.map +0 -1
  165. package/skinny/contexts-dd0ce341.cjs.js.map +0 -1
  166. package/skinny/option-utils-4f037568.esm.js +0 -153
  167. package/skinny/option-utils-4f037568.esm.js.map +0 -1
  168. package/skinny/option-utils-5e4e85bd.cjs.js +0 -162
  169. package/skinny/option-utils-5e4e85bd.cjs.js.map +0 -1
  170. package/skinny/registerSlider-73e80194.cjs.js.map +0 -1
  171. package/skinny/registerSlider-efdba013.esm.js.map +0 -1
  172. package/skinny/utils-18b2465b.cjs.js.map +0 -1
  173. package/skinny/utils-cf2632c9.esm.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"registerTooltip.cjs.js","sources":["../src/registerTooltip.tsx"],"sourcesContent":["import { mergeProps } from \"@react-aria/utils\";\nimport React from \"react\";\nimport { useTooltipTrigger } from \"react-aria\";\nimport { TooltipProps } from \"react-aria-components\";\nimport flattenChildren from \"react-keyed-flatten-children\";\nimport { TooltipTriggerProps, useTooltipTriggerState } from \"react-stately\";\nimport {\n CodeComponentMetaOverrides,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nexport interface BaseTooltipProps extends TooltipTriggerProps, TooltipProps {\n children?: React.ReactElement<HTMLElement>;\n tooltipContent?: React.ReactNode;\n resetClassName?: string;\n}\n\nexport function BaseTooltip(props: BaseTooltipProps) {\n const { children, tooltipContent, className, resetClassName, ...restProps } =\n props;\n const state = useTooltipTriggerState(restProps);\n const ref = React.useRef(null);\n const { triggerProps, tooltipProps } = useTooltipTrigger(\n restProps,\n state,\n ref\n );\n /** We are only accepting a single child here, so we can just use the first one.\n * This is because the trigger props will be applied to the child to enable the triggering of the tooltip.\n * If there has to be more than one things here, wrap them in a horizontal stack for instance.\n * */\n const focusableChild = flattenChildren(children)[0];\n\n return (\n <div\n // this is to ensure that the absolutely positioned tooltip can be positioned correctly within this relatively positioned container.\n style={{ position: \"relative\" }}\n >\n {React.isValidElement(focusableChild)\n ? React.cloneElement(focusableChild, {\n ref,\n ...mergeProps(\n focusableChild.props as Record<string, any>,\n triggerProps\n ),\n } as Record<string, any> & { ref?: React.Ref<HTMLElement> })\n : null}\n {state.isOpen && (\n <span {...tooltipProps} className={`${className} ${resetClassName}`}>\n {tooltipContent}\n </span>\n )}\n </div>\n );\n}\n\nexport function registerTooltip(\n loader?: Registerable,\n overrides?: CodeComponentMetaOverrides<typeof BaseTooltip>\n) {\n registerComponentHelper(\n loader,\n BaseTooltip,\n {\n name: \"plasmic-react-aria-tooltip\",\n displayName: \"Aria Tooltip\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerTooltip\",\n importName: \"BaseTooltip\",\n isAttachment: true,\n styleSections: true,\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"text\",\n value: \"Hover me!\",\n },\n },\n tooltipContent: {\n type: \"slot\",\n displayName: \"Tooltip Content\",\n // NOTE: This is not applied in attachment\n defaultValue: {\n type: \"text\",\n value: \"Hello from Tooltip!\",\n },\n },\n resetClassName: {\n type: \"themeResetClass\",\n },\n isDisabled: {\n type: \"boolean\",\n },\n delay: {\n type: \"number\",\n defaultValueHint: 1500,\n description:\n \"The delay (in milliseconds) for the tooltip to show up.\",\n },\n closeDelay: {\n type: \"number\",\n defaultValueHint: 500,\n description: \"The delay (in milliseconds) for the tooltip to close.\",\n },\n trigger: {\n type: \"choice\",\n options: [\"focus\", \"focus and hover\"],\n defaultValueHint: \"focus and hover\",\n },\n isOpen: {\n type: \"boolean\",\n editOnly: true,\n uncontrolledProp: \"defaultOpen\",\n description: \"Whether the overlay is open by default\",\n defaultValueHint: false,\n },\n onOpenChange: {\n type: \"eventHandler\",\n argTypes: [{ name: \"isOpen\", type: \"boolean\" }],\n },\n },\n states: {\n isOpen: {\n type: \"writable\",\n valueProp: \"isOpen\",\n onChangeProp: \"onOpenChange\",\n variableType: \"boolean\",\n },\n },\n },\n overrides\n );\n}\n"],"names":["useTooltipTriggerState","React","useTooltipTrigger","flattenChildren","mergeProps","registerComponentHelper"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBO,SAAS,YAAY,KAAyB,EAAA;AACnD,EAAA,MACE,EADM,GAAA,KAAA,EAAA,EAAA,QAAA,EAAU,cAAgB,EAAA,SAAA,EAAW,cAnB/C,EAAA,GAoBI,EAD8D,EAAA,SAAA,GAAA,SAAA,CAC9D,EAD8D,EAAA,CAAxD,UAAU,EAAA,gBAAA,EAAgB,WAAW,EAAA,gBAAA,CAAA,CAAA,CAAA;AAE7C,EAAM,MAAA,KAAA,GAAQA,oCAAuB,SAAS,CAAA,CAAA;AAC9C,EAAM,MAAA,GAAA,GAAMC,sBAAM,CAAA,MAAA,CAAO,IAAI,CAAA,CAAA;AAC7B,EAAM,MAAA,EAAE,YAAc,EAAA,YAAA,EAAiB,GAAAC,2BAAA;AAAA,IACrC,SAAA;AAAA,IACA,KAAA;AAAA,IACA,GAAA;AAAA,GACF,CAAA;AAKA,EAAA,MAAM,cAAiB,GAAAC,gCAAA,CAAgB,QAAQ,CAAA,CAAE,CAAC,C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AA,YACN,KAAO,EAAA,qBAAA;AAAA,WACT;AAAA,SACF;AAAA,QACA,cAAgB,EAAA;AAAA,UACd,IAAM,EAAA,iBAAA;AAAA,SACR;AAAA,QACA,UAAY,EAAA;AAAA,UACV,IAAM,EAAA,SAAA;AAAA,SACR;AAAA,QACA,KAAO,EAAA;AAAA,UACL,IAAM,EAAA,QAAA;AAAA,UACN,gBAAkB,EAAA,IAAA;AAAA,UAClB,WACE,EAAA,yDAAA;AAAA,SACJ;AAAA,QACA,UAAY,EAAA;AAAA,UACV,IAAM,EAAA,QAAA;AAAA,UACN,gBAAkB,EAAA,GAAA;AAAA,UAClB,WAAa,EAAA,uDAAA;AAAA,SACf;AAAA,QACA,OAAS,EAAA;AAAA,UACP,IAAM,EAAA,QAAA;AAAA,UACN,OAAA,EAAS,CAAC,OAAA,EAAS,iBAAiB,CAAA;AAAA,UACpC,gBAAkB,EAAA,iBAAA;AAAA,SACpB;AAAA,QACA,MAAQ,EAAA;AAAA,UACN,IAAM,EAAA,SAAA;AAAA,UACN,QAAU,EAAA,IAAA;AAAA,UACV,gBAAkB,EAAA,aAAA;AAAA,UAClB,WAAa,EAAA,wCAAA;AAAA,UACb,gBAAkB,EAAA,KAAA;AAAA,SACpB;AAAA,QACA,YAAc,EAAA;AAAA,UACZ,IAAM,EAAA,cAAA;AAAA,UACN,UAAU,CAAC,EAAE,MAAM,QAAU,EAAA,IAAA,EAAM,WAAW,CAAA;AAAA,SAChD;AAAA,OACF;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,MAAQ,EAAA;AAAA,UACN,IAAM,EAAA,UAAA;AAAA,UACN,SAAW,EAAA,QAAA;AAAA,UACX,YAAc,EAAA,cAAA;AAAA,UACd,YAAc,EAAA,SAAA;AAAA,SAChB;AAAA,OACF;AAAA,KACF;AAAA,IACA,SAAA;AAAA,GACF,CAAA;AACF;;;;;"}
1
+ {"version":3,"file":"registerTooltip.cjs.js","sources":["../src/registerTooltip.tsx"],"sourcesContent":["import { mergeProps } from \"@react-aria/utils\";\nimport React from \"react\";\nimport { useTooltipTrigger } from \"react-aria\";\nimport { TooltipProps } from \"react-aria-components\";\nimport flattenChildren from \"react-keyed-flatten-children\";\nimport { TooltipTriggerProps, useTooltipTriggerState } from \"react-stately\";\nimport {\n CodeComponentMetaOverrides,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nexport interface BaseTooltipProps extends TooltipTriggerProps, TooltipProps {\n children?: React.ReactElement<HTMLElement>;\n tooltipContent?: React.ReactElement;\n resetClassName?: string;\n className?: string;\n}\n\nexport function BaseTooltip(props: BaseTooltipProps) {\n const { children, tooltipContent, className, resetClassName, ...restProps } =\n props;\n const state = useTooltipTriggerState(restProps);\n const ref = React.useRef(null);\n const { triggerProps, tooltipProps } = useTooltipTrigger(\n restProps,\n state,\n ref\n );\n\n const hasContent =\n tooltipContent &&\n (tooltipContent.type as any).name !== \"CanvasSlotPlaceholder\";\n\n /** We are only accepting a single child here, so we can just use the first one.\n * This is because the trigger props will be applied to the child to enable the triggering of the tooltip.\n * If there has to be more than one things here, wrap them in a horizontal stack for instance.\n * */\n const focusableChild = flattenChildren(children)[0];\n\n return (\n <div\n // this is to ensure that the absolutely positioned tooltip can be positioned correctly within this relatively positioned container.\n style={{ position: \"relative\" }}\n className={resetClassName}\n >\n {React.isValidElement(focusableChild)\n ? React.cloneElement(focusableChild, {\n ref,\n ...mergeProps(\n focusableChild.props as Record<string, any>,\n triggerProps\n ),\n } as Record<string, any> & { ref?: React.Ref<HTMLElement> })\n : null}\n {state.isOpen && (\n <>\n {React.cloneElement(\n hasContent ? (\n tooltipContent\n ) : (\n <p>Add some content to the tooltip...</p>\n ),\n mergeProps(tooltipProps, tooltipContent?.props.attrs, { className })\n )}\n </>\n )}\n </div>\n );\n}\n\nexport function registerTooltip(\n loader?: Registerable,\n overrides?: CodeComponentMetaOverrides<typeof BaseTooltip>\n) {\n registerComponentHelper(\n loader,\n BaseTooltip,\n {\n name: \"plasmic-react-aria-tooltip\",\n displayName: \"Aria Tooltip\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerTooltip\",\n importName: \"BaseTooltip\",\n isAttachment: true,\n styleSections: true,\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"text\",\n value: \"Hover me!\",\n },\n },\n tooltipContent: {\n type: \"slot\",\n displayName: \"Tooltip Content\",\n // NOTE: This is not applied in attachment\n defaultValue: {\n type: \"text\",\n value: \"Hello from Tooltip!\",\n },\n },\n resetClassName: {\n type: \"themeResetClass\",\n },\n isDisabled: {\n type: \"boolean\",\n },\n delay: {\n type: \"number\",\n defaultValueHint: 1500,\n description:\n \"The delay (in milliseconds) for the tooltip to show up.\",\n },\n closeDelay: {\n type: \"number\",\n defaultValueHint: 500,\n description: \"The delay (in milliseconds) for the tooltip to close.\",\n },\n trigger: {\n type: \"choice\",\n options: [\"focus\", \"focus and hover\"],\n defaultValueHint: \"focus and hover\",\n },\n isOpen: {\n type: \"boolean\",\n editOnly: true,\n uncontrolledProp: \"defaultOpen\",\n description: \"Whether the overlay is open by default\",\n defaultValueHint: false,\n },\n onOpenChange: {\n type: \"eventHandler\",\n argTypes: [{ name: \"isOpen\", type: \"boolean\" }],\n },\n },\n states: {\n isOpen: {\n type: \"writable\",\n valueProp: \"isOpen\",\n onChangeProp: \"onOpenChange\",\n variableType: \"boolean\",\n },\n },\n },\n overrides\n );\n}\n"],"names":["useTooltipTriggerState","React","useTooltipTrigger","flattenChildren","mergeProps","registerComponentHelper"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBO,SAAS,YAAY,KAAyB,EAAA;AACnD,EAAA,MACE,EADM,GAAA,KAAA,EAAA,EAAA,QAAA,EAAU,cAAgB,EAAA,SAAA,EAAW,cApB/C,EAAA,GAqBI,EAD8D,EAAA,SAAA,GAAA,SAAA,CAC9D,EAD8D,EAAA,CAAxD,UAAU,EAAA,gBAAA,EAAgB,WAAW,EAAA,gBAAA,CAAA,CAAA,CAAA;A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,UACN,QAAU,EAAA,IAAA;AAAA,UACV,gBAAkB,EAAA,aAAA;AAAA,UAClB,WAAa,EAAA,wCAAA;AAAA,UACb,gBAAkB,EAAA,KAAA;AAAA,SACpB;AAAA,QACA,YAAc,EAAA;AAAA,UACZ,IAAM,EAAA,cAAA;AAAA,UACN,UAAU,CAAC,EAAE,MAAM,QAAU,EAAA,IAAA,EAAM,WAAW,CAAA;AAAA,SAChD;AAAA,OACF;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,MAAQ,EAAA;AAAA,UACN,IAAM,EAAA,UAAA;AAAA,UACN,SAAW,EAAA,QAAA;AAAA,UACX,YAAc,EAAA,cAAA;AAAA,UACd,YAAc,EAAA,SAAA;AAAA,SAChB;AAAA,OACF;AAAA,KACF;AAAA,IACA,SAAA;AAAA,GACF,CAAA;AACF;;;;;"}
@@ -4,8 +4,9 @@ import { TooltipTriggerProps } from "react-stately";
4
4
  import { CodeComponentMetaOverrides, Registerable } from "./utils";
5
5
  export interface BaseTooltipProps extends TooltipTriggerProps, TooltipProps {
6
6
  children?: React.ReactElement<HTMLElement>;
7
- tooltipContent?: React.ReactNode;
7
+ tooltipContent?: React.ReactElement;
8
8
  resetClassName?: string;
9
+ className?: string;
9
10
  }
10
11
  export declare function BaseTooltip(props: BaseTooltipProps): React.JSX.Element;
11
12
  export declare function registerTooltip(loader?: Registerable, overrides?: CodeComponentMetaOverrides<typeof BaseTooltip>): void;
@@ -3,12 +3,10 @@ import React from 'react';
3
3
  import { useTooltipTrigger } from 'react-aria';
4
4
  import flattenChildren from 'react-keyed-flatten-children';
5
5
  import { useTooltipTriggerState } from 'react-stately';
6
- import { r as registerComponentHelper } from './utils-cf2632c9.esm.js';
6
+ import { r as registerComponentHelper } from './utils-5051df41.esm.js';
7
7
  import '@plasmicapp/host/registerComponent';
8
8
 
9
9
  var __defProp = Object.defineProperty;
10
- var __defProps = Object.defineProperties;
11
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
12
10
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
13
11
  var __hasOwnProp = Object.prototype.hasOwnProperty;
14
12
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -24,7 +22,6 @@ var __spreadValues = (a, b) => {
24
22
  }
25
23
  return a;
26
24
  };
27
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
28
25
  var __objRest = (source, exclude) => {
29
26
  var target = {};
30
27
  for (var prop in source)
@@ -46,11 +43,13 @@ function BaseTooltip(props) {
46
43
  state,
47
44
  ref
48
45
  );
46
+ const hasContent = tooltipContent && tooltipContent.type.name !== "CanvasSlotPlaceholder";
49
47
  const focusableChild = flattenChildren(children)[0];
50
48
  return /* @__PURE__ */ React.createElement(
51
49
  "div",
52
50
  {
53
- style: { position: "relative" }
51
+ style: { position: "relative" },
52
+ className: resetClassName
54
53
  },
55
54
  React.isValidElement(focusableChild) ? React.cloneElement(focusableChild, __spreadValues({
56
55
  ref
@@ -58,7 +57,10 @@ function BaseTooltip(props) {
58
57
  focusableChild.props,
59
58
  triggerProps
60
59
  ))) : null,
61
- state.isOpen && /* @__PURE__ */ React.createElement("span", __spreadProps(__spreadValues({}, tooltipProps), { className: `${className} ${resetClassName}` }), tooltipContent)
60
+ state.isOpen && /* @__PURE__ */ React.createElement(React.Fragment, null, React.cloneElement(
61
+ hasContent ? tooltipContent : /* @__PURE__ */ React.createElement("p", null, "Add some content to the tooltip..."),
62
+ mergeProps(tooltipProps, tooltipContent == null ? void 0 : tooltipContent.props.attrs, { className })
63
+ ))
62
64
  );
63
65
  }
64
66
  function registerTooltip(loader, overrides) {
@@ -1 +1 @@
1
- {"version":3,"file":"registerTooltip.esm.js","sources":["../src/registerTooltip.tsx"],"sourcesContent":["import { mergeProps } from \"@react-aria/utils\";\nimport React from \"react\";\nimport { useTooltipTrigger } from \"react-aria\";\nimport { TooltipProps } from \"react-aria-components\";\nimport flattenChildren from \"react-keyed-flatten-children\";\nimport { TooltipTriggerProps, useTooltipTriggerState } from \"react-stately\";\nimport {\n CodeComponentMetaOverrides,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nexport interface BaseTooltipProps extends TooltipTriggerProps, TooltipProps {\n children?: React.ReactElement<HTMLElement>;\n tooltipContent?: React.ReactNode;\n resetClassName?: string;\n}\n\nexport function BaseTooltip(props: BaseTooltipProps) {\n const { children, tooltipContent, className, resetClassName, ...restProps } =\n props;\n const state = useTooltipTriggerState(restProps);\n const ref = React.useRef(null);\n const { triggerProps, tooltipProps } = useTooltipTrigger(\n restProps,\n state,\n ref\n );\n /** We are only accepting a single child here, so we can just use the first one.\n * This is because the trigger props will be applied to the child to enable the triggering of the tooltip.\n * If there has to be more than one things here, wrap them in a horizontal stack for instance.\n * */\n const focusableChild = flattenChildren(children)[0];\n\n return (\n <div\n // this is to ensure that the absolutely positioned tooltip can be positioned correctly within this relatively positioned container.\n style={{ position: \"relative\" }}\n >\n {React.isValidElement(focusableChild)\n ? React.cloneElement(focusableChild, {\n ref,\n ...mergeProps(\n focusableChild.props as Record<string, any>,\n triggerProps\n ),\n } as Record<string, any> & { ref?: React.Ref<HTMLElement> })\n : null}\n {state.isOpen && (\n <span {...tooltipProps} className={`${className} ${resetClassName}`}>\n {tooltipContent}\n </span>\n )}\n </div>\n );\n}\n\nexport function registerTooltip(\n loader?: Registerable,\n overrides?: CodeComponentMetaOverrides<typeof BaseTooltip>\n) {\n registerComponentHelper(\n loader,\n BaseTooltip,\n {\n name: \"plasmic-react-aria-tooltip\",\n displayName: \"Aria Tooltip\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerTooltip\",\n importName: \"BaseTooltip\",\n isAttachment: true,\n styleSections: true,\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"text\",\n value: \"Hover me!\",\n },\n },\n tooltipContent: {\n type: \"slot\",\n displayName: \"Tooltip Content\",\n // NOTE: This is not applied in attachment\n defaultValue: {\n type: \"text\",\n value: \"Hello from Tooltip!\",\n },\n },\n resetClassName: {\n type: \"themeResetClass\",\n },\n isDisabled: {\n type: \"boolean\",\n },\n delay: {\n type: \"number\",\n defaultValueHint: 1500,\n description:\n \"The delay (in milliseconds) for the tooltip to show up.\",\n },\n closeDelay: {\n type: \"number\",\n defaultValueHint: 500,\n description: \"The delay (in milliseconds) for the tooltip to close.\",\n },\n trigger: {\n type: \"choice\",\n options: [\"focus\", \"focus and hover\"],\n defaultValueHint: \"focus and hover\",\n },\n isOpen: {\n type: \"boolean\",\n editOnly: true,\n uncontrolledProp: \"defaultOpen\",\n description: \"Whether the overlay is open by default\",\n defaultValueHint: false,\n },\n onOpenChange: {\n type: \"eventHandler\",\n argTypes: [{ name: \"isOpen\", type: \"boolean\" }],\n },\n },\n states: {\n isOpen: {\n type: \"writable\",\n valueProp: \"isOpen\",\n onChangeProp: \"onOpenChange\",\n variableType: \"boolean\",\n },\n },\n },\n overrides\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBO,SAAS,YAAY,KAAyB,EAAA;AACnD,EAAA,MACE,EADM,GAAA,KAAA,EAAA,EAAA,QAAA,EAAU,cAAgB,EAAA,SAAA,EAAW,cAnB/C,EAAA,GAoBI,EAD8D,EAAA,SAAA,GAAA,SAAA,CAC9D,EAD8D,EAAA,CAAxD,UAAU,EAAA,gBAAA,EAAgB,WAAW,EAAA,gBAAA,CAAA,CAAA,CAAA;AAE7C,EAAM,MAAA,KAAA,GAAQ,uBAAuB,SAAS,CAAA,CAAA;AAC9C,EAAM,MAAA,GAAA,GAAM,KAAM,CAAA,MAAA,CAAO,IAAI,CAAA,CAAA;AAC7B,EAAM,MAAA,EAAE,YAAc,EAAA,YAAA,EAAiB,GAAA,iBAAA;AAAA,IACrC,SAAA;AAAA,IACA,KAAA;AAAA,IACA,GAAA;AAAA,GACF,CAAA;AAKA,EAAA,MAAM,cAAiB,GAAA,eAAA,CAAgB,QAAQ,CAAA,CAAE,CAAC,CAAA,CAAA;AAElD,EACE,uBAAA,KAAA,C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AAAA,QACA,cAAgB,EAAA;AAAA,UACd,IAAM,EAAA,iBAAA;AAAA,SACR;AAAA,QACA,UAAY,EAAA;AAAA,UACV,IAAM,EAAA,SAAA;AAAA,SACR;AAAA,QACA,KAAO,EAAA;AAAA,UACL,IAAM,EAAA,QAAA;AAAA,UACN,gBAAkB,EAAA,IAAA;AAAA,UAClB,WACE,EAAA,yDAAA;AAAA,SACJ;AAAA,QACA,UAAY,EAAA;AAAA,UACV,IAAM,EAAA,QAAA;AAAA,UACN,gBAAkB,EAAA,GAAA;AAAA,UAClB,WAAa,EAAA,uDAAA;AAAA,SACf;AAAA,QACA,OAAS,EAAA;AAAA,UACP,IAAM,EAAA,QAAA;AAAA,UACN,OAAA,EAAS,CAAC,OAAA,EAAS,iBAAiB,CAAA;AAAA,UACpC,gBAAkB,EAAA,iBAAA;AAAA,SACpB;AAAA,QACA,MAAQ,EAAA;AAAA,UACN,IAAM,EAAA,SAAA;AAAA,UACN,QAAU,EAAA,IAAA;AAAA,UACV,gBAAkB,EAAA,aAAA;AAAA,UAClB,WAAa,EAAA,wCAAA;AAAA,UACb,gBAAkB,EAAA,KAAA;AAAA,SACpB;AAAA,QACA,YAAc,EAAA;AAAA,UACZ,IAAM,EAAA,cAAA;AAAA,UACN,UAAU,CAAC,EAAE,MAAM,QAAU,EAAA,IAAA,EAAM,WAAW,CAAA;AAAA,SAChD;AAAA,OACF;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,MAAQ,EAAA;AAAA,UACN,IAAM,EAAA,UAAA;AAAA,UACN,SAAW,EAAA,QAAA;AAAA,UACX,YAAc,EAAA,cAAA;AAAA,UACd,YAAc,EAAA,SAAA;AAAA,SAChB;AAAA,OACF;AAAA,KACF;AAAA,IACA,SAAA;AAAA,GACF,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"registerTooltip.esm.js","sources":["../src/registerTooltip.tsx"],"sourcesContent":["import { mergeProps } from \"@react-aria/utils\";\nimport React from \"react\";\nimport { useTooltipTrigger } from \"react-aria\";\nimport { TooltipProps } from \"react-aria-components\";\nimport flattenChildren from \"react-keyed-flatten-children\";\nimport { TooltipTriggerProps, useTooltipTriggerState } from \"react-stately\";\nimport {\n CodeComponentMetaOverrides,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nexport interface BaseTooltipProps extends TooltipTriggerProps, TooltipProps {\n children?: React.ReactElement<HTMLElement>;\n tooltipContent?: React.ReactElement;\n resetClassName?: string;\n className?: string;\n}\n\nexport function BaseTooltip(props: BaseTooltipProps) {\n const { children, tooltipContent, className, resetClassName, ...restProps } =\n props;\n const state = useTooltipTriggerState(restProps);\n const ref = React.useRef(null);\n const { triggerProps, tooltipProps } = useTooltipTrigger(\n restProps,\n state,\n ref\n );\n\n const hasContent =\n tooltipContent &&\n (tooltipContent.type as any).name !== \"CanvasSlotPlaceholder\";\n\n /** We are only accepting a single child here, so we can just use the first one.\n * This is because the trigger props will be applied to the child to enable the triggering of the tooltip.\n * If there has to be more than one things here, wrap them in a horizontal stack for instance.\n * */\n const focusableChild = flattenChildren(children)[0];\n\n return (\n <div\n // this is to ensure that the absolutely positioned tooltip can be positioned correctly within this relatively positioned container.\n style={{ position: \"relative\" }}\n className={resetClassName}\n >\n {React.isValidElement(focusableChild)\n ? React.cloneElement(focusableChild, {\n ref,\n ...mergeProps(\n focusableChild.props as Record<string, any>,\n triggerProps\n ),\n } as Record<string, any> & { ref?: React.Ref<HTMLElement> })\n : null}\n {state.isOpen && (\n <>\n {React.cloneElement(\n hasContent ? (\n tooltipContent\n ) : (\n <p>Add some content to the tooltip...</p>\n ),\n mergeProps(tooltipProps, tooltipContent?.props.attrs, { className })\n )}\n </>\n )}\n </div>\n );\n}\n\nexport function registerTooltip(\n loader?: Registerable,\n overrides?: CodeComponentMetaOverrides<typeof BaseTooltip>\n) {\n registerComponentHelper(\n loader,\n BaseTooltip,\n {\n name: \"plasmic-react-aria-tooltip\",\n displayName: \"Aria Tooltip\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerTooltip\",\n importName: \"BaseTooltip\",\n isAttachment: true,\n styleSections: true,\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"text\",\n value: \"Hover me!\",\n },\n },\n tooltipContent: {\n type: \"slot\",\n displayName: \"Tooltip Content\",\n // NOTE: This is not applied in attachment\n defaultValue: {\n type: \"text\",\n value: \"Hello from Tooltip!\",\n },\n },\n resetClassName: {\n type: \"themeResetClass\",\n },\n isDisabled: {\n type: \"boolean\",\n },\n delay: {\n type: \"number\",\n defaultValueHint: 1500,\n description:\n \"The delay (in milliseconds) for the tooltip to show up.\",\n },\n closeDelay: {\n type: \"number\",\n defaultValueHint: 500,\n description: \"The delay (in milliseconds) for the tooltip to close.\",\n },\n trigger: {\n type: \"choice\",\n options: [\"focus\", \"focus and hover\"],\n defaultValueHint: \"focus and hover\",\n },\n isOpen: {\n type: \"boolean\",\n editOnly: true,\n uncontrolledProp: \"defaultOpen\",\n description: \"Whether the overlay is open by default\",\n defaultValueHint: false,\n },\n onOpenChange: {\n type: \"eventHandler\",\n argTypes: [{ name: \"isOpen\", type: \"boolean\" }],\n },\n },\n states: {\n isOpen: {\n type: \"writable\",\n valueProp: \"isOpen\",\n onChangeProp: \"onOpenChange\",\n variableType: \"boolean\",\n },\n },\n },\n overrides\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBO,SAAS,YAAY,KAAyB,EAAA;AACnD,EAAA,MACE,EADM,GAAA,KAAA,EAAA,EAAA,QAAA,EAAU,cAAgB,EAAA,SAAA,EAAW,cApB/C,EAAA,GAqBI,EAD8D,EAAA,SAAA,GAAA,SAAA,CAC9D,EAD8D,EAAA,CAAxD,UAAU,EAAA,gBAAA,EAAgB,WAAW,EAAA,gBAAA,CAAA,CAAA,CAAA;AAE7C,EAAM,MAAA,KAAA,GAAQ,uBAAuB,SAAS,CAAA,CAAA;AAC9C,EAAM,MAAA,GAAA,GAAM,KAAM,CAAA,MAAA,CAAO,I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AAc,EAAA;AAAA,UACZ,IAAM,EAAA,cAAA;AAAA,UACN,UAAU,CAAC,EAAE,MAAM,QAAU,EAAA,IAAA,EAAM,WAAW,CAAA;AAAA,SAChD;AAAA,OACF;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,MAAQ,EAAA;AAAA,UACN,IAAM,EAAA,UAAA;AAAA,UACN,SAAW,EAAA,QAAA;AAAA,UACX,YAAc,EAAA,cAAA;AAAA,UACd,YAAc,EAAA,SAAA;AAAA,SAChB;AAAA,OACF;AAAA,KACF;AAAA,IACA,SAAA;AAAA,GACF,CAAA;AACF;;;;"}
@@ -36,6 +36,7 @@ function registerComponentHelper(loader, component, meta, overrides) {
36
36
  } else {
37
37
  registerComponent(component, meta);
38
38
  }
39
+ return meta;
39
40
  }
40
41
  function makeComponentName(name) {
41
42
  return `plasmic-react-aria-${name}`;
@@ -58,5 +59,5 @@ function withoutNils(array) {
58
59
  return array.filter((x) => x != null);
59
60
  }
60
61
 
61
- export { makeChildComponentName as a, extractPlasmicDataProps as e, makeComponentName as m, registerComponentHelper as r, withoutNils as w };
62
- //# sourceMappingURL=utils-cf2632c9.esm.js.map
62
+ export { makeComponentName as a, extractPlasmicDataProps as e, makeChildComponentName as m, registerComponentHelper as r, withoutNils as w };
63
+ //# sourceMappingURL=utils-5051df41.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-5051df41.esm.js","sources":["../src/utils.ts"],"sourcesContent":["import type { CodeComponentMeta } from \"@plasmicapp/host\";\nimport registerComponent from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\n\nexport type BaseControlContextData = {\n isStandalone: boolean;\n};\n\nexport type Registerable = {\n registerComponent: typeof registerComponent;\n};\n\nexport type OtherCodeComponentsMeta = {\n text: CodeComponentMeta<any>;\n description: CodeComponentMeta<any>;\n};\n\nexport type CodeComponentMetaOverrides<T extends React.ComponentType<any>> =\n Partial<\n Pick<\n CodeComponentMeta<React.ComponentProps<T>>,\n \"parentComponentName\" | \"props\" | \"displayName\" | \"name\"\n >\n >;\n\nexport function registerComponentHelper<T extends React.ComponentType<any>>(\n loader: Registerable | undefined,\n component: T,\n meta: CodeComponentMeta<React.ComponentProps<T>>,\n overrides?: CodeComponentMetaOverrides<T>\n) {\n if (overrides) {\n meta = {\n ...meta,\n ...overrides,\n props: {\n ...meta.props,\n ...overrides.props,\n },\n };\n if (overrides.parentComponentName) {\n meta.name = makeChildComponentName(\n overrides.parentComponentName,\n meta.name\n );\n }\n }\n if (loader) {\n loader.registerComponent(component, meta);\n } else {\n registerComponent(component, meta);\n }\n return meta;\n}\n\nexport function makeComponentName(name: string) {\n return `plasmic-react-aria-${name}`;\n}\n\nexport function makeChildComponentName(\n fullParentName: string | undefined,\n fullChildName: string\n) {\n if (!fullParentName) {\n return fullChildName;\n }\n return `${fullParentName}-${fullChildName.replace(\n \"plasmic-react-aria-\",\n \"\"\n )}`;\n}\n\nexport interface Styleable {\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport function extractPlasmicDataProps(props: Record<string, any>) {\n return Object.fromEntries(\n Object.entries(props).filter(([key]) => key.startsWith(\"data-plasmic-\"))\n );\n}\n\nexport function withoutNils<T>(array: (T | undefined | null)[]) {\n return array.filter((x): x is T => x != null);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyBO,SAAS,uBACd,CAAA,MAAA,EACA,SACA,EAAA,IAAA,EACA,SACA,EAAA;AACA,EAAA,IAAI,SAAW,EAAA;AACb,IAAO,IAAA,GAAA,aAAA,CAAA,cAAA,CAAA,cAAA,CAAA,EAAA,EACF,OACA,SAFE,CAAA,EAAA;AAAA,MAGL,KAAO,EAAA,cAAA,CAAA,cAAA,CAAA,EAAA,EACF,IAAK,CAAA,KAAA,CAAA,EACL,SAAU,CAAA,KAAA,CAAA;AAAA,KAEjB,CAAA,CAAA;AACA,IAAA,IAAI,UAAU,mBAAqB,EAAA;AACjC,MAAA,IAAA,CAAK,IAAO,GAAA,sBAAA;AAAA,QACV,SAAU,CAAA,mBAAA;AAAA,QACV,IAAK,CAAA,IAAA;AAAA,OACP,CAAA;AAAA,KACF;AAAA,GACF;AACA,EAAA,IAAI,MAAQ,EAAA;AACV,IAAO,MAAA,CAAA,iBAAA,CAAkB,WAAW,IAAI,CAAA,CAAA;AAAA,GACnC,MAAA;AACL,IAAA,iBAAA,CAAkB,WAAW,IAAI,CAAA,CAAA;AAAA,GACnC;AACA,EAAO,OAAA,IAAA,CAAA;AACT,CAAA;AAEO,SAAS,kBAAkB,IAAc,EAAA;AAC9C,EAAA,OAAO,CAAsB,mBAAA,EAAA,IAAA,CAAA,CAAA,CAAA;AAC/B,CAAA;AAEgB,SAAA,sBAAA,CACd,gBACA,aACA,EAAA;AACA,EAAA,IAAI,CAAC,cAAgB,EAAA;AACnB,IAAO,OAAA,aAAA,CAAA;AAAA,GACT;AACA,EAAO,OAAA,CAAA,EAAG,kBAAkB,aAAc,CAAA,OAAA;AAAA,IACxC,qBAAA;AAAA,IACA,EAAA;AAAA,GACF,CAAA,CAAA,CAAA;AACF,CAAA;AAOO,SAAS,wBAAwB,KAA4B,EAAA;AAClE,EAAA,OAAO,MAAO,CAAA,WAAA;AAAA,IACZ,MAAO,CAAA,OAAA,CAAQ,KAAK,CAAA,CAAE,MAAO,CAAA,CAAC,CAAC,GAAG,CAAM,KAAA,GAAA,CAAI,UAAW,CAAA,eAAe,CAAC,CAAA;AAAA,GACzE,CAAA;AACF,CAAA;AAEO,SAAS,YAAe,KAAiC,EAAA;AAC9D,EAAA,OAAO,KAAM,CAAA,MAAA,CAAO,CAAC,CAAA,KAAc,KAAK,IAAI,CAAA,CAAA;AAC9C;;;;"}
@@ -42,6 +42,7 @@ function registerComponentHelper(loader, component, meta, overrides) {
42
42
  } else {
43
43
  registerComponent__default.default(component, meta);
44
44
  }
45
+ return meta;
45
46
  }
46
47
  function makeComponentName(name) {
47
48
  return `plasmic-react-aria-${name}`;
@@ -69,4 +70,4 @@ exports.makeChildComponentName = makeChildComponentName;
69
70
  exports.makeComponentName = makeComponentName;
70
71
  exports.registerComponentHelper = registerComponentHelper;
71
72
  exports.withoutNils = withoutNils;
72
- //# sourceMappingURL=utils-18b2465b.cjs.js.map
73
+ //# sourceMappingURL=utils-745db876.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-745db876.cjs.js","sources":["../src/utils.ts"],"sourcesContent":["import type { CodeComponentMeta } from \"@plasmicapp/host\";\nimport registerComponent from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\n\nexport type BaseControlContextData = {\n isStandalone: boolean;\n};\n\nexport type Registerable = {\n registerComponent: typeof registerComponent;\n};\n\nexport type OtherCodeComponentsMeta = {\n text: CodeComponentMeta<any>;\n description: CodeComponentMeta<any>;\n};\n\nexport type CodeComponentMetaOverrides<T extends React.ComponentType<any>> =\n Partial<\n Pick<\n CodeComponentMeta<React.ComponentProps<T>>,\n \"parentComponentName\" | \"props\" | \"displayName\" | \"name\"\n >\n >;\n\nexport function registerComponentHelper<T extends React.ComponentType<any>>(\n loader: Registerable | undefined,\n component: T,\n meta: CodeComponentMeta<React.ComponentProps<T>>,\n overrides?: CodeComponentMetaOverrides<T>\n) {\n if (overrides) {\n meta = {\n ...meta,\n ...overrides,\n props: {\n ...meta.props,\n ...overrides.props,\n },\n };\n if (overrides.parentComponentName) {\n meta.name = makeChildComponentName(\n overrides.parentComponentName,\n meta.name\n );\n }\n }\n if (loader) {\n loader.registerComponent(component, meta);\n } else {\n registerComponent(component, meta);\n }\n return meta;\n}\n\nexport function makeComponentName(name: string) {\n return `plasmic-react-aria-${name}`;\n}\n\nexport function makeChildComponentName(\n fullParentName: string | undefined,\n fullChildName: string\n) {\n if (!fullParentName) {\n return fullChildName;\n }\n return `${fullParentName}-${fullChildName.replace(\n \"plasmic-react-aria-\",\n \"\"\n )}`;\n}\n\nexport interface Styleable {\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport function extractPlasmicDataProps(props: Record<string, any>) {\n return Object.fromEntries(\n Object.entries(props).filter(([key]) => key.startsWith(\"data-plasmic-\"))\n );\n}\n\nexport function withoutNils<T>(array: (T | undefined | null)[]) {\n return array.filter((x): x is T => x != null);\n}\n"],"names":["registerComponent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,SAAS,uBACd,CAAA,MAAA,EACA,SACA,EAAA,IAAA,EACA,SACA,EAAA;AACA,EAAA,IAAI,SAAW,EAAA;AACb,IAAO,IAAA,GAAA,aAAA,CAAA,cAAA,CAAA,cAAA,CAAA,EAAA,EACF,OACA,SAFE,CAAA,EAAA;AAAA,MAGL,KAAO,EAAA,cAAA,CAAA,cAAA,CAAA,EAAA,EACF,IAAK,CAAA,KAAA,CAAA,EACL,SAAU,CAAA,KAAA,CAAA;AAAA,KAEjB,CAAA,CAAA;AACA,IAAA,IAAI,UAAU,mBAAqB,EAAA;AACjC,MAAA,IAAA,CAAK,IAAO,GAAA,sBAAA;AAAA,QACV,SAAU,CAAA,mBAAA;AAAA,QACV,IAAK,CAAA,IAAA;AAAA,OACP,CAAA;AAAA,KACF;AAAA,GACF;AACA,EAAA,IAAI,MAAQ,EAAA;AACV,IAAO,MAAA,CAAA,iBAAA,CAAkB,WAAW,IAAI,CAAA,CAAA;AAAA,GACnC,MAAA;AACL,IAAAA,kCAAA,CAAkB,WAAW,IAAI,CAAA,CAAA;AAAA,GACnC;AACA,EAAO,OAAA,IAAA,CAAA;AACT,CAAA;AAEO,SAAS,kBAAkB,IAAc,EAAA;AAC9C,EAAA,OAAO,CAAsB,mBAAA,EAAA,IAAA,CAAA,CAAA,CAAA;AAC/B,CAAA;AAEgB,SAAA,sBAAA,CACd,gBACA,aACA,EAAA;AACA,EAAA,IAAI,CAAC,cAAgB,EAAA;AACnB,IAAO,OAAA,aAAA,CAAA;AAAA,GACT;AACA,EAAO,OAAA,CAAA,EAAG,kBAAkB,aAAc,CAAA,OAAA;AAAA,IACxC,qBAAA;AAAA,IACA,EAAA;AAAA,GACF,CAAA,CAAA,CAAA;AACF,CAAA;AAOO,SAAS,wBAAwB,KAA4B,EAAA;AAClE,EAAA,OAAO,MAAO,CAAA,WAAA;AAAA,IACZ,MAAO,CAAA,OAAA,CAAQ,KAAK,CAAA,CAAE,MAAO,CAAA,CAAC,CAAC,GAAG,CAAM,KAAA,GAAA,CAAI,UAAW,CAAA,eAAe,CAAC,CAAA;AAAA,GACzE,CAAA;AACF,CAAA;AAEO,SAAS,YAAe,KAAiC,EAAA;AAC9D,EAAA,OAAO,KAAM,CAAA,MAAA,CAAO,CAAC,CAAA,KAAc,KAAK,IAAI,CAAA,CAAA;AAC9C;;;;;;;;"}
package/skinny/utils.d.ts CHANGED
@@ -1,11 +1,18 @@
1
1
  import type { CodeComponentMeta } from "@plasmicapp/host";
2
2
  import registerComponent from "@plasmicapp/host/registerComponent";
3
3
  import React from "react";
4
+ export type BaseControlContextData = {
5
+ isStandalone: boolean;
6
+ };
4
7
  export type Registerable = {
5
8
  registerComponent: typeof registerComponent;
6
9
  };
7
- export type CodeComponentMetaOverrides<T extends React.ComponentType<any>> = Partial<Pick<CodeComponentMeta<React.ComponentProps<T>>, "parentComponentName" | "props" | "displayName">>;
8
- export declare function registerComponentHelper<T extends React.ComponentType<any>>(loader: Registerable | undefined, component: T, meta: CodeComponentMeta<React.ComponentProps<T>>, overrides?: CodeComponentMetaOverrides<T>): void;
10
+ export type OtherCodeComponentsMeta = {
11
+ text: CodeComponentMeta<any>;
12
+ description: CodeComponentMeta<any>;
13
+ };
14
+ export type CodeComponentMetaOverrides<T extends React.ComponentType<any>> = Partial<Pick<CodeComponentMeta<React.ComponentProps<T>>, "parentComponentName" | "props" | "displayName" | "name">>;
15
+ export declare function registerComponentHelper<T extends React.ComponentType<any>>(loader: Registerable | undefined, component: T, meta: CodeComponentMeta<React.ComponentProps<T>>, overrides?: CodeComponentMetaOverrides<T>): CodeComponentMeta<React.ComponentProps<T>>;
9
16
  export declare function makeComponentName(name: string): string;
10
17
  export declare function makeChildComponentName(fullParentName: string | undefined, fullChildName: string): string;
11
18
  export interface Styleable {
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
-
3
- const PlasmicSliderContext = React.createContext(void 0);
4
- React.createContext(void 0);
5
- const PlasmicListBoxContext = React.createContext(void 0);
6
- const PlasmicPopoverContext = React.createContext(void 0);
7
- const PlasmicItemContext = React.createContext(void 0);
8
- const PlasmicSectionContext = React.createContext(void 0);
9
- const PlasmicHeaderContext = React.createContext(void 0);
10
- const PlasmicInputContext = React.createContext(void 0);
11
-
12
- export { PlasmicListBoxContext as P, PlasmicInputContext as a, PlasmicSectionContext as b, PlasmicItemContext as c, PlasmicPopoverContext as d, PlasmicHeaderContext as e, PlasmicSliderContext as f };
13
- //# sourceMappingURL=contexts-8a2a183b.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contexts-8a2a183b.esm.js","sources":["../src/contexts.tsx"],"sourcesContent":["import React from \"react\";\nimport type { BaseHeader } from \"./registerHeader\";\nimport type { BaseInput } from \"./registerInput\";\nimport type { BaseLabel } from \"./registerLabel\";\nimport type { BaseListBoxProps } from \"./registerListBox\";\nimport type { BaseListBoxItem } from \"./registerListBoxItem\";\nimport type { BasePopover } from \"./registerPopover\";\nimport type { BaseSection } from \"./registerSection\";\nimport { BaseSlider } from \"./registerSlider\";\n\n// We pass down context props via our own Plasmic*Context instead of directly\n// using react-aria-component's *Context, because react-aria-component's\n// contexts don't \"merge\" with contexts further up the tree, so if we render\n// a context provider, it will just be overwritten by react-aria-component's\n// context provider. So we do the merging within our own Base* components\n// instead.\n\nexport const PlasmicSliderContext = React.createContext<\n React.ComponentProps<typeof BaseSlider> | undefined\n>(undefined);\n\nexport const PlasmicLabelContext = React.createContext<\n React.ComponentProps<typeof BaseLabel> | undefined\n>(undefined);\n\nexport const PlasmicListBoxContext = React.createContext<\n BaseListBoxProps | undefined\n>(undefined);\n\nexport const PlasmicPopoverContext = React.createContext<\n React.ComponentProps<typeof BasePopover> | undefined\n>(undefined);\n\nexport const PlasmicItemContext = React.createContext<\n React.ComponentProps<typeof BaseListBoxItem> | undefined\n>(undefined);\n\nexport const PlasmicSectionContext = React.createContext<\n React.ComponentProps<typeof BaseSection> | undefined\n>(undefined);\n\nexport const PlasmicHeaderContext = React.createContext<\n React.ComponentProps<typeof BaseHeader> | undefined\n>(undefined);\n\nexport const PlasmicInputContext = React.createContext<\n React.ComponentProps<typeof BaseInput> | undefined\n>(undefined);\n"],"names":[],"mappings":";;AAiBa,MAAA,oBAAA,GAAuB,KAAM,CAAA,aAAA,CAExC,KAAS,CAAA,EAAA;AAEwB,KAAM,CAAA,aAAA,CAEvC,KAAS,CAAA,EAAA;AAEE,MAAA,qBAAA,GAAwB,KAAM,CAAA,aAAA,CAEzC,KAAS,CAAA,EAAA;AAEE,MAAA,qBAAA,GAAwB,KAAM,CAAA,aAAA,CAEzC,KAAS,CAAA,EAAA;AAEE,MAAA,kBAAA,GAAqB,KAAM,CAAA,aAAA,CAEtC,KAAS,CAAA,EAAA;AAEE,MAAA,qBAAA,GAAwB,KAAM,CAAA,aAAA,CAEzC,KAAS,CAAA,EAAA;AAEE,MAAA,oBAAA,GAAuB,KAAM,CAAA,aAAA,CAExC,KAAS,CAAA,EAAA;AAEE,MAAA,mBAAA,GAAsB,KAAM,CAAA,aAAA,CAEvC,KAAS,CAAA;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"contexts-dd0ce341.cjs.js","sources":["../src/contexts.tsx"],"sourcesContent":["import React from \"react\";\nimport type { BaseHeader } from \"./registerHeader\";\nimport type { BaseInput } from \"./registerInput\";\nimport type { BaseLabel } from \"./registerLabel\";\nimport type { BaseListBoxProps } from \"./registerListBox\";\nimport type { BaseListBoxItem } from \"./registerListBoxItem\";\nimport type { BasePopover } from \"./registerPopover\";\nimport type { BaseSection } from \"./registerSection\";\nimport { BaseSlider } from \"./registerSlider\";\n\n// We pass down context props via our own Plasmic*Context instead of directly\n// using react-aria-component's *Context, because react-aria-component's\n// contexts don't \"merge\" with contexts further up the tree, so if we render\n// a context provider, it will just be overwritten by react-aria-component's\n// context provider. So we do the merging within our own Base* components\n// instead.\n\nexport const PlasmicSliderContext = React.createContext<\n React.ComponentProps<typeof BaseSlider> | undefined\n>(undefined);\n\nexport const PlasmicLabelContext = React.createContext<\n React.ComponentProps<typeof BaseLabel> | undefined\n>(undefined);\n\nexport const PlasmicListBoxContext = React.createContext<\n BaseListBoxProps | undefined\n>(undefined);\n\nexport const PlasmicPopoverContext = React.createContext<\n React.ComponentProps<typeof BasePopover> | undefined\n>(undefined);\n\nexport const PlasmicItemContext = React.createContext<\n React.ComponentProps<typeof BaseListBoxItem> | undefined\n>(undefined);\n\nexport const PlasmicSectionContext = React.createContext<\n React.ComponentProps<typeof BaseSection> | undefined\n>(undefined);\n\nexport const PlasmicHeaderContext = React.createContext<\n React.ComponentProps<typeof BaseHeader> | undefined\n>(undefined);\n\nexport const PlasmicInputContext = React.createContext<\n React.ComponentProps<typeof BaseInput> | undefined\n>(undefined);\n"],"names":["React"],"mappings":";;;;;;;;AAiBa,MAAA,oBAAA,GAAuBA,sBAAM,CAAA,aAAA,CAExC,KAAS,CAAA,EAAA;AAEwBA,sBAAM,CAAA,aAAA,CAEvC,KAAS,CAAA,EAAA;AAEE,MAAA,qBAAA,GAAwBA,sBAAM,CAAA,aAAA,CAEzC,KAAS,CAAA,EAAA;AAEE,MAAA,qBAAA,GAAwBA,sBAAM,CAAA,aAAA,CAEzC,KAAS,CAAA,EAAA;AAEE,MAAA,kBAAA,GAAqBA,sBAAM,CAAA,aAAA,CAEtC,KAAS,CAAA,EAAA;AAEE,MAAA,qBAAA,GAAwBA,sBAAM,CAAA,aAAA,CAEzC,KAAS,CAAA,EAAA;AAEE,MAAA,oBAAA,GAAuBA,sBAAM,CAAA,aAAA,CAExC,KAAS,CAAA,EAAA;AAEE,MAAA,mBAAA,GAAsBA,sBAAM,CAAA,aAAA,CAEvC,KAAS,CAAA;;;;;;;;;;"}
@@ -1,153 +0,0 @@
1
- import React from 'react';
2
-
3
- function useStrictOptions(props) {
4
- const { options, optionInfo } = props;
5
- return React.useMemo(() => {
6
- return deriveStrictOptions({ options, optionInfo });
7
- }, [options, optionInfo]);
8
- }
9
- function deriveStrictOptions(props) {
10
- var _a;
11
- const { options, optionInfo } = props;
12
- let sectionCount = 0;
13
- const makeStrict = (op) => {
14
- var _a2, _b, _c, _d, _e, _f;
15
- if (!op) {
16
- return void 0;
17
- } else if (typeof op === "string" || typeof op === "number") {
18
- const item = {
19
- id: op
20
- };
21
- return item;
22
- } else if (optionInfo) {
23
- const info = optionInfo(op);
24
- if (info.type === "option-group") {
25
- const section = {
26
- type: "option-group",
27
- items: (_c = (_b = (_a2 = info.items) == null ? void 0 : _a2.map) == null ? void 0 : _b.call(_a2, (item) => makeStrict(item))) == null ? void 0 : _c.filter((x) => !!x),
28
- label: info.label,
29
- key: `option-group-${sectionCount}`
30
- };
31
- sectionCount += 1;
32
- return section;
33
- } else {
34
- let item = info;
35
- if (!("id" in item)) {
36
- item = {
37
- type: "option",
38
- id: JSON.stringify(item)
39
- };
40
- }
41
- return item;
42
- }
43
- } else if (typeof op === "object") {
44
- if ("items" in op) {
45
- const section = {
46
- type: "option-group",
47
- items: (_f = (_e = (_d = op.items) == null ? void 0 : _d.map) == null ? void 0 : _e.call(_d, (item) => makeStrict(item))) == null ? void 0 : _f.filter((x) => !!x),
48
- label: op.label,
49
- key: `option-group-${sectionCount}`
50
- };
51
- sectionCount += 1;
52
- return section;
53
- } else {
54
- let item = op;
55
- if (!("id" in item)) {
56
- item = {
57
- type: "option",
58
- id: JSON.stringify(item)
59
- };
60
- }
61
- return item;
62
- }
63
- } else {
64
- return void 0;
65
- }
66
- };
67
- const strictOptions = (_a = options == null ? void 0 : options.map(makeStrict)) == null ? void 0 : _a.filter((x) => !!x);
68
- const optionText = (op) => {
69
- var _a2;
70
- return (_a2 = op.label) != null ? _a2 : op.id;
71
- };
72
- return { options: strictOptions, optionText };
73
- }
74
- function flattenOptions(options) {
75
- if (!options) {
76
- return [];
77
- } else {
78
- return options.flatMap(
79
- (op) => {
80
- var _a;
81
- return op.type === "option-group" ? (_a = op.items) != null ? _a : [] : op;
82
- }
83
- );
84
- }
85
- }
86
- function makeOptionsPropType() {
87
- const type = {
88
- type: "array",
89
- itemType: {
90
- type: "object",
91
- nameFunc: (item) => item.label || item.id,
92
- fields: {
93
- type: {
94
- type: "choice",
95
- options: [
96
- { value: "option", label: "Option" },
97
- { value: "option-group", label: "Option Group" }
98
- ],
99
- defaultValue: "option"
100
- },
101
- id: {
102
- type: "string",
103
- hidden: (_ps, _ctx, { item }) => item.type !== "option"
104
- },
105
- label: "string",
106
- items: {
107
- type: "array",
108
- displayName: "Options",
109
- hidden: (_ps, _ctx, { item }) => {
110
- return item.type !== "option-group";
111
- },
112
- itemType: {
113
- type: "object",
114
- nameFunc: (item) => item.label || item.id,
115
- fields: {
116
- id: "string",
117
- label: "string"
118
- }
119
- }
120
- }
121
- }
122
- },
123
- defaultValue: [
124
- {
125
- id: "option1",
126
- label: "Option 1",
127
- type: "option"
128
- },
129
- {
130
- id: "option2",
131
- label: "Option 2",
132
- type: "option"
133
- }
134
- ]
135
- };
136
- return type;
137
- }
138
- function makeValuePropType() {
139
- const type = {
140
- type: "choice",
141
- options: (ps) => {
142
- const { options, optionText } = deriveStrictOptions(ps);
143
- return flattenOptions(options).map((op) => ({
144
- value: op.id,
145
- label: optionText(op)
146
- }));
147
- }
148
- };
149
- return type;
150
- }
151
-
152
- export { makeValuePropType as a, flattenOptions as f, makeOptionsPropType as m, useStrictOptions as u };
153
- //# sourceMappingURL=option-utils-4f037568.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"option-utils-4f037568.esm.js","sources":["../src/option-utils.ts"],"sourcesContent":["import type { ArrayType, ChoiceType } from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\n\nexport interface ObjectSectionType<T extends object> {\n label?: string;\n items?: ObjectItemType<T>[];\n}\ninterface FlexSectionType<T extends object> {\n label?: string;\n items?: FlexItemType<T>[];\n}\n\nexport type ObjectItemType<T extends object> = StrictOptionType | T;\ntype FlexItemType<T extends object> = ObjectItemType<T> | string;\n\nexport type FlexOptionType<T extends object> =\n | FlexItemType<T>\n | FlexSectionType<T>;\n\nexport type ObjectOptionType<T extends object> =\n | ObjectSectionType<T>\n | ObjectItemType<T>;\n\nexport interface HasOptions<T extends object> {\n options?: FlexOptionType<T>[];\n optionInfo?: (option: FlexOptionType<T>) => StrictOptionType;\n}\n\nexport interface StrictItemType {\n type?: \"option\";\n id: string;\n label?: string;\n isDisabled?: boolean;\n}\n\nexport interface StrictSectionType {\n type: \"option-group\";\n label?: string;\n items?: StrictItemType[];\n key: string;\n}\n\nexport type StrictOptionType = StrictItemType | StrictSectionType;\n\nexport function useStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n return React.useMemo(() => {\n return deriveStrictOptions({ options, optionInfo });\n }, [options, optionInfo]);\n}\n\nexport function deriveStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n let sectionCount = 0;\n\n const makeStrict = (op: FlexOptionType<T>): StrictOptionType | undefined => {\n if (!op) {\n return undefined;\n } else if (typeof op === \"string\" || typeof op === \"number\") {\n const item = {\n id: op,\n };\n return item;\n } else if (optionInfo) {\n const info = optionInfo(op);\n if (info.type === \"option-group\") {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: info.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: info.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = info;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else if (typeof op === \"object\") {\n if (\"items\" in op) {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: op.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: op.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = op;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else {\n return undefined;\n }\n };\n\n const strictOptions = options\n ?.map(makeStrict)\n ?.filter((x): x is StrictOptionType => !!x);\n\n const optionText = (op: StrictItemType) => {\n return op.label ?? op.id;\n };\n\n return { options: strictOptions, optionText };\n}\n\nexport function flattenOptions(\n options: (StrictItemType | StrictSectionType)[] | undefined\n): StrictItemType[] {\n if (!options) {\n return [];\n } else {\n return options.flatMap((op) =>\n op.type === \"option-group\" ? op.items ?? [] : op\n );\n }\n}\n\nexport function makeOptionsPropType() {\n const type: ArrayType<HasOptions<any>> = {\n type: \"array\",\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n type: {\n type: \"choice\",\n options: [\n { value: \"option\", label: \"Option\" },\n { value: \"option-group\", label: \"Option Group\" },\n ],\n defaultValue: \"option\",\n },\n id: {\n type: \"string\",\n hidden: (_ps: any, _ctx: any, { item }: any) =>\n item.type !== \"option\",\n },\n label: \"string\",\n items: {\n type: \"array\",\n displayName: \"Options\",\n hidden: (_ps: any, _ctx: any, { item }: any) => {\n return item.type !== \"option-group\";\n },\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n id: \"string\",\n label: \"string\",\n },\n },\n },\n },\n },\n defaultValue: [\n {\n id: \"option1\",\n label: \"Option 1\",\n type: \"option\",\n },\n {\n id: \"option2\",\n label: \"Option 2\",\n type: \"option\",\n },\n ],\n };\n return type;\n}\n\nexport function makeValuePropType() {\n const type: ChoiceType<HasOptions<any>> = {\n type: \"choice\",\n options: (ps: HasOptions<any>) => {\n const { options, optionText } = deriveStrictOptions(ps);\n return flattenOptions(options).map((op) => ({\n value: op.id,\n label: optionText(op),\n }));\n },\n };\n return type;\n}\n"],"names":["_a"],"mappings":";;AA4CO,SAAS,iBAAmC,KAAsB,EAAA;AACvE,EAAM,MAAA,EAAE,OAAS,EAAA,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EAAA,SAAA;AAAA,QACJ,KAAO,EAAA,UAAA;AAAA,QACP,IAAM,EAAA,QAAA;AAAA,OACR;AAAA,KACF;AAAA,GACF,CAAA;AACA,EAAO,OAAA,IAAA,CAAA;AACT,CAAA;AAEO,SAAS,iBAAoB,GAAA;AAClC,EAAA,MAAM,IAAoC,GAAA;AAAA,IACxC,IAAM,EAAA,QAAA;AAAA,IACN,OAAA,EAAS,CAAC,EAAwB,KAAA;AAChC,MAAA,MAAM,EAAE,OAAA,EAAS,UAAW,EAAA,GAAI,oBAAoB,EAAE,CAAA,CAAA;AACtD,MAAA,OAAO,cAAe,CAAA,OAAO,CAAE,CAAA,GAAA,CAAI,CAAC,EAAQ,MAAA;AAAA,QAC1C,OAAO,EAAG,CAAA,EAAA;AAAA,QACV,KAAA,EAAO,WAAW,EAAE,CAAA;AAAA,OACpB,CAAA,CAAA,CAAA;AAAA,KACJ;AAAA,GACF,CAAA;AACA,EAAO,OAAA,IAAA,CAAA;AACT;;;;"}
@@ -1,162 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
-
5
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
-
7
- var React__default = /*#__PURE__*/_interopDefault(React);
8
-
9
- function useStrictOptions(props) {
10
- const { options, optionInfo } = props;
11
- return React__default.default.useMemo(() => {
12
- return deriveStrictOptions({ options, optionInfo });
13
- }, [options, optionInfo]);
14
- }
15
- function deriveStrictOptions(props) {
16
- var _a;
17
- const { options, optionInfo } = props;
18
- let sectionCount = 0;
19
- const makeStrict = (op) => {
20
- var _a2, _b, _c, _d, _e, _f;
21
- if (!op) {
22
- return void 0;
23
- } else if (typeof op === "string" || typeof op === "number") {
24
- const item = {
25
- id: op
26
- };
27
- return item;
28
- } else if (optionInfo) {
29
- const info = optionInfo(op);
30
- if (info.type === "option-group") {
31
- const section = {
32
- type: "option-group",
33
- items: (_c = (_b = (_a2 = info.items) == null ? void 0 : _a2.map) == null ? void 0 : _b.call(_a2, (item) => makeStrict(item))) == null ? void 0 : _c.filter((x) => !!x),
34
- label: info.label,
35
- key: `option-group-${sectionCount}`
36
- };
37
- sectionCount += 1;
38
- return section;
39
- } else {
40
- let item = info;
41
- if (!("id" in item)) {
42
- item = {
43
- type: "option",
44
- id: JSON.stringify(item)
45
- };
46
- }
47
- return item;
48
- }
49
- } else if (typeof op === "object") {
50
- if ("items" in op) {
51
- const section = {
52
- type: "option-group",
53
- items: (_f = (_e = (_d = op.items) == null ? void 0 : _d.map) == null ? void 0 : _e.call(_d, (item) => makeStrict(item))) == null ? void 0 : _f.filter((x) => !!x),
54
- label: op.label,
55
- key: `option-group-${sectionCount}`
56
- };
57
- sectionCount += 1;
58
- return section;
59
- } else {
60
- let item = op;
61
- if (!("id" in item)) {
62
- item = {
63
- type: "option",
64
- id: JSON.stringify(item)
65
- };
66
- }
67
- return item;
68
- }
69
- } else {
70
- return void 0;
71
- }
72
- };
73
- const strictOptions = (_a = options == null ? void 0 : options.map(makeStrict)) == null ? void 0 : _a.filter((x) => !!x);
74
- const optionText = (op) => {
75
- var _a2;
76
- return (_a2 = op.label) != null ? _a2 : op.id;
77
- };
78
- return { options: strictOptions, optionText };
79
- }
80
- function flattenOptions(options) {
81
- if (!options) {
82
- return [];
83
- } else {
84
- return options.flatMap(
85
- (op) => {
86
- var _a;
87
- return op.type === "option-group" ? (_a = op.items) != null ? _a : [] : op;
88
- }
89
- );
90
- }
91
- }
92
- function makeOptionsPropType() {
93
- const type = {
94
- type: "array",
95
- itemType: {
96
- type: "object",
97
- nameFunc: (item) => item.label || item.id,
98
- fields: {
99
- type: {
100
- type: "choice",
101
- options: [
102
- { value: "option", label: "Option" },
103
- { value: "option-group", label: "Option Group" }
104
- ],
105
- defaultValue: "option"
106
- },
107
- id: {
108
- type: "string",
109
- hidden: (_ps, _ctx, { item }) => item.type !== "option"
110
- },
111
- label: "string",
112
- items: {
113
- type: "array",
114
- displayName: "Options",
115
- hidden: (_ps, _ctx, { item }) => {
116
- return item.type !== "option-group";
117
- },
118
- itemType: {
119
- type: "object",
120
- nameFunc: (item) => item.label || item.id,
121
- fields: {
122
- id: "string",
123
- label: "string"
124
- }
125
- }
126
- }
127
- }
128
- },
129
- defaultValue: [
130
- {
131
- id: "option1",
132
- label: "Option 1",
133
- type: "option"
134
- },
135
- {
136
- id: "option2",
137
- label: "Option 2",
138
- type: "option"
139
- }
140
- ]
141
- };
142
- return type;
143
- }
144
- function makeValuePropType() {
145
- const type = {
146
- type: "choice",
147
- options: (ps) => {
148
- const { options, optionText } = deriveStrictOptions(ps);
149
- return flattenOptions(options).map((op) => ({
150
- value: op.id,
151
- label: optionText(op)
152
- }));
153
- }
154
- };
155
- return type;
156
- }
157
-
158
- exports.flattenOptions = flattenOptions;
159
- exports.makeOptionsPropType = makeOptionsPropType;
160
- exports.makeValuePropType = makeValuePropType;
161
- exports.useStrictOptions = useStrictOptions;
162
- //# sourceMappingURL=option-utils-5e4e85bd.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"option-utils-5e4e85bd.cjs.js","sources":["../src/option-utils.ts"],"sourcesContent":["import type { ArrayType, ChoiceType } from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\n\nexport interface ObjectSectionType<T extends object> {\n label?: string;\n items?: ObjectItemType<T>[];\n}\ninterface FlexSectionType<T extends object> {\n label?: string;\n items?: FlexItemType<T>[];\n}\n\nexport type ObjectItemType<T extends object> = StrictOptionType | T;\ntype FlexItemType<T extends object> = ObjectItemType<T> | string;\n\nexport type FlexOptionType<T extends object> =\n | FlexItemType<T>\n | FlexSectionType<T>;\n\nexport type ObjectOptionType<T extends object> =\n | ObjectSectionType<T>\n | ObjectItemType<T>;\n\nexport interface HasOptions<T extends object> {\n options?: FlexOptionType<T>[];\n optionInfo?: (option: FlexOptionType<T>) => StrictOptionType;\n}\n\nexport interface StrictItemType {\n type?: \"option\";\n id: string;\n label?: string;\n isDisabled?: boolean;\n}\n\nexport interface StrictSectionType {\n type: \"option-group\";\n label?: string;\n items?: StrictItemType[];\n key: string;\n}\n\nexport type StrictOptionType = StrictItemType | StrictSectionType;\n\nexport function useStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n return React.useMemo(() => {\n return deriveStrictOptions({ options, optionInfo });\n }, [options, optionInfo]);\n}\n\nexport function deriveStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n let sectionCount = 0;\n\n const makeStrict = (op: FlexOptionType<T>): StrictOptionType | undefined => {\n if (!op) {\n return undefined;\n } else if (typeof op === \"string\" || typeof op === \"number\") {\n const item = {\n id: op,\n };\n return item;\n } else if (optionInfo) {\n const info = optionInfo(op);\n if (info.type === \"option-group\") {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: info.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: info.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = info;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else if (typeof op === \"object\") {\n if (\"items\" in op) {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: op.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: op.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = op;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else {\n return undefined;\n }\n };\n\n const strictOptions = options\n ?.map(makeStrict)\n ?.filter((x): x is StrictOptionType => !!x);\n\n const optionText = (op: StrictItemType) => {\n return op.label ?? op.id;\n };\n\n return { options: strictOptions, optionText };\n}\n\nexport function flattenOptions(\n options: (StrictItemType | StrictSectionType)[] | undefined\n): StrictItemType[] {\n if (!options) {\n return [];\n } else {\n return options.flatMap((op) =>\n op.type === \"option-group\" ? op.items ?? [] : op\n );\n }\n}\n\nexport function makeOptionsPropType() {\n const type: ArrayType<HasOptions<any>> = {\n type: \"array\",\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n type: {\n type: \"choice\",\n options: [\n { value: \"option\", label: \"Option\" },\n { value: \"option-group\", label: \"Option Group\" },\n ],\n defaultValue: \"option\",\n },\n id: {\n type: \"string\",\n hidden: (_ps: any, _ctx: any, { item }: any) =>\n item.type !== \"option\",\n },\n label: \"string\",\n items: {\n type: \"array\",\n displayName: \"Options\",\n hidden: (_ps: any, _ctx: any, { item }: any) => {\n return item.type !== \"option-group\";\n },\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n id: \"string\",\n label: \"string\",\n },\n },\n },\n },\n },\n defaultValue: [\n {\n id: \"option1\",\n label: \"Option 1\",\n type: \"option\",\n },\n {\n id: \"option2\",\n label: \"Option 2\",\n type: \"option\",\n },\n ],\n };\n return type;\n}\n\nexport function makeValuePropType() {\n const type: ChoiceType<HasOptions<any>> = {\n type: \"choice\",\n options: (ps: HasOptions<any>) => {\n const { options, optionText } = deriveStrictOptions(ps);\n return flattenOptions(options).map((op) => ({\n value: op.id,\n label: optionText(op),\n }));\n },\n };\n return type;\n}\n"],"names":["React","_a"],"mappings":";;;;;;;;AA4CO,SAAS,iBAAmC,KAAsB,EAAA;AACvE,EAAM,MAAA,EAAE,OAAS,EAAA,UAAA,EAAe,GAAA,KAAA,CAAA;AAChC,EAAO,OAAAA,sBAAA,CAAM,QAAQ,MAAM;AACzB,IAAA,OAAO,mBAAoB,CAAA,EAAE,OAAS,EAAA,UAAA,EAAY,CAAA,CAAA;AAAA,GACjD,EAAA,CAAC,OAAS,EAAA,UAAU,CAAC,CAAA,CAAA;AAC1B,CAAA;AAEO,SAAS,oBAAsC,KAAsB,EAAA;AAnD5E,EAAA,IAAA,EAAA,CAAA;AAoDE,EAAM,MAAA,EAAE,OAAS,EAAA,UAAA,EAAe,GAAA,KAAA,CAAA;AAChC,EAAA,IAAI,YAAe,GAAA,C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