@plasmicpkgs/antd5 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/index.js ADDED
@@ -0,0 +1,910 @@
1
+ 'use strict';
2
+
3
+ var host = require('@plasmicapp/host');
4
+ var registerToken = require('@plasmicapp/host/registerToken');
5
+ var query = require('@plasmicapp/query');
6
+ var App = require('antd/lib/app');
7
+ var ConfigProvider = require('antd/lib/config-provider');
8
+ var theme = require('antd/lib/theme');
9
+ var React = require('react');
10
+ var registerComponent = require('@plasmicapp/host/registerComponent');
11
+ var registerGlobalContext = require('@plasmicapp/host/registerGlobalContext');
12
+ var Select = require('antd/lib/select');
13
+ var Table = require('antd/lib/table');
14
+
15
+ function makeRegisterGlobalContext(component, meta) {
16
+ return function(loader) {
17
+ if (loader) {
18
+ loader.registerGlobalContext(component, meta);
19
+ } else {
20
+ registerGlobalContext(component, meta);
21
+ }
22
+ };
23
+ }
24
+ function registerComponentHelper(loader, component, meta) {
25
+ if (loader) {
26
+ loader.registerComponent(component, meta);
27
+ } else {
28
+ registerComponent(component, meta);
29
+ }
30
+ }
31
+ function traverseReactEltTree(children, callback) {
32
+ const rec = (elts) => {
33
+ (Array.isArray(elts) ? elts : [elts]).forEach((elt) => {
34
+ var _a;
35
+ if (elt) {
36
+ callback(elt);
37
+ if (elt.children) {
38
+ rec(elt.children);
39
+ }
40
+ if (((_a = elt.props) == null ? void 0 : _a.children) && elt.props.children !== elt.children) {
41
+ rec(elt.props.children);
42
+ }
43
+ }
44
+ });
45
+ };
46
+ rec(children);
47
+ }
48
+ function asArray(x) {
49
+ if (Array.isArray(x)) {
50
+ return x;
51
+ } else if (x == null) {
52
+ return [];
53
+ } else {
54
+ return [x];
55
+ }
56
+ }
57
+
58
+ var __defProp$2 = Object.defineProperty;
59
+ var __defProps$1 = Object.defineProperties;
60
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
61
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
62
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
63
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
64
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
65
+ var __spreadValues$2 = (a, b) => {
66
+ for (var prop in b || (b = {}))
67
+ if (__hasOwnProp$2.call(b, prop))
68
+ __defNormalProp$2(a, prop, b[prop]);
69
+ if (__getOwnPropSymbols$2)
70
+ for (var prop of __getOwnPropSymbols$2(b)) {
71
+ if (__propIsEnum$2.call(b, prop))
72
+ __defNormalProp$2(a, prop, b[prop]);
73
+ }
74
+ return a;
75
+ };
76
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
77
+ var __objRest$2 = (source, exclude) => {
78
+ var target = {};
79
+ for (var prop in source)
80
+ if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
81
+ target[prop] = source[prop];
82
+ if (source != null && __getOwnPropSymbols$2)
83
+ for (var prop of __getOwnPropSymbols$2(source)) {
84
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
85
+ target[prop] = source[prop];
86
+ }
87
+ return target;
88
+ };
89
+ function themeToAntdConfig(opts) {
90
+ const {
91
+ colorTextBase,
92
+ colorPrimary,
93
+ colorSuccess,
94
+ colorWarning,
95
+ colorInfo,
96
+ fontFamily,
97
+ fontSize,
98
+ lineWidth,
99
+ borderRadius,
100
+ controlHeight,
101
+ sizeUnit,
102
+ sizeStep,
103
+ wireframe,
104
+ spacing
105
+ } = opts;
106
+ return __spreadProps$1(__spreadValues$2({}, spacing && { size: spacing }), {
107
+ theme: {
108
+ token: Object.fromEntries(Object.entries({
109
+ colorTextBase,
110
+ colorPrimary,
111
+ colorSuccess,
112
+ colorWarning,
113
+ colorInfo,
114
+ fontFamily,
115
+ fontSize,
116
+ lineWidth,
117
+ borderRadius,
118
+ controlHeight,
119
+ sizeUnit,
120
+ sizeStep,
121
+ wireframe
122
+ }).filter(([key, val]) => !!val))
123
+ }
124
+ });
125
+ }
126
+ function AntdConfigProvider(props) {
127
+ const _a = props, { children, themeStyles } = _a, rest = __objRest$2(_a, ["children", "themeStyles"]);
128
+ return /* @__PURE__ */ React.createElement(ConfigProvider, __spreadValues$2({}, themeToAntdConfig(__spreadProps$1(__spreadValues$2({}, rest), {
129
+ fontFamily: themeStyles.fontFamily,
130
+ fontSize: themeStyles.fontSize ? parseInt(themeStyles.fontSize) : void 0,
131
+ lineHeight: themeStyles.lineHeight ? parseInt(themeStyles.lineHeight) : void 0,
132
+ colorTextBase: themeStyles.color
133
+ }))), /* @__PURE__ */ React.createElement(App, null, /* @__PURE__ */ React.createElement(InnerConfigProvider, null, children)));
134
+ }
135
+ function InnerConfigProvider(props) {
136
+ const { children } = props;
137
+ const { token } = theme.useToken();
138
+ const makeVarName = (name) => `--antd-${name}`;
139
+ const cssStyles = React.useMemo(() => `
140
+ :root {
141
+ ${Object.entries(token).map(([key, val]) => `${makeVarName(key)}:${typeof val === "string" ? val.trim() : val};`).join("\n")}
142
+ }
143
+ `, [token]);
144
+ const app = App.useApp();
145
+ const actions = React.useMemo(() => ({
146
+ showNotification: (opts) => {
147
+ var _b;
148
+ const _a = opts, rest = __objRest$2(_a, ["type"]);
149
+ app.notification[(_b = opts.type) != null ? _b : "info"](__spreadValues$2({}, rest));
150
+ },
151
+ hideNotifications: () => {
152
+ app.notification.destroy();
153
+ }
154
+ }), [app]);
155
+ if (!host.GlobalActionsProvider) {
156
+ warnOutdatedDeps();
157
+ }
158
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("style", null, cssStyles), host.GlobalActionsProvider && /* @__PURE__ */ React.createElement(host.GlobalActionsProvider, {
159
+ contextName: "plasmic-antd5-config-provider",
160
+ actions
161
+ }, children), /* @__PURE__ */ React.createElement(GlobalLoadingIndicator, null));
162
+ }
163
+ let warned = false;
164
+ function warnOutdatedDeps() {
165
+ if (!warned) {
166
+ console.log(`You are using a version of @plasmicapp/* that is too old. Please upgrade to the latest version.`);
167
+ warned = true;
168
+ }
169
+ }
170
+ function GlobalLoadingIndicator() {
171
+ const app = App.useApp();
172
+ React.useEffect(() => {
173
+ if (query.addLoadingStateListener) {
174
+ return query.addLoadingStateListener((isLoading) => {
175
+ if (isLoading) {
176
+ app.message.open({
177
+ content: "Loading...",
178
+ duration: 0,
179
+ key: `plasmic-antd5-global-loading-indicator`
180
+ });
181
+ } else {
182
+ app.message.destroy(`plasmic-antd5-global-loading-indicator`);
183
+ }
184
+ }, { immediate: true });
185
+ } else {
186
+ warnOutdatedDeps();
187
+ return () => {
188
+ };
189
+ }
190
+ }, [app]);
191
+ return null;
192
+ }
193
+ function registerTokens(loader) {
194
+ const regs = [];
195
+ const makeColorToken = (name) => {
196
+ const colorIndex = name.indexOf("color");
197
+ const humanName = makeNiceName(colorIndex >= 0 ? name.substring(name.indexOf("color") + "color".length) : name);
198
+ return {
199
+ name: `Sys: ${humanName}`,
200
+ value: `var(--antd-${name})`,
201
+ type: "color"
202
+ };
203
+ };
204
+ function makeNiceName(name) {
205
+ name = name[0].toUpperCase() + name.substring(1);
206
+ return name.replace(/([a-z])([A-Z])/g, "$1 $2");
207
+ }
208
+ const colorTokens = [
209
+ "colorPrimary",
210
+ "colorSuccess",
211
+ "colorWarning",
212
+ "colorError",
213
+ "colorInfo",
214
+ "colorText",
215
+ "colorTextSecondary",
216
+ "colorTextTertiary",
217
+ "colorTextQuaternary",
218
+ "colorBorder",
219
+ "colorBorderSecondary",
220
+ "colorFill",
221
+ "colorFillSecondary",
222
+ "colorFillTertiary",
223
+ "colorFillQuaternary",
224
+ "colorBgLayout",
225
+ "colorBgContainer",
226
+ "colorBgElevated",
227
+ "colorBgSpotlight",
228
+ "colorPrimaryBg",
229
+ "colorPrimaryBgHover",
230
+ "colorPrimaryBorder",
231
+ "colorPrimaryBorderHover",
232
+ "colorPrimaryHover",
233
+ "colorPrimaryActive",
234
+ "colorPrimaryTextHover",
235
+ "colorPrimaryText",
236
+ "colorPrimaryTextActive",
237
+ "colorSuccessBg",
238
+ "colorSuccessBgHover",
239
+ "colorSuccessBorder",
240
+ "colorSuccessBorderHover",
241
+ "colorSuccessHover",
242
+ "colorSuccessActive",
243
+ "colorSuccessTextHover",
244
+ "colorSuccessText",
245
+ "colorSuccessTextActive",
246
+ "colorWarningBg",
247
+ "colorWarningBgHover",
248
+ "colorWarningBorder",
249
+ "colorWarningBorderHover",
250
+ "colorWarningHover",
251
+ "colorWarningActive",
252
+ "colorWarningTextHover",
253
+ "colorWarningText",
254
+ "colorWarningTextActive",
255
+ "colorInfoBg",
256
+ "colorInfoBgHover",
257
+ "colorInfoBorder",
258
+ "colorInfoBorderHover",
259
+ "colorInfoHover",
260
+ "colorInfoActive",
261
+ "colorInfoTextHover",
262
+ "colorInfoText",
263
+ "colorInfoTextActive",
264
+ "colorErrorBg",
265
+ "colorErrorBgHover",
266
+ "colorErrorBorder",
267
+ "colorErrorBorderHover",
268
+ "colorErrorHover",
269
+ "colorErrorActive",
270
+ "colorErrorTextHover",
271
+ "colorErrorText",
272
+ "colorErrorTextActive",
273
+ "colorWhite",
274
+ "colorBgMask",
275
+ "colorFillContentHover",
276
+ "colorFillAlter",
277
+ "colorFillContent",
278
+ "colorBgContainerDisabled",
279
+ "colorBgTextHover",
280
+ "colorBgTextActive",
281
+ "colorBorderBg",
282
+ "colorSplit",
283
+ "colorTextPlaceholder",
284
+ "colorTextDisabled",
285
+ "colorTextHeading",
286
+ "colorTextLabel",
287
+ "colorTextDescription",
288
+ "colorTextLightSolid",
289
+ "colorIcon",
290
+ "colorIconHover",
291
+ "colorLink",
292
+ "colorLinkHover",
293
+ "colorLinkActive",
294
+ "colorLinkHighlight",
295
+ "controlOutline",
296
+ "controlWarningOutline",
297
+ "controlErrorOutline",
298
+ "controlItemBgHover",
299
+ "controlItemBgActive",
300
+ "controlItemBgActiveHover",
301
+ "controlItemBgActiveDisabled"
302
+ ];
303
+ colorTokens.forEach((name) => regs.push(makeColorToken(name)));
304
+ const makeGenericToken = (name, type) => {
305
+ return {
306
+ name: `Sys: ${makeNiceName(name)}`,
307
+ value: `var(--antd-${name})`,
308
+ type
309
+ };
310
+ };
311
+ const spacingTokens = [
312
+ "lineWidth",
313
+ "borderRadius",
314
+ "controlHeight",
315
+ "sizeXXL",
316
+ "sizeXL",
317
+ "sizeLG",
318
+ "sizeMD",
319
+ "sizeMS",
320
+ "size",
321
+ "sizeSM",
322
+ "sizeXS",
323
+ "sizeXXS",
324
+ "controlHeightXS",
325
+ "controlHeightSM",
326
+ "controlHeightLG",
327
+ "lineWidthBold",
328
+ "borderRadiusXS",
329
+ "borderRadiusSM",
330
+ "borderRadiusLG",
331
+ "borderRadiusOuter",
332
+ "controlOutlineWidth",
333
+ "controlInteractiveSize",
334
+ "paddingXXS",
335
+ "paddingXS",
336
+ "paddingSM",
337
+ "padding",
338
+ "paddingMD",
339
+ "paddingLG",
340
+ "paddingXL",
341
+ "paddingContentHorizontalLG",
342
+ "paddingContentHorizontal",
343
+ "paddingContentHorizontalSM",
344
+ "paddingContentVerticalLG",
345
+ "paddingContentVertical",
346
+ "paddingContentVerticalSM",
347
+ "marginXXS",
348
+ "marginXS",
349
+ "marginSM",
350
+ "margin",
351
+ "marginMD",
352
+ "marginLG",
353
+ "marginXL",
354
+ "marginXXL",
355
+ "controlPaddingHorizontal",
356
+ "controlPaddingHorizontalSM"
357
+ ];
358
+ spacingTokens.forEach((token) => regs.push(makeGenericToken(token, "spacing")));
359
+ const fontSizeTokens = [
360
+ "fontSizeSM",
361
+ "fontSizeLG",
362
+ "fontSizeXL",
363
+ "fontSizeHeading1",
364
+ "fontSizeHeading2",
365
+ "fontSizeHeading3",
366
+ "fontSizeHeading4",
367
+ "fontSizeHeading5"
368
+ ];
369
+ fontSizeTokens.forEach((token) => regs.push(makeGenericToken(token, "font-size")));
370
+ const lineHeightTokens = [
371
+ "lineHeightLG",
372
+ "lineHeightSM",
373
+ "lineHeightHeading1",
374
+ "lineHeightHeading2",
375
+ "lineHeightHeading3",
376
+ "lineHeightHeading4",
377
+ "lineHeightHeading5"
378
+ ];
379
+ lineHeightTokens.forEach((token) => regs.push(makeGenericToken(token, "line-height")));
380
+ if (loader) {
381
+ regs.forEach((t) => loader.registerToken(t));
382
+ } else {
383
+ regs.forEach((t) => registerToken(t));
384
+ }
385
+ }
386
+ const registerConfigProvider = makeRegisterGlobalContext(AntdConfigProvider, __spreadProps$1(__spreadValues$2({
387
+ name: "plasmic-antd5-config-provider",
388
+ displayName: "Ant Design System Settings",
389
+ props: {
390
+ colorPrimary: {
391
+ type: "color",
392
+ defaultValue: "#1677ff"
393
+ },
394
+ colorSuccess: {
395
+ type: "color",
396
+ defaultValue: "#52c41a"
397
+ },
398
+ colorWarning: {
399
+ type: "color",
400
+ defaultValue: "#faad14"
401
+ },
402
+ colorError: {
403
+ type: "color",
404
+ defaultValue: "#ff4d4f"
405
+ },
406
+ colorInfo: {
407
+ type: "color",
408
+ defaultValue: "#1677ff"
409
+ },
410
+ colorBgBase: {
411
+ type: "color",
412
+ defaultValue: "#ffffff"
413
+ },
414
+ lineWidth: {
415
+ type: "number",
416
+ defaultValue: 1
417
+ },
418
+ borderRadius: {
419
+ type: "number",
420
+ defaultValue: 6
421
+ },
422
+ controlHeight: {
423
+ type: "number",
424
+ defaultValue: 32
425
+ },
426
+ sizeUnit: {
427
+ type: "number",
428
+ defaultValue: 4
429
+ },
430
+ sizeStep: {
431
+ type: "number",
432
+ defaultValue: 4
433
+ },
434
+ wireframe: {
435
+ type: "boolean",
436
+ defaultValue: false
437
+ },
438
+ spacing: {
439
+ type: "choice",
440
+ options: ["small", "middle", "large"]
441
+ },
442
+ themeStyles: {
443
+ type: "themeStyles"
444
+ }
445
+ }
446
+ }, {
447
+ unstable__globalActions: {
448
+ showNotification: {
449
+ displayName: "Show notification",
450
+ parameters: {
451
+ type: {
452
+ type: "choice",
453
+ options: ["success", "error", "info", "warning"],
454
+ defaultValue: "info"
455
+ },
456
+ message: {
457
+ type: "string",
458
+ defaultValue: "A message for you!"
459
+ },
460
+ description: {
461
+ type: "string",
462
+ defaultValue: "Would you like to learn more?"
463
+ },
464
+ duration: {
465
+ type: "number",
466
+ defaultValueHint: 5
467
+ },
468
+ placement: {
469
+ type: "choice",
470
+ options: [
471
+ "top",
472
+ "topLeft",
473
+ "topRight",
474
+ "bottom",
475
+ "bottomLeft",
476
+ "bottomRight"
477
+ ],
478
+ defaultValueHint: "topRight"
479
+ }
480
+ }
481
+ },
482
+ hideNotifications: {
483
+ displayName: "Hide notifications"
484
+ }
485
+ }
486
+ }), {
487
+ importPath: "@plasmicpkgs/antd5/skinny/registerConfigProvider",
488
+ importName: "AntdConfigProvider"
489
+ }));
490
+
491
+ var __defProp$1 = Object.defineProperty;
492
+ var __defProps = Object.defineProperties;
493
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
494
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
495
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
496
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
497
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
498
+ var __spreadValues$1 = (a, b) => {
499
+ for (var prop in b || (b = {}))
500
+ if (__hasOwnProp$1.call(b, prop))
501
+ __defNormalProp$1(a, prop, b[prop]);
502
+ if (__getOwnPropSymbols$1)
503
+ for (var prop of __getOwnPropSymbols$1(b)) {
504
+ if (__propIsEnum$1.call(b, prop))
505
+ __defNormalProp$1(a, prop, b[prop]);
506
+ }
507
+ return a;
508
+ };
509
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
510
+ var __objRest$1 = (source, exclude) => {
511
+ var target = {};
512
+ for (var prop in source)
513
+ if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
514
+ target[prop] = source[prop];
515
+ if (source != null && __getOwnPropSymbols$1)
516
+ for (var prop of __getOwnPropSymbols$1(source)) {
517
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
518
+ target[prop] = source[prop];
519
+ }
520
+ return target;
521
+ };
522
+ const AntdOption = Select.Option;
523
+ function AntdSelect(props) {
524
+ const _a = props, {
525
+ popupClassName,
526
+ popupScopeClassName,
527
+ defaultStylesClassName,
528
+ suffixIcon,
529
+ mode
530
+ } = _a, rest = __objRest$1(_a, [
531
+ "popupClassName",
532
+ "popupScopeClassName",
533
+ "defaultStylesClassName",
534
+ "suffixIcon",
535
+ "mode"
536
+ ]);
537
+ return /* @__PURE__ */ React.createElement(Select, __spreadValues$1(__spreadProps(__spreadValues$1({}, rest), {
538
+ mode: !mode || mode === "single" ? void 0 : mode,
539
+ popupClassName: `${defaultStylesClassName} ${popupScopeClassName} ${popupClassName}`
540
+ }), suffixIcon && { suffixIcon }));
541
+ }
542
+ function registerSelect(loader) {
543
+ registerComponentHelper(loader, AntdSelect, {
544
+ name: "plasmic-antd5-select",
545
+ displayName: "Select",
546
+ props: {
547
+ children: {
548
+ type: "slot",
549
+ allowedComponents: ["AntdOption"]
550
+ },
551
+ placeholder: {
552
+ type: "slot",
553
+ defaultValue: "Select..."
554
+ },
555
+ suffixIcon: {
556
+ type: "slot",
557
+ hidePlaceholder: true
558
+ },
559
+ open: {
560
+ type: "boolean",
561
+ editOnly: true,
562
+ uncontrolledProp: "defaultOpen"
563
+ },
564
+ value: {
565
+ type: "choice",
566
+ displayName: "Selected value",
567
+ editOnly: true,
568
+ uncontrolledProp: "defaultValue",
569
+ description: "Initial selected option",
570
+ multiSelect: (ps) => ps.mode === "multiple",
571
+ options: (ps) => {
572
+ const options = /* @__PURE__ */ new Set();
573
+ traverseReactEltTree(ps.children, (elt) => {
574
+ var _a;
575
+ if ((elt == null ? void 0 : elt.type) === Select.Option && typeof ((_a = elt == null ? void 0 : elt.props) == null ? void 0 : _a.value) === "string") {
576
+ options.add(elt.props.value);
577
+ }
578
+ });
579
+ return Array.from(options.keys());
580
+ }
581
+ },
582
+ mode: {
583
+ type: "choice",
584
+ options: ["single", "multiple"],
585
+ defaultValueHint: "single"
586
+ },
587
+ size: {
588
+ type: "choice",
589
+ options: ["small", "middle", "large"]
590
+ },
591
+ showSearch: {
592
+ type: "boolean",
593
+ defaultValueHint: false,
594
+ advanced: true
595
+ },
596
+ status: {
597
+ type: "choice",
598
+ options: ["error", "warning"],
599
+ advanced: true
600
+ },
601
+ bordered: {
602
+ type: "boolean",
603
+ defaultValueHint: true
604
+ },
605
+ autoFocus: {
606
+ type: "boolean",
607
+ displayName: "Focus automatically",
608
+ advanced: true
609
+ },
610
+ onChange: {
611
+ type: "eventHandler",
612
+ argTypes: [
613
+ { name: "value", type: "string" },
614
+ { name: "option", type: "object" }
615
+ ]
616
+ },
617
+ dropdownMatchSelectWidth: {
618
+ type: "boolean",
619
+ displayName: "Should dropdown match trigger button width?",
620
+ defaultValueHint: true,
621
+ advanced: true
622
+ },
623
+ triggerClassName: {
624
+ type: "class",
625
+ displayName: "Trigger styles",
626
+ noSelf: true,
627
+ selectors: [
628
+ {
629
+ selector: ":component .ant-select-selector.ant-select-selector",
630
+ label: "Base"
631
+ },
632
+ {
633
+ selector: ":component .ant-select-selector:hover",
634
+ label: "Hovered"
635
+ }
636
+ ],
637
+ advanced: true
638
+ },
639
+ popupScopeClassName: {
640
+ type: "styleScopeClass",
641
+ scopeName: "popup"
642
+ },
643
+ popupClassName: {
644
+ type: "class",
645
+ displayName: "Popup styles",
646
+ selectors: [],
647
+ advanced: true
648
+ },
649
+ optionClassName: {
650
+ type: "class",
651
+ displayName: "Option styles",
652
+ noSelf: true,
653
+ selectors: [
654
+ {
655
+ selector: ":popup.ant-select-dropdown .ant-select-item-option",
656
+ label: "Base"
657
+ },
658
+ {
659
+ selector: ":popup.ant-select-dropdown .ant-select-item-option-active",
660
+ label: "Focused"
661
+ },
662
+ {
663
+ selector: ":popup.ant-select-dropdown .ant-select-item-option-selected",
664
+ label: "Selected"
665
+ }
666
+ ],
667
+ advanced: true
668
+ },
669
+ placeholderClassName: {
670
+ type: "class",
671
+ displayName: "Placeholder styles",
672
+ selectors: [
673
+ {
674
+ selector: ":component .ant-select-selector .ant-select-selection-placeholder",
675
+ label: "Base"
676
+ }
677
+ ],
678
+ advanced: true
679
+ },
680
+ defaultStylesClassName: {
681
+ type: "themeResetClass"
682
+ },
683
+ tagRender: {
684
+ type: "slot",
685
+ renderPropParams: ["tagProps"],
686
+ hidePlaceholder: true
687
+ }
688
+ },
689
+ unstable__states: {
690
+ value: {
691
+ type: "writable",
692
+ valueProp: "value",
693
+ onChangeProp: "onChange"
694
+ }
695
+ },
696
+ importPath: "@plasmicpkgs/antd5/skinny/registerSelect",
697
+ importName: "AntdSelect"
698
+ });
699
+ registerComponentHelper(loader, AntdOption, {
700
+ name: "plasmic-antd5-option",
701
+ displayName: "Option",
702
+ parentComponentName: "plasmic-antd5-select",
703
+ props: {
704
+ children: {
705
+ type: "slot",
706
+ defaultValue: "Option"
707
+ },
708
+ value: {
709
+ type: "string"
710
+ }
711
+ },
712
+ importPath: "@plasmicpkgs/antd5/skinny/registerSelect",
713
+ importName: "AntdOption"
714
+ });
715
+ }
716
+
717
+ var __defProp = Object.defineProperty;
718
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
719
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
720
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
721
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
722
+ var __spreadValues = (a, b) => {
723
+ for (var prop in b || (b = {}))
724
+ if (__hasOwnProp.call(b, prop))
725
+ __defNormalProp(a, prop, b[prop]);
726
+ if (__getOwnPropSymbols)
727
+ for (var prop of __getOwnPropSymbols(b)) {
728
+ if (__propIsEnum.call(b, prop))
729
+ __defNormalProp(a, prop, b[prop]);
730
+ }
731
+ return a;
732
+ };
733
+ var __objRest = (source, exclude) => {
734
+ var target = {};
735
+ for (var prop in source)
736
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
737
+ target[prop] = source[prop];
738
+ if (source != null && __getOwnPropSymbols)
739
+ for (var prop of __getOwnPropSymbols(source)) {
740
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
741
+ target[prop] = source[prop];
742
+ }
743
+ return target;
744
+ };
745
+ function AntdTable(props) {
746
+ var _b;
747
+ const _a = props, {
748
+ data,
749
+ onSelectionChange,
750
+ isSelectable,
751
+ rowKey,
752
+ setControlContextData,
753
+ selectedRowKeys
754
+ } = _a, rest = __objRest(_a, [
755
+ "data",
756
+ "onSelectionChange",
757
+ "isSelectable",
758
+ "rowKey",
759
+ "setControlContextData",
760
+ "selectedRowKeys"
761
+ ]);
762
+ setControlContextData == null ? void 0 : setControlContextData(data);
763
+ const selection = isSelectable ? {
764
+ onChange: (rowKeys, rows) => {
765
+ onSelectionChange == null ? void 0 : onSelectionChange(rowKeys, rows);
766
+ },
767
+ type: isSelectable === "single" ? "radio" : "checkbox",
768
+ selectedRowKeys: (_b = asArray(selectedRowKeys)) != null ? _b : []
769
+ } : void 0;
770
+ return /* @__PURE__ */ React.createElement(Table, __spreadValues({
771
+ loading: data == null ? void 0 : data.isLoading,
772
+ dataSource: data == null ? void 0 : data.data,
773
+ rowSelection: selection,
774
+ rowKey
775
+ }, rest));
776
+ }
777
+ const AntdColumnGroup = Table.ColumnGroup;
778
+ const AntdColumn = Table.Column;
779
+ function registerTable(loader) {
780
+ registerComponentHelper(loader, AntdTable, {
781
+ name: "plasmic-antd5-table",
782
+ displayName: "Table",
783
+ props: {
784
+ data: {
785
+ type: "dataSourceOpData",
786
+ displayName: "Data"
787
+ },
788
+ children: {
789
+ type: "slot",
790
+ allowedComponents: [
791
+ "plasmic-antd5-table-column",
792
+ "plasmic-antd5-table-column-group"
793
+ ]
794
+ },
795
+ bordered: {
796
+ type: "boolean",
797
+ defaultValueHint: false,
798
+ advanced: true
799
+ },
800
+ isSelectable: {
801
+ type: "choice",
802
+ options: ["single", "multiple"],
803
+ displayName: "Select rows?"
804
+ },
805
+ rowKey: {
806
+ type: "choice",
807
+ options: (ps, ctx) => {
808
+ if (ctx.schema) {
809
+ return ctx.schema.fields.map((f) => ({
810
+ value: f.id,
811
+ label: f.label || f.id
812
+ }));
813
+ }
814
+ return [];
815
+ },
816
+ hidden: (ps) => !ps.isSelectable
817
+ },
818
+ selectedRowKeys: {
819
+ type: "choice",
820
+ multiSelect: (ps) => ps.isSelectable === "multiple",
821
+ options: (ps, ctx) => {
822
+ const key = ps.rowKey;
823
+ if (key && ctx.data) {
824
+ return ctx.data.map((r) => r[key]);
825
+ }
826
+ return [];
827
+ },
828
+ hidden: (ps) => !ps.rowKey
829
+ },
830
+ onSelectionChange: {
831
+ type: "eventHandler",
832
+ argTypes: [
833
+ { name: "keys", type: "object" },
834
+ { name: "rows", type: "object" }
835
+ ],
836
+ hidden: (ps) => !ps.isSelectable
837
+ }
838
+ },
839
+ importPath: "@plasmicpkgs/antd5/registerTable",
840
+ importName: "AntdTable",
841
+ unstable__states: {
842
+ selectedRows: {
843
+ type: "writable",
844
+ valueProp: "selectedRowKeys",
845
+ onChangeProp: "onSelectionChange"
846
+ }
847
+ }
848
+ });
849
+ registerComponentHelper(loader, AntdColumn, __spreadValues({
850
+ name: "plasmic-antd5-table-column",
851
+ displayName: "Column",
852
+ parentComponentName: "plasmic-antd5-table",
853
+ props: {
854
+ title: {
855
+ type: "slot",
856
+ defaultValue: "Column Name"
857
+ },
858
+ dataIndex: {
859
+ type: "string"
860
+ },
861
+ render: {
862
+ type: "slot",
863
+ renderPropParams: ["cell", "row", "index"]
864
+ },
865
+ align: {
866
+ type: "choice",
867
+ options: ["left", "right", "center"],
868
+ defaultValueHint: "left"
869
+ },
870
+ fixed: {
871
+ type: "choice",
872
+ options: ["left", "right"],
873
+ advanced: true
874
+ },
875
+ colSpan: {
876
+ type: "number",
877
+ advanced: true
878
+ }
879
+ },
880
+ importPath: "@plasmicpkgs/antd5/registerTable",
881
+ importName: "AntdColumn"
882
+ }, { isRenderless: true }));
883
+ registerComponentHelper(loader, AntdColumnGroup, __spreadValues({
884
+ name: "plasmic-antd5-table-column-group",
885
+ displayName: "Column Group",
886
+ parentComponentName: "plasmic-antd5-table",
887
+ props: {
888
+ title: {
889
+ type: "slot",
890
+ defaultValue: "Column Group Name"
891
+ },
892
+ children: {
893
+ type: "slot",
894
+ allowedComponents: ["plasmic-antd5-table-column"]
895
+ }
896
+ },
897
+ importPath: "@plasmicpkgs/antd5/skinny/registerTable",
898
+ importName: "AntdColumnGroup"
899
+ }, { isRenderless: true }));
900
+ }
901
+
902
+ function registerAll(loader) {
903
+ registerConfigProvider(loader);
904
+ registerTokens(loader);
905
+ registerSelect(loader);
906
+ registerTable(loader);
907
+ }
908
+
909
+ exports.registerAll = registerAll;
910
+ //# sourceMappingURL=index.js.map