@plasmicpkgs/plasmic-tabs 0.0.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Abdukhamid Latipov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
File without changes
@@ -0,0 +1,5 @@
1
+ import registerComponent from "@plasmicapp/host/registerComponent";
2
+ export declare function registerAll(loader?: {
3
+ registerComponent: typeof registerComponent;
4
+ }): void;
5
+ export * from "./tabs";
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+
2
+ 'use strict'
3
+
4
+ if (process.env.NODE_ENV === 'production') {
5
+ module.exports = require('./plasmic-tabs.cjs.production.min.js')
6
+ } else {
7
+ module.exports = require('./plasmic-tabs.cjs.development.js')
8
+ }
@@ -0,0 +1,347 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
+
7
+ var registerComponent = _interopDefault(require('@plasmicapp/host/registerComponent'));
8
+ var host = require('@plasmicapp/host');
9
+ var constate = _interopDefault(require('constate'));
10
+ var React = require('react');
11
+ var React__default = _interopDefault(React);
12
+
13
+ function _extends() {
14
+ _extends = Object.assign || function (target) {
15
+ for (var i = 1; i < arguments.length; i++) {
16
+ var source = arguments[i];
17
+
18
+ for (var key in source) {
19
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
20
+ target[key] = source[key];
21
+ }
22
+ }
23
+ }
24
+
25
+ return target;
26
+ };
27
+
28
+ return _extends.apply(this, arguments);
29
+ }
30
+
31
+ var noop = function noop() {};
32
+
33
+ function defaultButtonChildren(label) {
34
+ return {
35
+ type: "default-component",
36
+ kind: "button",
37
+ props: {
38
+ children: {
39
+ type: "text",
40
+ value: label
41
+ }
42
+ }
43
+ };
44
+ }
45
+
46
+ var DebugContext = /*#__PURE__*/React.createContext(false);
47
+
48
+ function useTabsData(_ref) {
49
+ var initialKey = _ref.initialKey;
50
+
51
+ var _useState = React.useState(initialKey),
52
+ tabKey = _useState[0],
53
+ setTabKey = _useState[1];
54
+
55
+ var _useState2 = React.useState(undefined),
56
+ bbox = _useState2[0],
57
+ setBbox = _useState2[1];
58
+
59
+ return {
60
+ tabKey: tabKey,
61
+ bbox: bbox,
62
+ setTabKey: setTabKey,
63
+ setBbox: setBbox
64
+ };
65
+ }
66
+
67
+ var _constate = /*#__PURE__*/constate(useTabsData),
68
+ TabsProvider = _constate[0],
69
+ useTabsContextUnsafe = _constate[1];
70
+
71
+ function useTabsContext() {
72
+ var result = useTabsContextUnsafe();
73
+ return "setTabKey" in result ? result : undefined;
74
+ }
75
+
76
+ var modulePath = "@plasmicpkgs/plasmic-tabs";
77
+ var TabsContainerMeta = {
78
+ name: "TabsContainer",
79
+ displayName: "Tabs Container",
80
+ importName: "TabsContainer",
81
+ importPath: modulePath,
82
+ providesData: true,
83
+ defaultStyles: {
84
+ width: "stretch",
85
+ padding: "8px"
86
+ },
87
+ props: {
88
+ initialKey: {
89
+ type: "string",
90
+ description: "Key of the initially selected tab",
91
+ defaultValue: "tab1"
92
+ },
93
+ previewKey: {
94
+ type: "string",
95
+ description: "SShow this key while editing in Plasmic Studio"
96
+ },
97
+ previewAll: {
98
+ type: "boolean",
99
+ description: "Reveal all tab contents while editing in Plasmic Studio"
100
+ },
101
+ children: {
102
+ type: "slot",
103
+ defaultValue: {
104
+ type: "vbox",
105
+ children: [{
106
+ type: "hbox",
107
+ children: [{
108
+ type: "component",
109
+ name: "TabButton",
110
+ props: {
111
+ tabKey: "tab1",
112
+ children: /*#__PURE__*/defaultButtonChildren("Tab 1")
113
+ }
114
+ }, {
115
+ type: "component",
116
+ name: "TabButton",
117
+ props: {
118
+ tabKey: "tab2",
119
+ children: /*#__PURE__*/defaultButtonChildren("Tab 2")
120
+ }
121
+ }, {
122
+ type: "component",
123
+ name: "TabUnderline"
124
+ }]
125
+ }, {
126
+ type: "vbox",
127
+ children: [{
128
+ type: "component",
129
+ name: "TabContent",
130
+ props: {
131
+ tabKey: "tab1",
132
+ children: [{
133
+ type: "vbox",
134
+ children: ["Some content for tab 1"]
135
+ }]
136
+ }
137
+ }, {
138
+ type: "component",
139
+ name: "TabContent",
140
+ props: {
141
+ tabKey: "tab2",
142
+ children: [{
143
+ type: "vbox",
144
+ children: ["Some content for tab 2"]
145
+ }]
146
+ }
147
+ }]
148
+ }]
149
+ }
150
+ }
151
+ }
152
+ };
153
+ function TabsContainer(_ref2) {
154
+ var children = _ref2.children,
155
+ initialKey = _ref2.initialKey,
156
+ previewKey = _ref2.previewKey,
157
+ _ref2$previewAll = _ref2.previewAll,
158
+ previewAll = _ref2$previewAll === void 0 ? false : _ref2$previewAll;
159
+ var inEditor = !!host.usePlasmicCanvasContext();
160
+ return React__default.createElement(TabsProvider, {
161
+ initialKey: initialKey
162
+ }, React__default.createElement(DebugContext.Provider, {
163
+ value: inEditor && previewAll
164
+ }, React__default.createElement(Helper, {
165
+ previewKey: previewKey || initialKey
166
+ }, children)));
167
+ }
168
+
169
+ function ensure(x) {
170
+ if (!x) {
171
+ throw new Error("unexpected nil");
172
+ }
173
+
174
+ return x;
175
+ }
176
+
177
+ function Helper(_ref3) {
178
+ var children = _ref3.children,
179
+ previewKey = _ref3.previewKey;
180
+ var inEditor = host.usePlasmicCanvasContext();
181
+
182
+ var _ensure = ensure(useTabsContext()),
183
+ tabKey = _ensure.tabKey;
184
+
185
+ var effectiveKey = inEditor ? previewKey || tabKey : tabKey;
186
+ return React__default.createElement(host.DataProvider, {
187
+ name: "currentTabKey",
188
+ data: effectiveKey
189
+ }, children);
190
+ }
191
+
192
+ var TabUnderlineMeta = {
193
+ name: "TabUnderline",
194
+ displayName: "Tab Underline",
195
+ importName: "TabUnderline",
196
+ importPath: modulePath,
197
+ props: {
198
+ children: {
199
+ type: "slot"
200
+ }
201
+ },
202
+ defaultStyles: {
203
+ background: "#7777ff",
204
+ height: "2px"
205
+ }
206
+ };
207
+ function TabUnderline(_ref4) {
208
+ var _useTabsContext;
209
+
210
+ var className = _ref4.className;
211
+
212
+ var _ref5 = (_useTabsContext = useTabsContext()) != null ? _useTabsContext : {
213
+ bbox: undefined
214
+ },
215
+ bbox = _ref5.bbox;
216
+
217
+ return bbox ? React__default.createElement("div", {
218
+ className: className,
219
+ style: _extends({}, JSON.parse(JSON.stringify(bbox)), {
220
+ top: undefined,
221
+ bottom: 0,
222
+ position: "absolute",
223
+ transition: ".4s ease all"
224
+ })
225
+ }) : null;
226
+ }
227
+ var TabButtonMeta = {
228
+ name: "TabButton",
229
+ isAttachment: true,
230
+ displayName: "Tab Button",
231
+ importName: "TabButton",
232
+ importPath: modulePath,
233
+ props: {
234
+ tabKey: {
235
+ type: "string",
236
+ description: "The answer value selecting this choice sets"
237
+ },
238
+ children: {
239
+ type: "slot",
240
+ defaultValue: /*#__PURE__*/defaultButtonChildren("Some tab")
241
+ }
242
+ },
243
+ defaultStyles: {
244
+ width: "hug"
245
+ }
246
+ };
247
+ function TabButton(_ref6) {
248
+ var className = _ref6.className,
249
+ children = _ref6.children,
250
+ tabKey = _ref6.tabKey;
251
+ var tabsContext = useTabsContext();
252
+ var ref = React.useRef(null);
253
+
254
+ var _ref7 = tabsContext != null ? tabsContext : {
255
+ tabKey: undefined,
256
+ setTabKey: noop,
257
+ bbox: undefined,
258
+ setBbox: noop
259
+ },
260
+ activeKey = _ref7.tabKey,
261
+ setTabKey = _ref7.setTabKey,
262
+ bbox = _ref7.bbox,
263
+ setBbox = _ref7.setBbox;
264
+
265
+ React.useEffect(function () {
266
+ if (tabKey === activeKey) {
267
+ setBbox({
268
+ width: ref.current.offsetWidth,
269
+ left: ref.current.offsetLeft
270
+ });
271
+ }
272
+ }, [ref.current, setBbox, JSON.stringify(bbox), tabKey, activeKey]);
273
+ return React__default.createElement("div", {
274
+ className: className,
275
+ ref: ref
276
+ }, React.cloneElement(React__default.Children.toArray(children)[0], {
277
+ isActive: tabKey && activeKey && activeKey === tabKey,
278
+ onClick: function onClick() {
279
+ setTabKey(tabKey);
280
+ }
281
+ }));
282
+ }
283
+ var TabContentMeta = {
284
+ name: "TabContent",
285
+ isAttachment: true,
286
+ displayName: "Tab Content",
287
+ importName: "TabContent",
288
+ importPath: modulePath,
289
+ props: {
290
+ tabKey: {
291
+ type: "string",
292
+ description: "The answer value selecting this choice sets"
293
+ },
294
+ children: {
295
+ type: "slot",
296
+ defaultValue: {
297
+ type: "vbox",
298
+ children: {
299
+ type: "text",
300
+ value: "This is some tab content"
301
+ }
302
+ }
303
+ }
304
+ }
305
+ };
306
+ function TabContent(_ref8) {
307
+ var children = _ref8.children,
308
+ tabKey = _ref8.tabKey;
309
+ var tabsContext = useTabsContext();
310
+ var previewAll = React.useContext(DebugContext);
311
+
312
+ var _ref9 = tabsContext != null ? tabsContext : {
313
+ tabKey: undefined
314
+ },
315
+ activeKey = _ref9.tabKey;
316
+
317
+ return React__default.createElement(React__default.Fragment, null, tabsContext === undefined || activeKey === tabKey || previewAll ? children : null);
318
+ }
319
+
320
+ function registerAll(loader) {
321
+ var _registerComponent = function _registerComponent(Component, defaultMeta) {
322
+ if (loader) {
323
+ loader.registerComponent(Component, defaultMeta);
324
+ } else {
325
+ registerComponent(Component, defaultMeta);
326
+ }
327
+ };
328
+
329
+ _registerComponent(TabsContainer, TabsContainerMeta);
330
+
331
+ _registerComponent(TabUnderline, TabUnderlineMeta);
332
+
333
+ _registerComponent(TabButton, TabButtonMeta);
334
+
335
+ _registerComponent(TabContent, TabContentMeta);
336
+ }
337
+
338
+ exports.TabButton = TabButton;
339
+ exports.TabButtonMeta = TabButtonMeta;
340
+ exports.TabContent = TabContent;
341
+ exports.TabContentMeta = TabContentMeta;
342
+ exports.TabUnderline = TabUnderline;
343
+ exports.TabUnderlineMeta = TabUnderlineMeta;
344
+ exports.TabsContainer = TabsContainer;
345
+ exports.TabsContainerMeta = TabsContainerMeta;
346
+ exports.registerAll = registerAll;
347
+ //# sourceMappingURL=plasmic-tabs.cjs.development.js.map
@@ -0,0 +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: \"TabsContainer\",\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: \"TabButton\",\n props: {\n tabKey: \"tab1\",\n children:defaultButtonChildren(\"Tab 1\")\n },\n },\n {\n type: \"component\",\n name: \"TabButton\",\n props: {\n tabKey: \"tab2\",\n children:defaultButtonChildren(\"Tab 2\")\n },\n },\n {\n type: \"component\",\n name: \"TabUnderline\",\n },\n ],\n },\n {\n type: \"vbox\",\n children: [\n {\n type: \"component\",\n name: \"TabContent\",\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: \"TabContent\",\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: \"TabUnderline\",\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: \"TabButton\",\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: \"TabContent\",\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,C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}
@@ -0,0 +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||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 l=function(){};function s(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 u=a(c),b=u[0],d=u[1];function y(){var e=d();return"setTabKey"in e?e:void 0}var m="@plasmicpkgs/plasmic-tabs",v={name:"TabsContainer",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:"TabButton",props:{tabKey:"tab1",children:s("Tab 1")}},{type:"component",name:"TabButton",props:{tabKey:"tab2",children:s("Tab 2")}},{type:"component",name:"TabUnderline"}]},{type:"vbox",children:[{type:"component",name:"TabContent",props:{tabKey:"tab1",children:[{type:"vbox",children:["Some content for tab 1"]}]}},{type:"component",name:"TabContent",props:{tabKey:"tab2",children:[{type:"vbox",children:["Some content for tab 2"]}]}}]}]}}}};function h(e){var t=e.children,a=e.initialKey,r=e.previewKey,o=e.previewAll,l=void 0!==o&&o,s=!!n.usePlasmicCanvasContext();return i.createElement(b,{initialKey:a},i.createElement(p.Provider,{value:s&&l},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 T={name:"TabUnderline",displayName:"Tab Underline",importName:"TabUnderline",importPath:m,props:{children:{type:"slot"}},defaultStyles:{background:"#7777ff",height:"2px"}};function x(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 K={name:"TabButton",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:s("Some tab")}},defaultStyles:{width:"hug"}};function C(e){var t=e.className,n=e.children,a=e.tabKey,o=y(),s=r.useRef(null),p=null!=o?o:{tabKey:void 0,setTabKey:l,bbox:void 0,setBbox:l},c=p.tabKey,u=p.setTabKey,b=p.setBbox;return r.useEffect((function(){a===c&&b({width:s.current.offsetWidth,left:s.current.offsetLeft})}),[s.current,b,JSON.stringify(p.bbox),a,c]),i.createElement("div",{className:t,ref:s},r.cloneElement(i.Children.toArray(n)[0],{isActive:a&&c&&c===a,onClick:function(){u(a)}}))}var g={name:"TabContent",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=C,exports.TabButtonMeta=K,exports.TabContent=w,exports.TabContentMeta=g,exports.TabUnderline=x,exports.TabUnderlineMeta=T,exports.TabsContainer=h,exports.TabsContainerMeta=v,exports.registerAll=function(e){var n=function(n,a){e?e.registerComponent(n,a):t(n,a)};n(h,v),n(x,T),n(C,K),n(w,g)};
2
+ //# sourceMappingURL=plasmic-tabs.cjs.production.min.js.map
@@ -0,0 +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: \"TabsContainer\",\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: \"TabButton\",\n props: {\n tabKey: \"tab1\",\n children:defaultButtonChildren(\"Tab 1\")\n },\n },\n {\n type: \"component\",\n name: \"TabButton\",\n props: {\n tabKey: \"tab2\",\n children:defaultButtonChildren(\"Tab 2\")\n },\n },\n {\n type: \"component\",\n name: \"TabUnderline\",\n },\n ],\n },\n {\n type: \"vbox\",\n children: [\n {\n type: \"component\",\n name: \"TabContent\",\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: \"TabContent\",\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: \"TabUnderline\",\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: \"TabButton\",\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: \"TabContent\",\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,gBACNC,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,YACNpB,MAAO,CACLQ,OAAQ,OACRP,SAASL,EAAsB,WAGnC,CACEE,KAAM,YACNsB,KAAM,YACNpB,MAAO,CACLQ,OAAQ,OACRP,SAASL,EAAsB,WAGnC,CACEE,KAAM,YACNsB,KAAM,kBAIZ,CACEtB,KAAM,OACNG,SAAU,CACR,CACEH,KAAM,YACNsB,KAAM,aACNpB,MAAO,CACLQ,OAAQ,OACRP,SAAU,CACR,CACEH,KAAM,OACNG,SAAU,CAAC,8BAKnB,CACEH,KAAM,YACNsB,KAAM,aACNpB,MAAO,CACLQ,OAAQ,OACRP,SAAU,CACR,CACEH,KAAM,OACNG,SAAU,CAAC,8CAcjB+B,SACd/B,IAA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II,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,aACNqC,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"}
@@ -0,0 +1,332 @@
1
+ import registerComponent from '@plasmicapp/host/registerComponent';
2
+ import { usePlasmicCanvasContext, DataProvider } from '@plasmicapp/host';
3
+ import constate from 'constate';
4
+ import React, { useRef, useEffect, cloneElement, useContext, createContext, useState } from 'react';
5
+
6
+ function _extends() {
7
+ _extends = Object.assign || function (target) {
8
+ for (var i = 1; i < arguments.length; i++) {
9
+ var source = arguments[i];
10
+
11
+ for (var key in source) {
12
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
13
+ target[key] = source[key];
14
+ }
15
+ }
16
+ }
17
+
18
+ return target;
19
+ };
20
+
21
+ return _extends.apply(this, arguments);
22
+ }
23
+
24
+ var noop = function noop() {};
25
+
26
+ function defaultButtonChildren(label) {
27
+ return {
28
+ type: "default-component",
29
+ kind: "button",
30
+ props: {
31
+ children: {
32
+ type: "text",
33
+ value: label
34
+ }
35
+ }
36
+ };
37
+ }
38
+
39
+ var DebugContext = /*#__PURE__*/createContext(false);
40
+
41
+ function useTabsData(_ref) {
42
+ var initialKey = _ref.initialKey;
43
+
44
+ var _useState = useState(initialKey),
45
+ tabKey = _useState[0],
46
+ setTabKey = _useState[1];
47
+
48
+ var _useState2 = useState(undefined),
49
+ bbox = _useState2[0],
50
+ setBbox = _useState2[1];
51
+
52
+ return {
53
+ tabKey: tabKey,
54
+ bbox: bbox,
55
+ setTabKey: setTabKey,
56
+ setBbox: setBbox
57
+ };
58
+ }
59
+
60
+ var _constate = /*#__PURE__*/constate(useTabsData),
61
+ TabsProvider = _constate[0],
62
+ useTabsContextUnsafe = _constate[1];
63
+
64
+ function useTabsContext() {
65
+ var result = useTabsContextUnsafe();
66
+ return "setTabKey" in result ? result : undefined;
67
+ }
68
+
69
+ var modulePath = "@plasmicpkgs/plasmic-tabs";
70
+ var TabsContainerMeta = {
71
+ name: "TabsContainer",
72
+ displayName: "Tabs Container",
73
+ importName: "TabsContainer",
74
+ importPath: modulePath,
75
+ providesData: true,
76
+ defaultStyles: {
77
+ width: "stretch",
78
+ padding: "8px"
79
+ },
80
+ props: {
81
+ initialKey: {
82
+ type: "string",
83
+ description: "Key of the initially selected tab",
84
+ defaultValue: "tab1"
85
+ },
86
+ previewKey: {
87
+ type: "string",
88
+ description: "SShow this key while editing in Plasmic Studio"
89
+ },
90
+ previewAll: {
91
+ type: "boolean",
92
+ description: "Reveal all tab contents while editing in Plasmic Studio"
93
+ },
94
+ children: {
95
+ type: "slot",
96
+ defaultValue: {
97
+ type: "vbox",
98
+ children: [{
99
+ type: "hbox",
100
+ children: [{
101
+ type: "component",
102
+ name: "TabButton",
103
+ props: {
104
+ tabKey: "tab1",
105
+ children: /*#__PURE__*/defaultButtonChildren("Tab 1")
106
+ }
107
+ }, {
108
+ type: "component",
109
+ name: "TabButton",
110
+ props: {
111
+ tabKey: "tab2",
112
+ children: /*#__PURE__*/defaultButtonChildren("Tab 2")
113
+ }
114
+ }, {
115
+ type: "component",
116
+ name: "TabUnderline"
117
+ }]
118
+ }, {
119
+ type: "vbox",
120
+ children: [{
121
+ type: "component",
122
+ name: "TabContent",
123
+ props: {
124
+ tabKey: "tab1",
125
+ children: [{
126
+ type: "vbox",
127
+ children: ["Some content for tab 1"]
128
+ }]
129
+ }
130
+ }, {
131
+ type: "component",
132
+ name: "TabContent",
133
+ props: {
134
+ tabKey: "tab2",
135
+ children: [{
136
+ type: "vbox",
137
+ children: ["Some content for tab 2"]
138
+ }]
139
+ }
140
+ }]
141
+ }]
142
+ }
143
+ }
144
+ }
145
+ };
146
+ function TabsContainer(_ref2) {
147
+ var children = _ref2.children,
148
+ initialKey = _ref2.initialKey,
149
+ previewKey = _ref2.previewKey,
150
+ _ref2$previewAll = _ref2.previewAll,
151
+ previewAll = _ref2$previewAll === void 0 ? false : _ref2$previewAll;
152
+ var inEditor = !!usePlasmicCanvasContext();
153
+ return React.createElement(TabsProvider, {
154
+ initialKey: initialKey
155
+ }, React.createElement(DebugContext.Provider, {
156
+ value: inEditor && previewAll
157
+ }, React.createElement(Helper, {
158
+ previewKey: previewKey || initialKey
159
+ }, children)));
160
+ }
161
+
162
+ function ensure(x) {
163
+ if (!x) {
164
+ throw new Error("unexpected nil");
165
+ }
166
+
167
+ return x;
168
+ }
169
+
170
+ function Helper(_ref3) {
171
+ var children = _ref3.children,
172
+ previewKey = _ref3.previewKey;
173
+ var inEditor = usePlasmicCanvasContext();
174
+
175
+ var _ensure = ensure(useTabsContext()),
176
+ tabKey = _ensure.tabKey;
177
+
178
+ var effectiveKey = inEditor ? previewKey || tabKey : tabKey;
179
+ return React.createElement(DataProvider, {
180
+ name: "currentTabKey",
181
+ data: effectiveKey
182
+ }, children);
183
+ }
184
+
185
+ var TabUnderlineMeta = {
186
+ name: "TabUnderline",
187
+ displayName: "Tab Underline",
188
+ importName: "TabUnderline",
189
+ importPath: modulePath,
190
+ props: {
191
+ children: {
192
+ type: "slot"
193
+ }
194
+ },
195
+ defaultStyles: {
196
+ background: "#7777ff",
197
+ height: "2px"
198
+ }
199
+ };
200
+ function TabUnderline(_ref4) {
201
+ var _useTabsContext;
202
+
203
+ var className = _ref4.className;
204
+
205
+ var _ref5 = (_useTabsContext = useTabsContext()) != null ? _useTabsContext : {
206
+ bbox: undefined
207
+ },
208
+ bbox = _ref5.bbox;
209
+
210
+ return bbox ? React.createElement("div", {
211
+ className: className,
212
+ style: _extends({}, JSON.parse(JSON.stringify(bbox)), {
213
+ top: undefined,
214
+ bottom: 0,
215
+ position: "absolute",
216
+ transition: ".4s ease all"
217
+ })
218
+ }) : null;
219
+ }
220
+ var TabButtonMeta = {
221
+ name: "TabButton",
222
+ isAttachment: true,
223
+ displayName: "Tab Button",
224
+ importName: "TabButton",
225
+ importPath: modulePath,
226
+ props: {
227
+ tabKey: {
228
+ type: "string",
229
+ description: "The answer value selecting this choice sets"
230
+ },
231
+ children: {
232
+ type: "slot",
233
+ defaultValue: /*#__PURE__*/defaultButtonChildren("Some tab")
234
+ }
235
+ },
236
+ defaultStyles: {
237
+ width: "hug"
238
+ }
239
+ };
240
+ function TabButton(_ref6) {
241
+ var className = _ref6.className,
242
+ children = _ref6.children,
243
+ tabKey = _ref6.tabKey;
244
+ var tabsContext = useTabsContext();
245
+ var ref = useRef(null);
246
+
247
+ var _ref7 = tabsContext != null ? tabsContext : {
248
+ tabKey: undefined,
249
+ setTabKey: noop,
250
+ bbox: undefined,
251
+ setBbox: noop
252
+ },
253
+ activeKey = _ref7.tabKey,
254
+ setTabKey = _ref7.setTabKey,
255
+ bbox = _ref7.bbox,
256
+ setBbox = _ref7.setBbox;
257
+
258
+ useEffect(function () {
259
+ if (tabKey === activeKey) {
260
+ setBbox({
261
+ width: ref.current.offsetWidth,
262
+ left: ref.current.offsetLeft
263
+ });
264
+ }
265
+ }, [ref.current, setBbox, JSON.stringify(bbox), tabKey, activeKey]);
266
+ return React.createElement("div", {
267
+ className: className,
268
+ ref: ref
269
+ }, cloneElement(React.Children.toArray(children)[0], {
270
+ isActive: tabKey && activeKey && activeKey === tabKey,
271
+ onClick: function onClick() {
272
+ setTabKey(tabKey);
273
+ }
274
+ }));
275
+ }
276
+ var TabContentMeta = {
277
+ name: "TabContent",
278
+ isAttachment: true,
279
+ displayName: "Tab Content",
280
+ importName: "TabContent",
281
+ importPath: modulePath,
282
+ props: {
283
+ tabKey: {
284
+ type: "string",
285
+ description: "The answer value selecting this choice sets"
286
+ },
287
+ children: {
288
+ type: "slot",
289
+ defaultValue: {
290
+ type: "vbox",
291
+ children: {
292
+ type: "text",
293
+ value: "This is some tab content"
294
+ }
295
+ }
296
+ }
297
+ }
298
+ };
299
+ function TabContent(_ref8) {
300
+ var children = _ref8.children,
301
+ tabKey = _ref8.tabKey;
302
+ var tabsContext = useTabsContext();
303
+ var previewAll = useContext(DebugContext);
304
+
305
+ var _ref9 = tabsContext != null ? tabsContext : {
306
+ tabKey: undefined
307
+ },
308
+ activeKey = _ref9.tabKey;
309
+
310
+ return React.createElement(React.Fragment, null, tabsContext === undefined || activeKey === tabKey || previewAll ? children : null);
311
+ }
312
+
313
+ function registerAll(loader) {
314
+ var _registerComponent = function _registerComponent(Component, defaultMeta) {
315
+ if (loader) {
316
+ loader.registerComponent(Component, defaultMeta);
317
+ } else {
318
+ registerComponent(Component, defaultMeta);
319
+ }
320
+ };
321
+
322
+ _registerComponent(TabsContainer, TabsContainerMeta);
323
+
324
+ _registerComponent(TabUnderline, TabUnderlineMeta);
325
+
326
+ _registerComponent(TabButton, TabButtonMeta);
327
+
328
+ _registerComponent(TabContent, TabContentMeta);
329
+ }
330
+
331
+ export { TabButton, TabButtonMeta, TabContent, TabContentMeta, TabUnderline, TabUnderlineMeta, TabsContainer, TabsContainerMeta, registerAll };
332
+ //# sourceMappingURL=plasmic-tabs.esm.js.map
@@ -0,0 +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: \"TabsContainer\",\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: \"TabButton\",\n props: {\n tabKey: \"tab1\",\n children:defaultButtonChildren(\"Tab 1\")\n },\n },\n {\n type: \"component\",\n name: \"TabButton\",\n props: {\n tabKey: \"tab2\",\n children:defaultButtonChildren(\"Tab 2\")\n },\n },\n {\n type: \"component\",\n name: \"TabUnderline\",\n },\n ],\n },\n {\n type: \"vbox\",\n children: [\n {\n type: \"component\",\n name: \"TabContent\",\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: \"TabContent\",\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: \"TabUnderline\",\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: \"TabButton\",\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: \"TabContent\",\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","use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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;;;;"}
package/dist/tabs.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ import { ComponentMeta } from "@plasmicapp/host";
2
+ import { ReactNode } from "react";
3
+ export interface TabsProviderProps {
4
+ children?: ReactNode;
5
+ initialKey?: string;
6
+ previewKey?: string;
7
+ previewAll?: boolean;
8
+ }
9
+ export declare const TabsContainerMeta: ComponentMeta<TabsProviderProps>;
10
+ export declare function TabsContainer({ children, initialKey, previewKey, previewAll, }: TabsProviderProps): JSX.Element;
11
+ export interface TabUnderlineProps {
12
+ className?: string;
13
+ }
14
+ export declare const TabUnderlineMeta: ComponentMeta<TabUnderlineProps>;
15
+ export declare function TabUnderline({ className }: TabUnderlineProps): JSX.Element | null;
16
+ export interface TabButtonProps {
17
+ className?: string;
18
+ children?: ReactNode;
19
+ tabKey?: string;
20
+ }
21
+ export declare const TabButtonMeta: ComponentMeta<TabButtonProps>;
22
+ export declare function TabButton({ className, children, tabKey }: TabButtonProps): JSX.Element;
23
+ export interface TabContentProps {
24
+ children?: ReactNode;
25
+ tabKey?: string;
26
+ }
27
+ export declare const TabContentMeta: ComponentMeta<TabContentProps>;
28
+ export declare function TabContent({ children, tabKey }: TabContentProps): JSX.Element;
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "version": "0.0.2",
3
+ "license": "MIT",
4
+ "main": "dist/index.js",
5
+ "typings": "dist/index.d.ts",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "engines": {
13
+ "node": ">=10"
14
+ },
15
+ "scripts": {
16
+ "start": "tsdx watch",
17
+ "build": "tsdx build",
18
+ "test": "tsdx test --passWithNoTests",
19
+ "lint": "tsdx lint",
20
+ "prepare": "if-env PREPARE_NO_BUILD=true || yarn build",
21
+ "size": "size-limit",
22
+ "analyze": "size-limit --why"
23
+ },
24
+ "peerDependencies": {
25
+ "react": ">=16"
26
+ },
27
+ "husky": {
28
+ "hooks": {
29
+ "pre-commit": "tsdx lint"
30
+ }
31
+ },
32
+ "prettier": {
33
+ "printWidth": 80,
34
+ "semi": true,
35
+ "singleQuote": true,
36
+ "trailingComma": "es5"
37
+ },
38
+ "name": "@plasmicpkgs/plasmic-tabs",
39
+ "author": "Abdukhamid Latipov",
40
+ "module": "dist/plasmic-tabs.esm.js",
41
+ "size-limit": [
42
+ {
43
+ "path": "dist/plasmic-tabs.cjs.production.min.js",
44
+ "limit": "10 KB"
45
+ },
46
+ {
47
+ "path": "dist/plasmic-tabs.esm.js",
48
+ "limit": "10 KB"
49
+ }
50
+ ],
51
+ "devDependencies": {
52
+ "@size-limit/preset-small-lib": "^7.0.4",
53
+ "@types/react": "^17.0.37",
54
+ "@types/react-dom": "^17.0.11",
55
+ "husky": "^7.0.4",
56
+ "react": "^17.0.2",
57
+ "react-dom": "^17.0.2",
58
+ "size-limit": "^7.0.4",
59
+ "tsdx": "^0.14.1",
60
+ "tslib": "^2.3.1",
61
+ "typescript": "^4.5.4"
62
+ },
63
+ "dependencies": {
64
+ "constate": "^3.3.2"
65
+ },
66
+ "gitHead": "175e6524f251278913ff80e4caef98a9ded73959"
67
+ }