Skip to content

Commit

Permalink
Merge with main and resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula committed Nov 24, 2021
2 parents 8653a82 + d6ac415 commit 473bb99
Show file tree
Hide file tree
Showing 2,143 changed files with 4,373 additions and 3,014 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ To localize strings in React, use either `FormattedMessage` or `i18n.translate`.
["source","js"]
-----------
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { FormattedMessage } from '@kbn/i18n-react';
export const Component = () => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from '@kbn/i18n/react';
import { FormattedMessage } from '@kbn/i18n-react';
import { EuiEmptyPrompt } from '@elastic/eui';
import { InspectorViewProps, Adapters } from '../../../../src/plugins/inspector/public';
import { AstDebugView } from './ast_debug_view';
Expand Down
2 changes: 1 addition & 1 deletion examples/screenshot_mode_example/public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import React, { useEffect } from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
import { FormattedMessage, I18nProvider } from '@kbn/i18n/react';
import { FormattedMessage, I18nProvider } from '@kbn/i18n-react';

import {
EuiPage,
Expand Down
2 changes: 1 addition & 1 deletion examples/search_examples/public/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, Redirect } from 'react-router-dom';
import { I18nProvider } from '@kbn/i18n/react';
import { I18nProvider } from '@kbn/i18n-react';
import { AppMountParameters, CoreStart } from '../../../src/core/public';
import { AppPluginStartDependencies } from './types';
import { SearchExamplePage, ExampleLink } from './common/example_page';
Expand Down
2 changes: 1 addition & 1 deletion examples/search_examples/public/search/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import React, { useState, useEffect } from 'react';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { FormattedMessage } from '@kbn/i18n-react';

import {
EuiButtonEmpty,
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
"@kbn/es-query": "link:bazel-bin/packages/kbn-es-query",
"@kbn/field-types": "link:bazel-bin/packages/kbn-field-types",
"@kbn/i18n": "link:bazel-bin/packages/kbn-i18n",
"@kbn/i18n-react": "link:bazel-bin/packages/kbn-i18n-react",
"@kbn/interpreter": "link:bazel-bin/packages/kbn-interpreter",
"@kbn/io-ts-utils": "link:bazel-bin/packages/kbn-io-ts-utils",
"@kbn/logging": "link:bazel-bin/packages/kbn-logging",
Expand Down Expand Up @@ -553,6 +554,8 @@
"@types/json-stable-stringify": "^1.0.32",
"@types/json5": "^0.0.30",
"@types/kbn__ace": "link:bazel-bin/packages/kbn-ace/npm_module_types",
"@types/kbn__i18n": "link:bazel-bin/packages/kbn-i18n/npm_module_types",
"@types/kbn__i18n-react": "link:bazel-bin/packages/kbn-i18n-react/npm_module_types",
"@types/license-checker": "15.0.0",
"@types/listr": "^0.14.0",
"@types/loader-utils": "^1.1.3",
Expand Down
3 changes: 3 additions & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ filegroup(
"//packages/kbn-expect:build",
"//packages/kbn-field-types:build",
"//packages/kbn-i18n:build",
"//packages/kbn-i18n-react:build",
"//packages/kbn-interpreter:build",
"//packages/kbn-io-ts-utils:build",
"//packages/kbn-logging:build",
Expand Down Expand Up @@ -77,6 +78,8 @@ filegroup(
"//packages/elastic-apm-synthtrace:build_types",
"//packages/elastic-datemath:build_types",
"//packages/kbn-ace:build_types",
"//packages/kbn-i18n:build_types",
"//packages/kbn-i18n-react:build_types",
],
)

Expand Down
4 changes: 2 additions & 2 deletions packages/elastic-eslint-config-kibana/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ module.exports = {
},
{
from: 'react-intl',
to: '@kbn/i18n/react',
disallowedMessage: `import from @kbn/i18n/react instead`
to: '@kbn/i18n-react',
disallowedMessage: `import from @kbn/i18n-react instead`
},
{
from: 'styled-components',
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-alerts/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ RUNTIME_DEPS = [
]

TYPES_DEPS = [
"//packages/kbn-i18n",
"//packages/kbn-i18n:npm_module_types",
"@npm//@elastic/eui",
"@npm//resize-observer-polyfill",
"@npm//tslib",
"@npm//@types/enzyme",
"@npm//@types/jest",
"@npm//@types/node",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ TYPES_DEPS = [
"//packages/kbn-logging",
"//packages/kbn-std",
"//packages/kbn-utility-types",
"//packages/kbn-i18n",
"//packages/kbn-i18n:npm_module_types",
"@npm//load-json-file",
"@npm//rxjs",
"@npm//@types/jest",
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-es-query/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ RUNTIME_DEPS = [
"@npm//load-json-file",
"@npm//lodash",
"@npm//moment-timezone",
"@npm//tslib",
]

TYPES_DEPS = [
"//packages/kbn-utility-types",
"//packages/kbn-i18n",
"//packages/kbn-i18n:npm_module_types",
"@npm//@elastic/elasticsearch",
"@npm//tslib",
"@npm//@types/jest",
"@npm//@types/lodash",
"@npm//@types/moment-timezone",
Expand Down
123 changes: 123 additions & 0 deletions packages/kbn-i18n-react/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")

PKG_BASE_NAME = "kbn-i18n-react"
PKG_REQUIRE_NAME = "@kbn/i18n-react"
TYPES_PKG_REQUIRE_NAME = "@types/kbn__i18n-react"

SOURCE_FILES = glob(
[
"src/**/*.ts",
"src/**/*.tsx",
],
exclude = [
"**/*.test.*",
"**/__snapshots__/**",
],
)

SRCS = SOURCE_FILES

filegroup(
name = "srcs",
srcs = SRCS,
)

NPM_MODULE_EXTRA_FILES = [
"package.json",
"README.md"
]

RUNTIME_DEPS = [
"//packages/kbn-i18n",
"@npm//prop-types",
"@npm//react",
"@npm//react-intl"
]

TYPES_DEPS = [
"//packages/kbn-i18n:npm_module_types",
"@npm//tslib",
"@npm//@types/jest",
"@npm//@types/node",
"@npm//@types/prop-types",
"@npm//@types/react",
"@npm//@types/react-intl",
]

jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)

jsts_transpiler(
name = "target_web",
srcs = SRCS,
build_pkg_name = package_name(),
web = True,
)

ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
"//:tsconfig.bazel.json",
],
)

ts_project(
name = "tsc_types",
args = ['--pretty'],
srcs = SRCS,
deps = TYPES_DEPS,
declaration = True,
declaration_map = True,
emit_declaration_only = True,
out_dir = "target_types",
source_map = True,
root_dir = "src",
tsconfig = ":tsconfig",
)

js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node", ":target_web"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)

pkg_npm(
name = "npm_module",
deps = [
":%s" % PKG_BASE_NAME,
]
)

filegroup(
name = "build",
srcs = [
":npm_module",
],
visibility = ["//visibility:public"],
)

pkg_npm_types(
name = "npm_module_types",
srcs = SRCS,
deps = [":tsc_types"],
package_name = TYPES_PKG_REQUIRE_NAME,
tsconfig = ":tsconfig",
visibility = ["//visibility:public"],
)

filegroup(
name = "build_types",
srcs = [
":npm_module_types",
],
visibility = ["//visibility:public"],
)
3 changes: 3 additions & 0 deletions packages/kbn-i18n-react/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# I18n-React

Please check the [@kbn/I18n README](../kbn-i18n/README.md) for all the information
14 changes: 14 additions & 0 deletions packages/kbn-i18n-react/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-i18n-react'],
testRunner: 'jasmine2',
};
8 changes: 8 additions & 0 deletions packages/kbn-i18n-react/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@kbn/i18n-react",
"browser": "./target_web/browser.js",
"main": "./target_node/index.js",
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0",
"private": true
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as React from 'react';
// eslint-disable-next-line @kbn/eslint/module_migration
import { IntlProvider } from 'react-intl';

import * as i18n from '../core';
import { i18n } from '@kbn/i18n';
import { PseudoLocaleWrapper } from './pseudo_locale_wrapper';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

import * as PropTypes from 'prop-types';
import * as React from 'react';
import * as i18n from '../core';
import { isPseudoLocale, translateUsingPseudoLocale } from '../core/pseudo_locale';
import { i18n } from '@kbn/i18n';

/**
* To translate label that includes nested `FormattedMessage` instances React Intl
Expand All @@ -26,11 +25,11 @@ function translateFormattedMessageUsingPseudoLocale(message: string) {
if (formattedMessageDelimiter !== null) {
return message
.split(formattedMessageDelimiter[0])
.map((part) => (part.startsWith('ELEMENT-') ? part : translateUsingPseudoLocale(part)))
.map((part) => (part.startsWith('ELEMENT-') ? part : i18n.translateUsingPseudoLocale(part)))
.join(formattedMessageDelimiter[0]);
}

return translateUsingPseudoLocale(message);
return i18n.translateUsingPseudoLocale(message);
}

/**
Expand All @@ -51,7 +50,7 @@ export class PseudoLocaleWrapper extends React.PureComponent {
constructor(props: { children: React.ReactNode }, context: any) {
super(props, context);

if (isPseudoLocale(i18n.getLocale())) {
if (i18n.isPseudoLocale(i18n.getLocale())) {
const formatMessage = context.intl.formatMessage;
context.intl.formatMessage = (...args: any[]) =>
translateFormattedMessageUsingPseudoLocale(formatMessage(...args));
Expand Down
19 changes: 19 additions & 0 deletions packages/kbn-i18n-react/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "../../tsconfig.bazel.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "./target_types",
"sourceMap": true,
"sourceRoot": "../../../../../packages/kbn-i18n-react/src",
"types": [
"jest",
"node"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
],
}
Loading

0 comments on commit 473bb99

Please sign in to comment.