@omnibase/shadcn 0.2.0 → 0.3.0

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 (3) hide show
  1. package/dist/index.cjs +120 -60
  2. package/dist/index.js +120 -60
  3. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -307,84 +307,144 @@ function isUiNodeInputAttributes(attributes) {
307
307
  return attributes && typeof attributes === "object" && "name" in attributes && "type" in attributes;
308
308
  }
309
309
  function CustomFlowForm({ flow, Header }) {
310
+ const nodesByGroup = flow.ui.nodes.reduce((groups, node) => {
311
+ const group = node.group || "default";
312
+ if (!groups[group]) {
313
+ groups[group] = [];
314
+ }
315
+ groups[group].push(node);
316
+ return groups;
317
+ }, {});
318
+ const oidcNodes = nodesByGroup.oidc || [];
319
+ const regularNodes = Object.entries(nodesByGroup).filter(([group]) => group !== "oidc").flatMap(([, nodes]) => nodes);
320
+ const csrfToken = regularNodes.find(
321
+ (node) => isUiNodeInputAttributes(node.attributes) && node.attributes.name === "csrf_token"
322
+ );
310
323
  const hasSubmitButton = flow.ui.nodes.some(
311
324
  (node) => isUiNodeInputAttributes(node.attributes) && node.attributes.type === "submit"
312
325
  );
313
326
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
314
327
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Messages, { flow }),
315
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Card, { className: "w-full max-w-md mx-auto", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("form", { action: flow.ui.action, method: flow.ui.method, children: [
316
- Header && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CardHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CardTitle, { className: "text-center pb-4", children: Header }) }),
317
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(CardContent, { className: "space-y-4", children: [
318
- flow.ui.nodes.map((node) => {
319
- if (isUiNodeInputAttributes(node.attributes)) {
320
- const isSubmitButton = node.attributes.type === "submit";
321
- const isHiddenField = node.attributes.type === "hidden";
322
- const isVisibleField = !isHiddenField && !isSubmitButton;
323
- if (isHiddenField) {
324
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
325
- "input",
326
- {
327
- name: node.attributes.name,
328
- type: "hidden",
329
- value: node.attributes.value || "",
330
- readOnly: true
331
- },
332
- node.attributes.name
333
- );
334
- }
335
- if (isSubmitButton) {
336
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
337
- Button,
338
- {
339
- type: "submit",
340
- name: node.attributes.name,
341
- value: node.attributes.value || "",
342
- className: "w-full mt-2",
343
- children: node.meta.label?.text || node.attributes.value || "Submit"
344
- },
345
- node.attributes.name
346
- );
347
- }
348
- if (isVisibleField && [
349
- "default",
350
- "password",
351
- "code",
352
- "webauthn",
353
- "passkey",
354
- "totp",
355
- "lookup_secret"
356
- ].includes(node.group)) {
328
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Card, { className: "w-full max-w-md mx-auto", children: [
329
+ Header && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CardHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CardTitle, { className: "text-center pb-1", children: Header }) }),
330
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(CardContent, { className: "space-y-6", children: [
331
+ oidcNodes.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-3", children: [
332
+ oidcNodes.map((node, index) => {
333
+ if (isUiNodeInputAttributes(node.attributes) && node.attributes.type === "submit") {
357
334
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
358
- "div",
335
+ "form",
359
336
  {
360
- className: "space-y-2",
337
+ action: flow.ui.action,
338
+ method: flow.ui.method,
339
+ className: "w-full",
361
340
  children: [
362
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Label, { htmlFor: node.attributes.name, children: [
363
- node.meta.label?.text,
364
- node.attributes.required && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-destructive ml-1", children: "*" })
365
- ] }),
341
+ csrfToken && isUiNodeInputAttributes(csrfToken.attributes) && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
342
+ "input",
343
+ {
344
+ name: csrfToken.attributes.name,
345
+ type: "hidden",
346
+ value: csrfToken.attributes.value || "",
347
+ readOnly: true
348
+ }
349
+ ),
366
350
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
367
- Input,
351
+ Button,
368
352
  {
369
- id: node.attributes.name,
353
+ type: "submit",
370
354
  name: node.attributes.name,
371
- type: node.attributes.type,
372
- defaultValue: node.attributes.value || "",
373
- required: node.attributes.required,
374
- placeholder: `Enter your ${node.meta.label?.text?.toLowerCase() || node.attributes.name}`
355
+ value: node.attributes.value || "",
356
+ variant: "outline",
357
+ className: "w-full",
358
+ children: node.meta.label?.text || node.attributes.value || "Sign in"
375
359
  }
376
360
  )
377
361
  ]
378
362
  },
379
- node.meta.label?.id || node.attributes.name
363
+ `oidc-${index}`
380
364
  );
381
365
  }
382
- }
383
- return null;
384
- }),
385
- !hasSubmitButton && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Button, { type: "submit", className: "w-full", children: "Submit" })
366
+ return null;
367
+ }),
368
+ regularNodes.some(
369
+ (node) => isUiNodeInputAttributes(node.attributes) && !["hidden", "submit"].includes(node.attributes.type)
370
+ ) && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "relative my-6", children: [
371
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "absolute inset-0 flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "w-full border-t border-border" }) }),
372
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "relative flex justify-center text-xs uppercase", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "bg-background px-3 text-muted-foreground font-medium", children: "Or continue with email" }) })
373
+ ] })
374
+ ] }),
375
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("form", { action: flow.ui.action, method: flow.ui.method, children: [
376
+ regularNodes.map((node) => {
377
+ if (isUiNodeInputAttributes(node.attributes)) {
378
+ const isSubmitButton = node.attributes.type === "submit";
379
+ const isHiddenField = node.attributes.type === "hidden";
380
+ const isVisibleField = !isHiddenField && !isSubmitButton;
381
+ if (isHiddenField) {
382
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
383
+ "input",
384
+ {
385
+ name: node.attributes.name,
386
+ type: "hidden",
387
+ value: node.attributes.value || "",
388
+ readOnly: true
389
+ },
390
+ node.attributes.name
391
+ );
392
+ }
393
+ if (isSubmitButton) {
394
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
395
+ Button,
396
+ {
397
+ type: "submit",
398
+ name: node.attributes.name,
399
+ value: node.attributes.value || "",
400
+ className: "w-full mt-2",
401
+ children: node.meta.label?.text || node.attributes.value || "Submit"
402
+ },
403
+ node.attributes.name
404
+ );
405
+ }
406
+ if (isVisibleField && [
407
+ "default",
408
+ "password",
409
+ "code",
410
+ "webauthn",
411
+ "passkey",
412
+ "totp",
413
+ "lookup_secret",
414
+ "profile"
415
+ ].includes(node.group)) {
416
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
417
+ "div",
418
+ {
419
+ className: "space-y-2 mb-4",
420
+ children: [
421
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Label, { htmlFor: node.attributes.name, children: [
422
+ node.meta.label?.text,
423
+ node.attributes.required && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-destructive ml-1", children: "*" })
424
+ ] }),
425
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
426
+ Input,
427
+ {
428
+ id: node.attributes.name,
429
+ name: node.attributes.name,
430
+ type: node.attributes.type,
431
+ defaultValue: node.attributes.value || "",
432
+ required: node.attributes.required,
433
+ placeholder: `Enter your ${node.meta.label?.text?.toLowerCase() || node.attributes.name}`
434
+ }
435
+ )
436
+ ]
437
+ },
438
+ node.meta.label?.id || node.attributes.name
439
+ );
440
+ }
441
+ }
442
+ return null;
443
+ }),
444
+ !hasSubmitButton && !oidcNodes.length && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Button, { type: "submit", className: "w-full", children: "Submit" })
445
+ ] })
386
446
  ] })
387
- ] }) })
447
+ ] })
388
448
  ] });
389
449
  }
390
450
 
package/dist/index.js CHANGED
@@ -269,84 +269,144 @@ function isUiNodeInputAttributes(attributes) {
269
269
  return attributes && typeof attributes === "object" && "name" in attributes && "type" in attributes;
270
270
  }
271
271
  function CustomFlowForm({ flow, Header }) {
272
+ const nodesByGroup = flow.ui.nodes.reduce((groups, node) => {
273
+ const group = node.group || "default";
274
+ if (!groups[group]) {
275
+ groups[group] = [];
276
+ }
277
+ groups[group].push(node);
278
+ return groups;
279
+ }, {});
280
+ const oidcNodes = nodesByGroup.oidc || [];
281
+ const regularNodes = Object.entries(nodesByGroup).filter(([group]) => group !== "oidc").flatMap(([, nodes]) => nodes);
282
+ const csrfToken = regularNodes.find(
283
+ (node) => isUiNodeInputAttributes(node.attributes) && node.attributes.name === "csrf_token"
284
+ );
272
285
  const hasSubmitButton = flow.ui.nodes.some(
273
286
  (node) => isUiNodeInputAttributes(node.attributes) && node.attributes.type === "submit"
274
287
  );
275
288
  return /* @__PURE__ */ jsxs("div", { children: [
276
289
  /* @__PURE__ */ jsx7(Messages, { flow }),
277
- /* @__PURE__ */ jsx7(Card, { className: "w-full max-w-md mx-auto", children: /* @__PURE__ */ jsxs("form", { action: flow.ui.action, method: flow.ui.method, children: [
278
- Header && /* @__PURE__ */ jsx7(CardHeader, { children: /* @__PURE__ */ jsx7(CardTitle, { className: "text-center pb-4", children: Header }) }),
279
- /* @__PURE__ */ jsxs(CardContent, { className: "space-y-4", children: [
280
- flow.ui.nodes.map((node) => {
281
- if (isUiNodeInputAttributes(node.attributes)) {
282
- const isSubmitButton = node.attributes.type === "submit";
283
- const isHiddenField = node.attributes.type === "hidden";
284
- const isVisibleField = !isHiddenField && !isSubmitButton;
285
- if (isHiddenField) {
286
- return /* @__PURE__ */ jsx7(
287
- "input",
288
- {
289
- name: node.attributes.name,
290
- type: "hidden",
291
- value: node.attributes.value || "",
292
- readOnly: true
293
- },
294
- node.attributes.name
295
- );
296
- }
297
- if (isSubmitButton) {
298
- return /* @__PURE__ */ jsx7(
299
- Button,
300
- {
301
- type: "submit",
302
- name: node.attributes.name,
303
- value: node.attributes.value || "",
304
- className: "w-full mt-2",
305
- children: node.meta.label?.text || node.attributes.value || "Submit"
306
- },
307
- node.attributes.name
308
- );
309
- }
310
- if (isVisibleField && [
311
- "default",
312
- "password",
313
- "code",
314
- "webauthn",
315
- "passkey",
316
- "totp",
317
- "lookup_secret"
318
- ].includes(node.group)) {
290
+ /* @__PURE__ */ jsxs(Card, { className: "w-full max-w-md mx-auto", children: [
291
+ Header && /* @__PURE__ */ jsx7(CardHeader, { children: /* @__PURE__ */ jsx7(CardTitle, { className: "text-center pb-1", children: Header }) }),
292
+ /* @__PURE__ */ jsxs(CardContent, { className: "space-y-6", children: [
293
+ oidcNodes.length > 0 && /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
294
+ oidcNodes.map((node, index) => {
295
+ if (isUiNodeInputAttributes(node.attributes) && node.attributes.type === "submit") {
319
296
  return /* @__PURE__ */ jsxs(
320
- "div",
297
+ "form",
321
298
  {
322
- className: "space-y-2",
299
+ action: flow.ui.action,
300
+ method: flow.ui.method,
301
+ className: "w-full",
323
302
  children: [
324
- /* @__PURE__ */ jsxs(Label, { htmlFor: node.attributes.name, children: [
325
- node.meta.label?.text,
326
- node.attributes.required && /* @__PURE__ */ jsx7("span", { className: "text-destructive ml-1", children: "*" })
327
- ] }),
303
+ csrfToken && isUiNodeInputAttributes(csrfToken.attributes) && /* @__PURE__ */ jsx7(
304
+ "input",
305
+ {
306
+ name: csrfToken.attributes.name,
307
+ type: "hidden",
308
+ value: csrfToken.attributes.value || "",
309
+ readOnly: true
310
+ }
311
+ ),
328
312
  /* @__PURE__ */ jsx7(
329
- Input,
313
+ Button,
330
314
  {
331
- id: node.attributes.name,
315
+ type: "submit",
332
316
  name: node.attributes.name,
333
- type: node.attributes.type,
334
- defaultValue: node.attributes.value || "",
335
- required: node.attributes.required,
336
- placeholder: `Enter your ${node.meta.label?.text?.toLowerCase() || node.attributes.name}`
317
+ value: node.attributes.value || "",
318
+ variant: "outline",
319
+ className: "w-full",
320
+ children: node.meta.label?.text || node.attributes.value || "Sign in"
337
321
  }
338
322
  )
339
323
  ]
340
324
  },
341
- node.meta.label?.id || node.attributes.name
325
+ `oidc-${index}`
342
326
  );
343
327
  }
344
- }
345
- return null;
346
- }),
347
- !hasSubmitButton && /* @__PURE__ */ jsx7(Button, { type: "submit", className: "w-full", children: "Submit" })
328
+ return null;
329
+ }),
330
+ regularNodes.some(
331
+ (node) => isUiNodeInputAttributes(node.attributes) && !["hidden", "submit"].includes(node.attributes.type)
332
+ ) && /* @__PURE__ */ jsxs("div", { className: "relative my-6", children: [
333
+ /* @__PURE__ */ jsx7("div", { className: "absolute inset-0 flex items-center", children: /* @__PURE__ */ jsx7("span", { className: "w-full border-t border-border" }) }),
334
+ /* @__PURE__ */ jsx7("div", { className: "relative flex justify-center text-xs uppercase", children: /* @__PURE__ */ jsx7("span", { className: "bg-background px-3 text-muted-foreground font-medium", children: "Or continue with email" }) })
335
+ ] })
336
+ ] }),
337
+ /* @__PURE__ */ jsxs("form", { action: flow.ui.action, method: flow.ui.method, children: [
338
+ regularNodes.map((node) => {
339
+ if (isUiNodeInputAttributes(node.attributes)) {
340
+ const isSubmitButton = node.attributes.type === "submit";
341
+ const isHiddenField = node.attributes.type === "hidden";
342
+ const isVisibleField = !isHiddenField && !isSubmitButton;
343
+ if (isHiddenField) {
344
+ return /* @__PURE__ */ jsx7(
345
+ "input",
346
+ {
347
+ name: node.attributes.name,
348
+ type: "hidden",
349
+ value: node.attributes.value || "",
350
+ readOnly: true
351
+ },
352
+ node.attributes.name
353
+ );
354
+ }
355
+ if (isSubmitButton) {
356
+ return /* @__PURE__ */ jsx7(
357
+ Button,
358
+ {
359
+ type: "submit",
360
+ name: node.attributes.name,
361
+ value: node.attributes.value || "",
362
+ className: "w-full mt-2",
363
+ children: node.meta.label?.text || node.attributes.value || "Submit"
364
+ },
365
+ node.attributes.name
366
+ );
367
+ }
368
+ if (isVisibleField && [
369
+ "default",
370
+ "password",
371
+ "code",
372
+ "webauthn",
373
+ "passkey",
374
+ "totp",
375
+ "lookup_secret",
376
+ "profile"
377
+ ].includes(node.group)) {
378
+ return /* @__PURE__ */ jsxs(
379
+ "div",
380
+ {
381
+ className: "space-y-2 mb-4",
382
+ children: [
383
+ /* @__PURE__ */ jsxs(Label, { htmlFor: node.attributes.name, children: [
384
+ node.meta.label?.text,
385
+ node.attributes.required && /* @__PURE__ */ jsx7("span", { className: "text-destructive ml-1", children: "*" })
386
+ ] }),
387
+ /* @__PURE__ */ jsx7(
388
+ Input,
389
+ {
390
+ id: node.attributes.name,
391
+ name: node.attributes.name,
392
+ type: node.attributes.type,
393
+ defaultValue: node.attributes.value || "",
394
+ required: node.attributes.required,
395
+ placeholder: `Enter your ${node.meta.label?.text?.toLowerCase() || node.attributes.name}`
396
+ }
397
+ )
398
+ ]
399
+ },
400
+ node.meta.label?.id || node.attributes.name
401
+ );
402
+ }
403
+ }
404
+ return null;
405
+ }),
406
+ !hasSubmitButton && !oidcNodes.length && /* @__PURE__ */ jsx7(Button, { type: "submit", className: "w-full", children: "Submit" })
407
+ ] })
348
408
  ] })
349
- ] }) })
409
+ ] })
350
410
  ] });
351
411
  }
352
412
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnibase/shadcn",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "OmniBase ShadCN UI Package",
5
5
  "type": "module",
6
6
  "exports": {