@pisell/materials 1.0.1055 → 1.0.1057

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.
Files changed (72) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +7 -7
  6. package/build/lowcode/preview.js +9 -9
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +20 -20
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +24 -24
  11. package/es/components/PisellLayouts/index.d.ts +9 -5
  12. package/es/components/PisellLayouts/index.js +5 -3
  13. package/es/components/dataSourceComponents/dataSourceSubForm/index.js +18 -5
  14. package/es/components/dataSourceComponents/dataSourceSubForm/schema-full-example.json +38 -32
  15. package/es/components/dataSourceComponents/fields/RecordListWrapper/WithMode.js +58 -26
  16. package/es/components/dataSourceComponents/fields/Tabs/Tabs.js +1 -1
  17. package/es/components/dataSourceComponents/fields/Tabs/Tabs.less +2 -1
  18. package/es/components/pisellFloorMapLayout/PisellFloorMapLayout.d.ts +12 -0
  19. package/es/components/pisellFloorMapLayout/PisellFloorMapLayout.js +264 -0
  20. package/es/components/pisellFloorMapLayout/PisellFloorMapLayout.less +7 -0
  21. package/es/components/pisellFloorMapLayout/PisellFloorMapLayout.stories.d.ts +42 -0
  22. package/es/components/pisellFloorMapLayout/PisellFloorMapLayout.stories.js +1234 -0
  23. package/es/components/pisellFloorMapLayout/components/ItemLayer.d.ts +36 -0
  24. package/es/components/pisellFloorMapLayout/components/ItemLayer.js +121 -0
  25. package/es/components/pisellFloorMapLayout/components/ItemLayer.less +19 -0
  26. package/es/components/pisellFloorMapLayout/components/MapLayer.d.ts +23 -0
  27. package/es/components/pisellFloorMapLayout/components/MapLayer.js +74 -0
  28. package/es/components/pisellFloorMapLayout/components/MapLayer.less +7 -0
  29. package/es/components/pisellFloorMapLayout/components/ViewControls.d.ts +22 -0
  30. package/es/components/pisellFloorMapLayout/components/ViewControls.js +59 -0
  31. package/es/components/pisellFloorMapLayout/components/ViewControls.less +76 -0
  32. package/es/components/pisellFloorMapLayout/components/index.d.ts +7 -0
  33. package/es/components/pisellFloorMapLayout/components/index.js +6 -0
  34. package/es/components/pisellFloorMapLayout/index.d.ts +6 -0
  35. package/es/components/pisellFloorMapLayout/index.js +5 -0
  36. package/es/components/pisellFloorMapLayout/types.d.ts +197 -0
  37. package/es/components/pisellFloorMapLayout/types.js +1 -0
  38. package/es/components/pisellMultipleSelect/components/EditView.js +3 -3
  39. package/es/index.d.ts +4 -3
  40. package/es/index.js +1 -0
  41. package/lib/components/PisellLayouts/index.d.ts +9 -5
  42. package/lib/components/PisellLayouts/index.js +2 -0
  43. package/lib/components/dataSourceComponents/dataSourceSubForm/index.js +16 -3
  44. package/lib/components/dataSourceComponents/dataSourceSubForm/schema-full-example.json +38 -32
  45. package/lib/components/dataSourceComponents/fields/RecordListWrapper/WithMode.js +49 -21
  46. package/lib/components/dataSourceComponents/fields/Tabs/Tabs.js +1 -1
  47. package/lib/components/dataSourceComponents/fields/Tabs/Tabs.less +2 -1
  48. package/lib/components/pisellFloorMapLayout/PisellFloorMapLayout.d.ts +12 -0
  49. package/lib/components/pisellFloorMapLayout/PisellFloorMapLayout.js +257 -0
  50. package/lib/components/pisellFloorMapLayout/PisellFloorMapLayout.less +7 -0
  51. package/lib/components/pisellFloorMapLayout/PisellFloorMapLayout.stories.d.ts +42 -0
  52. package/lib/components/pisellFloorMapLayout/PisellFloorMapLayout.stories.js +755 -0
  53. package/lib/components/pisellFloorMapLayout/components/ItemLayer.d.ts +36 -0
  54. package/lib/components/pisellFloorMapLayout/components/ItemLayer.js +153 -0
  55. package/lib/components/pisellFloorMapLayout/components/ItemLayer.less +19 -0
  56. package/lib/components/pisellFloorMapLayout/components/MapLayer.d.ts +23 -0
  57. package/lib/components/pisellFloorMapLayout/components/MapLayer.js +103 -0
  58. package/lib/components/pisellFloorMapLayout/components/MapLayer.less +7 -0
  59. package/lib/components/pisellFloorMapLayout/components/ViewControls.d.ts +22 -0
  60. package/lib/components/pisellFloorMapLayout/components/ViewControls.js +89 -0
  61. package/lib/components/pisellFloorMapLayout/components/ViewControls.less +76 -0
  62. package/lib/components/pisellFloorMapLayout/components/index.d.ts +7 -0
  63. package/lib/components/pisellFloorMapLayout/components/index.js +35 -0
  64. package/lib/components/pisellFloorMapLayout/index.d.ts +6 -0
  65. package/lib/components/pisellFloorMapLayout/index.js +29 -0
  66. package/lib/components/pisellFloorMapLayout/types.d.ts +197 -0
  67. package/lib/components/pisellFloorMapLayout/types.js +17 -0
  68. package/lib/index.d.ts +4 -3
  69. package/lib/index.js +3 -0
  70. package/lowcode/data-source-form/utils.ts +3 -0
  71. package/lowcode/pisell-floor-map-layout/meta.ts +1511 -0
  72. package/package.json +4 -3
@@ -8,9 +8,9 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
8
8
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
9
9
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
10
10
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
11
- /**
12
- * PisellMultipleSelect - EditView (编辑态视图)
13
- * 正常可编辑状态下的渲染
11
+ /**
12
+ * PisellMultipleSelect - EditView (编辑态视图)
13
+ * 正常可编辑状态下的渲染
14
14
  */
15
15
 
16
16
  import React, { forwardRef, useMemo, useCallback, useState, useRef } from 'react';
package/es/index.d.ts CHANGED
@@ -14,7 +14,7 @@ export type { PisellSingleLineTextProps, PisellLongTextProps, PisellNumberProps,
14
14
  * <PisellMetrics.MetricCard title="Total Sales" value={1580} />
15
15
  */
16
16
  export { default as PisellMetrics } from './components/PisellMetrics';
17
- export type { PisellMetricCardProps, PisellStatisticProps } from './components/PisellMetrics';
17
+ export type { PisellMetricCardProps, PisellStatisticProps, } from './components/PisellMetrics';
18
18
  /**
19
19
  * PisellLayouts - 布局组件命名空间
20
20
  * @example
@@ -22,7 +22,7 @@ export type { PisellMetricCardProps, PisellStatisticProps } from './components/P
22
22
  * <PisellLayouts.BasicGrid columns={3}>{children}</PisellLayouts.BasicGrid>
23
23
  */
24
24
  export { default as PisellLayouts } from './components/PisellLayouts';
25
- export type { PisellBasicGridProps, PisellScrollViewProps, PisellLayoutProps, CompoundedComponent, PisellRowProps, } from './components/PisellLayouts';
25
+ export type { PisellBasicGridProps, PisellScrollViewProps, PisellFloorMapLayoutProps, PisellFloorMapLayoutRef, PisellLayoutProps, CompoundedComponent, PisellRowProps, } from './components/PisellLayouts';
26
26
  export { Affix, Alert, Anchor, Avatar, Breadcrumb, Card, Carousel, Col, ColorPicker, Descriptions, Divider, Empty, Grid, InputNumber, Mentions, Menu, Pagination, Popconfirm, Popover, Progress, Rate, Result, Row, Space, Spin, Statistic, Steps, Switch, Tag, Timeline, Tooltip, Transfer, Tree, message, notification, version, } from 'antd';
27
27
  export { default as AutoComplete } from './components/auto-complete';
28
28
  export { default as AutoCompleteNumber } from './components/auto-complete-number';
@@ -114,6 +114,7 @@ export { default as PisellRow } from './components/pisellRow';
114
114
  export { default as Div } from './components/div';
115
115
  export { default as PisellBasicGrid } from './components/PisellBasicGrid';
116
116
  export { default as PisellScrollView } from './components/PisellScrollView';
117
+ export { PisellFloorMapLayout } from './components/pisellFloorMapLayout';
117
118
  export { default as PisellViewGrid } from './components/pisellViewGrid';
118
119
  export { default as Table } from './components/table';
119
120
  export { default as PisellGridView } from './components/pisellGridPro/GridView';
@@ -143,7 +144,7 @@ export { default as CropPhoto } from './components/cropPhoto';
143
144
  export { default as PisellUpload } from './components/pisellUpload';
144
145
  export { default as Translation } from './components/translation';
145
146
  export { PisellLookup } from './components/pisellLookup';
146
- export type { PisellLookupProps, PisellLookupRef } from './components/pisellLookup';
147
+ export type { PisellLookupProps, PisellLookupRef, } from './components/pisellLookup';
147
148
  export { PisellFind } from './components/pisellFind';
148
149
  export type { PisellFindProps, PisellFindRef } from './components/pisellFind';
149
150
  export { default as DataSourceForm } from './components/dataSourceComponents/dataSourceForm';
package/es/index.js CHANGED
@@ -127,6 +127,7 @@ export { default as Div } from "./components/div";
127
127
  export { default as PisellBasicGrid } from "./components/PisellBasicGrid";
128
128
  // 类型已在 PisellLayouts 命名空间中导出
129
129
  export { default as PisellScrollView } from "./components/PisellScrollView";
130
+ export { PisellFloorMapLayout } from "./components/pisellFloorMapLayout";
130
131
  // 类型已在 PisellLayouts 命名空间中导出
131
132
  export { default as PisellViewGrid } from "./components/pisellViewGrid";
132
133
 
@@ -17,17 +17,21 @@
17
17
  declare const PisellLayouts: {
18
18
  BasicGrid: <T>(props: import("../PisellBasicGrid").PisellBasicGridProps<T>) => JSX.Element;
19
19
  ScrollView: import("react").ForwardRefExoticComponent<Omit<import("../PisellScrollView").PisellScrollViewProps, "ref"> & import("react").RefAttributes<import("../PisellScrollView").PisellScrollViewRef>>;
20
+ FloorMapLayout: <T_1 extends import("../pisellFloorMapLayout").FloorMapItemBase = import("../pisellFloorMapLayout").FloorMapItemBase>(props: import("../pisellFloorMapLayout").PisellFloorMapLayoutProps<T_1> & {
21
+ ref?: import("react").Ref<import("../pisellFloorMapLayout").PisellFloorMapLayoutRef> | undefined;
22
+ }) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
20
23
  Layout: import("../pisellLayout").CompoundedComponent;
21
24
  Content: import("react").FC<import("../pisellLayout/content").PisellContentProps>;
22
25
  Footer: import("react").FC<import("../pisellLayout/footer").PisellFooterProps>;
23
26
  Header: import("react").FC<import("../pisellLayout/header").PisellHeaderProps>;
24
27
  Sider: import("react").FC<import("../pisellLayout/sider").PisellSiderProps>;
25
- Container: <T_1 extends import("../pisellContainer").RenderType>(props: import("../pisellContainer").PisellContainerProps<T_1>) => any;
28
+ Container: <T_2 extends import("../pisellContainer").RenderType>(props: import("../pisellContainer").PisellContainerProps<T_2>) => any;
26
29
  Row: (props: import("../pisellRow").PisellRowProps) => JSX.Element;
27
30
  ViewGrid: import("react").FC<import("../pisellViewGrid").PisellViewGridProps>;
28
31
  };
29
32
  export default PisellLayouts;
30
- export type { PisellBasicGridProps, } from '../PisellBasicGrid';
31
- export type { PisellScrollViewProps, } from '../PisellScrollView';
32
- export type { PisellLayoutProps, CompoundedComponent, } from '../pisellLayout';
33
- export type { PisellRowProps, } from '../pisellRow';
33
+ export type { PisellBasicGridProps } from '../PisellBasicGrid';
34
+ export type { PisellScrollViewProps } from '../PisellScrollView';
35
+ export type { PisellFloorMapLayoutProps, PisellFloorMapLayoutRef, } from '../pisellFloorMapLayout';
36
+ export type { PisellLayoutProps, CompoundedComponent } from '../pisellLayout';
37
+ export type { PisellRowProps } from '../pisellRow';
@@ -34,6 +34,7 @@ __export(PisellLayouts_exports, {
34
34
  module.exports = __toCommonJS(PisellLayouts_exports);
35
35
  var import_PisellBasicGrid = __toESM(require("../PisellBasicGrid"));
36
36
  var import_PisellScrollView = __toESM(require("../PisellScrollView"));
37
+ var import_pisellFloorMapLayout = require("../pisellFloorMapLayout");
37
38
  var import_pisellLayout = __toESM(require("../pisellLayout"));
38
39
  var import_content = __toESM(require("../pisellLayout/content"));
39
40
  var import_footer = __toESM(require("../pisellLayout/footer"));
@@ -45,6 +46,7 @@ var import_pisellViewGrid = __toESM(require("../pisellViewGrid"));
45
46
  var PisellLayouts = {
46
47
  BasicGrid: import_PisellBasicGrid.default,
47
48
  ScrollView: import_PisellScrollView.default,
49
+ FloorMapLayout: import_pisellFloorMapLayout.PisellFloorMapLayout,
48
50
  Layout: import_pisellLayout.default,
49
51
  Content: import_content.default,
50
52
  Footer: import_footer.default,
@@ -115,8 +115,9 @@ var normalizeRecordSchema = (xRecordSchema) => {
115
115
  }
116
116
  return [];
117
117
  };
118
- var DataSourceSubForm = (props) => {
118
+ var DataSourceSubForm = (0, import_react.forwardRef)((props, ref) => {
119
119
  const {
120
+ activeKey,
120
121
  value = {},
121
122
  onChange,
122
123
  children,
@@ -127,15 +128,27 @@ var DataSourceSubForm = (props) => {
127
128
  style
128
129
  } = props;
129
130
  const [innerForm] = import_antd.Form.useForm();
131
+ const activeKeyRef = (0, import_react.useRef)(activeKey);
130
132
  const safeValue = (0, import_react.useMemo)(() => {
131
133
  if (value && typeof value === "object" && !Array.isArray(value)) {
132
134
  return value;
133
135
  }
134
136
  return {};
135
137
  }, [value]);
138
+ (0, import_react.useImperativeHandle)(ref, () => {
139
+ return {
140
+ getFieldsValue: () => {
141
+ return innerForm.getFieldsValue();
142
+ }
143
+ };
144
+ });
136
145
  (0, import_react.useEffect)(() => {
146
+ if (activeKeyRef.current !== activeKey) {
147
+ activeKeyRef.current = activeKey;
148
+ innerForm.resetFields();
149
+ }
137
150
  innerForm.setFieldsValue(safeValue);
138
- }, [safeValue, innerForm]);
151
+ }, [safeValue, innerForm, activeKey]);
139
152
  const handleValuesChange = (0, import_ahooks.useMemoizedFn)(
140
153
  (_, allValues) => {
141
154
  onChange == null ? void 0 : onChange({ ...safeValue, ...allValues });
@@ -212,5 +225,5 @@ var DataSourceSubForm = (props) => {
212
225
  },
213
226
  renderFormContent()
214
227
  );
215
- };
228
+ });
216
229
  var dataSourceSubForm_default = DataSourceSubForm;
@@ -319,20 +319,23 @@
319
319
  "x-component-props": {
320
320
  "direction": "horizontal"
321
321
  },
322
- "enum": [
323
- {
324
- "label": "上架",
325
- "value": "active"
326
- },
327
- {
328
- "label": "下架",
329
- "value": "inactive"
330
- },
331
- {
332
- "label": "待审核",
333
- "value": "pending"
334
- }
335
- ]
322
+ "x-data-source": {
323
+ "type": "default",
324
+ "options": [
325
+ {
326
+ "label": "上架",
327
+ "value": "active"
328
+ },
329
+ {
330
+ "label": "下架",
331
+ "value": "inactive"
332
+ },
333
+ {
334
+ "label": "待审核",
335
+ "value": "pending"
336
+ }
337
+ ]
338
+ }
336
339
  }
337
340
  },
338
341
  {
@@ -344,24 +347,27 @@
344
347
  "x-component-props": {
345
348
  "direction": "vertical"
346
349
  },
347
- "enum": [
348
- {
349
- "label": "支持退换",
350
- "value": "returnable"
351
- },
352
- {
353
- "label": "支持货到付款",
354
- "value": "cod"
355
- },
356
- {
357
- "label": "支持发票",
358
- "value": "invoice"
359
- },
360
- {
361
- "label": "支持分期",
362
- "value": "installment"
363
- }
364
- ]
350
+ "x-data-source": {
351
+ "type": "default",
352
+ "options": [
353
+ {
354
+ "label": "支持退换",
355
+ "value": "returnable"
356
+ },
357
+ {
358
+ "label": "支持货到付款",
359
+ "value": "cod"
360
+ },
361
+ {
362
+ "label": "支持发票",
363
+ "value": "invoice"
364
+ },
365
+ {
366
+ "label": "支持分期",
367
+ "value": "installment"
368
+ }
369
+ ]
370
+ }
365
371
  }
366
372
  },
367
373
  {
@@ -50,6 +50,8 @@ var RecordListWrapperBase = (props) => {
50
50
  __designMode,
51
51
  defaultValue
52
52
  } = props;
53
+ const isMounted = (0, import_react.useRef)(false);
54
+ const dataSourceSubFormRef = (0, import_react.useRef)(null);
53
55
  const safeValue = (0, import_react.useMemo)(() => {
54
56
  if (value && typeof value === "object" && !Array.isArray(value)) {
55
57
  return value;
@@ -74,6 +76,28 @@ var RecordListWrapperBase = (props) => {
74
76
  );
75
77
  }
76
78
  }, [options]);
79
+ (0, import_react.useEffect)(() => {
80
+ var _a, _b;
81
+ if (isMounted.current) {
82
+ return;
83
+ }
84
+ if ((options == null ? void 0 : options.length) > 0 && dataSourceSubFormRef.current) {
85
+ const defaultValues = ((_b = (_a = dataSourceSubFormRef.current).getFieldsValue) == null ? void 0 : _b.call(_a)) ?? {};
86
+ const completeValue = options.reduce(
87
+ (acc, option) => {
88
+ if (option.value === null || option.value === void 0) return acc;
89
+ acc[String(option.value)] = {
90
+ ...defaultValues,
91
+ ...safeValue[String(option.value)] || {}
92
+ };
93
+ return acc;
94
+ },
95
+ {}
96
+ );
97
+ onChange == null ? void 0 : onChange(completeValue);
98
+ isMounted.current = true;
99
+ }
100
+ }, [options, safeValue]);
77
101
  const renderTopSlot = () => {
78
102
  const slotElement = topSlot || slot;
79
103
  if (slotElement && import_react.default.isValidElement(slotElement)) {
@@ -87,6 +111,9 @@ var RecordListWrapperBase = (props) => {
87
111
  ...o,
88
112
  label: o.label ?? String(o.value)
89
113
  }));
114
+ if (!options.length) {
115
+ return /* @__PURE__ */ import_react.default.createElement("div", { style: { color: "#999", fontSize: 16 } }, "暂无选项,请配置数据源。");
116
+ }
90
117
  return /* @__PURE__ */ import_react.default.createElement(
91
118
  import_Tabs.default,
92
119
  {
@@ -98,27 +125,28 @@ var RecordListWrapperBase = (props) => {
98
125
  );
99
126
  };
100
127
  const renderBottom = () => {
101
- if (!options.length) {
102
- return /* @__PURE__ */ import_react.default.createElement("div", { style: { color: "#999", fontSize: 12 } }, "No options available. Configure xDataSource options first.");
103
- }
104
- return (
105
- /**
106
- * key={activeKey}:Tab 切换时强制重新挂载 DataSourceSubForm,
107
- * 使其用新的 value 初始化内部 Form,避免手动 setFieldsValue。
108
- */
109
- /* @__PURE__ */ import_react.default.createElement(
110
- import_dataSourceSubForm.default,
111
- {
112
- key: activeKey,
113
- value: safeValue[activeKey],
114
- onChange: (recordValue) => onChange == null ? void 0 : onChange({ ...safeValue, [activeKey]: recordValue }),
115
- xRecordSchema,
116
- renderMode,
117
- __designMode
118
- },
119
- children
120
- )
121
- );
128
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
129
+ import_dataSourceSubForm.default,
130
+ {
131
+ activeKey,
132
+ value: safeValue[activeKey],
133
+ onChange: (recordValue) => onChange == null ? void 0 : onChange({ ...safeValue || {}, [activeKey]: recordValue || {} }),
134
+ xRecordSchema,
135
+ renderMode,
136
+ __designMode
137
+ },
138
+ children
139
+ ), /* @__PURE__ */ import_react.default.createElement("div", { style: { width: "100%", height: 0, visibility: "hidden", overflow: "hidden" } }, /* @__PURE__ */ import_react.default.createElement(
140
+ import_dataSourceSubForm.default,
141
+ {
142
+ key: "record-list-wrapper-default-value-form",
143
+ ref: dataSourceSubFormRef,
144
+ xRecordSchema,
145
+ renderMode,
146
+ __designMode
147
+ },
148
+ children
149
+ )));
122
150
  };
123
151
  return /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("div", { style: { marginBottom: 12 } }, renderTopSlot()), renderBottom());
124
152
  };
@@ -56,7 +56,7 @@ var Tabs = ({
56
56
  };
57
57
  const tabItems = (0, import_react.useMemo)(() => {
58
58
  return options.map((option) => {
59
- const isActive = selectedValue === option.value;
59
+ const isActive = selectedValue != null && selectedValue !== void 0 && String(selectedValue) === String(option.value);
60
60
  const isDisabled = disabled || option.disabled;
61
61
  return /* @__PURE__ */ import_react.default.createElement(
62
62
  "div",
@@ -7,10 +7,11 @@
7
7
  border-radius: 8px;
8
8
  padding: 2px;
9
9
  gap: 2px;
10
- flex-wrap: wrap;
10
+ flex-wrap: nowrap;
11
11
  box-sizing: border-box;
12
12
  color: rgba(0, 0, 0, .65);
13
13
  background-color: rgba(0, 0, 0, .04);
14
+ overflow-x: auto;
14
15
 
15
16
  &-item {
16
17
  min-height: 36px;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * PisellFloorMapLayout - 空间布局视图
3
+ * 在二维平面按坐标渲染资源,支持缩放/平移/复位,仅负责展示与交互
4
+ */
5
+ import React from 'react';
6
+ import type { FloorMapItemBase, PisellFloorMapLayoutProps, PisellFloorMapLayoutRef } from './types';
7
+ import './PisellFloorMapLayout.less';
8
+ declare const PisellFloorMapLayout: <T extends FloorMapItemBase = FloorMapItemBase>(props: PisellFloorMapLayoutProps<T> & {
9
+ ref?: React.Ref<PisellFloorMapLayoutRef> | undefined;
10
+ }) => React.ReactElement;
11
+ export { PisellFloorMapLayout };
12
+ export default PisellFloorMapLayout;
@@ -0,0 +1,257 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/components/pisellFloorMapLayout/PisellFloorMapLayout.tsx
30
+ var PisellFloorMapLayout_exports = {};
31
+ __export(PisellFloorMapLayout_exports, {
32
+ PisellFloorMapLayout: () => PisellFloorMapLayout,
33
+ default: () => PisellFloorMapLayout_default
34
+ });
35
+ module.exports = __toCommonJS(PisellFloorMapLayout_exports);
36
+ var import_react = __toESM(require("react"));
37
+ var import_classnames = __toESM(require("classnames"));
38
+ var import_react_zoom_pan_pinch = require("react-zoom-pan-pinch");
39
+ var import_MapLayer = __toESM(require("./components/MapLayer"));
40
+ var import_ItemLayer = __toESM(require("./components/ItemLayer"));
41
+ var import_ViewControls = __toESM(require("./components/ViewControls"));
42
+ var import_PisellFloorMapLayout = require("./PisellFloorMapLayout.less");
43
+ var PREFIX = "pisell-floor-map-layout";
44
+ var DEFAULT_CELL_SIZE = 64;
45
+ var DEFAULT_ITEM_GAP = 8;
46
+ function gapToPx(gap) {
47
+ if (gap === void 0) return DEFAULT_ITEM_GAP;
48
+ if (typeof gap === "number") return gap;
49
+ const match = String(gap).match(/^(\d+(?:\.\d+)?)\s*px?$/i);
50
+ return match ? Number(match[1]) : DEFAULT_ITEM_GAP;
51
+ }
52
+ function getContentSize(items, cellSize, itemGap, itemUnit) {
53
+ if (!items.length) {
54
+ if (itemUnit === "pixel") {
55
+ return { contentWidth: cellSize * 4, contentHeight: cellSize * 3 };
56
+ }
57
+ const g2 = itemGap;
58
+ return {
59
+ contentWidth: 4 * (cellSize + g2) + g2,
60
+ contentHeight: 3 * (cellSize + g2) + g2
61
+ };
62
+ }
63
+ if (itemUnit === "pixel") {
64
+ let maxRight = 0;
65
+ let maxBottom = 0;
66
+ for (const item of items) {
67
+ const w = item.width ?? cellSize;
68
+ const h = item.height ?? cellSize;
69
+ maxRight = Math.max(maxRight, item.x + w);
70
+ maxBottom = Math.max(maxBottom, item.y + h);
71
+ }
72
+ return { contentWidth: maxRight, contentHeight: maxBottom };
73
+ }
74
+ let maxX = 0;
75
+ let maxY = 0;
76
+ for (const item of items) {
77
+ const w = item.width ?? 1;
78
+ const h = item.height ?? 1;
79
+ maxX = Math.max(maxX, item.x + w);
80
+ maxY = Math.max(maxY, item.y + h);
81
+ }
82
+ const g = itemGap;
83
+ return {
84
+ contentWidth: maxX * (cellSize + g) + g,
85
+ contentHeight: maxY * (cellSize + g) + g
86
+ };
87
+ }
88
+ function PisellFloorMapLayoutInner(props, ref) {
89
+ const {
90
+ className,
91
+ style,
92
+ items,
93
+ renderItem,
94
+ rowKey,
95
+ mapLayer,
96
+ cellSize: cellSizeProp,
97
+ itemUnit = "cell",
98
+ layoutMode = "free",
99
+ gridLayout,
100
+ zoom = {},
101
+ pan = {},
102
+ controls = {},
103
+ enableHover = true,
104
+ onItemClick,
105
+ onItemHover,
106
+ onItemLeave
107
+ } = props;
108
+ const transformRef = (0, import_react.useRef)(null);
109
+ const containerRef = (0, import_react.useRef)(null);
110
+ const cellSize = cellSizeProp ?? DEFAULT_CELL_SIZE;
111
+ const itemGap = (0, import_react.useMemo)(
112
+ () => gapToPx(mapLayer == null ? void 0 : mapLayer.gap),
113
+ [mapLayer == null ? void 0 : mapLayer.gap]
114
+ );
115
+ const { contentWidth, contentHeight } = (0, import_react.useMemo)(
116
+ () => getContentSize(items, cellSize, itemGap, itemUnit),
117
+ [items, cellSize, itemGap, itemUnit]
118
+ );
119
+ const zoomConfig = (0, import_react.useMemo)(
120
+ () => ({
121
+ initialScale: zoom.defaultScale ?? 1,
122
+ minScale: zoom.min ?? 0.5,
123
+ maxScale: zoom.max ?? 2,
124
+ step: zoom.step ?? 0.1
125
+ }),
126
+ [zoom.defaultScale, zoom.min, zoom.max, zoom.step]
127
+ );
128
+ const [scale, setScale] = (0, import_react.useState)(zoomConfig.initialScale);
129
+ const fitBounds = (0, import_react.useCallback)(() => {
130
+ const ctx = transformRef.current;
131
+ const container = containerRef.current;
132
+ if (!ctx || !container) return;
133
+ const wrapper = container.querySelector(".react-transform-wrapper");
134
+ if (!wrapper) return;
135
+ const wrapperRect = wrapper.getBoundingClientRect();
136
+ const scale2 = Math.min(
137
+ wrapperRect.width / contentWidth,
138
+ wrapperRect.height / contentHeight,
139
+ zoom.max ?? 2
140
+ );
141
+ const x = (wrapperRect.width - contentWidth * scale2) / 2;
142
+ const y = (wrapperRect.height - contentHeight * scale2) / 2;
143
+ ctx.setTransform(x, y, scale2);
144
+ }, [contentWidth, contentHeight, zoom.max]);
145
+ (0, import_react.useImperativeHandle)(
146
+ ref,
147
+ () => ({
148
+ zoomIn: () => {
149
+ var _a;
150
+ return (_a = transformRef.current) == null ? void 0 : _a.zoomIn();
151
+ },
152
+ zoomOut: () => {
153
+ var _a;
154
+ return (_a = transformRef.current) == null ? void 0 : _a.zoomOut();
155
+ },
156
+ reset: () => {
157
+ var _a;
158
+ return (_a = transformRef.current) == null ? void 0 : _a.resetTransform();
159
+ },
160
+ fitBounds
161
+ }),
162
+ [fitBounds]
163
+ );
164
+ const controlsApi = (0, import_react.useMemo)(
165
+ () => ({
166
+ zoomIn: () => {
167
+ var _a;
168
+ return (_a = transformRef.current) == null ? void 0 : _a.zoomIn();
169
+ },
170
+ zoomOut: () => {
171
+ var _a;
172
+ return (_a = transformRef.current) == null ? void 0 : _a.zoomOut();
173
+ },
174
+ resetTransform: () => {
175
+ var _a;
176
+ return (_a = transformRef.current) == null ? void 0 : _a.resetTransform();
177
+ },
178
+ fitBounds
179
+ }),
180
+ [fitBounds]
181
+ );
182
+ return /* @__PURE__ */ import_react.default.createElement(
183
+ "div",
184
+ {
185
+ ref: containerRef,
186
+ className: (0, import_classnames.default)(PREFIX, className),
187
+ style
188
+ },
189
+ /* @__PURE__ */ import_react.default.createElement(
190
+ import_react_zoom_pan_pinch.TransformWrapper,
191
+ {
192
+ initialScale: zoomConfig.initialScale,
193
+ minScale: zoomConfig.minScale,
194
+ maxScale: zoomConfig.maxScale,
195
+ step: zoomConfig.step,
196
+ panning: { disabled: !pan.enabled },
197
+ doubleClick: { disabled: true },
198
+ onTransformed: (_, state) => setScale(state.scale)
199
+ },
200
+ (ctx) => {
201
+ transformRef.current = ctx;
202
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
203
+ import_react_zoom_pan_pinch.TransformComponent,
204
+ {
205
+ wrapperStyle: {
206
+ width: "100%",
207
+ height: "100%",
208
+ backgroundColor: "#F2F4F7",
209
+ overflow: "visible"
210
+ },
211
+ contentStyle: {
212
+ width: contentWidth,
213
+ height: contentHeight,
214
+ minWidth: contentWidth,
215
+ minHeight: contentHeight,
216
+ position: "relative",
217
+ overflow: "visible",
218
+ backgroundColor: "#F2F4F7"
219
+ }
220
+ },
221
+ /* @__PURE__ */ import_react.default.createElement(
222
+ import_MapLayer.default,
223
+ {
224
+ config: mapLayer,
225
+ contentWidth,
226
+ contentHeight,
227
+ cellSize
228
+ }
229
+ ),
230
+ /* @__PURE__ */ import_react.default.createElement(
231
+ import_ItemLayer.default,
232
+ {
233
+ items,
234
+ renderItem,
235
+ rowKey,
236
+ cellSize,
237
+ itemUnit,
238
+ itemGap,
239
+ contentWidth,
240
+ contentHeight,
241
+ enableHover,
242
+ onItemClick,
243
+ onItemHover,
244
+ onItemLeave
245
+ }
246
+ )
247
+ ), /* @__PURE__ */ import_react.default.createElement(import_ViewControls.default, { api: controlsApi, config: controls, scale }));
248
+ }
249
+ )
250
+ );
251
+ }
252
+ var PisellFloorMapLayout = import_react.default.forwardRef(PisellFloorMapLayoutInner);
253
+ var PisellFloorMapLayout_default = PisellFloorMapLayout;
254
+ // Annotate the CommonJS export names for ESM import in node:
255
+ 0 && (module.exports = {
256
+ PisellFloorMapLayout
257
+ });
@@ -0,0 +1,7 @@
1
+ .pisell-floor-map-layout {
2
+ position: relative;
3
+ width: 100%;
4
+ height: 400px;
5
+ overflow: hidden;
6
+ background: #fafafa;
7
+ }