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