@satorijs/adapter-lark 3.10.1 → 3.10.2

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/lib/content.d.ts CHANGED
@@ -419,12 +419,29 @@ export declare namespace MessageContent {
419
419
  type: 'text' | 'primary_text' | 'danger_text';
420
420
  }
421
421
  }
422
+ interface ColumnSetElement extends BaseElement<'column_set'> {
423
+ horizontal_spacing?: string;
424
+ horizontal_align?: 'left' | 'center' | 'right';
425
+ margin?: string;
426
+ flex_mode?: 'none' | 'stretch' | 'flow' | 'bisect' | 'trisect';
427
+ background_style?: string;
428
+ columns: ColumnElement[];
429
+ }
430
+ interface ColumnElement extends BaseElement<'column'> {
431
+ background_style?: string;
432
+ width?: 'auto' | 'weighted' | string;
433
+ weight?: number;
434
+ vertical_align?: 'top' | 'center' | 'bottom';
435
+ vertical_spacing?: 'default' | 'medium' | 'large' | string;
436
+ padding?: string;
437
+ elements: Element[];
438
+ }
422
439
  namespace ButtonElement {
423
440
  type Size = 'tiny' | 'small' | 'medium' | 'large';
424
441
  type Width = 'default' | 'fill' | string;
425
442
  type Type = 'default' | 'primary' | 'danger' | 'text' | 'primary_text' | 'danger_text' | 'primary_filled' | 'danger_filled' | 'laser';
426
443
  }
427
- type Element = DivElement | MarkdownElement | HRElement | ActionElement | NoteElement | ChartElement | TableElement | ImageElement | FormElement | InputElement | ButtonElement | CheckerElement;
444
+ type Element = DivElement | MarkdownElement | HRElement | ActionElement | NoteElement | ChartElement | TableElement | ImageElement | FormElement | InputElement | ButtonElement | CheckerElement | ColumnSetElement;
428
445
  }
429
446
  interface Template {
430
447
  type: 'template';
package/lib/index.cjs CHANGED
@@ -801,6 +801,37 @@ var LarkMessageEncoder = class extends import_core3.MessageEncoder {
801
801
  tag: "standard_icon",
802
802
  token: attrs.token
803
803
  });
804
+ } else if (tag === "column-set") {
805
+ this.flushText();
806
+ const parent = this.card;
807
+ const columns = [];
808
+ parent?.elements.push({
809
+ tag: "column_set",
810
+ margin: attrs.margin,
811
+ flex_mode: attrs.flexMode,
812
+ horizontal_align: attrs.horizontalAlign,
813
+ horizontal_spacing: attrs.horizontalSpacing,
814
+ background_style: attrs.backgroundStyle,
815
+ columns
816
+ });
817
+ for (const child of children) {
818
+ if (child.type !== "lark:column" && child.type !== "feishu:column") {
819
+ continue;
820
+ }
821
+ this.card = { elements: [] };
822
+ await this.render(child.children);
823
+ columns.push({
824
+ tag: "column",
825
+ width: child.attrs.width,
826
+ weight: child.attrs.weight,
827
+ padding: child.attrs.padding,
828
+ vertical_align: child.attrs.verticalAlign,
829
+ vertical_spacing: child.attrs.verticalSpacing,
830
+ background_style: child.attrs.backgroundStyle,
831
+ elements: this.card.elements
832
+ });
833
+ }
834
+ this.card = parent;
804
835
  }
805
836
  } else {
806
837
  await this.render(children);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@satorijs/adapter-lark",
3
3
  "description": "Lark (飞书) Adapter for Satorijs",
4
- "version": "3.10.1",
4
+ "version": "3.10.2",
5
5
  "type": "module",
6
6
  "main": "lib/index.cjs",
7
7
  "types": "lib/index.d.ts",
package/src/content.ts CHANGED
@@ -512,6 +512,27 @@ export namespace MessageContent {
512
512
  }
513
513
  }
514
514
 
515
+ export interface ColumnSetElement extends BaseElement<'column_set'> {
516
+ horizontal_spacing?: string
517
+ horizontal_align?: 'left' | 'center' | 'right'
518
+ margin?: string
519
+ flex_mode?: 'none' | 'stretch' | 'flow' | 'bisect' | 'trisect'
520
+ background_style?: string
521
+ columns: ColumnElement[]
522
+ // action?: Action
523
+ }
524
+
525
+ export interface ColumnElement extends BaseElement<'column'> {
526
+ background_style?: string
527
+ width?: 'auto' | 'weighted' | string
528
+ weight?: number
529
+ vertical_align?: 'top' | 'center' | 'bottom'
530
+ vertical_spacing?: 'default' | 'medium' | 'large' | string
531
+ padding?: string
532
+ elements: Element[]
533
+ // action?: Action
534
+ }
535
+
515
536
  export namespace ButtonElement {
516
537
  export type Size = 'tiny' | 'small' | 'medium' | 'large'
517
538
  export type Width = 'default' | 'fill' | string
@@ -531,6 +552,7 @@ export namespace MessageContent {
531
552
  | InputElement
532
553
  | ButtonElement
533
554
  | CheckerElement
555
+ | ColumnSetElement
534
556
  }
535
557
 
536
558
  export interface Template {
package/src/message.ts CHANGED
@@ -417,6 +417,38 @@ export class LarkMessageEncoder<C extends Context = Context> extends MessageEnco
417
417
  tag: 'standard_icon',
418
418
  token: attrs.token,
419
419
  })
420
+ } else if (tag === 'column-set') {
421
+ this.flushText()
422
+ const parent = this.card
423
+ const columns: MessageContent.Card.ColumnElement[] = []
424
+ parent?.elements.push({
425
+ tag: 'column_set',
426
+ margin: attrs.margin,
427
+ flex_mode: attrs.flexMode,
428
+ horizontal_align: attrs.horizontalAlign,
429
+ horizontal_spacing: attrs.horizontalSpacing,
430
+ background_style: attrs.backgroundStyle,
431
+ columns,
432
+ })
433
+ for (const child of children) {
434
+ if (child.type !== 'lark:column' && child.type !== 'feishu:column') {
435
+ // throw unexpected?
436
+ continue
437
+ }
438
+ this.card = { elements: [] }
439
+ await this.render(child.children)
440
+ columns.push({
441
+ tag: 'column',
442
+ width: child.attrs.width,
443
+ weight: child.attrs.weight,
444
+ padding: child.attrs.padding,
445
+ vertical_align: child.attrs.verticalAlign,
446
+ vertical_spacing: child.attrs.verticalSpacing,
447
+ background_style: child.attrs.backgroundStyle,
448
+ elements: this.card.elements,
449
+ })
450
+ }
451
+ this.card = parent
420
452
  }
421
453
  } else {
422
454
  await this.render(children)