@plasmicpkgs/plasmic-tabs 0.0.4 → 0.0.5

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.
@@ -28,11 +28,11 @@ function _extends() {
28
28
  var noop = function noop() {};
29
29
  function defaultButtonChildren(label) {
30
30
  return {
31
- type: "default-component",
32
- kind: "button",
31
+ type: 'default-component',
32
+ kind: 'button',
33
33
  props: {
34
34
  children: {
35
- type: "text",
35
+ type: 'text',
36
36
  value: label
37
37
  }
38
38
  }
@@ -59,77 +59,77 @@ var _constate = /*#__PURE__*/constate(useTabsData),
59
59
  useTabsContextUnsafe = _constate[1];
60
60
  function useTabsContext() {
61
61
  var result = useTabsContextUnsafe();
62
- return "setTabKey" in result ? result : undefined;
62
+ return 'setTabKey' in result ? result : undefined;
63
63
  }
64
- var modulePath = "@plasmicpkgs/plasmic-tabs";
64
+ var modulePath = '@plasmicpkgs/plasmic-tabs';
65
65
  var TabsContainerMeta = {
66
- name: "hostless-tabs-container",
67
- displayName: "Tabs Container",
68
- importName: "TabsContainer",
66
+ name: 'hostless-tabs-container',
67
+ displayName: 'Tabs Container',
68
+ importName: 'TabsContainer',
69
69
  importPath: modulePath,
70
70
  providesData: true,
71
71
  defaultStyles: {
72
- width: "stretch",
73
- padding: "8px"
72
+ width: 'stretch',
73
+ padding: '8px'
74
74
  },
75
75
  props: {
76
76
  initialKey: {
77
- type: "string",
78
- description: "Key of the initially selected tab",
79
- defaultValue: "tab1"
77
+ type: 'string',
78
+ description: 'Key of the initially selected tab',
79
+ defaultValue: 'tab1'
80
80
  },
81
81
  previewKey: {
82
- type: "string",
83
- description: "SShow this key while editing in Plasmic Studio"
82
+ type: 'string',
83
+ description: 'SShow this key while editing in Plasmic Studio'
84
84
  },
85
85
  previewAll: {
86
- type: "boolean",
87
- description: "Reveal all tab contents while editing in Plasmic Studio"
86
+ type: 'boolean',
87
+ description: 'Reveal all tab contents while editing in Plasmic Studio'
88
88
  },
89
89
  children: {
90
- type: "slot",
90
+ type: 'slot',
91
91
  defaultValue: {
92
- type: "vbox",
92
+ type: 'vbox',
93
93
  children: [{
94
- type: "hbox",
94
+ type: 'hbox',
95
95
  children: [{
96
- type: "component",
97
- name: "hostless-tab-button",
96
+ type: 'component',
97
+ name: 'hostless-tab-button',
98
98
  props: {
99
- tabKey: "tab1",
100
- children: /*#__PURE__*/defaultButtonChildren("Tab 1")
99
+ tabKey: 'tab1',
100
+ children: /*#__PURE__*/defaultButtonChildren('Tab 1')
101
101
  }
102
102
  }, {
103
- type: "component",
104
- name: "hostless-tab-button",
103
+ type: 'component',
104
+ name: 'hostless-tab-button',
105
105
  props: {
106
- tabKey: "tab2",
107
- children: /*#__PURE__*/defaultButtonChildren("Tab 2")
106
+ tabKey: 'tab2',
107
+ children: /*#__PURE__*/defaultButtonChildren('Tab 2')
108
108
  }
109
109
  }, {
110
- type: "component",
111
- name: "hostless-tab-underline"
110
+ type: 'component',
111
+ name: 'hostless-tab-underline'
112
112
  }]
113
113
  }, {
114
- type: "vbox",
114
+ type: 'vbox',
115
115
  children: [{
116
- type: "component",
117
- name: "hostless-tab-content",
116
+ type: 'component',
117
+ name: 'hostless-tab-content',
118
118
  props: {
119
- tabKey: "tab1",
119
+ tabKey: 'tab1',
120
120
  children: [{
121
- type: "vbox",
122
- children: ["Some content for tab 1"]
121
+ type: 'vbox',
122
+ children: ['Some content for tab 1']
123
123
  }]
124
124
  }
125
125
  }, {
126
- type: "component",
127
- name: "hostless-tab-content",
126
+ type: 'component',
127
+ name: 'hostless-tab-content',
128
128
  props: {
129
- tabKey: "tab2",
129
+ tabKey: 'tab2',
130
130
  children: [{
131
- type: "vbox",
132
- children: ["Some content for tab 2"]
131
+ type: 'vbox',
132
+ children: ['Some content for tab 2']
133
133
  }]
134
134
  }
135
135
  }]
@@ -155,7 +155,7 @@ function TabsContainer(_ref2) {
155
155
  }
156
156
  function ensure(x) {
157
157
  if (!x) {
158
- throw new Error("unexpected nil");
158
+ throw new Error('unexpected nil');
159
159
  }
160
160
  return x;
161
161
  }
@@ -167,23 +167,19 @@ function Helper(_ref3) {
167
167
  tabKey = _ensure.tabKey;
168
168
  var effectiveKey = inEditor ? previewKey || tabKey : tabKey;
169
169
  return React__default.createElement(host.DataProvider, {
170
- name: "currentTabKey",
170
+ name: 'currentTabKey',
171
171
  data: effectiveKey
172
172
  }, children);
173
173
  }
174
174
  var TabUnderlineMeta = {
175
- name: "hostless-tab-underline",
176
- displayName: "Tab Underline",
177
- importName: "TabUnderline",
175
+ name: 'hostless-tab-underline',
176
+ displayName: 'Tab Underline',
177
+ importName: 'TabUnderline',
178
178
  importPath: modulePath,
179
- props: {
180
- children: {
181
- type: "slot"
182
- }
183
- },
179
+ props: {},
184
180
  defaultStyles: {
185
- background: "#7777ff",
186
- height: "2px"
181
+ background: '#7777ff',
182
+ height: '2px'
187
183
  }
188
184
  };
189
185
  function TabUnderline(_ref4) {
@@ -198,29 +194,29 @@ function TabUnderline(_ref4) {
198
194
  style: _extends({}, JSON.parse(JSON.stringify(bbox)), {
199
195
  top: undefined,
200
196
  bottom: 0,
201
- position: "absolute",
202
- transition: ".4s ease all"
197
+ position: 'absolute',
198
+ transition: '.4s ease all'
203
199
  })
204
200
  }) : null;
205
201
  }
206
202
  var TabButtonMeta = {
207
- name: "hostless-tab-button",
203
+ name: 'hostless-tab-button',
208
204
  isAttachment: true,
209
- displayName: "Tab Button",
210
- importName: "TabButton",
205
+ displayName: 'Tab Button',
206
+ importName: 'TabButton',
211
207
  importPath: modulePath,
212
208
  props: {
213
209
  tabKey: {
214
- type: "string",
215
- description: "The answer value selecting this choice sets"
210
+ type: 'string',
211
+ description: 'The answer value selecting this choice sets'
216
212
  },
217
213
  children: {
218
- type: "slot",
219
- defaultValue: /*#__PURE__*/defaultButtonChildren("Some tab")
214
+ type: 'slot',
215
+ defaultValue: /*#__PURE__*/defaultButtonChildren('Some tab')
220
216
  }
221
217
  },
222
218
  defaultStyles: {
223
- width: "hug"
219
+ width: 'hug'
224
220
  }
225
221
  };
226
222
  function TabButton(_ref6) {
@@ -258,23 +254,23 @@ function TabButton(_ref6) {
258
254
  }));
259
255
  }
260
256
  var TabContentMeta = {
261
- name: "hostless-tab-content",
257
+ name: 'hostless-tab-content',
262
258
  isAttachment: true,
263
- displayName: "Tab Content",
264
- importName: "TabContent",
259
+ displayName: 'Tab Content',
260
+ importName: 'TabContent',
265
261
  importPath: modulePath,
266
262
  props: {
267
263
  tabKey: {
268
- type: "string",
269
- description: "The answer value selecting this choice sets"
264
+ type: 'string',
265
+ description: 'The answer value selecting this choice sets'
270
266
  },
271
267
  children: {
272
- type: "slot",
268
+ type: 'slot',
273
269
  defaultValue: {
274
- type: "vbox",
270
+ type: 'vbox',
275
271
  children: {
276
- type: "text",
277
- value: "This is some tab content"
272
+ type: 'text',
273
+ value: 'This is some tab content'
278
274
  }
279
275
  }
280
276
  }
@@ -1 +1 @@
1
- {"version":3,"file":"plasmic-tabs.cjs.development.js","sources":["../src/tabs.tsx","../src/index.tsx"],"sourcesContent":["import { DataProvider, usePlasmicCanvasContext,ComponentMeta } from \"@plasmicapp/host\";\nimport constate from \"constate\";\nimport React, {\n cloneElement,\n createContext,\n ReactElement,\n ReactNode,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\n\n\nconst noop = ()=>{};\n\nfunction defaultButtonChildren(label: string) {\n return {\n type: \"default-component\",\n kind: \"button\",\n props: {\n children: {\n type: \"text\",\n value: label,\n },\n },\n } as const;\n}\nexport interface TabsProviderProps {\n children?: ReactNode;\n initialKey?: string;\n previewKey?: string;\n previewAll?: boolean;\n}\n\nconst DebugContext = createContext(false);\n\nfunction useTabsData({ initialKey }: { initialKey?: string }) {\n const [tabKey, setTabKey] = useState<string | undefined>(initialKey);\n const [bbox, setBbox] = useState<{ left: number; width: number } | undefined>(\n undefined\n );\n return {\n tabKey,\n bbox,\n setTabKey,\n setBbox,\n };\n}\n\nconst [TabsProvider, useTabsContextUnsafe] = constate(useTabsData);\n\nfunction useTabsContext() {\n const result = useTabsContextUnsafe();\n return \"setTabKey\" in result ? result : undefined;\n}\nconst modulePath=\"@plasmicpkgs/plasmic-tabs\"\n\nexport const TabsContainerMeta: ComponentMeta<TabsProviderProps> = {\n name: \"hostless-tabs-container\",\n displayName: \"Tabs Container\",\n importName: \"TabsContainer\",\n importPath: modulePath,\n providesData:true,\n defaultStyles: {\n width: \"stretch\",\n padding: \"8px\",\n },\n props: {\n initialKey: {\n type: \"string\",\n description: \"Key of the initially selected tab\",\n defaultValue: \"tab1\",\n },\n previewKey: {\n type: \"string\",\n description: \"SShow this key while editing in Plasmic Studio\",\n },\n previewAll: {\n type: \"boolean\",\n description: \"Reveal all tab contents while editing in Plasmic Studio\",\n },\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"vbox\",\n children: [\n {\n type: \"hbox\",\n children: [\n {\n type: \"component\",\n name: \"hostless-tab-button\",\n props: {\n tabKey: \"tab1\",\n children:defaultButtonChildren(\"Tab 1\")\n },\n },\n {\n type: \"component\",\n name: \"hostless-tab-button\",\n props: {\n tabKey: \"tab2\",\n children:defaultButtonChildren(\"Tab 2\")\n },\n },\n {\n type: \"component\",\n name: \"hostless-tab-underline\",\n },\n ],\n },\n {\n type: \"vbox\",\n children: [\n {\n type: \"component\",\n name: \"hostless-tab-content\",\n props: {\n tabKey: \"tab1\",\n children: [\n {\n type: \"vbox\",\n children: [\"Some content for tab 1\"],\n },\n ],\n },\n },\n {\n type: \"component\",\n name: \"hostless-tab-content\",\n props: {\n tabKey: \"tab2\",\n children: [\n {\n type: \"vbox\",\n children: [\"Some content for tab 2\"],\n },\n ],\n },\n },\n ],\n },\n ],\n },\n },\n },\n };\n\n\nexport function TabsContainer({\n children,\n initialKey,\n previewKey,\n previewAll = false,\n}: TabsProviderProps) {\n const inEditor = !!usePlasmicCanvasContext();\n return (\n <TabsProvider initialKey={initialKey}>\n <DebugContext.Provider value={inEditor && previewAll}>\n <Helper previewKey={previewKey || initialKey}>{children}</Helper>\n </DebugContext.Provider>\n </TabsProvider>\n );\n}\n\nfunction ensure<T>(x: T | undefined | null) {\n if (!x) {\n throw new Error(\"unexpected nil\");\n }\n return x;\n}\n\nfunction Helper({\n children,\n previewKey,\n}: {\n previewKey?: string;\n children?: ReactNode;\n}) {\n const inEditor = usePlasmicCanvasContext();\n const { tabKey } = ensure(useTabsContext());\n const effectiveKey = inEditor ? previewKey || tabKey : tabKey;\n return (\n <DataProvider name={\"currentTabKey\"} data={effectiveKey}>\n {children}\n </DataProvider>\n );\n}\n\nexport interface TabUnderlineProps {\n className?: string;\n}\n\nexport const TabUnderlineMeta:ComponentMeta <TabUnderlineProps>={\n name: \"hostless-tab-underline\",\n displayName: \"Tab Underline\",\n importName: \"TabUnderline\",\n importPath: modulePath,\n props: {\n children: {\n type: \"slot\",\n },\n },\n defaultStyles: {\n background: \"#7777ff\",\n height: \"2px\",\n },\n}\n\n\nexport function TabUnderline({ className }: TabUnderlineProps) {\n const { bbox } = useTabsContext() ?? { bbox: undefined };\n return bbox ? (\n <div\n className={className}\n style={{\n ...JSON.parse(JSON.stringify(bbox)),\n top: undefined,\n bottom: 0,\n position: \"absolute\",\n transition: \".4s ease all\",\n }}\n ></div>\n ) : null;\n}\n\nexport interface TabButtonProps {\n className?: string;\n children?: ReactNode;\n tabKey?: string;\n}\n\nexport const TabButtonMeta:ComponentMeta<TabButtonProps>={\n name: \"hostless-tab-button\",\n isAttachment: true,\n displayName: \"Tab Button\",\n importName: \"TabButton\",\n importPath: modulePath,\n props: {\n tabKey: {\n type: \"string\",\n description: \"The answer value selecting this choice sets\",\n },\n children: {\n type: \"slot\",\n defaultValue:defaultButtonChildren(\"Some tab\")\n },\n },\n defaultStyles: {\n width: \"hug\",\n },\n}\n\nexport function TabButton({ className, children, tabKey }: TabButtonProps) {\n const tabsContext = useTabsContext();\n const ref = useRef<HTMLDivElement>(null);\n const { tabKey: activeKey, setTabKey, bbox, setBbox } = tabsContext ?? {\n tabKey: undefined,\n setTabKey: noop,\n bbox: undefined,\n setBbox:noop,\n };\n useEffect(() => {\n if (tabKey === activeKey) {\n setBbox({\n width: ref.current!.offsetWidth,\n left: ref.current!.offsetLeft,\n });\n }\n }, [ref.current, setBbox, JSON.stringify(bbox), tabKey, activeKey]);\n return (\n <div className={className} ref={ref}>\n {cloneElement(React.Children.toArray(children)[0] as ReactElement, {\n isActive: tabKey && activeKey && activeKey === tabKey,\n onClick: () => {\n setTabKey(tabKey);\n },\n })}\n </div>\n );\n}\n\nexport interface TabContentProps {\n children?: ReactNode;\n tabKey?: string;\n}\n\nexport const TabContentMeta:ComponentMeta<TabContentProps>={\n name: \"hostless-tab-content\",\n isAttachment: true,\n displayName: \"Tab Content\",\n importName: \"TabContent\",\n importPath: modulePath,\n props: {\n tabKey: {\n type: \"string\",\n description: \"The answer value selecting this choice sets\",\n },\n children: {\n type: \"slot\",\n defaultValue: {\n type:\"vbox\",\n children:{\n type:\"text\",\n value:\"This is some tab content\"\n }\n },\n },\n },\n}\nexport function TabContent({ children, tabKey }: TabContentProps) {\n const tabsContext = useTabsContext();\n const previewAll = useContext(DebugContext);\n const { tabKey: activeKey } = tabsContext ?? { tabKey: undefined };\n return (\n <>\n {tabsContext === undefined || activeKey === tabKey || previewAll\n ? children\n : null}\n </>\n );\n}\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\n\nimport {\n TabsContainer,\n TabsContainerMeta,\n TabUnderline,\n TabUnderlineMeta,\n TabButton,\n TabButtonMeta,\n TabContent, TabContentMeta\n} from \"./tabs\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n}) {\n const _registerComponent = <T extends React.ComponentType<any>>(\n Component: T,\n defaultMeta: ComponentMeta<React.ComponentProps<T>>\n ) => {\n if (loader) {\n loader.registerComponent(Component, defaultMeta);\n } else {\n registerComponent(Component, defaultMeta);\n }\n };\n \n _registerComponent(TabsContainer, TabsContainerMeta);\n _registerComponent(TabUnderline, TabUnderlineMeta);\n _registerComponent(TabButton, TabButtonMeta);\n _registerComponent(TabContent, TabContentMeta);\n\n}\n\nexport * from \"./tabs\";\n"],"names":["noop","defaultButtonChildren","label","type","kind","props","children","value","DebugContext","createContext","useTabsData","initialKey","useState","tabKey","setTabKey","undefined","bbox","setBbox","constate","TabsProvider","useTabsContextUnsafe","useTabsContext","result","modulePath","TabsContainerMeta","name","displayName","importName","importPath","providesData","defaultStyles","width","padding","description","defaultValue","previewKey","previewAll","TabsContainer","inEditor","usePlasmicCanvasContext","React","Provider","Helper","ensure","x","Error","effectiveKey","DataProvider","data","TabUnderlineMeta","background","height","TabUnderline","className","style","JSON","parse","stringify","top","bottom","position","transition","TabButtonMeta","isAttachment","TabButton","tabsContext","ref","useRef","activeKey","useEffect","current","offsetWidth","left","offsetLeft","cloneElement","Children","toArray","isActive","onClick","TabContentMeta","TabContent","useContext","registerAll","loader","_registerComponent","Component","defaultMeta","registerComponent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,IAAMA,IAAI,GAAG,SAAPA,IAAI,KAAS;AAEnB,SAASC,qBAAqB,CAACC,KAAa;EAC1C,OAAO;IACLC,IAAI,EAAE,mBAAmB;IACzBC,IAAI,EAAE,QAAQ;IACdC,KAAK,EAAE;MACLC,QAAQ,EAAE;QACRH,IAAI,EAAE,MAAM;QACZI,KAAK,EAAEL;;;GAGH;AACZ;AAQA,IAAMM,YAAY,gBAAGC,mBAAa,CAAC,KAAK,CAAC;AAEzC,SAASC,WAAW;MAAGC,UAAU,QAAVA,UAAU;EAC/B,gBAA4BC,cAAQ,CAAqBD,UAAU,CAAC;IAA7DE,MAAM;IAAEC,SAAS;EACxB,iBAAwBF,cAAQ,CAC9BG,SAAS,CACV;IAFMC,IAAI;IAAEC,OAAO;EAGpB,OAAO;IACLJ,MAAM,EAANA,MAAM;IACNG,IAAI,EAAJA,IAAI;IACJF,SAAS,EAATA,SAAS;IACTG,OAAO,EAAPA;GACD;AACH;AAEA,6BAA6CC,QAAQ,CAACR,WAAW,CA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3B,QAAQ,EAAE;MACRH,IAAI,EAAE,MAAM;MACZ+B,YAAY,EAAE;QACd/B,IAAI,EAAC,MAAM;QACXG,QAAQ,EAAC;UACPH,IAAI,EAAC,MAAM;UACXI,KAAK,EAAC;;;;;;SAMEyE,UAAU;MAAG1E,QAAQ,SAARA,QAAQ;IAAEO,MAAM,SAANA,MAAM;EAC3C,IAAMoD,WAAW,GAAG5C,cAAc,EAAE;EACpC,IAAMe,UAAU,GAAG6C,gBAAU,CAACzE,YAAY,CAAC;EAC3C,YAA8ByD,WAAW,WAAXA,WAAW,GAAI;MAAEpD,MAAM,EAAEE;KAAW;IAAlDqD,SAAS,SAAjBvD,MAAM;EACd,OACE2B,4DACGyB,WAAW,KAAKlD,SAAS,IAAIqD,SAAS,KAAKvD,MAAM,IAAIuB,UAAU,GAC5D9B,QAAQ,GACR,IAAI,CACP;AAEP;;SCpTgB4E,WAAW,CAACC,MAE3B;EACC,IAAMC,kBAAkB,GAAG,SAArBA,kBAAkB,CACtBC,SAAY,EACZC,WAAmD;IAEnD,IAAIH,MAAM,EAAE;MACVA,MAAM,CAACI,iBAAiB,CAACF,SAAS,EAAEC,WAAW,CAAC;KACjD,MAAM;MACLC,iBAAiB,CAACF,SAAS,EAAEC,WAAW,CAAC;;GAE5C;EAEDF,kBAAkB,CAAC/C,aAAa,EAAEb,iBAAiB,CAAC;EACpD4D,kBAAkB,CAAChC,YAAY,EAAEH,gBAAgB,CAAC;EAClDmC,kBAAkB,CAACpB,SAAS,EAAEF,aAAa,CAAC;EAC5CsB,kBAAkB,CAACJ,UAAU,EAAED,cAAc,CAAC;AAEhD;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plasmic-tabs.cjs.development.js","sources":["../src/tabs.tsx","../src/index.tsx"],"sourcesContent":["import {\n ComponentMeta,\n DataProvider,\n usePlasmicCanvasContext,\n} from '@plasmicapp/host';\nimport constate from 'constate';\nimport React, {\n cloneElement,\n createContext,\n ReactElement,\n ReactNode,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nconst noop = () => {};\n\nfunction defaultButtonChildren(label: string) {\n return {\n type: 'default-component',\n kind: 'button',\n props: {\n children: {\n type: 'text',\n value: label,\n },\n },\n } as const;\n}\nexport interface TabsProviderProps {\n children?: ReactNode;\n initialKey?: string;\n previewKey?: string;\n previewAll?: boolean;\n}\n\nconst DebugContext = createContext(false);\n\nfunction useTabsData({ initialKey }: { initialKey?: string }) {\n const [tabKey, setTabKey] = useState<string | undefined>(initialKey);\n const [bbox, setBbox] = useState<{ left: number; width: number } | undefined>(\n undefined\n );\n return {\n tabKey,\n bbox,\n setTabKey,\n setBbox,\n };\n}\n\nconst [TabsProvider, useTabsContextUnsafe] = constate(useTabsData);\n\nfunction useTabsContext() {\n const result = useTabsContextUnsafe();\n return 'setTabKey' in result ? result : undefined;\n}\nconst modulePath = '@plasmicpkgs/plasmic-tabs';\n\nexport const TabsContainerMeta: ComponentMeta<TabsProviderProps> = {\n name: 'hostless-tabs-container',\n displayName: 'Tabs Container',\n importName: 'TabsContainer',\n importPath: modulePath,\n providesData: true,\n defaultStyles: {\n width: 'stretch',\n padding: '8px',\n },\n props: {\n initialKey: {\n type: 'string',\n description: 'Key of the initially selected tab',\n defaultValue: 'tab1',\n },\n previewKey: {\n type: 'string',\n description: 'SShow this key while editing in Plasmic Studio',\n },\n previewAll: {\n type: 'boolean',\n description: 'Reveal all tab contents while editing in Plasmic Studio',\n },\n children: {\n type: 'slot',\n defaultValue: {\n type: 'vbox',\n children: [\n {\n type: 'hbox',\n children: [\n {\n type: 'component',\n name: 'hostless-tab-button',\n props: {\n tabKey: 'tab1',\n children: defaultButtonChildren('Tab 1'),\n },\n },\n {\n type: 'component',\n name: 'hostless-tab-button',\n props: {\n tabKey: 'tab2',\n children: defaultButtonChildren('Tab 2'),\n },\n },\n {\n type: 'component',\n name: 'hostless-tab-underline',\n },\n ],\n },\n {\n type: 'vbox',\n children: [\n {\n type: 'component',\n name: 'hostless-tab-content',\n props: {\n tabKey: 'tab1',\n children: [\n {\n type: 'vbox',\n children: ['Some content for tab 1'],\n },\n ],\n },\n },\n {\n type: 'component',\n name: 'hostless-tab-content',\n props: {\n tabKey: 'tab2',\n children: [\n {\n type: 'vbox',\n children: ['Some content for tab 2'],\n },\n ],\n },\n },\n ],\n },\n ],\n },\n },\n },\n};\n\nexport function TabsContainer({\n children,\n initialKey,\n previewKey,\n previewAll = false,\n}: TabsProviderProps) {\n const inEditor = !!usePlasmicCanvasContext();\n return (\n <TabsProvider initialKey={initialKey}>\n <DebugContext.Provider value={inEditor && previewAll}>\n <Helper previewKey={previewKey || initialKey}>{children}</Helper>\n </DebugContext.Provider>\n </TabsProvider>\n );\n}\n\nfunction ensure<T>(x: T | undefined | null) {\n if (!x) {\n throw new Error('unexpected nil');\n }\n return x;\n}\n\nfunction Helper({\n children,\n previewKey,\n}: {\n previewKey?: string;\n children?: ReactNode;\n}) {\n const inEditor = usePlasmicCanvasContext();\n const { tabKey } = ensure(useTabsContext());\n const effectiveKey = inEditor ? previewKey || tabKey : tabKey;\n return (\n <DataProvider name={'currentTabKey'} data={effectiveKey}>\n {children}\n </DataProvider>\n );\n}\n\nexport interface TabUnderlineProps {\n className?: string;\n}\n\nexport const TabUnderlineMeta: ComponentMeta<TabUnderlineProps> = {\n name: 'hostless-tab-underline',\n displayName: 'Tab Underline',\n importName: 'TabUnderline',\n importPath: modulePath,\n props: {},\n defaultStyles: {\n background: '#7777ff',\n height: '2px',\n },\n};\n\nexport function TabUnderline({ className }: TabUnderlineProps) {\n const { bbox } = useTabsContext() ?? { bbox: undefined };\n return bbox ? (\n <div\n className={className}\n style={{\n ...JSON.parse(JSON.stringify(bbox)),\n top: undefined,\n bottom: 0,\n position: 'absolute',\n transition: '.4s ease all',\n }}\n ></div>\n ) : null;\n}\n\nexport interface TabButtonProps {\n className?: string;\n children?: ReactNode;\n tabKey?: string;\n}\n\nexport const TabButtonMeta: ComponentMeta<TabButtonProps> = {\n name: 'hostless-tab-button',\n isAttachment: true,\n displayName: 'Tab Button',\n importName: 'TabButton',\n importPath: modulePath,\n props: {\n tabKey: {\n type: 'string',\n description: 'The answer value selecting this choice sets',\n },\n children: {\n type: 'slot',\n defaultValue: defaultButtonChildren('Some tab'),\n },\n },\n defaultStyles: {\n width: 'hug',\n },\n};\n\nexport function TabButton({ className, children, tabKey }: TabButtonProps) {\n const tabsContext = useTabsContext();\n const ref = useRef<HTMLDivElement>(null);\n const { tabKey: activeKey, setTabKey, bbox, setBbox } = tabsContext ?? {\n tabKey: undefined,\n setTabKey: noop,\n bbox: undefined,\n setBbox: noop,\n };\n useEffect(() => {\n if (tabKey === activeKey) {\n setBbox({\n width: ref.current!.offsetWidth,\n left: ref.current!.offsetLeft,\n });\n }\n }, [ref.current, setBbox, JSON.stringify(bbox), tabKey, activeKey]);\n return (\n <div className={className} ref={ref}>\n {cloneElement(React.Children.toArray(children)[0] as ReactElement, {\n isActive: tabKey && activeKey && activeKey === tabKey,\n onClick: () => {\n setTabKey(tabKey);\n },\n })}\n </div>\n );\n}\n\nexport interface TabContentProps {\n children?: ReactNode;\n tabKey?: string;\n}\n\nexport const TabContentMeta: ComponentMeta<TabContentProps> = {\n name: 'hostless-tab-content',\n isAttachment: true,\n displayName: 'Tab Content',\n importName: 'TabContent',\n importPath: modulePath,\n props: {\n tabKey: {\n type: 'string',\n description: 'The answer value selecting this choice sets',\n },\n children: {\n type: 'slot',\n defaultValue: {\n type: 'vbox',\n children: {\n type: 'text',\n value: 'This is some tab content',\n },\n },\n },\n },\n};\nexport function TabContent({ children, tabKey }: TabContentProps) {\n const tabsContext = useTabsContext();\n const previewAll = useContext(DebugContext);\n const { tabKey: activeKey } = tabsContext ?? { tabKey: undefined };\n return (\n <>\n {tabsContext === undefined || activeKey === tabKey || previewAll\n ? children\n : null}\n </>\n );\n}\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\n\nimport {\n TabsContainer,\n TabsContainerMeta,\n TabUnderline,\n TabUnderlineMeta,\n TabButton,\n TabButtonMeta,\n TabContent, TabContentMeta\n} from \"./tabs\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n}) {\n const _registerComponent = <T extends React.ComponentType<any>>(\n Component: T,\n defaultMeta: ComponentMeta<React.ComponentProps<T>>\n ) => {\n if (loader) {\n loader.registerComponent(Component, defaultMeta);\n } else {\n registerComponent(Component, defaultMeta);\n }\n };\n \n _registerComponent(TabsContainer, TabsContainerMeta);\n _registerComponent(TabUnderline, TabUnderlineMeta);\n _registerComponent(TabButton, TabButtonMeta);\n _registerComponent(TabContent, TabContentMeta);\n\n}\n\nexport * from \"./tabs\";\n"],"names":["noop","defaultButtonChildren","label","type","kind","props","children","value","DebugContext","createContext","useTabsData","initialKey","useState","tabKey","setTabKey","undefined","bbox","setBbox","constate","TabsProvider","useTabsContextUnsafe","useTabsContext","result","modulePath","TabsContainerMeta","name","displayName","importName","importPath","providesData","defaultStyles","width","padding","description","defaultValue","previewKey","previewAll","TabsContainer","inEditor","usePlasmicCanvasContext","React","Provider","Helper","ensure","x","Error","effectiveKey","DataProvider","data","TabUnderlineMeta","background","height","TabUnderline","className","style","JSON","parse","stringify","top","bottom","position","transition","TabButtonMeta","isAttachment","TabButton","tabsContext","ref","useRef","activeKey","useEffect","current","offsetWidth","left","offsetLeft","cloneElement","Children","toArray","isActive","onClick","TabContentMeta","TabContent","useContext","registerAll","loader","_registerComponent","Component","defaultMeta","registerComponent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,IAAMA,IAAI,GAAG,SAAPA,IAAI,KAAW;AAErB,SAASC,qBAAqB,CAACC,KAAa;EAC1C,OAAO;IACLC,IAAI,EAAE,mBAAmB;IACzBC,IAAI,EAAE,QAAQ;IACdC,KAAK,EAAE;MACLC,QAAQ,EAAE;QACRH,IAAI,EAAE,MAAM;QACZI,KAAK,EAAEL;;;GAGH;AACZ;AAQA,IAAMM,YAAY,gBAAGC,mBAAa,CAAC,KAAK,CAAC;AAEz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F,aAAa,CAAC;EAC5CsB,kBAAkB,CAACJ,UAAU,EAAED,cAAc,CAAC;AAEhD;;;;;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("@plasmicapp/host/registerComponent")),n=require("@plasmicapp/host"),a=e(require("constate")),r=require("react"),i=e(r);function o(){return(o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e}).apply(this,arguments)}var s=function(){};function l(e){return{type:"default-component",kind:"button",props:{children:{type:"text",value:e}}}}var p=r.createContext(!1);function c(e){var t=r.useState(e.initialKey),n=t[0],a=t[1],i=r.useState(void 0);return{tabKey:n,bbox:i[0],setTabKey:a,setBbox:i[1]}}var b=a(c),u=b[0],d=b[1];function y(){var e=d();return"setTabKey"in e?e:void 0}var h="@plasmicpkgs/plasmic-tabs",m={name:"hostless-tabs-container",displayName:"Tabs Container",importName:"TabsContainer",importPath:h,providesData:!0,defaultStyles:{width:"stretch",padding:"8px"},props:{initialKey:{type:"string",description:"Key of the initially selected tab",defaultValue:"tab1"},previewKey:{type:"string",description:"SShow this key while editing in Plasmic Studio"},previewAll:{type:"boolean",description:"Reveal all tab contents while editing in Plasmic Studio"},children:{type:"slot",defaultValue:{type:"vbox",children:[{type:"hbox",children:[{type:"component",name:"hostless-tab-button",props:{tabKey:"tab1",children:l("Tab 1")}},{type:"component",name:"hostless-tab-button",props:{tabKey:"tab2",children:l("Tab 2")}},{type:"component",name:"hostless-tab-underline"}]},{type:"vbox",children:[{type:"component",name:"hostless-tab-content",props:{tabKey:"tab1",children:[{type:"vbox",children:["Some content for tab 1"]}]}},{type:"component",name:"hostless-tab-content",props:{tabKey:"tab2",children:[{type:"vbox",children:["Some content for tab 2"]}]}}]}]}}}};function v(e){var t=e.children,a=e.initialKey,r=e.previewKey,o=e.previewAll,s=void 0!==o&&o,l=!!n.usePlasmicCanvasContext();return i.createElement(u,{initialKey:a},i.createElement(p.Provider,{value:l&&s},i.createElement(f,{previewKey:r||a},t)))}function f(e){var t=e.children,a=e.previewKey,r=n.usePlasmicCanvasContext(),o=function(e){if(!e)throw new Error("unexpected nil");return e}(y()).tabKey;return i.createElement(n.DataProvider,{name:"currentTabKey",data:r&&a||o},t)}var x={name:"hostless-tab-underline",displayName:"Tab Underline",importName:"TabUnderline",importPath:h,props:{children:{type:"slot"}},defaultStyles:{background:"#7777ff",height:"2px"}};function K(e){var t,n=e.className,a=(null!=(t=y())?t:{bbox:void 0}).bbox;return a?i.createElement("div",{className:n,style:o({},JSON.parse(JSON.stringify(a)),{top:void 0,bottom:0,position:"absolute",transition:".4s ease all"})}):null}var T={name:"hostless-tab-button",isAttachment:!0,displayName:"Tab Button",importName:"TabButton",importPath:h,props:{tabKey:{type:"string",description:"The answer value selecting this choice sets"},children:{type:"slot",defaultValue:l("Some tab")}},defaultStyles:{width:"hug"}};function g(e){var t=e.className,n=e.children,a=e.tabKey,o=y(),l=r.useRef(null),p=null!=o?o:{tabKey:void 0,setTabKey:s,bbox:void 0,setBbox:s},c=p.tabKey,b=p.setTabKey,u=p.setBbox;return r.useEffect((function(){a===c&&u({width:l.current.offsetWidth,left:l.current.offsetLeft})}),[l.current,u,JSON.stringify(p.bbox),a,c]),i.createElement("div",{className:t,ref:l},r.cloneElement(i.Children.toArray(n)[0],{isActive:a&&c&&c===a,onClick:function(){b(a)}}))}var C={name:"hostless-tab-content",isAttachment:!0,displayName:"Tab Content",importName:"TabContent",importPath:h,props:{tabKey:{type:"string",description:"The answer value selecting this choice sets"},children:{type:"slot",defaultValue:{type:"vbox",children:{type:"text",value:"This is some tab content"}}}}};function w(e){var t=e.children,n=e.tabKey,a=y(),o=r.useContext(p);return i.createElement(i.Fragment,null,void 0===a||(null!=a?a:{tabKey:void 0}).tabKey===n||o?t:null)}exports.TabButton=g,exports.TabButtonMeta=T,exports.TabContent=w,exports.TabContentMeta=C,exports.TabUnderline=K,exports.TabUnderlineMeta=x,exports.TabsContainer=v,exports.TabsContainerMeta=m,exports.registerAll=function(e){var n=function(n,a){e?e.registerComponent(n,a):t(n,a)};n(v,m),n(K,x),n(g,T),n(w,C)};
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("@plasmicapp/host/registerComponent")),n=require("@plasmicapp/host"),a=e(require("constate")),r=require("react"),i=e(r);function o(){return(o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e}).apply(this,arguments)}var s=function(){};function l(e){return{type:"default-component",kind:"button",props:{children:{type:"text",value:e}}}}var p=r.createContext(!1);function c(e){var t=r.useState(e.initialKey),n=t[0],a=t[1],i=r.useState(void 0);return{tabKey:n,bbox:i[0],setTabKey:a,setBbox:i[1]}}var b=a(c),u=b[0],d=b[1];function y(){var e=d();return"setTabKey"in e?e:void 0}var m="@plasmicpkgs/plasmic-tabs",h={name:"hostless-tabs-container",displayName:"Tabs Container",importName:"TabsContainer",importPath:m,providesData:!0,defaultStyles:{width:"stretch",padding:"8px"},props:{initialKey:{type:"string",description:"Key of the initially selected tab",defaultValue:"tab1"},previewKey:{type:"string",description:"SShow this key while editing in Plasmic Studio"},previewAll:{type:"boolean",description:"Reveal all tab contents while editing in Plasmic Studio"},children:{type:"slot",defaultValue:{type:"vbox",children:[{type:"hbox",children:[{type:"component",name:"hostless-tab-button",props:{tabKey:"tab1",children:l("Tab 1")}},{type:"component",name:"hostless-tab-button",props:{tabKey:"tab2",children:l("Tab 2")}},{type:"component",name:"hostless-tab-underline"}]},{type:"vbox",children:[{type:"component",name:"hostless-tab-content",props:{tabKey:"tab1",children:[{type:"vbox",children:["Some content for tab 1"]}]}},{type:"component",name:"hostless-tab-content",props:{tabKey:"tab2",children:[{type:"vbox",children:["Some content for tab 2"]}]}}]}]}}}};function v(e){var t=e.children,a=e.initialKey,r=e.previewKey,o=e.previewAll,s=void 0!==o&&o,l=!!n.usePlasmicCanvasContext();return i.createElement(u,{initialKey:a},i.createElement(p.Provider,{value:l&&s},i.createElement(f,{previewKey:r||a},t)))}function f(e){var t=e.children,a=e.previewKey,r=n.usePlasmicCanvasContext(),o=function(e){if(!e)throw new Error("unexpected nil");return e}(y()).tabKey;return i.createElement(n.DataProvider,{name:"currentTabKey",data:r&&a||o},t)}var x={name:"hostless-tab-underline",displayName:"Tab Underline",importName:"TabUnderline",importPath:m,props:{},defaultStyles:{background:"#7777ff",height:"2px"}};function K(e){var t,n=e.className,a=(null!=(t=y())?t:{bbox:void 0}).bbox;return a?i.createElement("div",{className:n,style:o({},JSON.parse(JSON.stringify(a)),{top:void 0,bottom:0,position:"absolute",transition:".4s ease all"})}):null}var T={name:"hostless-tab-button",isAttachment:!0,displayName:"Tab Button",importName:"TabButton",importPath:m,props:{tabKey:{type:"string",description:"The answer value selecting this choice sets"},children:{type:"slot",defaultValue:l("Some tab")}},defaultStyles:{width:"hug"}};function g(e){var t=e.className,n=e.children,a=e.tabKey,o=y(),l=r.useRef(null),p=null!=o?o:{tabKey:void 0,setTabKey:s,bbox:void 0,setBbox:s},c=p.tabKey,b=p.setTabKey,u=p.setBbox;return r.useEffect((function(){a===c&&u({width:l.current.offsetWidth,left:l.current.offsetLeft})}),[l.current,u,JSON.stringify(p.bbox),a,c]),i.createElement("div",{className:t,ref:l},r.cloneElement(i.Children.toArray(n)[0],{isActive:a&&c&&c===a,onClick:function(){b(a)}}))}var C={name:"hostless-tab-content",isAttachment:!0,displayName:"Tab Content",importName:"TabContent",importPath:m,props:{tabKey:{type:"string",description:"The answer value selecting this choice sets"},children:{type:"slot",defaultValue:{type:"vbox",children:{type:"text",value:"This is some tab content"}}}}};function w(e){var t=e.children,n=e.tabKey,a=y(),o=r.useContext(p);return i.createElement(i.Fragment,null,void 0===a||(null!=a?a:{tabKey:void 0}).tabKey===n||o?t:null)}exports.TabButton=g,exports.TabButtonMeta=T,exports.TabContent=w,exports.TabContentMeta=C,exports.TabUnderline=K,exports.TabUnderlineMeta=x,exports.TabsContainer=v,exports.TabsContainerMeta=h,exports.registerAll=function(e){var n=function(n,a){e?e.registerComponent(n,a):t(n,a)};n(v,h),n(K,x),n(g,T),n(w,C)};
2
2
  //# sourceMappingURL=plasmic-tabs.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plasmic-tabs.cjs.production.min.js","sources":["../src/tabs.tsx","../src/index.tsx"],"sourcesContent":["import { DataProvider, usePlasmicCanvasContext,ComponentMeta } from \"@plasmicapp/host\";\nimport constate from \"constate\";\nimport React, {\n cloneElement,\n createContext,\n ReactElement,\n ReactNode,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\n\n\nconst noop = ()=>{};\n\nfunction defaultButtonChildren(label: string) {\n return {\n type: \"default-component\",\n kind: \"button\",\n props: {\n children: {\n type: \"text\",\n value: label,\n },\n },\n } as const;\n}\nexport interface TabsProviderProps {\n children?: ReactNode;\n initialKey?: string;\n previewKey?: string;\n previewAll?: boolean;\n}\n\nconst DebugContext = createContext(false);\n\nfunction useTabsData({ initialKey }: { initialKey?: string }) {\n const [tabKey, setTabKey] = useState<string | undefined>(initialKey);\n const [bbox, setBbox] = useState<{ left: number; width: number } | undefined>(\n undefined\n );\n return {\n tabKey,\n bbox,\n setTabKey,\n setBbox,\n };\n}\n\nconst [TabsProvider, useTabsContextUnsafe] = constate(useTabsData);\n\nfunction useTabsContext() {\n const result = useTabsContextUnsafe();\n return \"setTabKey\" in result ? result : undefined;\n}\nconst modulePath=\"@plasmicpkgs/plasmic-tabs\"\n\nexport const TabsContainerMeta: ComponentMeta<TabsProviderProps> = {\n name: \"hostless-tabs-container\",\n displayName: \"Tabs Container\",\n importName: \"TabsContainer\",\n importPath: modulePath,\n providesData:true,\n defaultStyles: {\n width: \"stretch\",\n padding: \"8px\",\n },\n props: {\n initialKey: {\n type: \"string\",\n description: \"Key of the initially selected tab\",\n defaultValue: \"tab1\",\n },\n previewKey: {\n type: \"string\",\n description: \"SShow this key while editing in Plasmic Studio\",\n },\n previewAll: {\n type: \"boolean\",\n description: \"Reveal all tab contents while editing in Plasmic Studio\",\n },\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"vbox\",\n children: [\n {\n type: \"hbox\",\n children: [\n {\n type: \"component\",\n name: \"hostless-tab-button\",\n props: {\n tabKey: \"tab1\",\n children:defaultButtonChildren(\"Tab 1\")\n },\n },\n {\n type: \"component\",\n name: \"hostless-tab-button\",\n props: {\n tabKey: \"tab2\",\n children:defaultButtonChildren(\"Tab 2\")\n },\n },\n {\n type: \"component\",\n name: \"hostless-tab-underline\",\n },\n ],\n },\n {\n type: \"vbox\",\n children: [\n {\n type: \"component\",\n name: \"hostless-tab-content\",\n props: {\n tabKey: \"tab1\",\n children: [\n {\n type: \"vbox\",\n children: [\"Some content for tab 1\"],\n },\n ],\n },\n },\n {\n type: \"component\",\n name: \"hostless-tab-content\",\n props: {\n tabKey: \"tab2\",\n children: [\n {\n type: \"vbox\",\n children: [\"Some content for tab 2\"],\n },\n ],\n },\n },\n ],\n },\n ],\n },\n },\n },\n };\n\n\nexport function TabsContainer({\n children,\n initialKey,\n previewKey,\n previewAll = false,\n}: TabsProviderProps) {\n const inEditor = !!usePlasmicCanvasContext();\n return (\n <TabsProvider initialKey={initialKey}>\n <DebugContext.Provider value={inEditor && previewAll}>\n <Helper previewKey={previewKey || initialKey}>{children}</Helper>\n </DebugContext.Provider>\n </TabsProvider>\n );\n}\n\nfunction ensure<T>(x: T | undefined | null) {\n if (!x) {\n throw new Error(\"unexpected nil\");\n }\n return x;\n}\n\nfunction Helper({\n children,\n previewKey,\n}: {\n previewKey?: string;\n children?: ReactNode;\n}) {\n const inEditor = usePlasmicCanvasContext();\n const { tabKey } = ensure(useTabsContext());\n const effectiveKey = inEditor ? previewKey || tabKey : tabKey;\n return (\n <DataProvider name={\"currentTabKey\"} data={effectiveKey}>\n {children}\n </DataProvider>\n );\n}\n\nexport interface TabUnderlineProps {\n className?: string;\n}\n\nexport const TabUnderlineMeta:ComponentMeta <TabUnderlineProps>={\n name: \"hostless-tab-underline\",\n displayName: \"Tab Underline\",\n importName: \"TabUnderline\",\n importPath: modulePath,\n props: {\n children: {\n type: \"slot\",\n },\n },\n defaultStyles: {\n background: \"#7777ff\",\n height: \"2px\",\n },\n}\n\n\nexport function TabUnderline({ className }: TabUnderlineProps) {\n const { bbox } = useTabsContext() ?? { bbox: undefined };\n return bbox ? (\n <div\n className={className}\n style={{\n ...JSON.parse(JSON.stringify(bbox)),\n top: undefined,\n bottom: 0,\n position: \"absolute\",\n transition: \".4s ease all\",\n }}\n ></div>\n ) : null;\n}\n\nexport interface TabButtonProps {\n className?: string;\n children?: ReactNode;\n tabKey?: string;\n}\n\nexport const TabButtonMeta:ComponentMeta<TabButtonProps>={\n name: \"hostless-tab-button\",\n isAttachment: true,\n displayName: \"Tab Button\",\n importName: \"TabButton\",\n importPath: modulePath,\n props: {\n tabKey: {\n type: \"string\",\n description: \"The answer value selecting this choice sets\",\n },\n children: {\n type: \"slot\",\n defaultValue:defaultButtonChildren(\"Some tab\")\n },\n },\n defaultStyles: {\n width: \"hug\",\n },\n}\n\nexport function TabButton({ className, children, tabKey }: TabButtonProps) {\n const tabsContext = useTabsContext();\n const ref = useRef<HTMLDivElement>(null);\n const { tabKey: activeKey, setTabKey, bbox, setBbox } = tabsContext ?? {\n tabKey: undefined,\n setTabKey: noop,\n bbox: undefined,\n setBbox:noop,\n };\n useEffect(() => {\n if (tabKey === activeKey) {\n setBbox({\n width: ref.current!.offsetWidth,\n left: ref.current!.offsetLeft,\n });\n }\n }, [ref.current, setBbox, JSON.stringify(bbox), tabKey, activeKey]);\n return (\n <div className={className} ref={ref}>\n {cloneElement(React.Children.toArray(children)[0] as ReactElement, {\n isActive: tabKey && activeKey && activeKey === tabKey,\n onClick: () => {\n setTabKey(tabKey);\n },\n })}\n </div>\n );\n}\n\nexport interface TabContentProps {\n children?: ReactNode;\n tabKey?: string;\n}\n\nexport const TabContentMeta:ComponentMeta<TabContentProps>={\n name: \"hostless-tab-content\",\n isAttachment: true,\n displayName: \"Tab Content\",\n importName: \"TabContent\",\n importPath: modulePath,\n props: {\n tabKey: {\n type: \"string\",\n description: \"The answer value selecting this choice sets\",\n },\n children: {\n type: \"slot\",\n defaultValue: {\n type:\"vbox\",\n children:{\n type:\"text\",\n value:\"This is some tab content\"\n }\n },\n },\n },\n}\nexport function TabContent({ children, tabKey }: TabContentProps) {\n const tabsContext = useTabsContext();\n const previewAll = useContext(DebugContext);\n const { tabKey: activeKey } = tabsContext ?? { tabKey: undefined };\n return (\n <>\n {tabsContext === undefined || activeKey === tabKey || previewAll\n ? children\n : null}\n </>\n );\n}\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\n\nimport {\n TabsContainer,\n TabsContainerMeta,\n TabUnderline,\n TabUnderlineMeta,\n TabButton,\n TabButtonMeta,\n TabContent, TabContentMeta\n} from \"./tabs\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n}) {\n const _registerComponent = <T extends React.ComponentType<any>>(\n Component: T,\n defaultMeta: ComponentMeta<React.ComponentProps<T>>\n ) => {\n if (loader) {\n loader.registerComponent(Component, defaultMeta);\n } else {\n registerComponent(Component, defaultMeta);\n }\n };\n \n _registerComponent(TabsContainer, TabsContainerMeta);\n _registerComponent(TabUnderline, TabUnderlineMeta);\n _registerComponent(TabButton, TabButtonMeta);\n _registerComponent(TabContent, TabContentMeta);\n\n}\n\nexport * from \"./tabs\";\n"],"names":["noop","defaultButtonChildren","label","type","kind","props","children","value","DebugContext","createContext","useTabsData","useState","initialKey","tabKey","setTabKey","undefined","bbox","setBbox","constate","TabsProvider","useTabsContextUnsafe","useTabsContext","result","modulePath","TabsContainerMeta","name","displayName","importName","importPath","providesData","defaultStyles","width","padding","description","defaultValue","previewKey","previewAll","TabsContainer","_ref2$previewAll","inEditor","usePlasmicCanvasContext","React","Provider","Helper","x","Error","ensure","DataProvider","data","TabUnderlineMeta","background","height","TabUnderline","className","style","JSON","parse","stringify","top","bottom","position","transition","TabButtonMeta","isAttachment","TabButton","tabsContext","ref","useRef","activeKey","useEffect","current","offsetWidth","left","offsetLeft","cloneElement","Children","toArray","isActive","onClick","TabContentMeta","TabContent","useContext","loader","_registerComponent","Component","defaultMeta","registerComponent"],"mappings":"qfAcA,IAAMA,EAAO,aAEb,SAASC,EAAsBC,GAC7B,MAAO,CACLC,KAAM,oBACNC,KAAM,SACNC,MAAO,CACLC,SAAU,CACRH,KAAM,OACNI,MAAOL,KAYf,IAAMM,EAAeC,iBAAc,GAEnC,SAASC,WACqBC,aADPC,YACdC,OAAQC,SACSH,gBACtBI,GAEF,MAAO,CACLF,OAAAA,EACAG,UACAF,UAAAA,EACAG,cAIJ,MAA6CC,EAASR,GAA/CS,OAAcC,OAErB,SAASC,IACP,IAAMC,EAASF,IACf,MAAO,cAAeE,EAASA,OAASP,EAE1C,IAAMQ,EAAW,4BAEJC,EAAsD,CAC/DC,KAAM,0BACNC,YAAa,iBACbC,WAAY,gBACZC,WAAYL,EACZM,cAAa,EACbC,cAAe,CACfC,MAAO,UACPC,QAAS,OAET3B,MAAO,CACPO,WAAY,CACVT,KAAM,SACN8B,YAAa,oCACbC,aAAc,QAEhBC,WAAY,CACVhC,KAAM,SACN8B,YAAa,kDAEfG,WAAY,CACVjC,KAAM,UACN8B,YAAa,2DAEf3B,SAAU,CACRH,KAAM,OACN+B,aAAc,CACZ/B,KAAM,OACNG,SAAU,CACR,CACEH,KAAM,OACNG,SAAU,CACR,CACEH,KAAM,YACNsB,KAAM,sBACNpB,MAAO,CACLQ,OAAQ,OACRP,SAASL,EAAsB,WAGnC,CACEE,KAAM,YACNsB,KAAM,sBACNpB,MAAO,CACLQ,OAAQ,OACRP,SAASL,EAAsB,WAGnC,CACEE,KAAM,YACNsB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":"plasmic-tabs.cjs.production.min.js","sources":["../src/tabs.tsx","../src/index.tsx"],"sourcesContent":["import {\n ComponentMeta,\n DataProvider,\n usePlasmicCanvasContext,\n} from '@plasmicapp/host';\nimport constate from 'constate';\nimport React, {\n cloneElement,\n createContext,\n ReactElement,\n ReactNode,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nconst noop = () => {};\n\nfunction defaultButtonChildren(label: string) {\n return {\n type: 'default-component',\n kind: 'button',\n props: {\n children: {\n type: 'text',\n value: label,\n },\n },\n } as const;\n}\nexport interface TabsProviderProps {\n children?: ReactNode;\n initialKey?: string;\n previewKey?: string;\n previewAll?: boolean;\n}\n\nconst DebugContext = createContext(false);\n\nfunction useTabsData({ initialKey }: { initialKey?: string }) {\n const [tabKey, setTabKey] = useState<string | undefined>(initialKey);\n const [bbox, setBbox] = useState<{ left: number; width: number } | undefined>(\n undefined\n );\n return {\n tabKey,\n bbox,\n setTabKey,\n setBbox,\n };\n}\n\nconst [TabsProvider, useTabsContextUnsafe] = constate(useTabsData);\n\nfunction useTabsContext() {\n const result = useTabsContextUnsafe();\n return 'setTabKey' in result ? result : undefined;\n}\nconst modulePath = '@plasmicpkgs/plasmic-tabs';\n\nexport const TabsContainerMeta: ComponentMeta<TabsProviderProps> = {\n name: 'hostless-tabs-container',\n displayName: 'Tabs Container',\n importName: 'TabsContainer',\n importPath: modulePath,\n providesData: true,\n defaultStyles: {\n width: 'stretch',\n padding: '8px',\n },\n props: {\n initialKey: {\n type: 'string',\n description: 'Key of the initially selected tab',\n defaultValue: 'tab1',\n },\n previewKey: {\n type: 'string',\n description: 'SShow this key while editing in Plasmic Studio',\n },\n previewAll: {\n type: 'boolean',\n description: 'Reveal all tab contents while editing in Plasmic Studio',\n },\n children: {\n type: 'slot',\n defaultValue: {\n type: 'vbox',\n children: [\n {\n type: 'hbox',\n children: [\n {\n type: 'component',\n name: 'hostless-tab-button',\n props: {\n tabKey: 'tab1',\n children: defaultButtonChildren('Tab 1'),\n },\n },\n {\n type: 'component',\n name: 'hostless-tab-button',\n props: {\n tabKey: 'tab2',\n children: defaultButtonChildren('Tab 2'),\n },\n },\n {\n type: 'component',\n name: 'hostless-tab-underline',\n },\n ],\n },\n {\n type: 'vbox',\n children: [\n {\n type: 'component',\n name: 'hostless-tab-content',\n props: {\n tabKey: 'tab1',\n children: [\n {\n type: 'vbox',\n children: ['Some content for tab 1'],\n },\n ],\n },\n },\n {\n type: 'component',\n name: 'hostless-tab-content',\n props: {\n tabKey: 'tab2',\n children: [\n {\n type: 'vbox',\n children: ['Some content for tab 2'],\n },\n ],\n },\n },\n ],\n },\n ],\n },\n },\n },\n};\n\nexport function TabsContainer({\n children,\n initialKey,\n previewKey,\n previewAll = false,\n}: TabsProviderProps) {\n const inEditor = !!usePlasmicCanvasContext();\n return (\n <TabsProvider initialKey={initialKey}>\n <DebugContext.Provider value={inEditor && previewAll}>\n <Helper previewKey={previewKey || initialKey}>{children}</Helper>\n </DebugContext.Provider>\n </TabsProvider>\n );\n}\n\nfunction ensure<T>(x: T | undefined | null) {\n if (!x) {\n throw new Error('unexpected nil');\n }\n return x;\n}\n\nfunction Helper({\n children,\n previewKey,\n}: {\n previewKey?: string;\n children?: ReactNode;\n}) {\n const inEditor = usePlasmicCanvasContext();\n const { tabKey } = ensure(useTabsContext());\n const effectiveKey = inEditor ? previewKey || tabKey : tabKey;\n return (\n <DataProvider name={'currentTabKey'} data={effectiveKey}>\n {children}\n </DataProvider>\n );\n}\n\nexport interface TabUnderlineProps {\n className?: string;\n}\n\nexport const TabUnderlineMeta: ComponentMeta<TabUnderlineProps> = {\n name: 'hostless-tab-underline',\n displayName: 'Tab Underline',\n importName: 'TabUnderline',\n importPath: modulePath,\n props: {},\n defaultStyles: {\n background: '#7777ff',\n height: '2px',\n },\n};\n\nexport function TabUnderline({ className }: TabUnderlineProps) {\n const { bbox } = useTabsContext() ?? { bbox: undefined };\n return bbox ? (\n <div\n className={className}\n style={{\n ...JSON.parse(JSON.stringify(bbox)),\n top: undefined,\n bottom: 0,\n position: 'absolute',\n transition: '.4s ease all',\n }}\n ></div>\n ) : null;\n}\n\nexport interface TabButtonProps {\n className?: string;\n children?: ReactNode;\n tabKey?: string;\n}\n\nexport const TabButtonMeta: ComponentMeta<TabButtonProps> = {\n name: 'hostless-tab-button',\n isAttachment: true,\n displayName: 'Tab Button',\n importName: 'TabButton',\n importPath: modulePath,\n props: {\n tabKey: {\n type: 'string',\n description: 'The answer value selecting this choice sets',\n },\n children: {\n type: 'slot',\n defaultValue: defaultButtonChildren('Some tab'),\n },\n },\n defaultStyles: {\n width: 'hug',\n },\n};\n\nexport function TabButton({ className, children, tabKey }: TabButtonProps) {\n const tabsContext = useTabsContext();\n const ref = useRef<HTMLDivElement>(null);\n const { tabKey: activeKey, setTabKey, bbox, setBbox } = tabsContext ?? {\n tabKey: undefined,\n setTabKey: noop,\n bbox: undefined,\n setBbox: noop,\n };\n useEffect(() => {\n if (tabKey === activeKey) {\n setBbox({\n width: ref.current!.offsetWidth,\n left: ref.current!.offsetLeft,\n });\n }\n }, [ref.current, setBbox, JSON.stringify(bbox), tabKey, activeKey]);\n return (\n <div className={className} ref={ref}>\n {cloneElement(React.Children.toArray(children)[0] as ReactElement, {\n isActive: tabKey && activeKey && activeKey === tabKey,\n onClick: () => {\n setTabKey(tabKey);\n },\n })}\n </div>\n );\n}\n\nexport interface TabContentProps {\n children?: ReactNode;\n tabKey?: string;\n}\n\nexport const TabContentMeta: ComponentMeta<TabContentProps> = {\n name: 'hostless-tab-content',\n isAttachment: true,\n displayName: 'Tab Content',\n importName: 'TabContent',\n importPath: modulePath,\n props: {\n tabKey: {\n type: 'string',\n description: 'The answer value selecting this choice sets',\n },\n children: {\n type: 'slot',\n defaultValue: {\n type: 'vbox',\n children: {\n type: 'text',\n value: 'This is some tab content',\n },\n },\n },\n },\n};\nexport function TabContent({ children, tabKey }: TabContentProps) {\n const tabsContext = useTabsContext();\n const previewAll = useContext(DebugContext);\n const { tabKey: activeKey } = tabsContext ?? { tabKey: undefined };\n return (\n <>\n {tabsContext === undefined || activeKey === tabKey || previewAll\n ? children\n : null}\n </>\n );\n}\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\n\nimport {\n TabsContainer,\n TabsContainerMeta,\n TabUnderline,\n TabUnderlineMeta,\n TabButton,\n TabButtonMeta,\n TabContent, TabContentMeta\n} from \"./tabs\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n}) {\n const _registerComponent = <T extends React.ComponentType<any>>(\n Component: T,\n defaultMeta: ComponentMeta<React.ComponentProps<T>>\n ) => {\n if (loader) {\n loader.registerComponent(Component, defaultMeta);\n } else {\n registerComponent(Component, defaultMeta);\n }\n };\n \n _registerComponent(TabsContainer, TabsContainerMeta);\n _registerComponent(TabUnderline, TabUnderlineMeta);\n _registerComponent(TabButton, TabButtonMeta);\n _registerComponent(TabContent, TabContentMeta);\n\n}\n\nexport * from \"./tabs\";\n"],"names":["noop","defaultButtonChildren","label","type","kind","props","children","value","DebugContext","createContext","useTabsData","useState","initialKey","tabKey","setTabKey","undefined","bbox","setBbox","constate","TabsProvider","useTabsContextUnsafe","useTabsContext","result","modulePath","TabsContainerMeta","name","displayName","importName","importPath","providesData","defaultStyles","width","padding","description","defaultValue","previewKey","previewAll","TabsContainer","_ref2$previewAll","inEditor","usePlasmicCanvasContext","React","Provider","Helper","x","Error","ensure","DataProvider","data","TabUnderlineMeta","background","height","TabUnderline","className","style","JSON","parse","stringify","top","bottom","position","transition","TabButtonMeta","isAttachment","TabButton","tabsContext","ref","useRef","activeKey","useEffect","current","offsetWidth","left","offsetLeft","cloneElement","Children","toArray","isActive","onClick","TabContentMeta","TabContent","useContext","loader","_registerComponent","Component","defaultMeta","registerComponent"],"mappings":"qfAiBA,IAAMA,EAAO,aAEb,SAASC,EAAsBC,GAC7B,MAAO,CACLC,KAAM,oBACNC,KAAM,SACNC,MAAO,CACLC,SAAU,CACRH,KAAM,OACNI,MAAOL,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KA,GAC7BQ,eAAajC,EAAMkC,SAASC,QAAQtE,GAAU,GAAoB,CACjEuE,SAAUhE,GAAUuD,GAAaA,IAAcvD,EAC/CiE,QAAS,WACPhE,EAAUD,WAYPkE,EAAiD,CAC5DtD,KAAM,uBACNsC,cAAc,EACdrC,YAAa,cACbC,WAAY,aACZC,WAAYL,EACZlB,MAAO,CACLQ,OAAQ,CACNV,KAAM,SACN8B,YAAa,+CAEf3B,SAAU,CACRH,KAAM,OACN+B,aAAc,CACZ/B,KAAM,OACNG,SAAU,CACRH,KAAM,OACNI,MAAO,yCAMDyE,SAAa1E,IAAAA,SAAUO,IAAAA,OAC/BoD,EAAc5C,IACde,EAAa6C,aAAWzE,GAE9B,OACEiC,qCACmB1B,IAAhBkD,UAHyBA,EAAAA,EAAe,CAAEpD,YAAQE,IAA/CF,SAGwCA,GAAUuB,EAClD9B,EACA,mOC9SkB4E,GAG1B,IAAMC,EAAqB,SACzBC,EACAC,GAEIH,EACFA,EAAOI,kBAAkBF,EAAWC,GAEpCC,EAAkBF,EAAWC,IAIjCF,EAAmB9C,EAAeb,GAClC2D,EAAmB/B,EAAcH,GACjCkC,EAAmBnB,EAAWF,GAC9BqB,EAAmBH,EAAYD"}
@@ -21,11 +21,11 @@ function _extends() {
21
21
  var noop = function noop() {};
22
22
  function defaultButtonChildren(label) {
23
23
  return {
24
- type: "default-component",
25
- kind: "button",
24
+ type: 'default-component',
25
+ kind: 'button',
26
26
  props: {
27
27
  children: {
28
- type: "text",
28
+ type: 'text',
29
29
  value: label
30
30
  }
31
31
  }
@@ -52,77 +52,77 @@ var _constate = /*#__PURE__*/constate(useTabsData),
52
52
  useTabsContextUnsafe = _constate[1];
53
53
  function useTabsContext() {
54
54
  var result = useTabsContextUnsafe();
55
- return "setTabKey" in result ? result : undefined;
55
+ return 'setTabKey' in result ? result : undefined;
56
56
  }
57
- var modulePath = "@plasmicpkgs/plasmic-tabs";
57
+ var modulePath = '@plasmicpkgs/plasmic-tabs';
58
58
  var TabsContainerMeta = {
59
- name: "hostless-tabs-container",
60
- displayName: "Tabs Container",
61
- importName: "TabsContainer",
59
+ name: 'hostless-tabs-container',
60
+ displayName: 'Tabs Container',
61
+ importName: 'TabsContainer',
62
62
  importPath: modulePath,
63
63
  providesData: true,
64
64
  defaultStyles: {
65
- width: "stretch",
66
- padding: "8px"
65
+ width: 'stretch',
66
+ padding: '8px'
67
67
  },
68
68
  props: {
69
69
  initialKey: {
70
- type: "string",
71
- description: "Key of the initially selected tab",
72
- defaultValue: "tab1"
70
+ type: 'string',
71
+ description: 'Key of the initially selected tab',
72
+ defaultValue: 'tab1'
73
73
  },
74
74
  previewKey: {
75
- type: "string",
76
- description: "SShow this key while editing in Plasmic Studio"
75
+ type: 'string',
76
+ description: 'SShow this key while editing in Plasmic Studio'
77
77
  },
78
78
  previewAll: {
79
- type: "boolean",
80
- description: "Reveal all tab contents while editing in Plasmic Studio"
79
+ type: 'boolean',
80
+ description: 'Reveal all tab contents while editing in Plasmic Studio'
81
81
  },
82
82
  children: {
83
- type: "slot",
83
+ type: 'slot',
84
84
  defaultValue: {
85
- type: "vbox",
85
+ type: 'vbox',
86
86
  children: [{
87
- type: "hbox",
87
+ type: 'hbox',
88
88
  children: [{
89
- type: "component",
90
- name: "hostless-tab-button",
89
+ type: 'component',
90
+ name: 'hostless-tab-button',
91
91
  props: {
92
- tabKey: "tab1",
93
- children: /*#__PURE__*/defaultButtonChildren("Tab 1")
92
+ tabKey: 'tab1',
93
+ children: /*#__PURE__*/defaultButtonChildren('Tab 1')
94
94
  }
95
95
  }, {
96
- type: "component",
97
- name: "hostless-tab-button",
96
+ type: 'component',
97
+ name: 'hostless-tab-button',
98
98
  props: {
99
- tabKey: "tab2",
100
- children: /*#__PURE__*/defaultButtonChildren("Tab 2")
99
+ tabKey: 'tab2',
100
+ children: /*#__PURE__*/defaultButtonChildren('Tab 2')
101
101
  }
102
102
  }, {
103
- type: "component",
104
- name: "hostless-tab-underline"
103
+ type: 'component',
104
+ name: 'hostless-tab-underline'
105
105
  }]
106
106
  }, {
107
- type: "vbox",
107
+ type: 'vbox',
108
108
  children: [{
109
- type: "component",
110
- name: "hostless-tab-content",
109
+ type: 'component',
110
+ name: 'hostless-tab-content',
111
111
  props: {
112
- tabKey: "tab1",
112
+ tabKey: 'tab1',
113
113
  children: [{
114
- type: "vbox",
115
- children: ["Some content for tab 1"]
114
+ type: 'vbox',
115
+ children: ['Some content for tab 1']
116
116
  }]
117
117
  }
118
118
  }, {
119
- type: "component",
120
- name: "hostless-tab-content",
119
+ type: 'component',
120
+ name: 'hostless-tab-content',
121
121
  props: {
122
- tabKey: "tab2",
122
+ tabKey: 'tab2',
123
123
  children: [{
124
- type: "vbox",
125
- children: ["Some content for tab 2"]
124
+ type: 'vbox',
125
+ children: ['Some content for tab 2']
126
126
  }]
127
127
  }
128
128
  }]
@@ -148,7 +148,7 @@ function TabsContainer(_ref2) {
148
148
  }
149
149
  function ensure(x) {
150
150
  if (!x) {
151
- throw new Error("unexpected nil");
151
+ throw new Error('unexpected nil');
152
152
  }
153
153
  return x;
154
154
  }
@@ -160,23 +160,19 @@ function Helper(_ref3) {
160
160
  tabKey = _ensure.tabKey;
161
161
  var effectiveKey = inEditor ? previewKey || tabKey : tabKey;
162
162
  return React.createElement(DataProvider, {
163
- name: "currentTabKey",
163
+ name: 'currentTabKey',
164
164
  data: effectiveKey
165
165
  }, children);
166
166
  }
167
167
  var TabUnderlineMeta = {
168
- name: "hostless-tab-underline",
169
- displayName: "Tab Underline",
170
- importName: "TabUnderline",
168
+ name: 'hostless-tab-underline',
169
+ displayName: 'Tab Underline',
170
+ importName: 'TabUnderline',
171
171
  importPath: modulePath,
172
- props: {
173
- children: {
174
- type: "slot"
175
- }
176
- },
172
+ props: {},
177
173
  defaultStyles: {
178
- background: "#7777ff",
179
- height: "2px"
174
+ background: '#7777ff',
175
+ height: '2px'
180
176
  }
181
177
  };
182
178
  function TabUnderline(_ref4) {
@@ -191,29 +187,29 @@ function TabUnderline(_ref4) {
191
187
  style: _extends({}, JSON.parse(JSON.stringify(bbox)), {
192
188
  top: undefined,
193
189
  bottom: 0,
194
- position: "absolute",
195
- transition: ".4s ease all"
190
+ position: 'absolute',
191
+ transition: '.4s ease all'
196
192
  })
197
193
  }) : null;
198
194
  }
199
195
  var TabButtonMeta = {
200
- name: "hostless-tab-button",
196
+ name: 'hostless-tab-button',
201
197
  isAttachment: true,
202
- displayName: "Tab Button",
203
- importName: "TabButton",
198
+ displayName: 'Tab Button',
199
+ importName: 'TabButton',
204
200
  importPath: modulePath,
205
201
  props: {
206
202
  tabKey: {
207
- type: "string",
208
- description: "The answer value selecting this choice sets"
203
+ type: 'string',
204
+ description: 'The answer value selecting this choice sets'
209
205
  },
210
206
  children: {
211
- type: "slot",
212
- defaultValue: /*#__PURE__*/defaultButtonChildren("Some tab")
207
+ type: 'slot',
208
+ defaultValue: /*#__PURE__*/defaultButtonChildren('Some tab')
213
209
  }
214
210
  },
215
211
  defaultStyles: {
216
- width: "hug"
212
+ width: 'hug'
217
213
  }
218
214
  };
219
215
  function TabButton(_ref6) {
@@ -251,23 +247,23 @@ function TabButton(_ref6) {
251
247
  }));
252
248
  }
253
249
  var TabContentMeta = {
254
- name: "hostless-tab-content",
250
+ name: 'hostless-tab-content',
255
251
  isAttachment: true,
256
- displayName: "Tab Content",
257
- importName: "TabContent",
252
+ displayName: 'Tab Content',
253
+ importName: 'TabContent',
258
254
  importPath: modulePath,
259
255
  props: {
260
256
  tabKey: {
261
- type: "string",
262
- description: "The answer value selecting this choice sets"
257
+ type: 'string',
258
+ description: 'The answer value selecting this choice sets'
263
259
  },
264
260
  children: {
265
- type: "slot",
261
+ type: 'slot',
266
262
  defaultValue: {
267
- type: "vbox",
263
+ type: 'vbox',
268
264
  children: {
269
- type: "text",
270
- value: "This is some tab content"
265
+ type: 'text',
266
+ value: 'This is some tab content'
271
267
  }
272
268
  }
273
269
  }
@@ -1 +1 @@
1
- {"version":3,"file":"plasmic-tabs.esm.js","sources":["../src/tabs.tsx","../src/index.tsx"],"sourcesContent":["import { DataProvider, usePlasmicCanvasContext,ComponentMeta } from \"@plasmicapp/host\";\nimport constate from \"constate\";\nimport React, {\n cloneElement,\n createContext,\n ReactElement,\n ReactNode,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\n\n\nconst noop = ()=>{};\n\nfunction defaultButtonChildren(label: string) {\n return {\n type: \"default-component\",\n kind: \"button\",\n props: {\n children: {\n type: \"text\",\n value: label,\n },\n },\n } as const;\n}\nexport interface TabsProviderProps {\n children?: ReactNode;\n initialKey?: string;\n previewKey?: string;\n previewAll?: boolean;\n}\n\nconst DebugContext = createContext(false);\n\nfunction useTabsData({ initialKey }: { initialKey?: string }) {\n const [tabKey, setTabKey] = useState<string | undefined>(initialKey);\n const [bbox, setBbox] = useState<{ left: number; width: number } | undefined>(\n undefined\n );\n return {\n tabKey,\n bbox,\n setTabKey,\n setBbox,\n };\n}\n\nconst [TabsProvider, useTabsContextUnsafe] = constate(useTabsData);\n\nfunction useTabsContext() {\n const result = useTabsContextUnsafe();\n return \"setTabKey\" in result ? result : undefined;\n}\nconst modulePath=\"@plasmicpkgs/plasmic-tabs\"\n\nexport const TabsContainerMeta: ComponentMeta<TabsProviderProps> = {\n name: \"hostless-tabs-container\",\n displayName: \"Tabs Container\",\n importName: \"TabsContainer\",\n importPath: modulePath,\n providesData:true,\n defaultStyles: {\n width: \"stretch\",\n padding: \"8px\",\n },\n props: {\n initialKey: {\n type: \"string\",\n description: \"Key of the initially selected tab\",\n defaultValue: \"tab1\",\n },\n previewKey: {\n type: \"string\",\n description: \"SShow this key while editing in Plasmic Studio\",\n },\n previewAll: {\n type: \"boolean\",\n description: \"Reveal all tab contents while editing in Plasmic Studio\",\n },\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"vbox\",\n children: [\n {\n type: \"hbox\",\n children: [\n {\n type: \"component\",\n name: \"hostless-tab-button\",\n props: {\n tabKey: \"tab1\",\n children:defaultButtonChildren(\"Tab 1\")\n },\n },\n {\n type: \"component\",\n name: \"hostless-tab-button\",\n props: {\n tabKey: \"tab2\",\n children:defaultButtonChildren(\"Tab 2\")\n },\n },\n {\n type: \"component\",\n name: \"hostless-tab-underline\",\n },\n ],\n },\n {\n type: \"vbox\",\n children: [\n {\n type: \"component\",\n name: \"hostless-tab-content\",\n props: {\n tabKey: \"tab1\",\n children: [\n {\n type: \"vbox\",\n children: [\"Some content for tab 1\"],\n },\n ],\n },\n },\n {\n type: \"component\",\n name: \"hostless-tab-content\",\n props: {\n tabKey: \"tab2\",\n children: [\n {\n type: \"vbox\",\n children: [\"Some content for tab 2\"],\n },\n ],\n },\n },\n ],\n },\n ],\n },\n },\n },\n };\n\n\nexport function TabsContainer({\n children,\n initialKey,\n previewKey,\n previewAll = false,\n}: TabsProviderProps) {\n const inEditor = !!usePlasmicCanvasContext();\n return (\n <TabsProvider initialKey={initialKey}>\n <DebugContext.Provider value={inEditor && previewAll}>\n <Helper previewKey={previewKey || initialKey}>{children}</Helper>\n </DebugContext.Provider>\n </TabsProvider>\n );\n}\n\nfunction ensure<T>(x: T | undefined | null) {\n if (!x) {\n throw new Error(\"unexpected nil\");\n }\n return x;\n}\n\nfunction Helper({\n children,\n previewKey,\n}: {\n previewKey?: string;\n children?: ReactNode;\n}) {\n const inEditor = usePlasmicCanvasContext();\n const { tabKey } = ensure(useTabsContext());\n const effectiveKey = inEditor ? previewKey || tabKey : tabKey;\n return (\n <DataProvider name={\"currentTabKey\"} data={effectiveKey}>\n {children}\n </DataProvider>\n );\n}\n\nexport interface TabUnderlineProps {\n className?: string;\n}\n\nexport const TabUnderlineMeta:ComponentMeta <TabUnderlineProps>={\n name: \"hostless-tab-underline\",\n displayName: \"Tab Underline\",\n importName: \"TabUnderline\",\n importPath: modulePath,\n props: {\n children: {\n type: \"slot\",\n },\n },\n defaultStyles: {\n background: \"#7777ff\",\n height: \"2px\",\n },\n}\n\n\nexport function TabUnderline({ className }: TabUnderlineProps) {\n const { bbox } = useTabsContext() ?? { bbox: undefined };\n return bbox ? (\n <div\n className={className}\n style={{\n ...JSON.parse(JSON.stringify(bbox)),\n top: undefined,\n bottom: 0,\n position: \"absolute\",\n transition: \".4s ease all\",\n }}\n ></div>\n ) : null;\n}\n\nexport interface TabButtonProps {\n className?: string;\n children?: ReactNode;\n tabKey?: string;\n}\n\nexport const TabButtonMeta:ComponentMeta<TabButtonProps>={\n name: \"hostless-tab-button\",\n isAttachment: true,\n displayName: \"Tab Button\",\n importName: \"TabButton\",\n importPath: modulePath,\n props: {\n tabKey: {\n type: \"string\",\n description: \"The answer value selecting this choice sets\",\n },\n children: {\n type: \"slot\",\n defaultValue:defaultButtonChildren(\"Some tab\")\n },\n },\n defaultStyles: {\n width: \"hug\",\n },\n}\n\nexport function TabButton({ className, children, tabKey }: TabButtonProps) {\n const tabsContext = useTabsContext();\n const ref = useRef<HTMLDivElement>(null);\n const { tabKey: activeKey, setTabKey, bbox, setBbox } = tabsContext ?? {\n tabKey: undefined,\n setTabKey: noop,\n bbox: undefined,\n setBbox:noop,\n };\n useEffect(() => {\n if (tabKey === activeKey) {\n setBbox({\n width: ref.current!.offsetWidth,\n left: ref.current!.offsetLeft,\n });\n }\n }, [ref.current, setBbox, JSON.stringify(bbox), tabKey, activeKey]);\n return (\n <div className={className} ref={ref}>\n {cloneElement(React.Children.toArray(children)[0] as ReactElement, {\n isActive: tabKey && activeKey && activeKey === tabKey,\n onClick: () => {\n setTabKey(tabKey);\n },\n })}\n </div>\n );\n}\n\nexport interface TabContentProps {\n children?: ReactNode;\n tabKey?: string;\n}\n\nexport const TabContentMeta:ComponentMeta<TabContentProps>={\n name: \"hostless-tab-content\",\n isAttachment: true,\n displayName: \"Tab Content\",\n importName: \"TabContent\",\n importPath: modulePath,\n props: {\n tabKey: {\n type: \"string\",\n description: \"The answer value selecting this choice sets\",\n },\n children: {\n type: \"slot\",\n defaultValue: {\n type:\"vbox\",\n children:{\n type:\"text\",\n value:\"This is some tab content\"\n }\n },\n },\n },\n}\nexport function TabContent({ children, tabKey }: TabContentProps) {\n const tabsContext = useTabsContext();\n const previewAll = useContext(DebugContext);\n const { tabKey: activeKey } = tabsContext ?? { tabKey: undefined };\n return (\n <>\n {tabsContext === undefined || activeKey === tabKey || previewAll\n ? children\n : null}\n </>\n );\n}\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\n\nimport {\n TabsContainer,\n TabsContainerMeta,\n TabUnderline,\n TabUnderlineMeta,\n TabButton,\n TabButtonMeta,\n TabContent, TabContentMeta\n} from \"./tabs\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n}) {\n const _registerComponent = <T extends React.ComponentType<any>>(\n Component: T,\n defaultMeta: ComponentMeta<React.ComponentProps<T>>\n ) => {\n if (loader) {\n loader.registerComponent(Component, defaultMeta);\n } else {\n registerComponent(Component, defaultMeta);\n }\n };\n \n _registerComponent(TabsContainer, TabsContainerMeta);\n _registerComponent(TabUnderline, TabUnderlineMeta);\n _registerComponent(TabButton, TabButtonMeta);\n _registerComponent(TabContent, TabContentMeta);\n\n}\n\nexport * from \"./tabs\";\n"],"names":["noop","defaultButtonChildren","label","type","kind","props","children","value","DebugContext","createContext","useTabsData","initialKey","useState","tabKey","setTabKey","undefined","bbox","setBbox","constate","TabsProvider","useTabsContextUnsafe","useTabsContext","result","modulePath","TabsContainerMeta","name","displayName","importName","importPath","providesData","defaultStyles","width","padding","description","defaultValue","previewKey","previewAll","TabsContainer","inEditor","usePlasmicCanvasContext","React","Provider","Helper","ensure","x","Error","effectiveKey","DataProvider","data","TabUnderlineMeta","background","height","TabUnderline","className","style","JSON","parse","stringify","top","bottom","position","transition","TabButtonMeta","isAttachment","TabButton","tabsContext","ref","useRef","activeKey","useEffect","current","offsetWidth","left","offsetLeft","cloneElement","Children","toArray","isActive","onClick","TabContentMeta","TabContent","useContext","registerAll","loader","_registerComponent","Component","defaultMeta","registerComponent"],"mappings":";;;;;;;;;;;;;;;;;;;;AAcA,IAAMA,IA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BC,SAAY,EACZC,WAAmD;IAEnD,IAAIH,MAAM,EAAE;MACVA,MAAM,CAACI,iBAAiB,CAACF,SAAS,EAAEC,WAAW,CAAC;KACjD,MAAM;MACLC,iBAAiB,CAACF,SAAS,EAAEC,WAAW,CAAC;;GAE5C;EAEDF,kBAAkB,CAAC/C,aAAa,EAAEb,iBAAiB,CAAC;EACpD4D,kBAAkB,CAAChC,YAAY,EAAEH,gBAAgB,CAAC;EAClDmC,kBAAkB,CAACpB,SAAS,EAAEF,aAAa,CAAC;EAC5CsB,kBAAkB,CAACJ,UAAU,EAAED,cAAc,CAAC;AAEhD;;;;"}
1
+ {"version":3,"file":"plasmic-tabs.esm.js","sources":["../src/tabs.tsx","../src/index.tsx"],"sourcesContent":["import {\n ComponentMeta,\n DataProvider,\n usePlasmicCanvasContext,\n} from '@plasmicapp/host';\nimport constate from 'constate';\nimport React, {\n cloneElement,\n createContext,\n ReactElement,\n ReactNode,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nconst noop = () => {};\n\nfunction defaultButtonChildren(label: string) {\n return {\n type: 'default-component',\n kind: 'button',\n props: {\n children: {\n type: 'text',\n value: label,\n },\n },\n } as const;\n}\nexport interface TabsProviderProps {\n children?: ReactNode;\n initialKey?: string;\n previewKey?: string;\n previewAll?: boolean;\n}\n\nconst DebugContext = createContext(false);\n\nfunction useTabsData({ initialKey }: { initialKey?: string }) {\n const [tabKey, setTabKey] = useState<string | undefined>(initialKey);\n const [bbox, setBbox] = useState<{ left: number; width: number } | undefined>(\n undefined\n );\n return {\n tabKey,\n bbox,\n setTabKey,\n setBbox,\n };\n}\n\nconst [TabsProvider, useTabsContextUnsafe] = constate(useTabsData);\n\nfunction useTabsContext() {\n const result = useTabsContextUnsafe();\n return 'setTabKey' in result ? result : undefined;\n}\nconst modulePath = '@plasmicpkgs/plasmic-tabs';\n\nexport const TabsContainerMeta: ComponentMeta<TabsProviderProps> = {\n name: 'hostless-tabs-container',\n displayName: 'Tabs Container',\n importName: 'TabsContainer',\n importPath: modulePath,\n providesData: true,\n defaultStyles: {\n width: 'stretch',\n padding: '8px',\n },\n props: {\n initialKey: {\n type: 'string',\n description: 'Key of the initially selected tab',\n defaultValue: 'tab1',\n },\n previewKey: {\n type: 'string',\n description: 'SShow this key while editing in Plasmic Studio',\n },\n previewAll: {\n type: 'boolean',\n description: 'Reveal all tab contents while editing in Plasmic Studio',\n },\n children: {\n type: 'slot',\n defaultValue: {\n type: 'vbox',\n children: [\n {\n type: 'hbox',\n children: [\n {\n type: 'component',\n name: 'hostless-tab-button',\n props: {\n tabKey: 'tab1',\n children: defaultButtonChildren('Tab 1'),\n },\n },\n {\n type: 'component',\n name: 'hostless-tab-button',\n props: {\n tabKey: 'tab2',\n children: defaultButtonChildren('Tab 2'),\n },\n },\n {\n type: 'component',\n name: 'hostless-tab-underline',\n },\n ],\n },\n {\n type: 'vbox',\n children: [\n {\n type: 'component',\n name: 'hostless-tab-content',\n props: {\n tabKey: 'tab1',\n children: [\n {\n type: 'vbox',\n children: ['Some content for tab 1'],\n },\n ],\n },\n },\n {\n type: 'component',\n name: 'hostless-tab-content',\n props: {\n tabKey: 'tab2',\n children: [\n {\n type: 'vbox',\n children: ['Some content for tab 2'],\n },\n ],\n },\n },\n ],\n },\n ],\n },\n },\n },\n};\n\nexport function TabsContainer({\n children,\n initialKey,\n previewKey,\n previewAll = false,\n}: TabsProviderProps) {\n const inEditor = !!usePlasmicCanvasContext();\n return (\n <TabsProvider initialKey={initialKey}>\n <DebugContext.Provider value={inEditor && previewAll}>\n <Helper previewKey={previewKey || initialKey}>{children}</Helper>\n </DebugContext.Provider>\n </TabsProvider>\n );\n}\n\nfunction ensure<T>(x: T | undefined | null) {\n if (!x) {\n throw new Error('unexpected nil');\n }\n return x;\n}\n\nfunction Helper({\n children,\n previewKey,\n}: {\n previewKey?: string;\n children?: ReactNode;\n}) {\n const inEditor = usePlasmicCanvasContext();\n const { tabKey } = ensure(useTabsContext());\n const effectiveKey = inEditor ? previewKey || tabKey : tabKey;\n return (\n <DataProvider name={'currentTabKey'} data={effectiveKey}>\n {children}\n </DataProvider>\n );\n}\n\nexport interface TabUnderlineProps {\n className?: string;\n}\n\nexport const TabUnderlineMeta: ComponentMeta<TabUnderlineProps> = {\n name: 'hostless-tab-underline',\n displayName: 'Tab Underline',\n importName: 'TabUnderline',\n importPath: modulePath,\n props: {},\n defaultStyles: {\n background: '#7777ff',\n height: '2px',\n },\n};\n\nexport function TabUnderline({ className }: TabUnderlineProps) {\n const { bbox } = useTabsContext() ?? { bbox: undefined };\n return bbox ? (\n <div\n className={className}\n style={{\n ...JSON.parse(JSON.stringify(bbox)),\n top: undefined,\n bottom: 0,\n position: 'absolute',\n transition: '.4s ease all',\n }}\n ></div>\n ) : null;\n}\n\nexport interface TabButtonProps {\n className?: string;\n children?: ReactNode;\n tabKey?: string;\n}\n\nexport const TabButtonMeta: ComponentMeta<TabButtonProps> = {\n name: 'hostless-tab-button',\n isAttachment: true,\n displayName: 'Tab Button',\n importName: 'TabButton',\n importPath: modulePath,\n props: {\n tabKey: {\n type: 'string',\n description: 'The answer value selecting this choice sets',\n },\n children: {\n type: 'slot',\n defaultValue: defaultButtonChildren('Some tab'),\n },\n },\n defaultStyles: {\n width: 'hug',\n },\n};\n\nexport function TabButton({ className, children, tabKey }: TabButtonProps) {\n const tabsContext = useTabsContext();\n const ref = useRef<HTMLDivElement>(null);\n const { tabKey: activeKey, setTabKey, bbox, setBbox } = tabsContext ?? {\n tabKey: undefined,\n setTabKey: noop,\n bbox: undefined,\n setBbox: noop,\n };\n useEffect(() => {\n if (tabKey === activeKey) {\n setBbox({\n width: ref.current!.offsetWidth,\n left: ref.current!.offsetLeft,\n });\n }\n }, [ref.current, setBbox, JSON.stringify(bbox), tabKey, activeKey]);\n return (\n <div className={className} ref={ref}>\n {cloneElement(React.Children.toArray(children)[0] as ReactElement, {\n isActive: tabKey && activeKey && activeKey === tabKey,\n onClick: () => {\n setTabKey(tabKey);\n },\n })}\n </div>\n );\n}\n\nexport interface TabContentProps {\n children?: ReactNode;\n tabKey?: string;\n}\n\nexport const TabContentMeta: ComponentMeta<TabContentProps> = {\n name: 'hostless-tab-content',\n isAttachment: true,\n displayName: 'Tab Content',\n importName: 'TabContent',\n importPath: modulePath,\n props: {\n tabKey: {\n type: 'string',\n description: 'The answer value selecting this choice sets',\n },\n children: {\n type: 'slot',\n defaultValue: {\n type: 'vbox',\n children: {\n type: 'text',\n value: 'This is some tab content',\n },\n },\n },\n },\n};\nexport function TabContent({ children, tabKey }: TabContentProps) {\n const tabsContext = useTabsContext();\n const previewAll = useContext(DebugContext);\n const { tabKey: activeKey } = tabsContext ?? { tabKey: undefined };\n return (\n <>\n {tabsContext === undefined || activeKey === tabKey || previewAll\n ? children\n : null}\n </>\n );\n}\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\n\nimport {\n TabsContainer,\n TabsContainerMeta,\n TabUnderline,\n TabUnderlineMeta,\n TabButton,\n TabButtonMeta,\n TabContent, TabContentMeta\n} from \"./tabs\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n}) {\n const _registerComponent = <T extends React.ComponentType<any>>(\n Component: T,\n defaultMeta: ComponentMeta<React.ComponentProps<T>>\n ) => {\n if (loader) {\n loader.registerComponent(Component, defaultMeta);\n } else {\n registerComponent(Component, defaultMeta);\n }\n };\n \n _registerComponent(TabsContainer, TabsContainerMeta);\n _registerComponent(TabUnderline, TabUnderlineMeta);\n _registerComponent(TabButton, TabButtonMeta);\n _registerComponent(TabContent, TabContentMeta);\n\n}\n\nexport * from \"./tabs\";\n"],"names":["noop","defaultButtonChildren","label","type","kind","props","children","value","DebugContext","createContext","useTabsData","initialKey","useState","tabKey","setTabKey","undefined","bbox","setBbox","constate","TabsProvider","useTabsContextUnsafe","useTabsContext","result","modulePath","TabsContainerMeta","name","displayName","importName","importPath","providesData","defaultStyles","width","padding","description","defaultValue","previewKey","previewAll","TabsContainer","inEditor","usePlasmicCanvasContext","React","Provider","Helper","ensure","x","Error","effectiveKey","DataProvider","data","TabUnderlineMeta","background","height","TabUnderline","className","style","JSON","parse","stringify","top","bottom","position","transition","TabButtonMeta","isAttachment","TabButton","tabsContext","ref","useRef","activeKey","useEffect","current","offsetWidth","left","offsetLeft","cloneElement","Children","toArray","isActive","onClick","TabContentMeta","TabContent","useContext","registerAll","loader","_registerComponent","Component","defaultMeta","registerComponent"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiBA,IAAMA,IAAI,GAAG,SAAPA,IAAI,KAAW;AAErB,SAASC,qBAAqB,CAACC,KAAa;EAC1C,OAAO;IACLC,IAAI,EAAE,mBAAmB;IACzBC,IAAI,EAAE,QAAQ;IACdC,KAAK,EAAE;MACLC,QAAQ,EAAE;QACRH,IAAI,EAAE,MAAM;QACZI,KAAK,EAAEL;;;GAGH;AACZ;AAQA,IAAMM,YAAY,gBAAGC,aAAa,CAAC,KAAK,CAAC;AAEzC,SAASC,WAAW;MAAGC,UAAU,QAAVA,UAAU;EAC/B,gBAA4BC,QAAQ,CAAqBD,UAAU,CAAC;IAA7DE,MAAM;IAAEC,SAAS;EACxB,iBAAwBF,QAAQ,CAC9BG,SAAS,CACV;IAFMC,IAAI;IAAEC,OAAO;EAGpB,OAAO;IACLJ,MAAM,EAANA,MAAM;IACNG,IAAI,EAAJA,IAAI;IACJF,SAAS,EAATA,SAAS;IACTG,OAAO,EAAPA;GACD;AACH;AAEA,6BAA6CC,QAAQ,CAACR,WAAW,CAAC;EAA3DS,YAAY;EAAEC,oBAAoB;AAEzC,SAASC,cAAc;EACrB,IAAMC,MAAM,GAAGF,oBAAoB,EAAE;EACrC,OAAO,WAAW,IAAIE,MAAM,GAAGA,MAAM,GAAGP,SAAS;AACnD;AACA,IAAMQ,UAAU,GAAG,2BAA2B;IAEjCC,iBAAiB,GAAqC;EACjEC,IAAI,EAAE,yBAAyB;EAC/BC,WAAW,EAAE,gBAAgB;EAC7BC,UAAU,EAAE,eAAe;EAC3BC,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XA,WAAW,GAAI;MAAEpD,MAAM,EAAEE;KAAW;IAAlDqD,SAAS,SAAjBvD,MAAM;EACd,OACE2B,0CACGyB,WAAW,KAAKlD,SAAS,IAAIqD,SAAS,KAAKvD,MAAM,IAAIuB,UAAU,GAC5D9B,QAAQ,GACR,IAAI,CACP;AAEP;;SCjTgB4E,WAAW,CAACC,MAE3B;EACC,IAAMC,kBAAkB,GAAG,SAArBA,kBAAkB,CACtBC,SAAY,EACZC,WAAmD;IAEnD,IAAIH,MAAM,EAAE;MACVA,MAAM,CAACI,iBAAiB,CAACF,SAAS,EAAEC,WAAW,CAAC;KACjD,MAAM;MACLC,iBAAiB,CAACF,SAAS,EAAEC,WAAW,CAAC;;GAE5C;EAEDF,kBAAkB,CAAC/C,aAAa,EAAEb,iBAAiB,CAAC;EACpD4D,kBAAkB,CAAChC,YAAY,EAAEH,gBAAgB,CAAC;EAClDmC,kBAAkB,CAACpB,SAAS,EAAEF,aAAa,CAAC;EAC5CsB,kBAAkB,CAACJ,UAAU,EAAED,cAAc,CAAC;AAEhD;;;;"}
package/dist/tabs.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ComponentMeta } from "@plasmicapp/host";
2
- import { ReactNode } from "react";
1
+ import { ComponentMeta } from '@plasmicapp/host';
2
+ import { ReactNode } from 'react';
3
3
  export interface TabsProviderProps {
4
4
  children?: ReactNode;
5
5
  initialKey?: string;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.4",
2
+ "version": "0.0.5",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -63,5 +63,5 @@
63
63
  "dependencies": {
64
64
  "constate": "^3.3.2"
65
65
  },
66
- "gitHead": "1a11e260711c67b16c0703de62e6d108a12fa2d9"
66
+ "gitHead": "aa76cffecca904270776e3de48960defac03e4d5"
67
67
  }