Skip to content

Commit

Permalink
rebase after introduction of headless packages
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinderoubaix committed Sep 17, 2023
1 parent 7ca3205 commit 1525905
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 46 deletions.
5 changes: 5 additions & 0 deletions angular/headless/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,8 @@ export type RatingState = WidgetState<RatingWidget>;
export type SelectWidget<Item> = AdaptWidgetSlots<import('@agnos-ui/core').SelectWidget<Item>>;
export type SelectProps<Item> = WidgetProps<SelectWidget<Item>>;
export type SelectState<Item> = WidgetState<SelectWidget<Item>>;

export type ProgressbarWidget = AdaptWidgetSlots<import('@agnos-ui/core').ProgressbarWidget>;
export type ProgressbarProps = WidgetProps<ProgressbarWidget>;
export type ProgressbarState = WidgetState<ProgressbarWidget>;
export type ProgressbarContext = AdaptSlotContentProps<import('@agnos-ui/core').ProgressbarContext>;
30 changes: 14 additions & 16 deletions angular/lib/src/lib/progressbar/progressbar.component.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import type {AdaptSlotContentProps, AdaptWidgetSlots, SlotContent} from '../slot.directive';
import {ComponentTemplate, SlotDirective, callWidgetFactory} from '../slot.directive';
import type {ProgressbarContext, ProgressbarProps, ProgressbarState, SlotContent} from '@agnos-ui/angular-headless';
import {
ComponentTemplate,
SlotDirective,
callWidgetFactory,
createProgressbar,
patchSimpleChanges,
toSlotContextWidget,
SlotDefaultDirective,
} from '@agnos-ui/angular-headless';
import type {AfterContentChecked, OnChanges, Signal, SimpleChanges} from '@angular/core';
import {NgClass, NgIf} from '@angular/common';
import {ChangeDetectionStrategy, Component, ContentChild, Directive, Input, TemplateRef, ViewChild, inject} from '@angular/core';
import type {ProgressbarContext as ProgressbarCoreContext, WidgetProps, WidgetState} from '@agnos-ui/core';
import {createProgressbar, toSlotContextWidget} from '@agnos-ui/core';
import {writable} from '@amadeus-it-group/tansu';
import {toSignal} from '@angular/core/rxjs-interop';
import {patchSimpleChanges} from '../utils';
import {SlotDefaultDirective} from '../slotDefault.directive';

export type ProgressbarWidget = AdaptWidgetSlots<ReturnType<typeof createProgressbar>>;
export type ProgressbarState = WidgetState<ProgressbarWidget>;
export type ProgressbarProps = WidgetProps<ProgressbarWidget>;

export type ProgressbarContext = AdaptSlotContentProps<ProgressbarCoreContext>;

@Directive({selector: 'ng-template[auProgressbarContent]', standalone: true})
export class ProgressbarContentDirective {
public templateRef = inject(TemplateRef<ProgressbarContext>);
static ngTemplateContextGuard(_dir: ProgressbarContentDirective, context: unknown): context is ProgressbarCoreContext {
static ngTemplateContextGuard(_dir: ProgressbarContentDirective, context: unknown): context is ProgressbarContext {
return true;

Check warning on line 21 in angular/lib/src/lib/progressbar/progressbar.component.ts

View check run for this annotation

Codecov / codecov/patch

angular/lib/src/lib/progressbar/progressbar.component.ts#L21

Added line #L21 was not covered by tests
}
}
Expand All @@ -46,7 +44,7 @@ export class ProgressbarContentDirective {
`,
})
export class ProgressbarDefaultSlotsComponent {
@ViewChild('content', {static: true}) content: TemplateRef<ProgressbarCoreContext>;
@ViewChild('content', {static: true}) content: TemplateRef<ProgressbarContext>;
}

export const progressbarDefaultSlotContent = new ComponentTemplate(ProgressbarDefaultSlotsComponent, 'content');
Expand Down Expand Up @@ -102,8 +100,8 @@ export class ProgressbarComponent implements AfterContentChecked, OnChanges {
*/
@Input() className: string | undefined;

@Input() slotDefault: SlotContent<AdaptSlotContentProps<ProgressbarCoreContext>>;
@Input() slotContent: SlotContent<AdaptSlotContentProps<ProgressbarCoreContext>>;
@Input() slotDefault: SlotContent<ProgressbarContext>;
@Input() slotContent: SlotContent<ProgressbarContext>;
@ContentChild(ProgressbarContentDirective, {static: false}) slotContentFromContent: ProgressbarContentDirective | undefined;

/**
Expand Down
2 changes: 1 addition & 1 deletion angular/lib/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export * from './lib/modal/modal.service';
export * from './lib/pagination/pagination.component';
export * from './lib/rating/rating.component';
export * from './lib/select/select.component';
export * from './lib/progressbar/progressbar.component';
export * from './lib/progressbar/progressbar.component';
5 changes: 5 additions & 0 deletions react/headless/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@ export type RatingState = WidgetState<RatingWidget>;
export type SelectWidget<Item> = AdaptWidgetSlots<import('@agnos-ui/core').SelectWidget<Item>>;
export type SelectProps<Item> = WidgetProps<SelectWidget<Item>>;
export type SelectState<Item> = WidgetState<SelectWidget<Item>>;

export type ProgressbarWidget = AdaptWidgetSlots<import('@agnos-ui/core').ProgressbarWidget>;
export type ProgressbarProps = WidgetProps<ProgressbarWidget>;
export type ProgressbarState = WidgetState<ProgressbarWidget>;
export type ProgressbarContext = AdaptSlotContentProps<import('@agnos-ui/core').ProgressbarContext>;
12 changes: 2 additions & 10 deletions react/lib/Progressbar.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import type {ProgressbarContext as ProgressbarCoreContext, WidgetProps, WidgetState} from '@agnos-ui/core';
import {createProgressbar, toSlotContextWidget} from '@agnos-ui/core';
import {type PropsWithChildren} from 'react';
import type {AdaptSlotContentProps, AdaptWidgetSlots} from './Slot';
import {Slot} from './Slot';
import {useWidgetWithConfig} from './utils';

export type ProgressbarContext = AdaptSlotContentProps<ProgressbarCoreContext>;
export type ProgressbarWidget = AdaptWidgetSlots<ReturnType<typeof createProgressbar>>;
export type ProgressbarProps = WidgetProps<ProgressbarWidget>;
export type ProgressbarState = WidgetState<ProgressbarWidget>;
import type {ProgressbarContext, ProgressbarProps} from '@agnos-ui/react-headless';
import {Slot, createProgressbar, toSlotContextWidget, useWidgetWithConfig} from '@agnos-ui/react-headless';

function DefaultSlotContent(slotContext: ProgressbarContext) {
const classList = ['progress-bar'];
Expand Down
2 changes: 1 addition & 1 deletion react/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export * from './modal/Modal';
export * from './modal/modalService';
export * from './pagination/PageItem';
export * from './pagination/Pagination';
export * from './Progressbar';
export * from './Progressbar';
5 changes: 5 additions & 0 deletions svelte/headless/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,8 @@ export type SelectWidget<Item> = AdaptWidgetSlots<import('@agnos-ui/core').Selec
export type SelectProps<Item> = WidgetProps<SelectWidget<Item>>;
export type SelectState<Item> = WidgetState<SelectWidget<Item>>;
export type SelectSlots<Item> = WidgetPropsSlots<SelectProps<Item>>;

export type ProgressbarWidget = AdaptWidgetSlots<import('@agnos-ui/core').ProgressbarWidget>;
export type ProgressbarProps = WidgetProps<ProgressbarWidget>;
export type ProgressbarState = WidgetState<ProgressbarWidget>;
export type ProgressbarSlots = WidgetPropsSlots<ProgressbarProps>;
15 changes: 13 additions & 2 deletions svelte/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ import Progressbar from './progressbar/Progressbar.svelte';

export * from './modal/modalService';
export * from './accordion/accordion';
export * from './progressbar/progressbar';

export {Select, Rating, Pagination, PaginationDefaultPages, Modal, ModalDefaultHeader, ModalDefaultStructure, Alert, Accordion, AccordionItem};
export {
Select,
Rating,
Pagination,
PaginationDefaultPages,
Modal,
ModalDefaultHeader,
ModalDefaultStructure,
Alert,
Accordion,
AccordionItem,
Progressbar,
};
9 changes: 2 additions & 7 deletions svelte/lib/progressbar/Progressbar.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
<script lang="ts" context="module">
import {createProgressbar} from '@agnos-ui/core';
import Slot from '../slot/Slot.svelte';
import type {WidgetPropsProps} from '../utils';
import {callWidgetFactory} from '../utils';
import type {ProgressbarProps as Props, WidgetPropsProps, ProgressbarSlots as Slots} from '@agnos-ui/svelte-headless';
import {Slot, callWidgetFactory, createProgressbar} from '@agnos-ui/svelte-headless';
import ProgressbarDefaultContent from './ProgressbarDefaultContent.svelte';
import type {ProgressbarProps as Props, ProgressbarSlots as Slots} from './progressbar';
const defaultConfig: Partial<Props> = {
slotContent: ProgressbarDefaultContent,
};
Expand Down
4 changes: 2 additions & 2 deletions svelte/lib/progressbar/ProgressbarDefaultContent.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import Slot from '../slot/Slot.svelte';
import type {ProgressbarSlots} from './progressbar';
import {Slot} from '@agnos-ui/svelte-headless';
import type {ProgressbarSlots} from '@agnos-ui/svelte-headless';
// cf https://github.com/ota-meshi/eslint-plugin-svelte/issues/348
type $$Props = ProgressbarSlots['content']; // eslint-disable-line @typescript-eslint/no-unused-vars
Expand Down
7 changes: 0 additions & 7 deletions svelte/lib/progressbar/progressbar.ts

This file was deleted.

0 comments on commit 1525905

Please sign in to comment.