Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an extendable template registry #995

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ To see Ember Freestyle in action, visit [https://chrislopresto.github.io/ember-f
* Node.js v18 or above
* Ember Auto Import v2 or above

ember-freestyle includes Typescript types and provides `addon/glint.ts` for Glint usage
ember-freestyle includes TypeScript types, and provides a template registry that can be imported from `ember-freestyle/template-registry` for Glint usage.

## Installation

Expand Down
82 changes: 0 additions & 82 deletions addon/glint.ts

This file was deleted.

107 changes: 107 additions & 0 deletions addon/template-registry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// components
import type FreestyleAnnotation from 'ember-freestyle/components/freestyle-annotation';
import type FreestyleCollection from 'ember-freestyle/components/freestyle-collection';
import type FreestyleDynamicInputSelectOption from 'ember-freestyle/components/freestyle-dynamic-input-select-option';
import type FreestyleDynamicInput from 'ember-freestyle/components/freestyle-dynamic-input';
import type FreestyleDynamic from 'ember-freestyle/components/freestyle-dynamic';
import type FreestyleFocusButton from 'ember-freestyle/components/freestyle-focus-button';
import type FreestyleGuide from 'ember-freestyle/components/freestyle-guide';
import type FreestyleMenu from 'ember-freestyle/components/freestyle-menu';
import type FreestylePaletteItem from 'ember-freestyle/components/freestyle-palette-item';
import type FreestylePalette from 'ember-freestyle/components/freestyle-palette';
import type FreestyleSection from 'ember-freestyle/components/freestyle-section';
import type FreestyleSource from 'ember-freestyle/components/freestyle-source';
import type FreestyleSubsection from 'ember-freestyle/components/freestyle-subsection';
import type FreestyleTypeface from 'ember-freestyle/components/freestyle-typeface';
import type FreestyleUsageControls from 'ember-freestyle/components/freestyle-usage-controls';
import type FreestyleUsageLegacy from 'ember-freestyle/components/freestyle-usage';
import type FreestyleVariantList from 'ember-freestyle/components/freestyle-variant-list';
import type FreestyleVariant from 'ember-freestyle/components/freestyle-variant';
import type FreestyleUsageArgument from 'ember-freestyle/components/freestyle/usage/argument';
import type FreestyleUsageArray from 'ember-freestyle/components/freestyle/usage/array';
import type FreestyleUsageBasicCssVariable from 'ember-freestyle/components/freestyle/usage/basic-css-variable';
import type FreestyleUsageBoolControl from 'ember-freestyle/components/freestyle/usage/bool/control';
import type FreestyleUsageBool from 'ember-freestyle/components/freestyle/usage/bool';
import type FreestyleUsageComponentLikeControl from 'ember-freestyle/components/freestyle/usage/component-like/control';
import type FreestyleUsageComponentLike from 'ember-freestyle/components/freestyle/usage/component-like';
import type FreestyleUsage from 'ember-freestyle/components/freestyle/usage';
import type FreestyleUsageNumberControl from 'ember-freestyle/components/freestyle/usage/number/control';
import type FreestyleUsageNumber from 'ember-freestyle/components/freestyle/usage/number';
import type FreestyleUsageObjectControl from 'ember-freestyle/components/freestyle/usage/object/control';
import type FreestyleUsageObject from 'ember-freestyle/components/freestyle/usage/object';
import type FreestyleUsageStringControl from 'ember-freestyle/components/freestyle/usage/string/control';
import type FreestyleUsageString from 'ember-freestyle/components/freestyle/usage/string';

// modifiers
import type FreestyleHighlight from 'ember-freestyle/modifiers/freestyle-highlight';

export default interface EmberFreestyleRegistry {
// components
'freestyle-annotation': typeof FreestyleAnnotation;
FreestyleAnnotation: typeof FreestyleAnnotation;
'freestyle-collection': typeof FreestyleCollection;
FreestyleCollection: typeof FreestyleCollection;
'freestyle-dynamic-input-select-option': typeof FreestyleDynamicInputSelectOption;
FreestyleDynamicInputSelectOption: typeof FreestyleDynamicInputSelectOption;
'freestyle-dynamic-input': typeof FreestyleDynamicInput;
FreestyleDynamicInput: typeof FreestyleDynamicInput;
'freestyle-dynamic': typeof FreestyleDynamic;
FreestyleDynamic: typeof FreestyleDynamic;
'freestyle-focus-button': typeof FreestyleFocusButton;
FreestyleFocusButton: typeof FreestyleFocusButton;
'freestyle-guide': typeof FreestyleGuide;
FreestyleGuide: typeof FreestyleGuide;
'freestyle-menu': typeof FreestyleMenu;
FreestyleMenu: typeof FreestyleMenu;
'freestyle-palette-item': typeof FreestylePaletteItem;
FreestylePaletteItem: typeof FreestylePaletteItem;
'freestyle-palette': typeof FreestylePalette;
FreestylePalette: typeof FreestylePalette;
'freestyle-section': typeof FreestyleSection;
FreestyleSection: typeof FreestyleSection;
'freestyle-source': typeof FreestyleSource;
FreestyleSource: typeof FreestyleSource;
'freestyle-subsection': typeof FreestyleSubsection;
FreestyleSubsection: typeof FreestyleSubsection;
'freestyle-typeface': typeof FreestyleTypeface;
FreestyleTypeface: typeof FreestyleTypeface;
'freestyle-usage-controls': typeof FreestyleUsageControls;
FreestyleUsageControls: typeof FreestyleUsageControls;
'freestyle-usage': typeof FreestyleUsageLegacy;
FreestyleUsage: typeof FreestyleUsageLegacy;
'freestyle-variant-list': typeof FreestyleVariantList;
FreestyleVariantList: typeof FreestyleVariantList;
'freestyle-variant': typeof FreestyleVariant;
FreestyleVariant: typeof FreestyleVariant;
'freestyle/usage/argument': typeof FreestyleUsageArgument;
'Freestyle::Usage::Argument': typeof FreestyleUsageArgument;
'freestyle/usage/array': typeof FreestyleUsageArray;
'Freestyle::Usage::Array': typeof FreestyleUsageArray;
'freestyle/usage/basic-css-variable': typeof FreestyleUsageBasicCssVariable;
'Freestyle::Usage::BasicCssVariable': typeof FreestyleUsageBasicCssVariable;
'freestyle/usage/bool/control': typeof FreestyleUsageBoolControl;
'Freestyle::Usage::Bool::Control': typeof FreestyleUsageBoolControl;
'freestyle/usage/bool': typeof FreestyleUsageBool;
'Freestyle::Usage::Bool': typeof FreestyleUsageBool;
'freestyle/usage/component-like/control': typeof FreestyleUsageComponentLikeControl;
'Freestyle::Usage::ComponentLike::Control': typeof FreestyleUsageComponentLikeControl;
'freestyle/usage/component-like': typeof FreestyleUsageComponentLike;
'Freestyle::Usage::ComponentLike': typeof FreestyleUsageComponentLike;
'freestyle/usage': typeof FreestyleUsage;
'Freestyle::Usage': typeof FreestyleUsage;
'freestyle/usage/number/control': typeof FreestyleUsageNumberControl;
'Freestyle::Usage::Number::Control': typeof FreestyleUsageNumberControl;
'freestyle/usage/number': typeof FreestyleUsageNumber;
'Freestyle::Usage::Number': typeof FreestyleUsageNumber;
'freestyle/usage/object/control': typeof FreestyleUsageObjectControl;
'Freestyle::Usage::Object::Control': typeof FreestyleUsageObjectControl;
'freestyle/usage/object': typeof FreestyleUsageObject;
'Freestyle::Usage::Object': typeof FreestyleUsageObject;
'freestyle/usage/string/control': typeof FreestyleUsageStringControl;
'Freestyle::Usage::String::Control': typeof FreestyleUsageStringControl;
'freestyle/usage/string': typeof FreestyleUsageString;
'Freestyle::Usage::String': typeof FreestyleUsageString;

// modifiers
'freestyle-highlight': typeof FreestyleHighlight;
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module(
});

test('Does not render the controls', async function (this: Context, assert) {
await render<Context>(hbs`<Freestyle::Usage::ComponentLike
await render<Context>(hbs`<Freestyle::Usage::ComponentLike
@hideControls={{true}}
@onChange={{this.onChange}}
/>`);
Expand Down
4 changes: 3 additions & 1 deletion types/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import '@glint/environment-ember-loose';

import type FreestyleRegistry from 'ember-freestyle/template-registry';

import AndHelper from 'ember-truth-helpers/helpers/and';
import EqHelper from 'ember-truth-helpers/helpers/eq';
import NotHelper from 'ember-truth-helpers/helpers/not';
import { HelperLike, ModifierLike } from '@glint/template';
import { SafeString } from '@ember/template/-private/handlebars';

declare module '@glint/environment-ember-loose/registry' {
export default interface Registry {
export default interface Registry extends FreestyleRegistry {
and: typeof AndHelper;
eq: typeof EqHelper;
not: typeof NotHelper;
Expand Down
Loading