Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
widoz committed Jan 21, 2024
1 parent f1504dd commit 6b5de4d
Show file tree
Hide file tree
Showing 19 changed files with 371 additions and 268 deletions.
29 changes: 17 additions & 12 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = tab
indent_style = space
insert_final_newline = true
max_line_length = 120
tab_width = 4
Expand All @@ -16,7 +16,9 @@ ij_visual_guides = 100
ij_wrap_on_typing = false

[*.css]
ij_continuation_indent_size = 4
indent_size = 2
tab_width = 2
ij_continuation_indent_size = 2
ij_visual_guides = none
ij_css_align_closing_brace_with_properties = false
ij_css_blank_lines_around_nested_selector = 1
Expand All @@ -38,7 +40,9 @@ ij_css_use_double_quotes = true
ij_css_value_alignment = do_not_align

[*.sass]
ij_continuation_indent_size = 4
indent_size = 2
tab_width = 2
ij_continuation_indent_size = 2
ij_visual_guides = none
ij_sass_align_closing_brace_with_properties = false
ij_sass_blank_lines_around_nested_selector = 1
Expand All @@ -61,7 +65,9 @@ ij_sass_use_double_quotes = true
ij_sass_value_alignment = 0

[*.scss]
ij_continuation_indent_size = 4
indent_size = 2
tab_width = 2
ij_continuation_indent_size = 2
ij_visual_guides = none
ij_scss_align_closing_brace_with_properties = false
ij_scss_blank_lines_around_nested_selector = 1
Expand Down Expand Up @@ -115,7 +121,7 @@ ij_xml_space_inside_empty_tag = false
ij_xml_text_wrap = normal

[{*.ats,*.cts,*.mts,*.ts,*.tsx}]
ij_continuation_indent_size = 4
ij_continuation_indent_size = 2
ij_typescript_align_imports = false
ij_typescript_align_multiline_array_initializer_expression = false
ij_typescript_align_multiline_binary_operation = false
Expand Down Expand Up @@ -286,6 +292,8 @@ ij_typescript_while_on_new_line = false
ij_typescript_wrap_comments = false

[{*.bash,*.sh,*.zsh}]
indent_size = 2
tab_width = 2
ij_visual_guides = none
ij_shell_binary_ops_start_line = false
ij_shell_keep_column_alignment_padding = false
Expand All @@ -295,7 +303,7 @@ ij_shell_switch_cases_indented = false
ij_shell_use_unix_line_separator = true

[{*.cjs,*.js}]
ij_continuation_indent_size = 4
ij_continuation_indent_size = 2
ij_javascript_align_imports = false
ij_javascript_align_multiline_array_initializer_expression = false
ij_javascript_align_multiline_binary_operation = false
Expand Down Expand Up @@ -462,9 +470,6 @@ ij_javascript_while_on_new_line = false
ij_javascript_wrap_comments = false

[{*.ctp,*.hphp,*.inc,*.module,*.php,*.php4,*.php5,*.phtml}]
tab_width = 2
indent_size = 2
indent_style = space
max_line_length = 100
ij_continuation_indent_size = 4
ij_visual_guides = 80
Expand Down Expand Up @@ -691,6 +696,7 @@ ij_php_while_brace_force = never
ij_php_while_on_new_line = false

[{*.har,*.jsb2,*.jsb3,*.json,.babelrc,.eslintrc,.prettierrc,.stylelintrc,bowerrc,composer.lock,jest.config}]
indent_size = 2
ij_visual_guides = none
ij_json_array_wrapping = split_into_lines
ij_json_keep_blank_lines_in_code = 0
Expand All @@ -708,9 +714,9 @@ ij_json_spaces_within_brackets = false
ij_json_wrap_long_lines = false

[{*.htm,*.html,*.sht,*.shtm,*.shtml}]
tab_width = 2
indent_size = 2
ij_continuation_indent_size = 4
tab_width = 2
ij_continuation_indent_size = 2
ij_html_add_new_line_before_tags = body,div,p,form,h1,h2,h3
ij_html_align_attributes = true
ij_html_align_text = false
Expand Down Expand Up @@ -757,7 +763,6 @@ ij_markdown_wrap_text_if_long = true
ij_markdown_wrap_text_inside_blockquotes = true

[{*.yaml,*.yml}]
tab_width = 2
indent_size = 2
ij_visual_guides = none
ij_yaml_align_values_properties = do_not_align
Expand Down
101 changes: 55 additions & 46 deletions @types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import type { Set } from '../sources/client/src/vo/set';

import { BaseEntityRecords, Context } from '@wordpress/core-data';

import type { Set } from '../sources/client/src/vo/set';

export default EntitiesSearch;

// TODO Try to convert it to a module.
Expand All @@ -19,7 +20,7 @@ declare namespace EntitiesSearch {
fields: EntitiesSearch.SearchQueryFields;
[p: string]: unknown;
}>
> { }
> {}

interface SearchEntityFields
extends Readonly<{
Expand All @@ -28,7 +29,7 @@ declare namespace EntitiesSearch {
url: string;
type: string;
subtype: string;
}> { }
}> {}

type ControlOption<V extends any> = Readonly<{
value: V;
Expand All @@ -37,35 +38,35 @@ declare namespace EntitiesSearch {

type SingularControl<V> = {
[K in keyof BaseControl<V>]: K extends 'value'
? V
: K extends 'onChange'
? (value: V) => void
: BaseControl<V>[K];
? V
: K extends 'onChange'
? (value: V) => void
: BaseControl<V>[K];
};

interface BaseControl<V>
extends Readonly<{
value: Set<V>;
options: Set<ControlOption<V>>;
onChange(values: BaseControl<V>['value']): void;
}> { }
}> {}

/*
* Hooks
*/
type ViewablePostType = Readonly<{
[K in keyof PostType<'edit'>]: K extends 'viewable'
? true
: PostType<'edit'>[K];
? true
: PostType<'edit'>[K];
}>;

// TODO Need Type Test.
type ViewableTaxonomy = Readonly<{
[K in keyof Taxonomy<'edit'>]: K extends 'visibility'
? BaseEntityRecords.TaxonomyVisibility & {
publicly_queryable: true;
}
: Taxonomy<'edit'>[K];
? BaseEntityRecords.TaxonomyVisibility & {
publicly_queryable: true;
}
: Taxonomy<'edit'>[K];
}>;

type EntitiesRecords<Entity> = Readonly<{
Expand All @@ -90,43 +91,51 @@ declare namespace EntitiesSearch {
K,
OptionSet = Set<EntitiesSearch.ControlOption<E>>
> extends Readonly<{
entities: BaseControl<E>['value'];
kind: BaseControl<K>['value'];
contextualEntitiesOptions: OptionSet;
currentEntitiesOptions: OptionSet;
selectedEntitiesOptions: OptionSet;
}> { }
entities: BaseControl<E>['value'];
kind: BaseControl<K>['value'];
contextualEntitiesOptions: OptionSet;
currentEntitiesOptions: OptionSet;
selectedEntitiesOptions: OptionSet;
}> {}

type StoreAction<E, K> =
| {
type: 'UPDATE_ENTITIES';
entities: EntitiesState<E, K>['entities'];
}
type: 'UPDATE_ENTITIES';
entities: EntitiesState<E, K>['entities'];
}
| {
type: 'UPDATE_KIND';
kind: EntitiesState<E, K>['kind'];
}
| {
type: 'UPDATE_CURRENT_ENTITIES_OPTIONS';
currentEntitiesOptions: EntitiesState<
E,
K
>['currentEntitiesOptions'];
}
| {
type: 'UPDATE_KIND';
kind: EntitiesState<E, K>['kind'];
}
type: 'UPDATE_CONTEXTUAL_ENTITIES_OPTIONS';
contextualEntitiesOptions: EntitiesState<
E,
K
>['contextualEntitiesOptions'];
}
| {
type: 'UPDATE_CURRENT_ENTITIES_OPTIONS';
currentEntitiesOptions: EntitiesState<
E,
K
>['currentEntitiesOptions'];
}
type: 'UPDATE_SELECTED_ENTITIES_OPTIONS';
selectedEntitiesOptions: EntitiesState<
E,
K
>['selectedEntitiesOptions'];
}
| {
type: 'UPDATE_CONTEXTUAL_ENTITIES_OPTIONS';
contextualEntitiesOptions: EntitiesState<
E,
K
>['contextualEntitiesOptions'];
}
type: 'CLEAN_ENTITIES_OPTIONS';
}
| {
type: 'UPDATE_SELECTED_ENTITIES_OPTIONS';
selectedEntitiesOptions: EntitiesState<
E,
K
>['selectedEntitiesOptions'];
};
type: 'UPDATE_ENTITIES_OPTIONS_FOR_NEW_KIND';
entitiesOptions: Set<EntitiesSearch.ControlOption<E>>;
kind: EntitiesState<E, K>['kind'];
};

/*
* Components
Expand All @@ -135,7 +144,7 @@ declare namespace EntitiesSearch {
extends Readonly<{
id?: string;
onChange(phrase: string | React.ChangeEvent<HTMLInputElement>);
}> { }
}> {}

interface CompositeEntitiesKinds<E, K>
extends Readonly<{
Expand All @@ -155,5 +164,5 @@ declare namespace EntitiesSearch {
phrase: Parameters<SearchControl<E, K>['search']>[0]
) => ReturnType<SearchControl<E, K>['search']>
): React.ReactNode;
}> { }
}> {}
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@wordpress/components": "~23.1.0",
"@wordpress/compose": "^6.23.0",
"@wordpress/core-data": "~6.12.0",
"@wordpress/hooks": "^3.49.0",
"@wordpress/i18n": "~4.24.0",
"classnames": "^2.3.2",
"react": "~18.2.0"
Expand All @@ -48,6 +49,7 @@
"cs:fix": "wp-scripts format ./sources/client",
"lint:js": "wp-scripts lint-js",
"lint:js:fix": "wp-scripts lint-js --fix",
"test": "jest"
"test": "jest",
"test:update-snapshots": "yarn test -u"
}
}
Loading

0 comments on commit 6b5de4d

Please sign in to comment.