@airoom/nextmin-react 1.4.2 → 1.4.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.
@@ -363,7 +363,9 @@ export function SchemaForm({ model, schemaOverride, initialValues, submitLabel =
363
363
  : parseJsonGroupValue(form[name], 'array');
364
364
  const canAdd = spec.maxItems == null || items.length < spec.maxItems;
365
365
  const canRemove = spec.minItems == null || items.length > spec.minItems;
366
- return (_jsxs("div", { className: "col-span-2", children: [_jsxs("label", { className: "text-sm font-medium", children: [attr?.label || spec.label || formatLabel(name), attr?.required ? ' *' : ''] }), _jsxs("div", { className: "flex flex-col gap-4 mt-2", children: [items.map((it, idx) => (_jsxs("div", { className: "grid grid-cols-2 gap-3 p-3 rounded-lg border border-default-200", children: [Object.entries(itemSchema).map(([k, a]) => (_jsx(Input, { variant: "bordered", classNames: inputClassNames, id: `${name}-${idx}-${k}`, name: `${name}.${idx}.${k}`, label: a?.label ?? formatLabel(k), labelPlacement: "outside-top", type: "text", value: typeof it?.[k] === 'string' ? it[k] : '', onChange: (e) => {
366
+ return (_jsxs("div", { className: "col-span-2", children: [_jsxs("label", { className: "text-sm font-medium", children: [attr?.label || spec.label || formatLabel(name), attr?.required ? ' *' : ''] }), _jsxs("div", { className: "flex flex-col gap-4 mt-2", children: [items.map((it, idx) => (_jsxs("div", { className: "grid grid-cols-2 gap-3 p-3 rounded-lg border border-default-200", children: [_jsxs("div", { className: "col-span-2 font-medium text-default-600", children: [(attr?.label ||
367
+ spec.label ||
368
+ formatLabel(name)).replace(/s$/, ''), ' ', idx + 1] }), Object.entries(itemSchema).map(([k, a]) => (_jsx(Input, { variant: "bordered", classNames: inputClassNames, id: `${name}-${idx}-${k}`, name: `${name}.${idx}.${k}`, label: a?.label ?? formatLabel(k), labelPlacement: "outside-top", type: "text", value: typeof it?.[k] === 'string' ? it[k] : '', onChange: (e) => {
367
369
  const next = items.slice();
368
370
  next[idx] = {
369
371
  ...(next[idx] || {}),
@@ -384,7 +386,10 @@ export function SchemaForm({ model, schemaOverride, initialValues, submitLabel =
384
386
  !Array.isArray(form[name])
385
387
  ? form[name]
386
388
  : parseJsonGroupValue(form[name], 'single');
387
- return (_jsxs("div", { className: "col-span-2", children: [_jsxs("label", { className: "text-sm font-medium", children: [attr?.label || spec.label || formatLabel(name), attr?.required ? ' *' : ''] }), _jsx("div", { className: "grid grid-cols-2 gap-3 p-3 rounded-lg border border-default-200 mt-2", children: Object.entries(itemSchema).map(([k, a]) => (_jsx(Input, { variant: "bordered", classNames: inputClassNames, id: `${name}-${k}`, name: `${name}.${k}`, label: a?.label ?? formatLabel(k), labelPlacement: "outside-top", type: "text", value: typeof obj?.[k] === 'string' ? obj[k] : '', onChange: (e) => {
389
+ return (_jsxs("div", { className: "col-span-2", children: [_jsxs("label", { className: "text-sm font-medium", children: [attr?.label || spec.label || formatLabel(name), attr?.required ? ' *' : ''] }), _jsx("div", { className: "grid grid-cols-2 gap-3 p-3 rounded-lg border border-default-200 mt-2", children: Object.entries(itemSchema).map(([k, a]) => a?.format === 'textarea' ? (_jsx(Textarea, { variant: "bordered", classNames: inputClassNames, id: `${name}-${k}`, name: `${name}.${k}`, label: a?.label ?? formatLabel(k), labelPlacement: "outside", value: typeof obj?.[k] === 'string' ? obj[k] : '', onChange: (e) => {
390
+ const next = { ...(obj || {}), [k]: e.target.value };
391
+ handleChange(name, next);
392
+ }, minRows: 3, maxRows: 20, isDisabled: busy, description: a?.description, className: "w-full col-span-2", isRequired: !!a?.required }, `${name}-${k}`)) : (_jsx(Input, { variant: "bordered", classNames: inputClassNames, id: `${name}-${k}`, name: `${name}.${k}`, label: a?.label ?? formatLabel(k), labelPlacement: "outside-top", type: "text", value: typeof obj?.[k] === 'string' ? obj[k] : '', onChange: (e) => {
388
393
  const next = { ...(obj || {}), [k]: e.target.value };
389
394
  handleChange(name, next);
390
395
  }, isDisabled: busy, description: a?.description, className: "w-full", isRequired: !!a?.required }, `${name}-${k}`))) })] }, name));
@@ -287,7 +287,7 @@ export const TiptapEditor = ({ value, onChange, className, placeholder = 'Start
287
287
  editor.chain().focus().insertContent(`<p class="text-red-500">Error loading data for ${selectedSchema.modelName}</p>`).run();
288
288
  }
289
289
  };
290
- const handleDistrictGridInsert = async ({ districts, baseType, specialitySlug }) => {
290
+ const handleDistrictGridInsert = async ({ districts, baseType, specialitySlug, specialityName }) => {
291
291
  if (!editor || districts.length === 0)
292
292
  return;
293
293
  try {
@@ -310,8 +310,11 @@ export const TiptapEditor = ({ value, onChange, className, placeholder = 'Start
310
310
  urlParts.push(specialitySlug);
311
311
  }
312
312
  const url = urlParts.join('/');
313
- const displayName = district.name || district.bnName || districtSlug;
314
- html += `<div data-type="grid-item" href="${url}"><p>${displayName}</p></div>`;
313
+ // Format: "Speciality Name in District Name" or just "District Name" if no speciality
314
+ const displayText = specialityName
315
+ ? `${specialityName} in ${district.name}`
316
+ : district.name;
317
+ html += `<div data-type="grid-item" href="${url}"><p>${displayText}</p></div>`;
315
318
  });
316
319
  html += `</div>`;
317
320
  // Insert spacing first, then grid
@@ -5,6 +5,7 @@ interface DistrictGridModalProps {
5
5
  districts: string[];
6
6
  baseType: 'doctors' | 'hospitals';
7
7
  specialitySlug?: string;
8
+ specialityName?: string;
8
9
  }) => void;
9
10
  currentSpeciality?: string;
10
11
  }
@@ -11,6 +11,7 @@ export const DistrictGridModal = ({ isOpen, onClose, onInsert, currentSpeciality
11
11
  const [selectedDistricts, setSelectedDistricts] = useState([]);
12
12
  const [selectedSpecialityId, setSelectedSpecialityId] = useState('');
13
13
  const [specialitySlug, setSpecialitySlug] = useState('');
14
+ const [specialityName, setSpecialityName] = useState('');
14
15
  // Fetch speciality data when ID changes
15
16
  useEffect(() => {
16
17
  if (!selectedSpecialityId) {
@@ -22,10 +23,12 @@ export const DistrictGridModal = ({ isOpen, onClose, onInsert, currentSpeciality
22
23
  const res = await api.get('Specialities', selectedSpecialityId);
23
24
  const speciality = res.data || res;
24
25
  setSpecialitySlug(speciality?.slug || '');
26
+ setSpecialityName(speciality?.name || '');
25
27
  }
26
28
  catch (err) {
27
29
  console.error('Failed to fetch speciality:', err);
28
30
  setSpecialitySlug('');
31
+ setSpecialityName('');
29
32
  }
30
33
  };
31
34
  fetchSpeciality();
@@ -34,7 +37,8 @@ export const DistrictGridModal = ({ isOpen, onClose, onInsert, currentSpeciality
34
37
  onInsert({
35
38
  districts: selectedDistricts,
36
39
  baseType,
37
- specialitySlug: specialitySlug
40
+ specialitySlug: specialitySlug,
41
+ specialityName: specialityName
38
42
  });
39
43
  onClose();
40
44
  // Reset state after a short delay
@@ -43,6 +47,7 @@ export const DistrictGridModal = ({ isOpen, onClose, onInsert, currentSpeciality
43
47
  setSelectedDistricts([]);
44
48
  setSelectedSpecialityId('');
45
49
  setSpecialitySlug('');
50
+ setSpecialityName('');
46
51
  }, 200);
47
52
  };
48
53
  const baseFrontendUrl = process.env.NEXT_PUBLIC_FRONTEND_URL || '';
@@ -5,11 +5,5 @@ import { cn } from '../../../lib/utils';
5
5
  export const ImageBubbleMenu = ({ editor }) => {
6
6
  if (!editor)
7
7
  return null;
8
- return (_jsxs(BubbleMenu, { editor: editor, pluginKey: "imageBubbleMenu", shouldShow: ({ editor }) => editor.isActive('image'),
9
- // @ts-ignore
10
- tippyOptions: {
11
- duration: 100,
12
- zIndex: 99, // Ensure it sits above other elements
13
- maxWidth: 'none',
14
- }, className: "flex items-center gap-1 bg-white dark:bg-zinc-800 border border-gray-200 dark:border-gray-700 shadow-lg p-1 rounded-lg z-50", children: [_jsx("button", { type: "button", onClick: () => editor.chain().focus().updateAttributes('image', { width: '100%', height: null }).run(), className: cn("p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200", editor.getAttributes('image').width === '100%' && "bg-gray-200 dark:bg-gray-600"), title: "Full Width", children: _jsx(StretchHorizontal, { size: 16 }) }), _jsx("button", { type: "button", onClick: () => editor.chain().focus().updateAttributes('image', { width: null, height: null }).run(), className: "p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200", title: "Original Size", children: _jsx(Minimize, { size: 16 }) }), _jsx("div", { className: "w-[1px] h-4 bg-gray-300 dark:bg-gray-600 mx-1" }), _jsx("button", { type: "button", onClick: () => editor.chain().focus().setTextAlign('left').run(), className: cn("p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200", editor.isActive({ textAlign: 'left' }) && "bg-gray-200 dark:bg-gray-600"), title: "Align Left", children: _jsx(AlignLeft, { size: 16 }) }), _jsx("button", { type: "button", onClick: () => editor.chain().focus().setTextAlign('center').run(), className: cn("p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200", editor.isActive({ textAlign: 'center' }) && "bg-gray-200 dark:bg-gray-600"), title: "Align Center", children: _jsx(AlignCenter, { size: 16 }) }), _jsx("button", { type: "button", onClick: () => editor.chain().focus().setTextAlign('right').run(), className: cn("p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200", editor.isActive({ textAlign: 'right' }) && "bg-gray-200 dark:bg-gray-600"), title: "Align Right", children: _jsx(AlignRight, { size: 16 }) }), _jsx("div", { className: "w-[1px] h-4 bg-gray-300 dark:bg-gray-600 mx-1" }), _jsx("button", { type: "button", onClick: () => editor.chain().focus().updateAttributes('image', { objectFit: 'contain' }).run(), className: cn("p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200 text-xs font-medium", editor.getAttributes('image').objectFit === 'contain' && "bg-gray-200 dark:bg-gray-600"), title: "Contain", children: "Fit" }), _jsx("button", { type: "button", onClick: () => editor.chain().focus().updateAttributes('image', { objectFit: 'cover' }).run(), className: cn("p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200 text-xs font-medium", editor.getAttributes('image').objectFit === 'cover' && "bg-gray-200 dark:bg-gray-600"), title: "Cover", children: "Cover" }), _jsx("button", { type: "button", onClick: () => editor.chain().focus().updateAttributes('image', { objectFit: 'fill' }).run(), className: cn("p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200 text-xs font-medium", editor.getAttributes('image').objectFit === 'fill' && "bg-gray-200 dark:bg-gray-600"), title: "Fill", children: "Fill" })] }));
8
+ return (_jsxs(BubbleMenu, { editor: editor, pluginKey: "imageBubbleMenu", shouldShow: ({ editor }) => editor.isActive('image'), className: "flex items-center gap-1 bg-white dark:bg-zinc-800 border border-gray-200 dark:border-gray-700 shadow-lg p-1 rounded-lg z-50", children: [_jsx("button", { type: "button", onClick: () => editor.chain().focus().updateAttributes('image', { width: '100%', height: null }).run(), className: cn("p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200", editor.getAttributes('image').width === '100%' && "bg-gray-200 dark:bg-gray-600"), title: "Full Width", children: _jsx(StretchHorizontal, { size: 16 }) }), _jsx("button", { type: "button", onClick: () => editor.chain().focus().updateAttributes('image', { width: null, height: null }).run(), className: "p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200", title: "Original Size", children: _jsx(Minimize, { size: 16 }) }), _jsx("div", { className: "w-[1px] h-4 bg-gray-300 dark:bg-gray-600 mx-1" }), _jsx("button", { type: "button", onClick: () => editor.chain().focus().setTextAlign('left').run(), className: cn("p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200", editor.isActive({ textAlign: 'left' }) && "bg-gray-200 dark:bg-gray-600"), title: "Align Left", children: _jsx(AlignLeft, { size: 16 }) }), _jsx("button", { type: "button", onClick: () => editor.chain().focus().setTextAlign('center').run(), className: cn("p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200", editor.isActive({ textAlign: 'center' }) && "bg-gray-200 dark:bg-gray-600"), title: "Align Center", children: _jsx(AlignCenter, { size: 16 }) }), _jsx("button", { type: "button", onClick: () => editor.chain().focus().setTextAlign('right').run(), className: cn("p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200", editor.isActive({ textAlign: 'right' }) && "bg-gray-200 dark:bg-gray-600"), title: "Align Right", children: _jsx(AlignRight, { size: 16 }) }), _jsx("div", { className: "w-[1px] h-4 bg-gray-300 dark:bg-gray-600 mx-1" }), _jsx("button", { type: "button", onClick: () => editor.chain().focus().updateAttributes('image', { objectFit: 'contain' }).run(), className: cn("p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200 text-xs font-medium", editor.getAttributes('image').objectFit === 'contain' && "bg-gray-200 dark:bg-gray-600"), title: "Contain", children: "Fit" }), _jsx("button", { type: "button", onClick: () => editor.chain().focus().updateAttributes('image', { objectFit: 'cover' }).run(), className: cn("p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200 text-xs font-medium", editor.getAttributes('image').objectFit === 'cover' && "bg-gray-200 dark:bg-gray-600"), title: "Cover", children: "Cover" }), _jsx("button", { type: "button", onClick: () => editor.chain().focus().updateAttributes('image', { objectFit: 'fill' }).run(), className: cn("p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200 text-xs font-medium", editor.getAttributes('image').objectFit === 'fill' && "bg-gray-200 dark:bg-gray-600"), title: "Fill", children: "Fill" })] }));
15
9
  };