@plasmicpkgs/plasmic-tabs 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/plasmic-tabs.cjs.development.js +31 -60
- package/dist/plasmic-tabs.cjs.development.js.map +1 -1
- package/dist/plasmic-tabs.cjs.production.min.js +1 -1
- package/dist/plasmic-tabs.cjs.production.min.js.map +1 -1
- package/dist/plasmic-tabs.esm.js +31 -60
- package/dist/plasmic-tabs.esm.js.map +1 -1
- package/package.json +6 -6
|
@@ -11,25 +11,21 @@ var React = require('react');
|
|
|
11
11
|
var React__default = _interopDefault(React);
|
|
12
12
|
|
|
13
13
|
function _extends() {
|
|
14
|
-
_extends = Object.assign
|
|
14
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
15
15
|
for (var i = 1; i < arguments.length; i++) {
|
|
16
16
|
var source = arguments[i];
|
|
17
|
-
|
|
18
17
|
for (var key in source) {
|
|
19
18
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
20
19
|
target[key] = source[key];
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
|
-
|
|
25
23
|
return target;
|
|
26
24
|
};
|
|
27
|
-
|
|
28
25
|
return _extends.apply(this, arguments);
|
|
29
26
|
}
|
|
30
27
|
|
|
31
28
|
var noop = function noop() {};
|
|
32
|
-
|
|
33
29
|
function defaultButtonChildren(label) {
|
|
34
30
|
return {
|
|
35
31
|
type: "default-component",
|
|
@@ -42,20 +38,15 @@ function defaultButtonChildren(label) {
|
|
|
42
38
|
}
|
|
43
39
|
};
|
|
44
40
|
}
|
|
45
|
-
|
|
46
41
|
var DebugContext = /*#__PURE__*/React.createContext(false);
|
|
47
|
-
|
|
48
42
|
function useTabsData(_ref) {
|
|
49
43
|
var initialKey = _ref.initialKey;
|
|
50
|
-
|
|
51
44
|
var _useState = React.useState(initialKey),
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
tabKey = _useState[0],
|
|
46
|
+
setTabKey = _useState[1];
|
|
55
47
|
var _useState2 = React.useState(undefined),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
bbox = _useState2[0],
|
|
49
|
+
setBbox = _useState2[1];
|
|
59
50
|
return {
|
|
60
51
|
tabKey: tabKey,
|
|
61
52
|
bbox: bbox,
|
|
@@ -63,16 +54,13 @@ function useTabsData(_ref) {
|
|
|
63
54
|
setBbox: setBbox
|
|
64
55
|
};
|
|
65
56
|
}
|
|
66
|
-
|
|
67
57
|
var _constate = /*#__PURE__*/constate(useTabsData),
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
58
|
+
TabsProvider = _constate[0],
|
|
59
|
+
useTabsContextUnsafe = _constate[1];
|
|
71
60
|
function useTabsContext() {
|
|
72
61
|
var result = useTabsContextUnsafe();
|
|
73
62
|
return "setTabKey" in result ? result : undefined;
|
|
74
63
|
}
|
|
75
|
-
|
|
76
64
|
var modulePath = "@plasmicpkgs/plasmic-tabs";
|
|
77
65
|
var TabsContainerMeta = {
|
|
78
66
|
name: "hostless-tabs-container",
|
|
@@ -152,10 +140,10 @@ var TabsContainerMeta = {
|
|
|
152
140
|
};
|
|
153
141
|
function TabsContainer(_ref2) {
|
|
154
142
|
var children = _ref2.children,
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
143
|
+
initialKey = _ref2.initialKey,
|
|
144
|
+
previewKey = _ref2.previewKey,
|
|
145
|
+
_ref2$previewAll = _ref2.previewAll,
|
|
146
|
+
previewAll = _ref2$previewAll === void 0 ? false : _ref2$previewAll;
|
|
159
147
|
var inEditor = !!host.usePlasmicCanvasContext();
|
|
160
148
|
return React__default.createElement(TabsProvider, {
|
|
161
149
|
initialKey: initialKey
|
|
@@ -165,30 +153,24 @@ function TabsContainer(_ref2) {
|
|
|
165
153
|
previewKey: previewKey || initialKey
|
|
166
154
|
}, children)));
|
|
167
155
|
}
|
|
168
|
-
|
|
169
156
|
function ensure(x) {
|
|
170
157
|
if (!x) {
|
|
171
158
|
throw new Error("unexpected nil");
|
|
172
159
|
}
|
|
173
|
-
|
|
174
160
|
return x;
|
|
175
161
|
}
|
|
176
|
-
|
|
177
162
|
function Helper(_ref3) {
|
|
178
163
|
var children = _ref3.children,
|
|
179
|
-
|
|
164
|
+
previewKey = _ref3.previewKey;
|
|
180
165
|
var inEditor = host.usePlasmicCanvasContext();
|
|
181
|
-
|
|
182
166
|
var _ensure = ensure(useTabsContext()),
|
|
183
|
-
|
|
184
|
-
|
|
167
|
+
tabKey = _ensure.tabKey;
|
|
185
168
|
var effectiveKey = inEditor ? previewKey || tabKey : tabKey;
|
|
186
169
|
return React__default.createElement(host.DataProvider, {
|
|
187
170
|
name: "currentTabKey",
|
|
188
171
|
data: effectiveKey
|
|
189
172
|
}, children);
|
|
190
173
|
}
|
|
191
|
-
|
|
192
174
|
var TabUnderlineMeta = {
|
|
193
175
|
name: "hostless-tab-underline",
|
|
194
176
|
displayName: "Tab Underline",
|
|
@@ -206,14 +188,11 @@ var TabUnderlineMeta = {
|
|
|
206
188
|
};
|
|
207
189
|
function TabUnderline(_ref4) {
|
|
208
190
|
var _useTabsContext;
|
|
209
|
-
|
|
210
191
|
var className = _ref4.className;
|
|
211
|
-
|
|
212
192
|
var _ref5 = (_useTabsContext = useTabsContext()) != null ? _useTabsContext : {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
193
|
+
bbox: undefined
|
|
194
|
+
},
|
|
195
|
+
bbox = _ref5.bbox;
|
|
217
196
|
return bbox ? React__default.createElement("div", {
|
|
218
197
|
className: className,
|
|
219
198
|
style: _extends({}, JSON.parse(JSON.stringify(bbox)), {
|
|
@@ -246,22 +225,20 @@ var TabButtonMeta = {
|
|
|
246
225
|
};
|
|
247
226
|
function TabButton(_ref6) {
|
|
248
227
|
var className = _ref6.className,
|
|
249
|
-
|
|
250
|
-
|
|
228
|
+
children = _ref6.children,
|
|
229
|
+
tabKey = _ref6.tabKey;
|
|
251
230
|
var tabsContext = useTabsContext();
|
|
252
231
|
var ref = React.useRef(null);
|
|
253
|
-
|
|
254
232
|
var _ref7 = tabsContext != null ? tabsContext : {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
233
|
+
tabKey: undefined,
|
|
234
|
+
setTabKey: noop,
|
|
235
|
+
bbox: undefined,
|
|
236
|
+
setBbox: noop
|
|
237
|
+
},
|
|
238
|
+
activeKey = _ref7.tabKey,
|
|
239
|
+
setTabKey = _ref7.setTabKey,
|
|
240
|
+
bbox = _ref7.bbox,
|
|
241
|
+
setBbox = _ref7.setBbox;
|
|
265
242
|
React.useEffect(function () {
|
|
266
243
|
if (tabKey === activeKey) {
|
|
267
244
|
setBbox({
|
|
@@ -305,15 +282,13 @@ var TabContentMeta = {
|
|
|
305
282
|
};
|
|
306
283
|
function TabContent(_ref8) {
|
|
307
284
|
var children = _ref8.children,
|
|
308
|
-
|
|
285
|
+
tabKey = _ref8.tabKey;
|
|
309
286
|
var tabsContext = useTabsContext();
|
|
310
287
|
var previewAll = React.useContext(DebugContext);
|
|
311
|
-
|
|
312
288
|
var _ref9 = tabsContext != null ? tabsContext : {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
289
|
+
tabKey: undefined
|
|
290
|
+
},
|
|
291
|
+
activeKey = _ref9.tabKey;
|
|
317
292
|
return React__default.createElement(React__default.Fragment, null, tabsContext === undefined || activeKey === tabKey || previewAll ? children : null);
|
|
318
293
|
}
|
|
319
294
|
|
|
@@ -325,13 +300,9 @@ function registerAll(loader) {
|
|
|
325
300
|
registerComponent(Component, defaultMeta);
|
|
326
301
|
}
|
|
327
302
|
};
|
|
328
|
-
|
|
329
303
|
_registerComponent(TabsContainer, TabsContainerMeta);
|
|
330
|
-
|
|
331
304
|
_registerComponent(TabUnderline, TabUnderlineMeta);
|
|
332
|
-
|
|
333
305
|
_registerComponent(TabButton, TabButtonMeta);
|
|
334
|
-
|
|
335
306
|
_registerComponent(TabContent, TabContentMeta);
|
|
336
307
|
}
|
|
337
308
|
|
|
@@ -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,IAAO,KAAb;;AAEA,SAASC,qBAAT,CAA+BC,KAA/B;AACE,SAAO;AACLC,IAAAA,IAAI,EAAE,mBADD;AAELC,IAAAA,IAAI,EAAE,QAFD;AAGLC,IAAAA,KAAK,EAAE;AACLC,MAAAA,QAAQ,EAAE;AACRH,QAAAA,IAAI,EAAE,MADE;AAERI,QAAAA,KAAK,EAAEL;AAFC;AADL;AAHF,GAAP;AAUD;;AAQD,IAAMM,YAAY,gBAAGC,mBAAa,CAAC,KAAD,CAAlC;;AAEA,SAASC,WAAT;MAAuBC,kBAAAA;;AACrB,kBAA4BC,cAAQ,CAAqBD,UAArB,CAApC;AAAA,MAAOE,MAAP;AAAA,MAAeC,SAAf;;AACA,mBAAwBF,cAAQ,CAC9BG,SAD8B,CAAhC;AAAA,MAAOC,IAAP;AAAA,MAAaC,OAAb;;AAGA,SAAO;AACLJ,IAAAA,MAAM,EAANA,MADK;AAELG,IAAAA,IAAI,EAAJA,IAFK;AAGLF,IAAAA,SAAS,EAATA,SAHK;AAILG,IAAAA,OAAO,EAAPA;AAJK,GAAP;AAMD;;AAED,6BAA6CC,QAAQ,CAACR,WAAD,CAArD;AAAA,IAAOS,YAAP;AAAA,IAAqBC,oBAArB;;AAEA,SAASC,cAAT;AACE,MAAMC,MAAM,GAAGF,oBAAoB,EAAnC;AACA,SAAO,eAAeE,MAAf,GAAwBA,MAAxB,GAAiCP,SAAxC;AACD;;AACD,IAAMQ,UAAU,GAAC,2BAAjB;IAEaC,iBAAiB,GAAqC;AAC/DC,EAAAA,IAAI,EAAE,yBADyD;AAE/DC,E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AAA,MAAM,EAAEE;AAAV,GAA7C;AAAA,MAAgBqD,SAAhB,SAAQvD,MAAR;;AACA,SACE2B,4BAAA,wBAAA,MAAA,EACGyB,WAAW,KAAKlD,SAAhB,IAA6BqD,SAAS,KAAKvD,MAA3C,IAAqDuB,UAArD,GACG9B,QADH,GAEG,IAHN,CADF;AAOD;;SCpTe4E,YAAYC;AAG1B,MAAMC,kBAAkB,GAAG,SAArBA,kBAAqB,CACzBC,SADyB,EAEzBC,WAFyB;AAIzB,QAAIH,MAAJ,EAAY;AACVA,MAAAA,MAAM,CAACI,iBAAP,CAAyBF,SAAzB,EAAoCC,WAApC;AACD,KAFD,MAEO;AACLC,MAAAA,iBAAiB,CAACF,SAAD,EAAYC,WAAZ,CAAjB;AACD;AACF,GATD;;AAWAF,EAAAA,kBAAkB,CAAC/C,aAAD,EAAgBb,iBAAhB,CAAlB;;AACA4D,EAAAA,kBAAkB,CAAChC,YAAD,EAAeH,gBAAf,CAAlB;;AACAmC,EAAAA,kBAAkB,CAACpB,SAAD,EAAYF,aAAZ,CAAlB;;AACAsB,EAAAA,kBAAkB,CAACJ,UAAD,EAAaD,cAAb,CAAlB;AAED;;;;;;;;;;;;"}
|
|
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,C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|
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"),
|
|
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)};
|
|
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","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":"ieAcA,IAAMA,EAAO,aAEb,SAASC,EAAsBC,SACtB,CACLC,KAAM,oBACNC,KAAM,SACNC,MAAO,CACLC,SAAU,CACRH,KAAM,OACNI,MAAOL,KAYf,IAAMM,EAAeC,iBAAc,GAEnC,SAASC,WACqBC,aADPC,YACdC,OAAQC,SACSH,gBACtBI,SAEK,CACLF,OAAAA,EACAG,UACAF,UAAAA,EACAG,cAIJ,MAA6CC,EAASR,GAA/CS,OAAcC,OAErB,SAASC,QACDC,EAASF,UACR,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,KAAM,4BAIZ,CACEtB,KAAM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W9C,IAAAA,SAAUO,IAAAA,OACzCmD,EAAc3C,IACd4C,EAAMC,SAAuB,cACqBF,EAAAA,EAAe,CACrEnD,YAAQE,EACRD,UAAWd,EACXgB,UAAMD,EACNE,QAAQjB,GAJMmE,IAARtD,OAAmBC,IAAAA,UAAiBG,IAAAA,eAM5CmD,aAAU,WACJvD,IAAWsD,GACblD,EAAQ,CACNc,MAAOkC,EAAII,QAASC,YACpBC,KAAMN,EAAII,QAASG,eAGtB,CAACP,EAAII,QAASpD,EAASqC,KAAKE,YAbOxC,MAaUH,EAAQsD,IAEtD3B,uBAAKY,UAAWA,EAAWa,IAAKA,GAC7BQ,eAAajC,EAAMkC,SAASC,QAAQrE,GAAU,GAAoB,CACjEsE,SAAU/D,GAAUsD,GAAaA,IAActD,EAC/CgE,QAAS,WACP/D,EAAUD,WAYPiE,EAA8C,CACzDrD,KAAM,uBACNqC,cAAc,EACdpC,YAAa,cACbC,WAAY,aACZC,WAAYL,EACZlB,MAAO,CACLQ,OAAQ,CACNV,KAAM,SACN8B,YAAa,+CAEf3B,SAAU,CACRH,KAAM,OACN+B,aAAc,CACd/B,KAAK,OACLG,SAAS,CACPH,KAAK,OACLI,MAAM,yCAMEwE,SAAazE,IAAAA,SAAUO,IAAAA,OAC/BmD,EAAc3C,IACde,EAAa4C,aAAWxE,UAG5BgC,qCACmBzB,IAAhBiD,UAHyBA,EAAAA,EAAe,CAAEnD,YAAQE,IAA/CF,SAGwCA,GAAUuB,EAClD9B,EACA,mOCjTkB2E,OAGpBC,EAAqB,SACzBC,EACAC,GAEIH,EACFA,EAAOI,kBAAkBF,EAAWC,GAEpCC,EAAkBF,EAAWC,IAIjCF,EAAmB7C,EAAeb,GAClC0D,EAAmB/B,EAAcH,GACjCkC,EAAmBnB,EAAWF,GAC9BqB,EAAmBH,EAAYD"}
|
|
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,C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KE,YAbOzC,MAaUH,EAAQuD,IAEtD3B,uBAAKY,UAAWA,EAAWa,IAAKA,GAC7BQ,eAAajC,EAAMkC,SAASC,QAAQtE,GAAU,GAAoB,CACjEuE,SAAUhE,GAAUuD,GAAaA,IAAcvD,EAC/CiE,QAAS,WACPhE,EAAUD,WAYPkE,EAA8C,CACzDtD,KAAM,uBACNsC,cAAc,EACdrC,YAAa,cACbC,WAAY,aACZC,WAAYL,EACZlB,MAAO,CACLQ,OAAQ,CACNV,KAAM,SACN8B,YAAa,+CAEf3B,SAAU,CACRH,KAAM,OACN+B,aAAc,CACd/B,KAAK,OACLG,SAAS,CACPH,KAAK,OACLI,MAAM,yCAMEyE,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,mOCjTkB4E,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"}
|
package/dist/plasmic-tabs.esm.js
CHANGED
|
@@ -4,25 +4,21 @@ import constate from 'constate';
|
|
|
4
4
|
import React, { useRef, useEffect, cloneElement, useContext, createContext, useState } from 'react';
|
|
5
5
|
|
|
6
6
|
function _extends() {
|
|
7
|
-
_extends = Object.assign
|
|
7
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
8
8
|
for (var i = 1; i < arguments.length; i++) {
|
|
9
9
|
var source = arguments[i];
|
|
10
|
-
|
|
11
10
|
for (var key in source) {
|
|
12
11
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
13
12
|
target[key] = source[key];
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
|
-
|
|
18
16
|
return target;
|
|
19
17
|
};
|
|
20
|
-
|
|
21
18
|
return _extends.apply(this, arguments);
|
|
22
19
|
}
|
|
23
20
|
|
|
24
21
|
var noop = function noop() {};
|
|
25
|
-
|
|
26
22
|
function defaultButtonChildren(label) {
|
|
27
23
|
return {
|
|
28
24
|
type: "default-component",
|
|
@@ -35,20 +31,15 @@ function defaultButtonChildren(label) {
|
|
|
35
31
|
}
|
|
36
32
|
};
|
|
37
33
|
}
|
|
38
|
-
|
|
39
34
|
var DebugContext = /*#__PURE__*/createContext(false);
|
|
40
|
-
|
|
41
35
|
function useTabsData(_ref) {
|
|
42
36
|
var initialKey = _ref.initialKey;
|
|
43
|
-
|
|
44
37
|
var _useState = useState(initialKey),
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
tabKey = _useState[0],
|
|
39
|
+
setTabKey = _useState[1];
|
|
48
40
|
var _useState2 = useState(undefined),
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
bbox = _useState2[0],
|
|
42
|
+
setBbox = _useState2[1];
|
|
52
43
|
return {
|
|
53
44
|
tabKey: tabKey,
|
|
54
45
|
bbox: bbox,
|
|
@@ -56,16 +47,13 @@ function useTabsData(_ref) {
|
|
|
56
47
|
setBbox: setBbox
|
|
57
48
|
};
|
|
58
49
|
}
|
|
59
|
-
|
|
60
50
|
var _constate = /*#__PURE__*/constate(useTabsData),
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
TabsProvider = _constate[0],
|
|
52
|
+
useTabsContextUnsafe = _constate[1];
|
|
64
53
|
function useTabsContext() {
|
|
65
54
|
var result = useTabsContextUnsafe();
|
|
66
55
|
return "setTabKey" in result ? result : undefined;
|
|
67
56
|
}
|
|
68
|
-
|
|
69
57
|
var modulePath = "@plasmicpkgs/plasmic-tabs";
|
|
70
58
|
var TabsContainerMeta = {
|
|
71
59
|
name: "hostless-tabs-container",
|
|
@@ -145,10 +133,10 @@ var TabsContainerMeta = {
|
|
|
145
133
|
};
|
|
146
134
|
function TabsContainer(_ref2) {
|
|
147
135
|
var children = _ref2.children,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
136
|
+
initialKey = _ref2.initialKey,
|
|
137
|
+
previewKey = _ref2.previewKey,
|
|
138
|
+
_ref2$previewAll = _ref2.previewAll,
|
|
139
|
+
previewAll = _ref2$previewAll === void 0 ? false : _ref2$previewAll;
|
|
152
140
|
var inEditor = !!usePlasmicCanvasContext();
|
|
153
141
|
return React.createElement(TabsProvider, {
|
|
154
142
|
initialKey: initialKey
|
|
@@ -158,30 +146,24 @@ function TabsContainer(_ref2) {
|
|
|
158
146
|
previewKey: previewKey || initialKey
|
|
159
147
|
}, children)));
|
|
160
148
|
}
|
|
161
|
-
|
|
162
149
|
function ensure(x) {
|
|
163
150
|
if (!x) {
|
|
164
151
|
throw new Error("unexpected nil");
|
|
165
152
|
}
|
|
166
|
-
|
|
167
153
|
return x;
|
|
168
154
|
}
|
|
169
|
-
|
|
170
155
|
function Helper(_ref3) {
|
|
171
156
|
var children = _ref3.children,
|
|
172
|
-
|
|
157
|
+
previewKey = _ref3.previewKey;
|
|
173
158
|
var inEditor = usePlasmicCanvasContext();
|
|
174
|
-
|
|
175
159
|
var _ensure = ensure(useTabsContext()),
|
|
176
|
-
|
|
177
|
-
|
|
160
|
+
tabKey = _ensure.tabKey;
|
|
178
161
|
var effectiveKey = inEditor ? previewKey || tabKey : tabKey;
|
|
179
162
|
return React.createElement(DataProvider, {
|
|
180
163
|
name: "currentTabKey",
|
|
181
164
|
data: effectiveKey
|
|
182
165
|
}, children);
|
|
183
166
|
}
|
|
184
|
-
|
|
185
167
|
var TabUnderlineMeta = {
|
|
186
168
|
name: "hostless-tab-underline",
|
|
187
169
|
displayName: "Tab Underline",
|
|
@@ -199,14 +181,11 @@ var TabUnderlineMeta = {
|
|
|
199
181
|
};
|
|
200
182
|
function TabUnderline(_ref4) {
|
|
201
183
|
var _useTabsContext;
|
|
202
|
-
|
|
203
184
|
var className = _ref4.className;
|
|
204
|
-
|
|
205
185
|
var _ref5 = (_useTabsContext = useTabsContext()) != null ? _useTabsContext : {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
186
|
+
bbox: undefined
|
|
187
|
+
},
|
|
188
|
+
bbox = _ref5.bbox;
|
|
210
189
|
return bbox ? React.createElement("div", {
|
|
211
190
|
className: className,
|
|
212
191
|
style: _extends({}, JSON.parse(JSON.stringify(bbox)), {
|
|
@@ -239,22 +218,20 @@ var TabButtonMeta = {
|
|
|
239
218
|
};
|
|
240
219
|
function TabButton(_ref6) {
|
|
241
220
|
var className = _ref6.className,
|
|
242
|
-
|
|
243
|
-
|
|
221
|
+
children = _ref6.children,
|
|
222
|
+
tabKey = _ref6.tabKey;
|
|
244
223
|
var tabsContext = useTabsContext();
|
|
245
224
|
var ref = useRef(null);
|
|
246
|
-
|
|
247
225
|
var _ref7 = tabsContext != null ? tabsContext : {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
226
|
+
tabKey: undefined,
|
|
227
|
+
setTabKey: noop,
|
|
228
|
+
bbox: undefined,
|
|
229
|
+
setBbox: noop
|
|
230
|
+
},
|
|
231
|
+
activeKey = _ref7.tabKey,
|
|
232
|
+
setTabKey = _ref7.setTabKey,
|
|
233
|
+
bbox = _ref7.bbox,
|
|
234
|
+
setBbox = _ref7.setBbox;
|
|
258
235
|
useEffect(function () {
|
|
259
236
|
if (tabKey === activeKey) {
|
|
260
237
|
setBbox({
|
|
@@ -298,15 +275,13 @@ var TabContentMeta = {
|
|
|
298
275
|
};
|
|
299
276
|
function TabContent(_ref8) {
|
|
300
277
|
var children = _ref8.children,
|
|
301
|
-
|
|
278
|
+
tabKey = _ref8.tabKey;
|
|
302
279
|
var tabsContext = useTabsContext();
|
|
303
280
|
var previewAll = useContext(DebugContext);
|
|
304
|
-
|
|
305
281
|
var _ref9 = tabsContext != null ? tabsContext : {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
282
|
+
tabKey: undefined
|
|
283
|
+
},
|
|
284
|
+
activeKey = _ref9.tabKey;
|
|
310
285
|
return React.createElement(React.Fragment, null, tabsContext === undefined || activeKey === tabKey || previewAll ? children : null);
|
|
311
286
|
}
|
|
312
287
|
|
|
@@ -318,13 +293,9 @@ function registerAll(loader) {
|
|
|
318
293
|
registerComponent(Component, defaultMeta);
|
|
319
294
|
}
|
|
320
295
|
};
|
|
321
|
-
|
|
322
296
|
_registerComponent(TabsContainer, TabsContainerMeta);
|
|
323
|
-
|
|
324
297
|
_registerComponent(TabUnderline, TabUnderlineMeta);
|
|
325
|
-
|
|
326
298
|
_registerComponent(TabButton, TabButtonMeta);
|
|
327
|
-
|
|
328
299
|
_registerComponent(TabContent, TabContentMeta);
|
|
329
300
|
}
|
|
330
301
|
|
|
@@ -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,IAAI,GAAG,SAAPA,IAAO,KAAb;;AAEA,SAASC,qBAAT,CAA+BC,KAA/B;AACE,SAAO;AACLC,IAAAA,IAAI,EAAE,mBADD;AAELC,IAAAA,IAAI,EAAE,QAFD;AAGLC,IAAAA,KAAK,EAAE;AACLC,MAAAA,QAAQ,EAAE;AACRH,QAAAA,IAAI,EAAE,MADE;AAERI,QAAAA,KAAK,EAAEL;AAFC;AADL;AAHF,GAAP;AAUD;;AAQD,IAAMM,YAAY,gBAAGC,aAAa,CAAC,KAAD,CAAlC;;AAEA,SAASC,WAAT;MAAuBC,kBAAAA;;AACrB,kBAA4BC,QAAQ,CAAqBD,UAArB,CAApC;AAAA,MAAOE,MAAP;AAAA,MAAeC,SAAf;;AACA,mBAAwBF,QAAQ,CAC9BG,SAD8B,CAAhC;AAAA,MAA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,"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":";;;;;;;;;;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B,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/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.4",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
],
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@size-limit/preset-small-lib": "^7.0.4",
|
|
53
|
-
"@types/react": "^
|
|
54
|
-
"@types/react-dom": "^
|
|
53
|
+
"@types/react": "^18.0.27",
|
|
54
|
+
"@types/react-dom": "^18.0.10",
|
|
55
55
|
"husky": "^7.0.4",
|
|
56
|
-
"react": "^
|
|
57
|
-
"react-dom": "^
|
|
56
|
+
"react": "^18.2.0",
|
|
57
|
+
"react-dom": "^18.2.0",
|
|
58
58
|
"size-limit": "^7.0.4",
|
|
59
59
|
"tsdx": "^0.14.1",
|
|
60
60
|
"tslib": "^2.3.1",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"constate": "^3.3.2"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "1a11e260711c67b16c0703de62e6d108a12fa2d9"
|
|
67
67
|
}
|